CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
python.entryComment.entryComment Class Reference
Inheritance diagram for python.entryComment.entryComment:

Public Member Functions

def __init__
 
def bulkinsertComments
 
def clearAllEntriesForTable
 
def createEntryCommentTable
 
def deleteCommentForId
 
def existCommentTable
 
def getCommentForId
 
def getCommentsForTable
 
def insertComment
 
def modifyCommentForId
 
def replaceId
 

Private Attributes

 __entryCommentTableColumns
 
 __entryCommentTableNotNullColumns
 
 __entryCommentTablePK
 
 __session
 

Detailed Description

Class add optional comment on given entry in a given table\n

Definition at line 5 of file entryComment.py.

Constructor & Destructor Documentation

def python.entryComment.entryComment.__init__ (   self,
  session 
)
Input: coral schema handle.

Definition at line 8 of file entryComment.py.

8 
9  def __init__( self, session ):
10  """Input: coral schema handle.
11  """
12  self.__session = session
13  self.__entryCommentTableColumns={'entryid':'unsigned long','tablename':'string','comment':'string'}
14  self.__entryCommentTableNotNullColumns=['entryid','tablename']
15  self.__entryCommentTablePK=('entryid','tablename')

Member Function Documentation

def python.entryComment.entryComment.bulkinsertComments (   self,
  tableName,
  bulkinput 
)
bulk insert comments for a given table
bulkinput [{'entryid':unsigned long, 'tablename':string,'comment':string}]

Definition at line 66 of file entryComment.py.

References python.entryComment.entryComment.__entryCommentTableColumns.

66 
67  def bulkinsertComments( self, tableName,bulkinput):
68  """bulk insert comments for a given table
69  bulkinput [{'entryid':unsigned long, 'tablename':string,'comment':string}]
70  """
71  transaction=self.__session.transaction()
72  try:
73  transaction.start(False)
74  schema = self.__session.nominalSchema()
75  dbop=DBImpl.DBImpl(schema)
76  dbop.bulkInsert(CommonUtils.commentTableName(),self.__entryCommentTableColumns,bulkinput)
77  transaction.commit()
78  except Exception, e:
79  transaction.rollback()
80  raise Exception, str(e)
def python.entryComment.entryComment.clearAllEntriesForTable (   self,
  tablename 
)
delete all entries related with given table

Definition at line 198 of file entryComment.py.

199  def clearAllEntriesForTable( self, tablename ):
200  """delete all entries related with given table
201  """
202  transaction=self.__session.transaction()
203  try:
204  transaction.start(False)
205  dbop=DBImpl.DBImpl(self.__session.nominalSchema())
206  condition='tablename = :tablename'
207  conditionbindDict=coral.AttributeList()
208  conditionbindDict.extend('tablename','string')
209  conditionbindDict['tablename'].setData(tablename)
210  dbop.deleteRows(CommonUtils.commentTableName(),condition,conditionbindDict)
211  transaction.commit()
212  except Exception, e:
213  transaction.rollback()
214  raise Exception, str(e)
def python.entryComment.entryComment.createEntryCommentTable (   self)
Create entry comment able.Existing table will be deleted.

Definition at line 31 of file entryComment.py.

References python.entryComment.entryComment.__entryCommentTableNotNullColumns, and python.entryComment.entryComment.__entryCommentTablePK.

31 
32  def createEntryCommentTable(self):
33  """Create entry comment able.Existing table will be deleted.
34  """
35  try:
36  transaction=self.__session.transaction()
37  transaction.start()
38  schema = self.__session.nominalSchema()
39  schema.dropIfExistsTable(CommonUtils.commentTableName())
40  description = coral.TableDescription()
41  description.setName(CommonUtils.commentTableName())
42  for columnName, columnType in self.__entryCommentTableColumns.items():
43  description.insertColumn(columnName,columnType)
44  for columnName in self.__entryCommentTableNotNullColumns:
45  description.setNotNullConstraint(columnName,True)
46  description.setPrimaryKey(self.__entryCommentTablePK)
47  tablehandle=schema.createTable(description)
48  tablehandle.privilegeManager().grantToPublic(coral.privilege_Select)
49  transaction.commit()
50  except Exception, e:
51  transaction.rollback()
raise Exception, str(e)
def python.entryComment.entryComment.deleteCommentForId (   self,
  tablename,
  entryid 
)
delete selected comment entry 

Definition at line 179 of file entryComment.py.

180  def deleteCommentForId( self, tablename, entryid):
181  """delete selected comment entry
182  """
183  transaction=self.__session.transaction()
184  try:
185  transaction.start(False)
186  dbop=DBImpl.DBImpl(self.__session.nominalSchema())
187  condition='tablename = :tablename AND entryid = :entryid'
188  conditionbindDict=coral.AttributeList()
189  conditionbindDict.extend('tablename','string')
190  conditionbindDict.extend('entryid','unsigned long')
191  conditionbindDict['tablename'].setData(tablename)
192  conditionbindDict['entryid'].setData(entryid)
193  dbop.deleteRows(CommonUtils.commentTableName(),condition,conditionbindDict)
194  transaction.commit()
195  except Exception, e:
196  transaction.rollback()
197  raise Exception, str(e)
def python.entryComment.entryComment.existCommentTable (   self)
Check if entry comment table exists

Definition at line 16 of file entryComment.py.

16 
17  def existCommentTable(self):
18  """Check if entry comment table exists
19  """
20  try:
21  transaction=self.__session.transaction()
22  transaction.start(True)
23  schema = self.__session.nominalSchema()
24  result=schema.existsTable(CommonUtils.commentTableName())
25  transaction.commit()
26  #print result
27  except Exception, er:
28  transaction.rollback()
29  raise Exception, str(er)
30  return result
def python.entryComment.entryComment.getCommentForId (   self,
  tableName,
  entryid 
)
get comment for given id in given table

Definition at line 81 of file entryComment.py.

References data.

81 
82  def getCommentForId( self, tableName, entryid ):
83  """get comment for given id in given table
84  """
85  transaction=self.__session.transaction()
86  comment=''
87  try:
88  transaction.start(True)
89  schema = self.__session.nominalSchema()
90  query = schema.tableHandle(CommonUtils.commentTableName()).newQuery()
91  condition='entryid = :entryid AND tablename = :tablename'
92  conditionbindDict=coral.AttributeList()
93  conditionbindDict.extend('entryid','unsigned long')
94  conditionbindDict.extend('tablename','string')
95  conditionbindDict['entryid'].setData(entryid)
96  conditionbindDict['tablename'].setData(tableName)
97  query.addToOutputList('comment')
98  query.setCondition(condition,conditionbindDict)
99  cursor=query.execute()
100  if cursor.next():
101  comment=cursor.currentRow()['comment'].data()
102  cursor.close()
103  transaction.commit()
104  del query
105  return comment
106  except Exception, e:
107  transaction.rollback()
raise Exception, str(e)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def python.entryComment.entryComment.getCommentsForTable (   self,
  tableName 
)
get all comments for given table
result=[(entryid,comment)]

Definition at line 108 of file entryComment.py.

References data.

109  def getCommentsForTable( self, tableName ):
110  """get all comments for given table
111  result=[(entryid,comment)]
112  """
113  transaction=self.__session.transaction()
114  result=[]
115 
116  try:
117  transaction.start(True)
118  schema = self.__session.nominalSchema()
119  query = schema.tableHandle(CommonUtils.commentTableName()).newQuery()
120  condition='tablename = :tablename'
121  conditionbindDict=coral.AttributeList()
122  conditionbindDict.extend('tablename','string')
123  conditionbindDict['tablename'].setData(tableName)
124  query.addToOutputList('entryid')
125  query.addToOutputList('comment')
126  query.setCondition(condition,conditionbindDict)
127  cursor=query.execute()
128  while cursor.next():
129  comment=cursor.currentRow()['comment'].data()
130  entryid=cursor.currentRow()['entryid'].data()
131  result.append((entryid,comment))
132  cursor.close()
133  transaction.commit()
134  del query
135  return result
136  except Exception, e:
137  transaction.rollback()
138  raise Exception, str(e)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def python.entryComment.entryComment.insertComment (   self,
  tablename,
  entryid,
  comment 
)
insert comment on the given entry of given table

Definition at line 52 of file entryComment.py.

References python.entryComment.entryComment.__entryCommentTableColumns.

52 
53  def insertComment( self, tablename, entryid,comment ):
54  """insert comment on the given entry of given table
55  """
56  transaction=self.__session.transaction()
57  try:
58  transaction.start(False)
59  tabrowValueDict={'entryid':entryid,'tablename':tablename,'comment':comment}
60  schema = self.__session.nominalSchema()
61  dbop=DBImpl.DBImpl(schema)
62  dbop.insertOneRow(CommonUtils.commentTableName(),self.__entryCommentTableColumns,tabrowValueDict)
63  transaction.commit()
64  except Exception, e:
65  transaction.rollback()
raise Exception, str(e)
def python.entryComment.entryComment.modifyCommentForId (   self,
  tableName,
  entryid,
  newcomment 
)
replace comment for given entry for given table

Definition at line 139 of file entryComment.py.

140  def modifyCommentForId( self, tableName, entryid, newcomment ):
141  """replace comment for given entry for given table
142  """
143  transaction=self.__session.transaction()
144  try:
145  transaction.start(False)
146  editor = self.__session.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
147  inputData = coral.AttributeList()
148  inputData.extend('newcomment','string')
149  inputData.extend('entryid','unsigned long')
150  inputData.extend('tablename','string')
151  inputData['newcomment'].setData(newcomment)
152  inputData['entryid'].setData(entryid)
153  inputData['tablename'].setData(tableName)
154  editor.updateRows( "comment = :newcomment", "entryid = :entryid AND tablename = :tablename", inputData )
155  transaction.commit()
156  except Exception, e:
157  transaction.rollback()
158  raise Exception, str(e)
def python.entryComment.entryComment.replaceId (   self,
  tableName,
  oldentryid,
  newentryid 
)
replace entryid in given table

Definition at line 159 of file entryComment.py.

160  def replaceId( self, tableName, oldentryid, newentryid ):
161  """replace entryid in given table
162  """
163  transaction=self.__session.transaction()
164  try:
165  transaction.start(False)
166  editor = self.__session.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
167  inputData = coral.AttributeList()
168  inputData.extend('newentryid','unsigned long')
169  inputData.extend('oldentryid','unsigned long')
170  inputData.extend('tablename','string')
171  inputData['newentryid'].setData(newentryid)
172  inputData['oldentryid'].setData(oldentryid)
173  inputData['tablename'].setData(tableName)
174  editor.updateRows( "entryid = :newentryid", "entryid = :oldentryid AND tablename = :tablename", inputData )
175  transaction.commit()
176  except Exception, e:
177  transaction.rollback()
178  raise Exception, str(e)

Member Data Documentation

python.entryComment.entryComment.__entryCommentTableColumns
private

Definition at line 12 of file entryComment.py.

Referenced by python.entryComment.entryComment.bulkinsertComments(), and python.entryComment.entryComment.insertComment().

python.entryComment.entryComment.__entryCommentTableNotNullColumns
private

Definition at line 13 of file entryComment.py.

Referenced by python.entryComment.entryComment.createEntryCommentTable().

python.entryComment.entryComment.__entryCommentTablePK
private

Definition at line 14 of file entryComment.py.

Referenced by python.entryComment.entryComment.createEntryCommentTable().

python.entryComment.entryComment.__session
private

Definition at line 11 of file entryComment.py.

Referenced by python.tagInventory.tagInventory.addEntriesReplaceService().