16 """copy entire inventory. The original inventory in the source db will be wiped.
19 inv.createInventoryTable()
20 dest_transaction=self.__destsession.transaction()
21 source_transaction=self.__sourcesession.transaction()
23 dest_transaction.start(
False)
25 data=coral.AttributeList()
26 my_editor=self.__destsession.nominalSchema().tableHandle(CommonUtils.inventoryTableName()).dataEditor()
27 source_transaction.start(
True)
28 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.inventoryTableName()).newQuery()
29 conditionData=coral.AttributeList()
30 source_query.setCondition(
'',conditionData)
31 source_query.setRowCacheSize(self.__rowcachesize)
32 my_editor.rowBuffer(data)
33 source_query.defineOutput(data)
34 bulkOperation=my_editor.bulkInsert(data,self.__rowcachesize)
35 cursor=source_query.execute()
36 while (cursor.next() ):
37 bulkOperation.processNextIteration()
43 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.inventoryIDTableName()).newQuery()
44 my_ideditor=self.__destsession.nominalSchema().tableHandle(CommonUtils.inventoryIDTableName()).dataEditor()
45 iddata=coral.AttributeList()
46 source_query.setCondition(
'',conditionData)
47 source_query.setRowCacheSize(self.__rowcachesize)
48 my_ideditor.rowBuffer(iddata)
49 source_query.defineOutput(iddata)
50 bulkOperation=my_ideditor.bulkInsert(iddata,self.__rowcachesize)
51 cursor=source_query.execute()
53 bulkOperation.processNextIteration()
59 if self.__sourcesession.nominalSchema().existsTable(CommonUtils.commentTableName()):
60 source_query=self.__sourcesession.nominalSchema().tableHandle(CommonUtils.commentTableName()).newQuery()
61 my_commenteditor=self.__destsession.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
62 commentdata=coral.AttributeList()
63 qcondition=coral.AttributeList()
64 qcondition.extend(
'tablename',
'string')
65 qcondition[
'tablename'].setData(CommonUtils.commentTableName())
66 source_query.setCondition(
'tablename = :tablename',qcondition)
67 source_query.setRowCacheSize(self.__rowcachesize)
68 my_commenteditor.rowBuffer(commentdata)
69 source_query.defineOutput(commentdata)
70 bulkOperation=my_commenteditor.bulkInsert(commentdata,self.__rowcachesize)
71 cursor=source_query.execute()
73 bulkOperation.processNextIteration()
78 source_transaction.commit()
79 dest_transaction.commit()
81 source_transaction.rollback()
82 dest_transaction.rollback()
83 raise Exception, str(e)