1 package org.enhydra.shark; 2 3 import org.enhydra.shark.api.SharkTransaction; 4 import org.enhydra.shark.api.TransactionException; 5 import org.enhydra.shark.api.client.wfbase.BaseException; 6 import org.enhydra.shark.api.common.SharkConstants; 7 import org.enhydra.shark.api.internal.eventaudit.AssignmentEventAuditPersistenceInterface; 8 import org.enhydra.shark.api.internal.eventaudit.EventAuditException; 9 import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface; 10 import org.enhydra.shark.api.internal.eventaudit.EventAuditPersistenceInterface; 11 import org.enhydra.shark.api.internal.working.WfActivityInternal; 12 import org.enhydra.shark.api.internal.working.WfAssignmentEventAuditInternal; 13 import org.enhydra.shark.api.internal.working.WfResourceInternal; 14 15 20 public class WfAssignmentEventAuditWrapper extends WfEventAuditWrapper 21 implements WfAssignmentEventAuditInternal { 22 23 25 private String oldResourceKey; 26 private String oldResourceName; 27 private String newResourceKey; 28 private String newResourceName; 29 private boolean isAccepted; 30 31 protected WfAssignmentEventAuditWrapper(SharkTransaction t,WfActivityInternal activity,WfResourceInternal oldRes, 32 WfResourceInternal newRes,boolean isAccepted) 33 throws BaseException { 34 super(t,activity,SharkConstants.EVENT_ACTIVITY_ASSIGNMENT_CHANGED); 35 36 if (oldRes!=null) { 37 this.oldResourceKey=oldRes.resource_key(t); 38 this.oldResourceName=oldRes.resource_name(t); 39 } 40 this.newResourceKey=newRes.resource_key(t); 41 this.newResourceName=newRes.resource_name(t); 42 this.isAccepted=((WfActivityInternal)activity).accepted_status(t); 43 this.isAccepted=isAccepted; 44 try { 45 persist(t); 46 } catch (Exception ex) { 47 throw new BaseException(ex); 48 } 49 } 50 51 54 protected WfAssignmentEventAuditWrapper (String userAuth,AssignmentEventAuditPersistenceInterface po) { 55 super(userAuth,po); 56 } 57 58 public String old_resource_key () throws BaseException { 59 return oldResourceKey; 60 } 61 62 public String old_resource_name () throws BaseException { 63 return oldResourceName; 64 } 65 66 public String new_resource_key () throws BaseException { 67 return newResourceKey; 68 } 69 70 public String new_resource_name () throws BaseException { 71 return newResourceName; 72 } 73 74 public boolean is_accepted () throws BaseException { 75 return isAccepted; 76 } 77 78 public void persist (SharkTransaction t) throws TransactionException { 79 try { 80 EventAuditManagerInterface eam=SharkEngineManager.getInstance().getEventAuditManager(); 81 if (null == eam) 82 return; 83 AssignmentEventAuditPersistenceInterface po= 84 eam.createAssignmentEventAudit(); 85 fillPersistentObject(po); 86 eam.persist(po,t); 87 } catch (EventAuditException pe) { 88 throw new TransactionException(pe); 90 } 91 } 92 93 public void refresh () { 94 } 96 97 public void delete (SharkTransaction t) throws TransactionException{ 98 } 100 101 protected void fillPersistentObject (EventAuditPersistenceInterface po) { 102 super.fillPersistentObject(po); 103 AssignmentEventAuditPersistenceInterface apo=(AssignmentEventAuditPersistenceInterface)po; 104 apo.setOldResourceUsername(this.oldResourceKey); 105 apo.setOldResourceName(this.oldResourceName); 106 apo.setNewResourceUsername(this.newResourceKey); 107 apo.setNewResourceName(this.newResourceName); 108 apo.setIsAccepted(this.isAccepted); 109 } 110 111 protected void restore (EventAuditPersistenceInterface po) { 112 super.restore(po); 113 AssignmentEventAuditPersistenceInterface apo=(AssignmentEventAuditPersistenceInterface)po; 114 this.oldResourceKey=apo.getOldResourceUsername(); 115 this.oldResourceName=apo.getOldResourceName(); 116 this.newResourceKey=apo.getNewResourceUsername(); 117 this.newResourceName=apo.getNewResourceName(); 118 this.isAccepted=apo.getIsAccepted(); 119 } 120 121 } 122 | Popular Tags |