Guest User

Untitled

a guest
Dec 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #title Update document ID
  2. # CAUTION! This script will create additional id
  3. # check the table that will store the ids before running the script
  4.  
  5. project = 'YNPOWER'
  6. #=======================================================================
  7.  
  8. from pmis.common.util import SessionUtil
  9. from sangah.security import MasterUserProfileImpl
  10. from pmis.common.util import CustomHashMap
  11.  
  12. docServ = Beans.documentService
  13.  
  14. user = MasterUserProfileImpl(project) # change current project
  15. SessionUtil.setSession(user) # update the session user
  16.  
  17. # load all documents with doc_id having suffix 'null'
  18. list = sql('''
  19. select doc_seq, owner_id
  20. from document t1
  21. where pjt_cd = ?
  22. and doc_status in ('IDLE', 'SENT')
  23. and doc_id is not null
  24. and doc_id like '%null'
  25. order by doc_seq asc;
  26. ''', project)
  27.  
  28. for _d in list:
  29. dparam = CustomHashMap();
  30. dparam.putAll(_d)
  31.  
  32. d = docServ.loadDocument( dparam.get('DOC_SEQ'), dparam.get('OWNER_ID') )
  33. docid = docServ.getNextDocId( d )
  34. d.put( 'doc_id', docid ) # update the docid
  35.  
  36. # we load all the documents having same doc_seq (SENT,RECV,...) only for old PMIS
  37. rlist = sql('''
  38. select doc_seq, owner_id
  39. from document
  40. where 1=1
  41. and doc_seq = ?
  42. order by doc_seq asc;
  43. ''', dparam.get('DOC_SEQ'))
  44.  
  45. for _dd in rlist:
  46. dparam = CustomHashMap();
  47. dparam.putAll(_dd)
  48.  
  49. dd = docServ.loadDocument( dparam.get('DOC_SEQ'), dparam.get('OWNER_ID') )
  50. dd.put('doc_id', docid)
  51.  
  52. # remove the comment to save the document
  53. #docServ.updateDocument(dd)
  54. print 'updating: %s %s' % (dd.get('doc_seq'), dd.get('owner_id'))
  55.  
  56. print 'Script terminated!'
Add Comment
Please, Sign In to add comment