KickJava   Java API By Example, From Geeks To Geeks.

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


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.internal.eventaudit.EventAuditException;
7 import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface;
8 import org.enhydra.shark.api.internal.eventaudit.EventAuditPersistenceInterface;
9 import org.enhydra.shark.api.internal.eventaudit.StateEventAuditPersistenceInterface;
10 import org.enhydra.shark.api.internal.working.WfExecutionObjectInternal;
11 import org.enhydra.shark.api.internal.working.WfStateEventAuditInternal;
12
13 /**
14  * WfStateEventAuditImpl - Workflow Event Audit implementation.
15  * @author Sasa Bojanic
16  */

17 public class WfStateEventAuditWrapper extends WfEventAuditWrapper implements WfStateEventAuditInternal {
18    
19    private String JavaDoc oldState;
20    private String JavaDoc newState;
21    
22    protected WfStateEventAuditWrapper(SharkTransaction t,WfExecutionObjectInternal object,String JavaDoc eventType,
23                                       String JavaDoc oldState,String JavaDoc newState) throws BaseException {
24       super(t,object,eventType);
25
26       this.oldState=oldState;
27       this.newState=newState;
28
29       try {
30          persist(t);
31       } catch (Exception JavaDoc ex) {
32          throw new BaseException(ex);
33       }
34    }
35
36    /**
37     * Used to create object when restoring it from database.
38     */

39    protected WfStateEventAuditWrapper (String JavaDoc userAuth,StateEventAuditPersistenceInterface po) {
40       super(userAuth,po);
41    }
42    
43    
44    public String JavaDoc old_state () throws BaseException {
45       return oldState;
46    }
47    
48    public String JavaDoc new_state () throws BaseException {
49       return newState;
50    }
51    
52    public void persist (SharkTransaction t) throws TransactionException {
53       try {
54          EventAuditManagerInterface eam=SharkEngineManager.getInstance().getEventAuditManager();
55          if (null == eam)
56             return;
57          StateEventAuditPersistenceInterface po=eam.createStateEventAudit();
58          fillPersistentObject(po);
59          eam.persist(po, t);
60       } catch (EventAuditException pe) {
61          pe.printStackTrace();
62          throw new TransactionException(pe);
63       }
64    }
65    
66    public void refresh () {
67       //
68
}
69    
70    public void delete (SharkTransaction t) throws TransactionException {
71       //
72
}
73    
74    protected void fillPersistentObject (EventAuditPersistenceInterface po) {
75       super.fillPersistentObject(po);
76       StateEventAuditPersistenceInterface spo=(StateEventAuditPersistenceInterface)po;
77       spo.setOldState(this.oldState);
78       spo.setNewState(this.newState);
79    }
80    
81    protected void restore (EventAuditPersistenceInterface po) {
82       super.restore(po);
83       StateEventAuditPersistenceInterface spo=(StateEventAuditPersistenceInterface)po;
84       this.oldState=spo.getOldState();
85       this.newState=spo.getNewState();
86    }
87    
88 }
89
Popular Tags