2 import CommonUtils, TagTree, tagInventory
6 def __init__( self, sourcesession, destsession, rowcachesize=1024 ):
8 self.__destsession=destsession
9 self.__rowcachesize=rowcachesize
12 self.__rowcachesize=newrowcachesize
15 """copy entire inventory. The original inventory in the source db will be wiped.
18 inv.createInventoryTable()
19 dest_transaction=self.__destsession.transaction()
20 source_transaction=self.__sourcesession.transaction()
22 dest_transaction.start(
False)
24 data=coral.AttributeList()
25 my_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.inventoryTableName()).dataEditor()
26 source_transaction.start(
True)
27 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.inventoryTableName()).newQuery()
28 conditionData=coral.AttributeList()
29 source_query.setCondition(
'',conditionData)
30 source_query.setRowCacheSize(self.__rowcachesize)
31 my_editor.rowBuffer(data)
32 source_query.defineOutput(data)
33 bulkOperation=my_editor.bulkInsert(data,self.__rowcachesize)
34 cursor=source_query.execute()
35 while (cursor.next() ):
36 bulkOperation.processNextIteration()
42 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.inventoryIDTableName()).newQuery()
43 my_ideditor=self.__destsession.nominalSchema().tableHandle(CommonUtils.inventoryIDTableName()).dataEditor()
44 iddata=coral.AttributeList()
45 source_query.setCondition(
'',conditionData)
46 source_query.setRowCacheSize(self.__rowcachesize)
47 my_ideditor.rowBuffer(iddata)
48 source_query.defineOutput(iddata)
49 bulkOperation=my_ideditor.bulkInsert(iddata,self.__rowcachesize)
50 cursor=source_query.execute()
52 bulkOperation.processNextIteration()
58 if self.__sourcesession.nominalSchema().existsTable(CommonUtils.commentTableName()):
59 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.commentTableName()).newQuery()
60 my_commenteditor=self.__destsession.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
61 commentdata=coral.AttributeList()
62 qcondition=coral.AttributeList()
63 qcondition.extend(
'tablename',
'string')
64 qcondition[
'tablename'].setData(CommonUtils.commentTableName())
65 source_query.setCondition(
'tablename = :tablename',qcondition)
66 source_query.setRowCacheSize(self.__rowcachesize)
67 my_commenteditor.rowBuffer(commentdata)
68 source_query.defineOutput(commentdata)
69 bulkOperation=my_commenteditor.bulkInsert(commentdata,self.__rowcachesize)
70 cursor=source_query.execute()
72 bulkOperation.processNextIteration()
77 source_transaction.commit()
78 dest_transaction.commit()
80 source_transaction.rollback()
81 dest_transaction.rollback()
82 raise Exception, str(e)
85 """copy tree from an external source.
86 Merge inventory if existing in the destination
89 for treename
in treenames:
91 allleafs.append(t.getAllLeaves())
98 sourcetags=sourceinv.getAllEntries()
100 for i
in merged.keys():
105 entry[
'tagname']=n.tagname
107 entry[
'recordname']=n.recordname
108 entry[
'objectname']=n.objectname
109 entry[
'labelname']=n.labelname
110 entries.append(entry)
112 tagiddict=inv.bulkInsertEntries(entries)
113 dest_transaction=self.__destsession.transaction()
114 source_transaction=self.__sourcesession.transaction()
117 for treename
in treenames:
119 desttree.createTagTreeTable()
120 dest_transaction.start(
False)
121 source_transaction.start(
True)
123 data=coral.AttributeList()
124 dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.treeTableName(treename)).dataEditor()
125 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.treeTableName(treename)).newQuery()
126 conditionData=coral.AttributeList()
127 source_query.setCondition(
'',conditionData)
128 source_query.setRowCacheSize(self.__rowcachesize)
129 dest_editor.rowBuffer(data)
130 source_query.defineOutput(data)
131 bulkOperation=dest_editor.bulkInsert(data,self.__rowcachesize)
132 cursor=source_query.execute()
134 bulkOperation.processNextIteration()
135 bulkOperation.flush()
139 iddata=coral.AttributeList()
140 dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.treeIDTableName(treename)).dataEditor()
141 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.treeIDTableName(treename)).newQuery()
142 conditionData=coral.AttributeList()
143 source_query.setCondition(
'',conditionData)
144 source_query.setRowCacheSize(self.__rowcachesize)
145 dest_editor.rowBuffer(iddata)
146 source_query.defineOutput(iddata)
147 bulkOperation=dest_editor.bulkInsert(iddata,self.__rowcachesize)
148 cursor=source_query.execute()
150 bulkOperation.processNextIteration()
151 bulkOperation.flush()
155 if self.__sourcesession.nominalSchema().existsTable(CommonUtils.commentTableName()):
156 data=coral.AttributeList()
157 dest_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
158 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.commentTableName()).newQuery()
159 conditionData=coral.AttributeList()
160 source_query.setCondition(
'tablename = :tablename',conditionData)
161 conditionData.extend(
'tablename',
'string')
162 conditionData[
'tablename'].setData(CommonUtils.treeTableName(treename))
163 source_query.setRowCacheSize(self.__rowcachesize)
164 dest_editor.rowBuffer(data)
165 source_query.defineOutput(data)
166 bulkOperation=dest_editor.bulkInsert(data,self.__rowcachesize)
167 cursor=source_query.execute()
169 bulkOperation.processNextIteration()
170 bulkOperation.flush()
174 source_transaction.commit()
175 dest_transaction.commit()
177 desttree.replaceLeafLinks(tagiddict)
179 source_transaction.rollback()
180 dest_transaction.rollback()
181 raise Exception, str(e)
185 """copy all globaltag related tables from an external source.
186 The destination database must be empty. If not so, it will be cleaned implicitly. Inventory are implicitly copied as well.
188 dest_transaction=self.__destsession.transaction()
189 source_transaction=self.__sourcesession.transaction()
194 source_transaction.start(
True)
195 tablelist=
list(self.__sourcesession.nominalSchema().listTables())
196 source_transaction.commit()
198 source_transaction.rollback()
199 raise Exception, str(e)
201 i = tablelist.index(CommonUtils.inventoryTableName())
202 alltablelist.append(CommonUtils.inventoryTableName())
204 raise 'Error: '+CommonUtils.inventoryTableName()+
' does not exist in the source'
206 i = tablelist.index(CommonUtils.inventoryIDTableName())
207 alltablelist.append(CommonUtils.inventoryIDTableName())
209 raise 'Error: '+CommonUtils.inventoryIDTableName()+
' does not exist'
212 i = tablelist.index(CommonUtils.commentTableName())
213 alltablelist.append(CommonUtils.commentTableName())
217 for tablename
in tablelist:
218 posbeg=tablename.find(
'TAGTREE_TABLE_')
220 treename=tablename[posbeg+len(
'TAGTREE_TABLE_'):]
221 trees.append(treename)
224 tablelist.index(CommonUtils.treeIDTableName(tree))
226 print 'non-existing id table for tree ',tree
228 alltablelist.append(CommonUtils.treeTableName(tree))
229 alltablelist.append(CommonUtils.treeIDTableName(tree))
232 inv.createInventoryTable()
233 for treename
in trees:
235 t.createTagTreeTable()
238 for mytable
in alltablelist:
239 dest_transaction.start(
False)
240 source_transaction.start(
True)
241 data=coral.AttributeList()
242 my_editor=self.__destsession.nominalSchema().tableHandle(mytable).dataEditor()
243 source_query=self.__sourcesession.nominalSchema().tableHandle(mytable).newQuery()
244 conditionData=coral.AttributeList()
245 source_query.setCondition(
'',conditionData)
246 source_query.setRowCacheSize(self.__rowcachesize)
247 my_editor.rowBuffer(data)
248 source_query.defineOutput(data)
249 bulkOperation=my_editor.bulkInsert(data,self.__rowcachesize)
250 cursor=source_query.execute()
252 bulkOperation.processNextIteration()
253 bulkOperation.flush()
256 source_transaction.commit()
257 dest_transaction.commit()
259 source_transaction.rollback()
260 dest_transaction.rollback()
261 raise Exception, str(e)
263 if __name__ ==
"__main__":
266 svc = coral.ConnectionService()
268 sourcesession = svc.connect(
'sqlite_file:source.db',
269 accessMode = coral.access_Update )
270 destsession = svc.connect(
'sqlite_file:dest.db',
271 accessMode = coral.access_Update )
273 dbcp=
DBCopy(sourcesession,destsession,1024)
274 print "TEST copyInventory"
276 print "TEST copytrees"
277 treenames=[
'CRUZET3_V2H']
278 dbcp.copyTrees(treenames)
282 print "Failed in unit test"
287 sourcesession = svc.connect(
'sqlite_file:source.db',
288 accessMode = coral.access_Update )
289 destsession = svc.connect(
'sqlite_file:dest2.db',
290 accessMode = coral.access_Update )
292 dbcp=
DBCopy(sourcesession,destsession,1024)
293 print "TEST full dbCopy"
298 print "Failed in unit test"
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run