CMS 3D CMS Logo

Public Member Functions | Private Attributes

python::entryComment::entryComment Class Reference

List of all members.

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.

00009                                  :
00010         """Input: coral schema handle.
00011         """
00012         self.__session = session
00013         self.__entryCommentTableColumns={'entryid':'unsigned long','tablename':'string','comment':'string'}
00014         self.__entryCommentTableNotNullColumns=['entryid','tablename']
00015         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.

00067                                                       :
00068         """bulk insert comments for a given table
00069         bulkinput [{'entryid':unsigned long, 'tablename':string,'comment':string}]
00070         """
00071         transaction=self.__session.transaction()
00072         try:
00073             transaction.start(False)
00074             schema = self.__session.nominalSchema()
00075             dbop=DBImpl.DBImpl(schema)
00076             dbop.bulkInsert(CommonUtils.commentTableName(),self.__entryCommentTableColumns,bulkinput)
00077             transaction.commit()  
00078         except Exception, e:
00079             transaction.rollback()
00080             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.

00199                                                   :
00200         """delete all entries related with given table
00201         """
00202         transaction=self.__session.transaction()
00203         try:
00204             transaction.start(False)
00205             dbop=DBImpl.DBImpl(self.__session.nominalSchema())
00206             condition='tablename = :tablename'
00207             conditionbindDict=coral.AttributeList()
00208             conditionbindDict.extend('tablename','string')
00209             conditionbindDict['tablename'].setData(tablename)
00210             dbop.deleteRows(CommonUtils.commentTableName(),condition,conditionbindDict)
00211             transaction.commit()
00212         except Exception, e:
00213             transaction.rollback()
00214             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.

00032                                      :
00033         """Create entry comment able.Existing table will be deleted.
00034         """
00035         try:
00036            transaction=self.__session.transaction()
00037            transaction.start()
00038            schema = self.__session.nominalSchema()
00039            schema.dropIfExistsTable(CommonUtils.commentTableName())
00040            description = coral.TableDescription()
00041            description.setName(CommonUtils.commentTableName())
00042            for columnName, columnType in self.__entryCommentTableColumns.items():
00043                description.insertColumn(columnName,columnType)
00044            for columnName in self.__entryCommentTableNotNullColumns:
00045                description.setNotNullConstraint(columnName,True)
00046            description.setPrimaryKey(self.__entryCommentTablePK)
00047            tablehandle=schema.createTable(description)
00048            tablehandle.privilegeManager().grantToPublic(coral.privilege_Select)
00049            transaction.commit()
00050         except Exception, e:
00051            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.

00180                                                      :
00181         """delete selected comment entry 
00182         """
00183         transaction=self.__session.transaction()
00184         try:
00185             transaction.start(False)
00186             dbop=DBImpl.DBImpl(self.__session.nominalSchema())
00187             condition='tablename = :tablename AND entryid = :entryid'
00188             conditionbindDict=coral.AttributeList()
00189             conditionbindDict.extend('tablename','string')
00190             conditionbindDict.extend('entryid','unsigned long')
00191             conditionbindDict['tablename'].setData(tablename)
00192             conditionbindDict['entryid'].setData(entryid)
00193             dbop.deleteRows(CommonUtils.commentTableName(),condition,conditionbindDict)
00194             transaction.commit()
00195         except Exception, e:
00196             transaction.rollback()
00197             raise Exception, str(e)
        
def python::entryComment::entryComment::existCommentTable (   self)
Check if entry comment table exists

Definition at line 16 of file entryComment.py.

00017                                :
00018         """Check if entry comment table exists
00019         """
00020         try:
00021             transaction=self.__session.transaction()
00022             transaction.start(True)
00023             schema = self.__session.nominalSchema()
00024             result=schema.existsTable(CommonUtils.commentTableName())
00025             transaction.commit()
00026             #print result
00027         except Exception, er:
00028             transaction.rollback()
00029             raise Exception, str(er)
00030         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.

00082                                                    :
00083         """get comment for given id in given table
00084         """
00085         transaction=self.__session.transaction()
00086         comment=''
00087         try:
00088             transaction.start(True)
00089             schema = self.__session.nominalSchema()
00090             query = schema.tableHandle(CommonUtils.commentTableName()).newQuery()
00091             condition='entryid = :entryid AND tablename = :tablename'
00092             conditionbindDict=coral.AttributeList()
00093             conditionbindDict.extend('entryid','unsigned long')
00094             conditionbindDict.extend('tablename','string')
00095             conditionbindDict['entryid'].setData(entryid)
00096             conditionbindDict['tablename'].setData(tableName)
00097             query.addToOutputList('comment')
00098             query.setCondition(condition,conditionbindDict)
00099             cursor=query.execute()
00100             if cursor.next():
00101                 comment=cursor.currentRow()['comment'].data()
00102                 cursor.close()
00103             transaction.commit()
00104             del query
00105             return comment
00106         except Exception, e:
00107             transaction.rollback()
            raise Exception, str(e)
def python::entryComment::entryComment::getCommentsForTable (   self,
  tableName 
)
get all comments for given table
result=[(entryid,comment)]

Definition at line 108 of file entryComment.py.

00109                                               :
00110         """get all comments for given table
00111         result=[(entryid,comment)]
00112         """
00113         transaction=self.__session.transaction()
00114         result=[]
00115         
00116         try:
00117             transaction.start(True)
00118             schema = self.__session.nominalSchema()
00119             query = schema.tableHandle(CommonUtils.commentTableName()).newQuery()
00120             condition='tablename = :tablename'
00121             conditionbindDict=coral.AttributeList()
00122             conditionbindDict.extend('tablename','string')
00123             conditionbindDict['tablename'].setData(tableName)
00124             query.addToOutputList('entryid')
00125             query.addToOutputList('comment')
00126             query.setCondition(condition,conditionbindDict)
00127             cursor=query.execute()
00128             while cursor.next():
00129                 comment=cursor.currentRow()['comment'].data()
00130                 entryid=cursor.currentRow()['entryid'].data()
00131                 result.append((entryid,comment))  
00132             cursor.close()
00133             transaction.commit()
00134             del query
00135             return result
00136         except Exception, e:
00137             transaction.rollback()
00138             raise Exception, str(e)
        
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.

00053                                                          :
00054         """insert comment on the given entry of given table
00055         """
00056         transaction=self.__session.transaction()
00057         try:
00058             transaction.start(False)
00059             tabrowValueDict={'entryid':entryid,'tablename':tablename,'comment':comment}
00060             schema = self.__session.nominalSchema()
00061             dbop=DBImpl.DBImpl(schema)
00062             dbop.insertOneRow(CommonUtils.commentTableName(),self.__entryCommentTableColumns,tabrowValueDict)
00063             transaction.commit()
00064         except Exception, e:
00065             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.

00140                                                                   :
00141         """replace comment for given entry for given table
00142         """
00143         transaction=self.__session.transaction()
00144         try:
00145             transaction.start(False)
00146             editor = self.__session.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
00147             inputData = coral.AttributeList()
00148             inputData.extend('newcomment','string')
00149             inputData.extend('entryid','unsigned long')
00150             inputData.extend('tablename','string')
00151             inputData['newcomment'].setData(newcomment)
00152             inputData['entryid'].setData(entryid)
00153             inputData['tablename'].setData(tableName)
00154             editor.updateRows( "comment = :newcomment", "entryid = :entryid AND tablename = :tablename", inputData )
00155             transaction.commit()
00156         except Exception, e:
00157             transaction.rollback()
00158             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.

00160                                                             :
00161         """replace entryid in given table
00162         """
00163         transaction=self.__session.transaction()
00164         try:
00165             transaction.start(False)
00166             editor = self.__session.nominalSchema().tableHandle(CommonUtils.commentTableName()).dataEditor()
00167             inputData = coral.AttributeList()
00168             inputData.extend('newentryid','unsigned long')
00169             inputData.extend('oldentryid','unsigned long')
00170             inputData.extend('tablename','string')
00171             inputData['newentryid'].setData(newentryid)
00172             inputData['oldentryid'].setData(oldentryid)
00173             inputData['tablename'].setData(tableName)
00174             editor.updateRows( "entryid = :newentryid", "entryid = :oldentryid AND tablename = :tablename", inputData )
00175             transaction.commit()
00176         except Exception, e:
00177             transaction.rollback()
00178             raise Exception, str(e)
        

Member Data Documentation

Definition at line 9 of file entryComment.py.

Definition at line 9 of file entryComment.py.

Definition at line 9 of file entryComment.py.

Definition at line 9 of file entryComment.py.