프로젝트

일반

사용자정보

개정판 8b646a19

ID8b646a19031ce467751bd71c6b0f0da11c3c7905
상위 60545a53
하위 cdea96b5

함의성이(가) 약 5년 전에 추가함

issue #1171: fix load from db and 563: line no attr and assoc saved

Change-Id: I2f807ada94d4db983f4edb25a5cde00fa2588b84

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
952 952
                        attr.DisplayAttribute = row[2]
953 953
                        attr.AttributeType = row[3]
954 954
                        attr.Length = row[4]
955
                        attr.IsProp = 5
955 956
                        self._lineNoProperties.append(attr)
956 957

  
957 958
                    res = self._lineNoProperties
......
1027 1028
                    attr.DisplayAttribute = row[2]
1028 1029
                    attr.AttributeType = row[3]
1029 1030
                    attr.Length = row[4]
1031
                    attr.IsProp = 5
1030 1032
                    res.append(attr)
1031 1033
                self._lineNoPropertiesUID[UID] = res
1032 1034
            # Catch the exception
......
2553 2555
                        pre = row['Components_UID']
2554 2556
                        compo = []
2555 2557
                        compo.append(row)
2558
                        if row is rows[-1]:
2559
                            self._connecterss[row['Components_UID']] = compo
2556 2560
                    else:
2557 2561
                        compo.append(row)
2558 2562
                        if row is rows[-1]:
......
2594 2598
                        pre = row['Components_UID']
2595 2599
                        compo = []
2596 2600
                        compo.append(row)
2601
                        if row is rows[-1]:
2602
                            self._associationss[row['Components_UID']] = compo
2597 2603
                    else:
2598 2604
                        compo.append(row)
2599 2605
                        if row is rows[-1]:
......
2635 2641
                        pre = row['Components_UID']
2636 2642
                        compo = []
2637 2643
                        compo.append(row)
2644
                        if row is rows[-1]:
2645
                            self._attributess[row['Components_UID']] = compo
2638 2646
                    else:
2639 2647
                        compo.append(row)
2640 2648
                        if row is rows[-1]:
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
792 792
                """ show icon item """
793 793
                self.show_icon_item(row, 2, key)
794 794

  
795
                """ show freeze state """
796
                if key.IsProp != 5:
797
                    checkbox = QCustomCheckBox(self, row, 0)
798
                    checkbox.setChecked(key.Freeze)
799
                    checkbox.stateChanged.connect(checkbox.state_changed)
800
                    self.setCellWidget(row, 0, checkbox)
801

  
795 802
                # value cell
796 803
                value = attrs[key]
797 804
                valueCell = QTableWidgetItem(value)
DTI_PID/DTI_PID/Scripts/MSSQL/ID2.sql
132 132
INSERT INTO SymbolType
133 133
(UID, Category, "Type")
134 134
VALUES(39, 'Package', 'Package');
135
INSERT INTO SymbolType
136
(UID, Category, "Type")
137
VALUES(40, 'Line No', 'Line No');
135 138

  
136 139
CREATE TABLE SymbolName (
137 140
    UID            INTEGER NOT NULL
......
1432 1435
VALUES('0b41a1ec-87b6-4635-bc6c-6c46642a32af', '33', 'UnitNumber', 'UnitNumber', 'Spec', '', 7, 7, NULL, 'ALL', 3);
1433 1436
INSERT INTO SymbolAttribute
1434 1437
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1435
VALUES('2c413303-cc5a-4d4c-af24-a837041276f4', '-1', 'Thickness', 'Thickness', 'Int', NULL, 1, NULL, NULL, NULL, NULL);
1438
VALUES('2c413303-cc5a-4d4c-af24-a837041276f4', '-1', 'Thickness', 'Thickness', 'Int', NULL, 1, NULL, NULL, NULL, 3);
1436 1439
INSERT INTO SymbolAttribute
1437 1440
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1438
VALUES('3bf98d8c-5736-4b4a-8008-deb36e09056b', '-1', 'LineType', 'Line Type', 'String', NULL, 0, NULL, NULL, NULL, NULL);
1441
VALUES('3bf98d8c-5736-4b4a-8008-deb36e09056b', '-1', 'LineType', 'Line Type', 'String', NULL, 0, NULL, NULL, NULL, 3);
1439 1442
INSERT INTO SymbolAttribute
1440 1443
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1441
VALUES('60c3f3bc-a69d-42b2-b198-9b6ee0dd2594', '-1', 'LineIndicator', 'Line Indicator', 'String', NULL, 3, NULL, NULL, NULL, NULL);
1444
VALUES('60c3f3bc-a69d-42b2-b198-9b6ee0dd2594', '-1', 'LineIndicator', 'Line Indicator', 'String', NULL, 3, NULL, NULL, NULL, 3);
1442 1445
INSERT INTO SymbolAttribute
1443 1446
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1444
VALUES('b8f6c3a5-4abb-462b-b90f-66afac591aab', '-1', 'FlowMark', 'Flow Mark', 'Int', NULL, 2, NULL, NULL, NULL, NULL);
1447
VALUES('b8f6c3a5-4abb-462b-b90f-66afac591aab', '-1', 'FlowMark', 'Flow Mark', 'Int', NULL, 2, NULL, NULL, NULL, 3);
1445 1448
INSERT INTO SymbolAttribute
1446 1449
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1447
VALUES('86699578-706a-4158-b636-6b5dc8a11ad7', '-1', 'From', 'From', 'String', NULL, 4, NULL, NULL, NULL, NULL);
1450
VALUES('86699578-706a-4158-b636-6b5dc8a11ad7', '-1', 'From', 'From', 'String', NULL, 4, NULL, NULL, NULL, 3);
1448 1451
INSERT INTO SymbolAttribute
1449 1452
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1450
VALUES('61190fa0-8074-4f25-8b47-8b0b686e1ede', '-1', 'Freeze', 'Freeze', 'Int', NULL, 6, 0, NULL, 'ALL', 0);
1453
VALUES('61190fa0-8074-4f25-8b47-8b0b686e1ede', '-1', 'Freeze', 'Freeze', 'Int', NULL, 6, NULL, NULL, 'ALL', 3);
1451 1454
INSERT INTO SymbolAttribute
1452 1455
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1453
VALUES('3329313c-cd06-4b89-a10b-795dcdf5830f', '-1', 'To', 'To', 'String', NULL, 5, 0, NULL, 'ALL', 0);
1456
VALUES('3329313c-cd06-4b89-a10b-795dcdf5830f', '-1', 'To', 'To', 'String', NULL, 5, NULL, NULL, NULL, 3);
1454 1457
INSERT INTO SymbolAttribute
1455 1458
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1456 1459
VALUES('3e073331-0faf-4fc1-8853-2db6291b9161', '33', 'UpStream', 'UpStream', 'Comp Item', 'item', 0, 0, NULL, 'ALL', 3);
......
1511 1514
INSERT INTO SymbolAttribute
1512 1515
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1513 1516
VALUES('a0b800a7-bb02-458c-8a06-061c86c24b5c', '39', 'Name', 'Name', 'Tag No', 'self.EvaluatedName', 0, 0, NULL, 'ALL', 1);
1517
INSERT INTO SymbolAttribute
1518
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1519
VALUES('d50c31b9-595f-4f4c-a2bd-afc6d8112b86', '40', 'From_eq', 'From_eq', 'Symbol Item', 'item.EvaluatedName', 0, 0, NULL, 'ALL', 1);
1520
INSERT INTO SymbolAttribute
1521
(UID, SymbolType_UID, "Attribute", DisplayAttribute, AttributeType, Expression, "index", AttrAt, "Length", Target, Property)
1522
VALUES('83ffef92-3c94-47ce-a6ec-737ba4a79a93', '40', 'To_eq', 'To_eq', 'Symbol Item', 'item.EvaluatedName', 1, 1, NULL, 'ALL', 1);
1514 1523

  
1515 1524
CREATE TABLE Attributes (
1516 1525
    UID                 VARCHAR (37) PRIMARY KEY,
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
232 232
            from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
233 233
            from EngineeringLineItem import QEngineeringLineItem
234 234
            from EngineeringVendorItem import QEngineeringVendorItem
235
            from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
235 236

  
236 237
            """ get attributes of item from database """
237 238
            docData = AppDocData.instance()
......
239 240
                symbolAttrs =  docData.getSymbolAttribute('Line')
240 241
            elif type(self) is QEngineeringVendorItem:
241 242
                symbolAttrs =  docData.getSymbolAttribute('Package')
243
            elif type(self) is QEngineeringLineNoTextItem:
244
                symbolAttrs =  docData.getSymbolAttribute('Line No')
245
                self.getLineNoAttributes(_attrs)
242 246
            else:
243 247
                symbolAttrs = docData.getSymbolAttribute(self.type)
244 248
            targetAttrs = []
245
            if type(self) is not QEngineeringLineItem:
249
            if not (type(self) is QEngineeringLineItem or type(self) is QEngineeringVendorItem or type(self) is QEngineeringLineNoTextItem):
246 250
                for attr in symbolAttrs:
247 251
                    if attr.Target is None or attr.Target == 'ALL' or [target for target in attr.Target.split(',') if self.dbUid is int(target)]:
248 252
                        targetAttrs.append(attr)
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
217 217
        @author     kyouho
218 218
        @date       2018.09.06
219 219
    '''
220
    def getAttributes(self):
220
    def getLineNoAttributes(self, _attrs=None):
221 221
        from SymbolAttr import SymbolAttr
222 222
        from Configs import LineNoConfig
223 223

  
224
        _attrs = {}
224
        if _attrs is None:
225
            _attrs = {}
226

  
225 227
        try:
226 228
            docData = AppDocData.instance()
227 229

  
......
242 244
                attr.Attribute = 'LINE NO'
243 245
                attr.DisplayAttribute = 'Line No'
244 246
                attr.AttributeType = 'String'
247
                attr.IsProp = 5
245 248
                _attrs[attr] = self.text()
246 249

  
247 250
                result = item[1]
......
293 296
                item.setVisible(False)
294 297
                for key in item._properties.keys():
295 298
                    item._properties[key] = key.parse_value(component[key.Attribute])
296
                    
299

  
297 300
                app_doc_data = AppDocData.instance()
301

  
302
                # get associations 
303
                associations = app_doc_data.get_component_associations(component['UID'])
304
                if associations:
305
                    for assoc in associations:
306
                        _attrType = assoc['Type']
307
                        if not _attrType in item._associations:
308
                            item._associations[_attrType] = []
309
                        item._associations[_attrType].append(
310
                            uuid.UUID(assoc['Association']) if assoc['Association'] != 'None' else None)
311
                # up to here
312

  
298 313
                attrs = app_doc_data.get_component_attributes(component['UID'])
299 314
                for _attr in attrs:
300 315
                    attr = SymbolAttr.from_record(_attr)
......
569 584
        values = ['?', '?', '?', '?']
570 585
        params = []
571 586
        attrs = self.getAttributes()
572
        first_lineNo = True
573 587
        for key,value in attrs.items():
574
            if first_lineNo:
575
                first_lineNo = False
588
            if key.Attribute == 'LINE NO':# or key.IsProp != 5:
576 589
                continue
577 590
            params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(value)))
578 591
        sql = 'insert into LineNoAttributes({}) values({})'.format(','.join(cols), ','.join(values))
579 592
        resLater.append((sql, tuple(params)))
580 593

  
581
        # insert line no's properties
582
        '''
583
        cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
584
        values = ['?', '?', '?', '?']
585
        for key in self._properties.keys():
586
            values[2] = "(select UID from SymbolAttribute where Attribute='{}' and SymbolType_UID=-1)".format(key.Attribute)
587
            params = [(str(uuid.uuid4()), str(self.uid), str(self.prop(key.Attribute)))]
588
            sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
589
            res.append((sql, tuple(params)))
590
        '''
594
        # insert line no's Attributes
595
        cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value', 'Association_UID', 'Freeze']
596
        values = ['?', '?', '?', '?', '?', '?']
597
        params = []
598
        for key in attrs.keys():
599
            if key.IsProp != 5:
600
                params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(attrs[key]), str(key.AssocItem),
601
                               str(key.Freeze)))
602
        sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
603
        res.append((sql, tuple(params)))
604

  
605
        if self.associations():
606
            cols = ['UID', '[Type]', 'Components_UID', 'Association']
607
            values = ['?', '?', '?', '?']
608
            params = []
609
            for assoc in self.associations():
610
                params.append(
611
                    (str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)))
612
            sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
613
            resLater.append((sql, tuple(params)))
591 614

  
592 615
        _index = 0
593 616
        for run in self.runs:
DTI_PID/DTI_PID/SymbolAttr.py
129 129
        self.Target = None
130 130
        self.Length = None
131 131
        self.AssocItem = None
132
        self.IsProp = 0  # default value is 0
132
        self.IsProp = 0  # default value is 0, 1 : provided ediable, 2 : provided not ediable, 3 : provided not ediable, 5 : for line no props not in database
133 133
        self.Codes = None
134 134

  
135 135
    @staticmethod

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)