Generate document ID if nullΒΆ

Note

You can find these scripts inside the folder pmis/STND_PMIS/test/console/example.
If you want to execute them, you can use the Jython Console from the devtool menu.

filename => ex29.py

from pmis.common.util import CustomHashMap
list = sql('''
select * from document where  pjt_cd = 'GLB_PMIS' and doc_status = 'IDLE' and doc_id is null;
''')

docServ = Beans.documentService

for _d in list:

    dparam = CustomHashMap();
    dparam.putAll(_d)

    d = docServ.loadDocument( dparam.get('DOC_SEQ'), dparam.get('OWNER_ID') )

    if d.get('doc_id_prefix') == None:
        d.put( 'doc_id', docServ.getNextDocId( d ) )
    else:
        d.put( 'doc_id', docServ.getNextDocId( d.get('doc_id_prefix') ) )

    docServ.updateDocument(d.get('doc_seq'), d.get('owner_id'), d)

print 'Script terminated!'