KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > WfDataEventAuditWrapper


1 package org.enhydra.shark;
2
3 import java.util.Map JavaDoc;
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 /**
15  * WfDataEventAuditImpl - Workflow Event Audit implementation
16  *
17  * @author Sasa Bojanic
18  */

19 public class WfDataEventAuditWrapper extends WfEventAuditWrapper implements WfDataEventAuditInternal {
20
21    private Map JavaDoc oldData;
22    private Map JavaDoc newData;
23
24    protected WfDataEventAuditWrapper(SharkTransaction t,WfExecutionObjectInternal object,String JavaDoc eventType,
25                                      Map JavaDoc oldData,Map JavaDoc 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 JavaDoc ex) {
33          throw new BaseException(ex);
34        }
35    }
36
37    /**
38     * Used to create object when restoring it from database.
39     */

40    protected WfDataEventAuditWrapper (String JavaDoc userAuth,DataEventAuditPersistenceInterface po) {
41       super(userAuth,po);
42    }
43
44
45    public Map JavaDoc old_data () {
46       return oldData;
47    }
48
49    public Map JavaDoc new_data () {
50       return newData;
51    }
52
53    public String JavaDoc 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       //
72
}
73
74    public void delete (SharkTransaction t) throws TransactionException {
75       //
76
}
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