KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
16  * WfEventAuditImpl - Workflow Event Audit implementation
17  *
18  * @author Sasa Bojanic
19  */

20 public class WfAssignmentEventAuditWrapper extends WfEventAuditWrapper
21    implements WfAssignmentEventAuditInternal {
22    
23    // private WfActivity activity;
24

25    private String JavaDoc oldResourceKey;
26    private String JavaDoc oldResourceName;
27    private String JavaDoc newResourceKey;
28    private String JavaDoc 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 JavaDoc ex) {
47          throw new BaseException(ex);
48        }
49    }
50    
51    /**
52     * Used to create object when restoring it from database.
53     */

54    protected WfAssignmentEventAuditWrapper (String JavaDoc userAuth,AssignmentEventAuditPersistenceInterface po) {
55       super(userAuth,po);
56    }
57    
58    public String JavaDoc old_resource_key () throws BaseException {
59       return oldResourceKey;
60    }
61    
62    public String JavaDoc old_resource_name () throws BaseException {
63       return oldResourceName;
64    }
65    
66    public String JavaDoc new_resource_key () throws BaseException {
67       return newResourceKey;
68    }
69    
70    public String JavaDoc 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          //pe.printStackTrace();
89
throw new TransactionException(pe);
90       }
91    }
92    
93    public void refresh () {
94       //
95
}
96    
97    public void delete (SharkTransaction t) throws TransactionException{
98       //
99
}
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