1 package org.enhydra.shark; 2 3 import java.util.Map ; 4 import org.enhydra.shark.api.SharkTransaction; 5 import org.enhydra.shark.api.TransactionException; 6 import org.enhydra.shark.api.client.wfbase.BaseException; 7 import org.enhydra.shark.api.internal.eventaudit.DataEventAuditPersistenceInterface; 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.WfDataEventAuditInternal; 12 import org.enhydra.shark.api.internal.working.WfExecutionObjectInternal; 13 14 19 public class WfDataEventAuditWrapper extends WfEventAuditWrapper implements WfDataEventAuditInternal { 20 21 private Map oldData; 22 private Map newData; 23 24 protected WfDataEventAuditWrapper(SharkTransaction t,WfExecutionObjectInternal object,String eventType, 25 Map oldData,Map newData) throws BaseException { 26 super(t,object,eventType); 27 28 this.oldData=oldData; 29 this.newData=newData; 30 try { 31 persist(t); 32 } catch (Exception ex) { 33 throw new BaseException(ex); 34 } 35 } 36 37 40 protected WfDataEventAuditWrapper (String userAuth,DataEventAuditPersistenceInterface po) { 41 super(userAuth,po); 42 } 43 44 45 public Map old_data () { 46 return oldData; 47 } 48 49 public Map new_data () { 50 return newData; 51 } 52 53 public String package_id () throws BaseException { 54 return packageId; 55 } 56 57 public void persist (SharkTransaction t) throws TransactionException { 58 try { 59 EventAuditManagerInterface eam=SharkEngineManager.getInstance().getEventAuditManager(); 60 if (null == eam) 61 return; 62 DataEventAuditPersistenceInterface po=eam.createDataEventAudit(); 63 fillPersistentObject(po); 64 eam.persist(po, t); 65 } catch (EventAuditException pe) { 66 throw new TransactionException(pe); 67 } 68 } 69 70 public void refresh () { 71 } 73 74 public void delete (SharkTransaction t) throws TransactionException { 75 } 77 78 protected void fillPersistentObject (EventAuditPersistenceInterface po) { 79 super.fillPersistentObject(po); 80 DataEventAuditPersistenceInterface dpo=(DataEventAuditPersistenceInterface)po; 81 dpo.setOldData(oldData); 82 dpo.setNewData(newData); 83 } 84 85 protected void restore (EventAuditPersistenceInterface po) { 86 super.restore(po); 87 DataEventAuditPersistenceInterface dpo=(DataEventAuditPersistenceInterface)po; 88 oldData=dpo.getOldData(); 89 newData=dpo.getNewData(); 90 } 91 92 } 93 | Popular Tags |