Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #title Update document ID
- # CAUTION! This script will create additional id
- # check the table that will store the ids before running the script
- project = 'YNPOWER'
- #=======================================================================
- from pmis.common.util import SessionUtil
- from sangah.security import MasterUserProfileImpl
- from pmis.common.util import CustomHashMap
- docServ = Beans.documentService
- user = MasterUserProfileImpl(project) # change current project
- SessionUtil.setSession(user) # update the session user
- # load all documents with doc_id having suffix 'null'
- list = sql('''
- select doc_seq, owner_id
- from document t1
- where pjt_cd = ?
- and doc_status in ('IDLE', 'SENT')
- and doc_id is not null
- and doc_id like '%null'
- order by doc_seq asc;
- ''', project)
- for _d in list:
- dparam = CustomHashMap();
- dparam.putAll(_d)
- d = docServ.loadDocument( dparam.get('DOC_SEQ'), dparam.get('OWNER_ID') )
- docid = docServ.getNextDocId( d )
- d.put( 'doc_id', docid ) # update the docid
- # we load all the documents having same doc_seq (SENT,RECV,...) only for old PMIS
- rlist = sql('''
- select doc_seq, owner_id
- from document
- where 1=1
- and doc_seq = ?
- order by doc_seq asc;
- ''', dparam.get('DOC_SEQ'))
- for _dd in rlist:
- dparam = CustomHashMap();
- dparam.putAll(_dd)
- dd = docServ.loadDocument( dparam.get('DOC_SEQ'), dparam.get('OWNER_ID') )
- dd.put('doc_id', docid)
- # remove the comment to save the document
- #docServ.updateDocument(dd)
- print 'updating: %s %s' % (dd.get('doc_seq'), dd.get('owner_id'))
- print 'Script terminated!'
Add Comment
Please, Sign In to add comment