프로젝트

일반

사용자정보

개정판 115ef24c

ID115ef24cdf87017aec6a4ae81f3b31dc7d26b6aa
상위 906274dc
하위 6d011c3c

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

issue #1171: fix line connector save and integrate tosql

Change-Id: I7792fdf039133fdd13f7185de7077ebdd416e4f5

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py
202 202
            return None
203 203

  
204 204
        return node
205

  
206
    def toSql_return_separately(self):
207
        """ convert equipment data to sql query """
208
        import uuid
209
        res = []
210
        resLater = []
211

  
212
        res.append(self.toSql_Components())
213

  
214
        _attrs = self.getAttributes()
215
        if _attrs:
216
            cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
217
            values = ['?', '?', '?', '?']
218
            params = []
219
            for key in _attrs.keys():
220
                params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(_attrs[key])))
221
            sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
222
            res.append((sql, tuple(params)))
223

  
224
        if self.associations():
225
            cols = ['UID', '[Type]', 'Components_UID', 'Association']
226
            values = ['?', '?', '?', '?']
227
            params = []
228
            for assoc in self.associations():
229
                params.append(
230
                    (str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)))
231
            sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
232
            resLater.append((sql, tuple(params)))
233

  
234
        # save connectors to database
235
        if self.connectors:
236
            cols = ['Components_UID', '[Index]', 'X', 'Y', 'Connected', 'Connected_At']
237
            values = ['?', '?', '?', '?', '?', '?']
238
            params = []
239
            index = 1
240
            for connector in self.connectors:
241
                params.append( \
242
                    (
243
                        str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1], \
244
                        str(connector.connectedItem.uid) if connector.connectedItem else None, \
245
                        str(connector._connected_at)) \
246
                    )
247
                index += 1
248

  
249
            sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values))
250
            resLater.append((sql, tuple(params)))
251
        # up to here
252

  
253
        return res, resLater
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
306 306
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
307 307
                                                      sys.exc_info()[-1].tb_lineno))
308 308

  
309
    def toSql_return_separately(self):
310
        """ convert instrument data to sql query """
311
        import uuid
312
        from AppDocData import AppDocData
313

  
314
        res = []
315
        resLater = []
316

  
317
        res.append(self.toSql_Components())
318

  
319
        _attrs = self.getAttributes()
320
        if _attrs:
321
            cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
322
            values = ['?', '?', '?', '?']
323
            params = []
324
            for key in _attrs.keys():
325
                params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(_attrs[key])))
326
            sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
327
            res.append((sql, tuple(params)))
328

  
329
        if self.associations():
330
            cols = ['UID', '[Type]', 'Components_UID', 'Association']
331
            values = ['?', '?', '?', '?']
332
            params = []
333
            for assoc in self.associations():
334
                params.append(
335
                    (str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)))
336
            sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
337
            resLater.append((sql, tuple(params)))
338

  
339
        # save connectors to database
340
        if self.connectors:
341
            cols = ['Components_UID', '[Index]', 'X', 'Y', 'Connected', 'Connected_At']
342
            values = ['?', '?', '?', '?', '?', '?']
343
            params = []
344
            index = 1
345
            for connector in self.connectors:
346
                params.append( \
347
                    (  # str(connector.uid),
348
                        str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1], \
349
                        str(connector.connectedItem.uid) if connector.connectedItem else None, \
350
                        str(connector._connected_at)) \
351
                    )
352
                index += 1
353
            sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values))
354
            resLater.append((sql, tuple(params)))
355
        # up to here
356

  
357
        return res, resLater
358

  
359 309
    '''
360 310
        @brief      return inst Data List
361 311
        @author     kyouho
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1562 1562
        index = 1
1563 1563
        for connector in self.connectors:
1564 1564
            params.append((  # str(connector.uid),
1565
                str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1], \
1565
                str(self.uid), index, connector.sceneConnectPoint[0], connector.sceneConnectPoint[1], \
1566 1566
                str(connector.connectedItem.uid) if connector.connectedItem else None, \
1567 1567
                str(connector._connected_at)))
1568 1568
            index += 1
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
125 125
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
126 126
                                                          sys.exc_info()[-1].tb_lineno)
127 127
            App.mainWnd().addMessage.emit(MessageType.Error, message)
128

  
129
    '''
130
    def getAttributes(self):
131
        """ get attributes of reducer """
132

  
133
        _attrs = {}
134
        try:
135
            from AppDocData import AppDocData
136
            from EngineeringAbstractItem import QEngineeringAbstractItem
137
            from EngineeringTextItem import QEngineeringTextItem
138

  
139
            # 해당 Type의 attribute setting
140
            docData = AppDocData.instance()
141
            symbolAttrs = docData.getSymbolAttribute(self.type)
142

  
143
            _texts = self.texts()
144
            _symbols = self.symbols()
145
            for attr in symbolAttrs:
146
                if attr.AttributeType == 'Size Text Item' or attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
147
                    at = int(attr.AttrAt)
148
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
149
                    if len(items) > at:
150
                        item = items[at]
151
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
152
                    else:
153
                        _attrs[attr] = ''
154
                else:
155
                    matches = [prop for prop in self.attrs if prop.UID == attr.UID]
156
                    if len(matches) == 1:
157
                        _attrs[matches[0]] = self.attrs[matches[0]]
158
                    else:
159
                        _attrs[attr] = ''
160
        except Exception as ex:
161
            from App import App 
162
            from AppDocData import MessageType
163

  
164
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
165
            App.mainWnd().addMessage.emit(MessageType.Error, message)
166
        
167
        return _attrs
168
    '''
169

  
170
    def toSql_return_separately(self):
171
        """ convert valve data to sql query """
172
        import uuid
173
        from AppDocData import AppDocData
174

  
175
        res = []
176
        resLater = []
177
        appDocData = AppDocData.instance()
178

  
179
        res.append(self.toSql_Components())
180

  
181
        cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
182
        values = ['?', '?', '?', '?']
183
        params = []
184
        _attrs = self.getAttributes()
185
        for key in _attrs.keys():
186
            params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(_attrs[key])))
187
        sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
188
        res.append((sql, tuple(params)))
189

  
190
        # save connectors to database
191
        if self.connectors:
192
            cols = ['Components_UID', '[Index]', 'X', 'Y', 'Connected', 'Connected_At']
193
            values = ['?', '?', '?', '?', '?', '?']
194
            params = []
195
            index = 1
196
            for connector in self.connectors:
197
                params.append( \
198
                    (  # str(connector.uid),
199
                        str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1], \
200
                        str(connector.connectedItem.uid) if connector.connectedItem else None, \
201
                        str(connector._connected_at)) \
202
                    )
203
                index += 1
204
            sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values))
205
            resLater.append((sql, tuple(params)))
206
        # up to here
207

  
208
        return res, resLater
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
524 524
    def toSql_return_separately(self):
525 525
        """ convert valve data to sql query """
526 526
        import uuid
527
        from AppDocData import AppDocData
528 527

  
529 528
        res = []
530 529
        resLater = []
531
        app_doc_data = AppDocData.instance()
532 530

  
533 531
        res.append(self.toSql_Components())
534 532

  

내보내기 Unified diff

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