개정판 690916dd
issue #1171: fix save dependency and spec break on going
Change-Id: I63f2da6a7ebc85eb991d017dcba665cd96fb8e14
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
2796 | 2796 |
sql = "delete from Components where Drawings_UID='{}'".format(drawing_uid) |
2797 | 2797 |
cursor.execute(sql) |
2798 | 2798 |
|
2799 |
sqlLters = [] |
|
2799 | 2800 |
for item in items: |
2800 |
sql = item.toSql() |
|
2801 |
if hasattr(item, 'toSql_return_separately'): |
|
2802 |
sql, sqlLater = item.toSql_return_separately() |
|
2803 |
sqlLters.append(sqlLater) |
|
2804 |
else: |
|
2805 |
sql = item.toSql() |
|
2806 |
|
|
2807 |
if type(sql) is list: |
|
2808 |
for item in sql: |
|
2809 |
if item is not None and 2 == len(item): |
|
2810 |
cursor.executemany(self.project.database.to_sql(item[0]), item[1]) |
|
2811 |
else: |
|
2812 |
if sql is not None and 2 == len(sql): |
|
2813 |
cursor.executemany(self.project.database.to_sql(sql[0]), sql[1]) |
|
2814 |
|
|
2815 |
for sql in sqlLters: |
|
2801 | 2816 |
if type(sql) is list: |
2802 | 2817 |
for item in sql: |
2803 | 2818 |
if item is not None and 2 == len(item): |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1165 | 1165 |
self.progress.show() |
1166 | 1166 |
## Load data on xml |
1167 | 1167 |
path = os.path.join(appDocData.getCurrentProject().getTempPath(), appDocData.imgName + '.xml') |
1168 |
if False:#os.path.isfile(path):
|
|
1168 |
if os.path.isfile(path): |
|
1169 | 1169 |
self.loadRecognitionResultFromXml(path) |
1170 | 1170 |
else: |
1171 | 1171 |
self.load_drawing(appDocData.activeDrawing) |
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py | ||
---|---|---|
229 | 229 |
|
230 | 230 |
return node |
231 | 231 |
|
232 |
def toSql(self): |
|
232 |
def toSql_return_separately(self):
|
|
233 | 233 |
""" convert equipment data to sql query """ |
234 | 234 |
from AppDocData import AppDocData |
235 | 235 |
res = [] |
236 |
resLater = [] |
|
236 | 237 |
|
237 | 238 |
appDocData = AppDocData.instance() |
238 | 239 |
|
... | ... | |
279 | 280 |
for assoc in self.associations(): |
280 | 281 |
param = [str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)] |
281 | 282 |
sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values)) |
282 |
res.append((sql, tuple(param))) |
|
283 |
resLater.append((sql, tuple(param)))
|
|
283 | 284 |
|
284 | 285 |
# save connectors to database |
285 | 286 |
if self.connectors: |
... | ... | |
295 | 296 |
str(connector._connected_at))\ |
296 | 297 |
) |
297 | 298 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
298 |
res.append((sql, tuple(params))) |
|
299 |
resLater.append((sql, tuple(params)))
|
|
299 | 300 |
# up to here |
300 | 301 |
|
301 |
return res |
|
302 |
return res, resLater
|
|
302 | 303 |
|
303 | 304 |
''' |
304 | 305 |
@brief return equip Data List |
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py | ||
---|---|---|
284 | 284 |
except Exception as ex: |
285 | 285 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
286 | 286 |
|
287 |
def toSql(self): |
|
287 |
def toSql_return_separately(self):
|
|
288 | 288 |
""" convert instrument data to sql query """ |
289 | 289 |
import uuid |
290 | 290 |
from AppDocData import AppDocData |
291 | 291 |
|
292 | 292 |
res = [] |
293 |
resLater = [] |
|
293 | 294 |
appDocData = AppDocData.instance() |
294 | 295 |
|
295 | 296 |
cols = ['UID', 'PNID_NO'] |
... | ... | |
326 | 327 |
for assoc in self.associations(): |
327 | 328 |
params.append((str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid))) |
328 | 329 |
sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values)) |
329 |
res.append((sql, tuple(params))) |
|
330 |
resLater.append((sql, tuple(params)))
|
|
330 | 331 |
|
331 | 332 |
# save connectors to database |
332 | 333 |
if self.connectors: |
... | ... | |
343 | 344 |
) |
344 | 345 |
index += 1 |
345 | 346 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
346 |
res.append((sql, tuple(params))) |
|
347 |
resLater.append((sql, tuple(params)))
|
|
347 | 348 |
# up to here |
348 | 349 |
|
349 |
return res |
|
350 |
return res, resLater
|
|
350 | 351 |
|
351 | 352 |
''' |
352 | 353 |
@brief return inst Data List |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
1430 | 1430 |
|
1431 | 1431 |
return node |
1432 | 1432 |
|
1433 |
def toSql(self): |
|
1433 |
def toSql_return_separately(self):
|
|
1434 | 1434 |
""" generate sql phrase to save line to database """ |
1435 | 1435 |
import uuid |
1436 | 1436 |
from AppDocData import AppDocData |
1437 | 1437 |
|
1438 | 1438 |
res = [] |
1439 |
resLater = [] |
|
1439 | 1440 |
|
1440 | 1441 |
app_doc_data = AppDocData.instance() |
1441 | 1442 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Area', 'Owner', 'SpecialItemTypes_UID'] |
... | ... | |
1459 | 1460 |
str(connector._connected_at))) |
1460 | 1461 |
index += 1 |
1461 | 1462 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
1462 |
res.append((sql, tuple(params))) |
|
1463 |
resLater.append((sql, tuple(params)))
|
|
1463 | 1464 |
# up to here |
1464 | 1465 |
|
1465 | 1466 |
# save attributes |
... | ... | |
1478 | 1479 |
res.append((sql, tuple(param))) |
1479 | 1480 |
# up to here |
1480 | 1481 |
|
1481 |
return res |
|
1482 |
return res, resLater
|
|
1482 | 1483 |
|
1483 | 1484 |
''' |
1484 | 1485 |
@brief Delete Line Item from scene |
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py | ||
---|---|---|
147 | 147 |
return _attrs |
148 | 148 |
''' |
149 | 149 |
|
150 |
def toSql(self): |
|
150 |
def toSql_return_separately(self):
|
|
151 | 151 |
""" convert valve data to sql query """ |
152 | 152 |
import uuid |
153 | 153 |
from AppDocData import AppDocData |
154 | 154 |
|
155 | 155 |
res = [] |
156 |
resLater = [] |
|
156 | 157 |
appDocData = AppDocData.instance() |
157 | 158 |
|
158 | 159 |
cols = ['UID', 'ITEM_NO', 'PNID_NO', 'MainSize', 'SubSize'] |
... | ... | |
198 | 199 |
) |
199 | 200 |
index += 1 |
200 | 201 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
201 |
res.append((sql, tuple(params))) |
|
202 |
resLater.append((sql, tuple(params)))
|
|
202 | 203 |
# up to here |
203 | 204 |
|
204 |
return res |
|
205 |
return res, resLater |
DTI_PID/DTI_PID/Shapes/EngineeringSpecBreakItem.py | ||
---|---|---|
23 | 23 |
''' |
24 | 24 |
def __init__(self, path, uid=None, flip=0): |
25 | 25 |
from SymbolAttr import SymbolProp |
26 |
from AppDocData import AppDocData |
|
26 | 27 |
SymbolSvgItem.__init__(self, path, uid, flip=flip) |
27 | 28 |
|
29 |
''' |
|
28 | 30 |
attr = SymbolAttr() |
29 | 31 |
attr.Attribute = 'UpStream' |
30 | 32 |
attr.AttributeType = 'Comp Item' |
... | ... | |
33 | 35 |
attr.Attribute = 'DownStream' |
34 | 36 |
attr.AttributeType = 'Comp Item' |
35 | 37 |
self.attrs[attr] = None |
38 |
''' |
|
39 |
specBreakAttrs = AppDocData.instance().getSymbolAttribute('Segment Breaks') |
|
40 |
self.attrs[[up for up in specBreakAttrs if up.Attribute == 'UpStream'][0]] = None |
|
41 |
self.attrs[[down for down in specBreakAttrs if down.Attribute == 'DownStream'][0]] = None |
|
36 | 42 |
|
37 | 43 |
self._properties = \ |
38 | 44 |
{\ |
DTI_PID/DTI_PID/Shapes/EngineeringUnknownItem.py | ||
---|---|---|
324 | 324 |
|
325 | 325 |
return node |
326 | 326 |
|
327 |
def toSql(self): |
|
327 |
def toSql_return_separately(self):
|
|
328 | 328 |
""" convert unknown data to sql query """ |
329 | 329 |
import uuid |
330 | 330 |
from AppDocData import AppDocData |
331 | 331 |
|
332 | 332 |
res = [] |
333 |
resLater = [] |
|
333 | 334 |
|
334 | 335 |
appDocData = AppDocData.instance() |
335 | 336 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Area'] |
... | ... | |
348 | 349 |
str(self.uid), index, pt.x(), pt.y())) |
349 | 350 |
index += 1 |
350 | 351 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
351 |
res.append((sql, tuple(params))) |
|
352 |
resLater.append((sql, tuple(params)))
|
|
352 | 353 |
|
353 | 354 |
# save attributes |
354 | 355 |
cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value'] |
... | ... | |
365 | 366 |
res.append((sql, tuple(param))) |
366 | 367 |
# up to here |
367 | 368 |
|
368 |
return res |
|
369 |
return res, resLater
|
|
369 | 370 |
|
370 | 371 |
''' |
371 | 372 |
@brief Delete from Scene |
DTI_PID/DTI_PID/Shapes/EngineeringVendorItem.py | ||
---|---|---|
126 | 126 |
|
127 | 127 |
return vendorItem |
128 | 128 |
|
129 |
def toSql(self): |
|
129 |
def toSql_return_separately(self):
|
|
130 | 130 |
""" convert vendor package data to sql query """ |
131 | 131 |
import uuid |
132 | 132 |
res = [] |
133 |
resLater = [] |
|
133 | 134 |
|
134 | 135 |
app_doc_data = AppDocData.instance() |
135 | 136 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Area', 'Owner', 'SpecialItemTypes_UID'] |
... | ... | |
150 | 151 |
params.append((#str(uuid.uuid4()), |
151 | 152 |
str(self.uid), index, point[0], point[1])) |
152 | 153 |
sql = 'insert or replace into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
153 |
res.append((sql, tuple(params))) |
|
154 |
resLater.append((sql, tuple(params)))
|
|
154 | 155 |
# up to here |
155 | 156 |
|
156 |
return res |
|
157 |
return res, resLater
|
|
157 | 158 |
|
158 | 159 |
@staticmethod |
159 | 160 |
def fromXml(node): |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
463 | 463 |
|
464 | 464 |
return super().itemChange(change, value) |
465 | 465 |
|
466 |
def toSql(self): |
|
466 |
def toSql_return_separately(self):
|
|
467 | 467 |
""" convert valve data to sql query """ |
468 | 468 |
import uuid |
469 | 469 |
from AppDocData import AppDocData |
470 | 470 |
|
471 | 471 |
res = [] |
472 |
resLater = [] |
|
472 | 473 |
appDocData = AppDocData.instance() |
473 | 474 |
|
474 | 475 |
cols = ['UID', 'ITEM_NO', 'MainSize', 'SubSize', 'PNID_NO'] |
... | ... | |
507 | 508 |
for assoc in self.associations(): |
508 | 509 |
params.append((str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid))) |
509 | 510 |
sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values)) |
510 |
res.append((sql, tuple(params))) |
|
511 |
resLater.append((sql, tuple(params)))
|
|
511 | 512 |
|
512 | 513 |
# save connectors to database |
513 | 514 |
if self.connectors: |
... | ... | |
524 | 525 |
) |
525 | 526 |
index += 1 |
526 | 527 |
sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
527 |
res.append((sql, tuple(params))) |
|
528 |
resLater.append((sql, tuple(params)))
|
|
528 | 529 |
# up to here |
529 | 530 |
|
530 |
return res |
|
531 |
return res, resLater
|
|
531 | 532 |
|
532 | 533 |
''' |
533 | 534 |
@brief build symbol item |
DTI_PID/DTI_PID/SpecBreakDialog.py | ||
---|---|---|
109 | 109 |
''' |
110 | 110 |
propertyComboBox = QComboBox(self) |
111 | 111 |
attrs = AppDocData.instance().getSymbolAttribute('Segment Breaks') |
112 |
for attr in attrs:
|
|
112 |
for attr in [attr for attr in attrs if attr.Attribute != 'UpStream' and attr.Attribute != 'DownStream']:
|
|
113 | 113 |
propertyComboBox.addItem(attr.DisplayAttribute) |
114 | 114 |
#propertyComboBox.addItem('NominalDiameter') |
115 | 115 |
#propertyComboBox.addItem('FluidCode') |
내보내기 Unified diff