Beispiel #1
0
 def _delete_all_holddoc_for_a_wfdoc(self, wfdocObj):
     '''may not be required any more '''
     search_string = {"wfdoc_name": wfdocObj.name}
     holddoc_repo = DomainRepo("Holddoc")
     result = holddoc_repo.delete(**search_string)#TODO: should be no doc found when not present
     return result
 
 
             
     
         
 
     
Beispiel #2
0
 def _create_draft_or_roll_back(self, wfdocObj, draft_data):
     draft_create_msg = {}
     draftdataObj = ent.Draftdata(name=wfdocObj.name, drafted_by=self.wfc.email,
                                target_role = self.wfc.roles,
                                wfdoc=wfdocObj, doc_data=draft_data)
     try:
         draftdoc_repo = DomainRepo("Draftdata")
         draft_search_string = {"name": wfdocObj.name}#delete before creating
         prev_draf_cleared_status = draftdoc_repo.delete(**draft_search_string)
         status = draftdoc_repo.add_list_of_domain_obj([draftdataObj])            
         wfdoc_update_msg = self._update_wfdoc_draft_status(wfdocObj, self.wfc.roles)
         draft_create_msg.update({"draft_create_msg": status, 
                                  "wfdoc_update_msg": wfdoc_update_msg,
                                  "prev_draf_cleared_status": prev_draf_cleared_status})
     except (rexc.FlexFlowException, Exception)  as e:
         delete_stat = draftdoc_repo.delete(**{"name": wfdocObj.name})
         reset_wfdoc_stat = self._update_wfdoc_draft_status(wfdocObj)            
         draft_create_msg.update({"delete_stat": delete_stat,
                                  "reset_wfdoc_stat": reset_wfdoc_stat,
                                  "rollback_msg": str(e)})
         raise rexc.FlexFlowException
     return draft_create_msg
Beispiel #3
0
 def _create_with_audit(self, wfdocObj, docid, input_data):
     wfdoc_repo = DomainRepo("Wfdoc")
     msg = wfdoc_repo.add_list_of_domain_obj([wfdocObj])
     try:
         audit_msg = self._create_audit_record(wfdocObj, 'Create', input_data)
         msg.update({"audit_msg": audit_msg})
         if audit_msg.get('status').lower().strip() in ['failed', 'Failed', 'error']:
             raise rexc.AuditRecordCreationFailed(docid, audit_msg.get('message') )
     except (rexc.AuditRecordCreationFailed, rexc.FlexFlowException, Exception)  as e:
         status = wfdoc_repo.delete(**{"name": docid})
         #status_roll_back_holddoc = holddoc_repo.delete(**search_filter)
         rollback_msg = {"status": status, "message": str(e) }
         msg.update({"rollback_msg": rollback_msg})
         raise rexc.AuditRecordCreationFailed(docid, audit_msg.get('message'), str(e) )
     return msg
Beispiel #4
0
 def _updadate_with_audit(self, wfdocObj, intended_action, changed_data ):
     ''' also takes care "has_draft_for_roles" role back'''
     wfdoc_repo = DomainRepo("Wfdoc")
     draftdata_repo = DomainRepo("Draftdata")
     target_doc_name = {"name": wfdocObj.name}
     msg = wfdoc_repo.update_from_dict(changed_data, **target_doc_name)
     try:
         draft_search_string = {"name": wfdocObj.name}            
         audit_msg = self._create_audit_record(wfdocObj, intended_action,  changed_data)
         draf_cleared_status = draftdata_repo.delete(**draft_search_string)
         msg.update({"audit_msg": audit_msg, "draf_cleared_status": draf_cleared_status})
         if audit_msg.get('status').lower().strip() in ['failed', 'Failed', 'error']:
             raise rexc.AuditRecordCreationFailed(target_doc_name, audit_msg.get('message') )
     except Exception as e:
         updated_data_dict = {"current_status": wfdocObj.current_status,
                              "prev_status": wfdocObj.prev_status,
                              "has_draft_for_roles": wfdocObj.has_draft_for_roles,
                              "doc_data": wfdocObj.doc_data}
         rollback_msg = wfdoc_repo.update_from_dict(updated_data_dict, **target_doc_name)
         msg.update({"rollback_msg": rollback_msg})
         raise rexc.AuditRecordCreationFailed(target_doc_name, audit_msg.get('message'), str(e) )
     return msg