3 return 'TAGINVENTORY_TABLE'
5 return 'TAGINVENTORY_IDS'
7 return 'TAGTREE_TABLE_'+str.upper(treename)
9 return 'TAGTREE_'+str.upper(treename)+
'_IDS'
11 return 'ENTRYCOMMENT_TABLE'
15 """drop all tagtree related tables
18 dbsession.transaction().
start(
False)
19 tablelist = dbsession.nominalSchema().listTables()
20 for tname
in tablelist:
21 if tname.find(
'TAGTREE_') != -1:
22 dbsession.nominalSchema().dropTable(tname)
23 dbsession.transaction().commit()
25 raise Exception, str(e)
28 """returns the tree names which contain the given tag
29 select tagid from taginventory_table where tagname=tagname
30 select count(*) from tablename where tablename.tagid=tagid
33 dbsession.transaction().
start(
True)
35 conditionbindDict=coral.AttributeList()
36 conditionbindDict.extend(
'tagname',
'string')
37 conditionbindDict[
'tagname'].setData(tagname)
38 condition=
'tagname = :tagname'
40 condition+=
' AND pfn = :pfn'
41 conditionbindDict.extend(
'pfn',
'string')
42 conditionbindDict[
'pfn'].setData(pfn)
43 invquery.setCondition(condition,conditionbindDict)
44 invquery.addToOutputList(
'tagid')
45 invquery.addToOutputList(
'pfn')
46 cursor = invquery.execute()
48 while ( cursor.next() ):
49 tagid=cursor.currentRow()[
'tagid'].
data()
50 pfn=cursor.currentRow()[
'pfn'].
data()
53 dbsession.transaction().commit()
60 dbsession.transaction().
start(
True)
61 tablelist = dbsession.nominalSchema().listTables()
63 if t.find(
'TAGTREE_TABLE_')!= -1:
64 treetablelist.append(t)
65 for (pfn,tagid)
in tagidmap.items():
67 condition=
'tagid = :tagid'
68 for t
in treetablelist:
69 conditionBind=coral.AttributeList()
70 conditionBind.extend(
'tagid',
'unsigned long')
71 conditionBind[
'tagid'].setData(tagid)
72 q=dbsession.nominalSchema().tableHandle(t).newQuery()
73 q.addToOutputList(
'count(*)',
'count')
74 myresult=coral.AttributeList()
75 myresult.extend(
'count',
'unsigned long')
76 q.defineOutput(myresult)
77 q.setCondition(condition,conditionBind)
80 if cr.currentRow()[
'count'].
data()!=0:
81 result[pfn].
append(t[len(
'TAGTREE_TABLE_'):])
84 dbsession.transaction().commit()
87 raise Exception, str(e)
89 if __name__ ==
"__main__":
92 svc = coral.ConnectionService()
93 session = svc.connect(
'sqlite_file:testInventory.db',
94 accessMode = coral.access_Update )
106 mikey=
tagInTrees(session,
'Tracker_Geometry_CRUZET3',
'frontier://(proxyurl=http://localhost:3128)(serverurl=http://frontier1.cms:8000/FrontierOnProd)(serverurl=http://frontier2.cms:8000/FrontierOnProd)(retrieve-ziplevel=0)/CMS_COND_20X_ALIGNMENT')
110 print "Failed in unit test"