KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > workflow > impl > WfEventAuditImpl


1 /*
2  * $Id: WfEventAuditImpl.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.workflow.impl;
26
27 import java.sql.Timestamp JavaDoc;
28 import java.util.Date JavaDoc;
29
30 import org.ofbiz.base.util.ObjectType;
31 import org.ofbiz.workflow.SourceNotAvailable;
32 import org.ofbiz.workflow.WfActivity;
33 import org.ofbiz.workflow.WfEventAudit;
34 import org.ofbiz.workflow.WfException;
35 import org.ofbiz.workflow.WfExecutionObject;
36 import org.ofbiz.workflow.WfProcess;
37
38 /**
39  * WfEventAuditImpl - Workflow Event Audit implementation
40  *
41  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
42  * @version $Rev: 5462 $
43  * @since 2.0
44  */

45 public class WfEventAuditImpl implements WfEventAudit {
46
47     private WfExecutionObject object = null;
48     private String JavaDoc eventType = null;
49     private Timestamp JavaDoc timeStamp = null;
50
51     public WfEventAuditImpl(WfExecutionObject object, String JavaDoc eventType) {
52         this.object = object;
53         this.eventType = eventType;
54         this.timeStamp = new Timestamp JavaDoc(new Date JavaDoc().getTime());
55     }
56     
57     /**
58      * @see org.ofbiz.workflow.WfEventAudit#source()
59      */

60     public WfExecutionObject source() throws WfException, SourceNotAvailable {
61         return object;
62     }
63  
64     /**
65      * @see org.ofbiz.workflow.WfEventAudit#timeStamp()
66      */

67     public Timestamp JavaDoc timeStamp() throws WfException {
68         return timeStamp;
69     }
70
71     /**
72      * @see org.ofbiz.workflow.WfEventAudit#eventType()
73      */

74     public String JavaDoc eventType() throws WfException {
75         return eventType;
76     }
77
78     /**
79      * @see org.ofbiz.workflow.WfEventAudit#activityKey()
80      */

81     public String JavaDoc activityKey() throws WfException {
82         try {
83             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity"))
84                 return object.key();
85         } catch (Exception JavaDoc e) {
86             throw new WfException("Source is not a WfActivity object");
87         }
88         throw new WfException("Source is not a WfActivity object");
89     }
90
91     /**
92      * @see org.ofbiz.workflow.WfEventAudit#activityName()
93      */

94     public String JavaDoc activityName() throws WfException {
95         try {
96             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity"))
97                 return object.name();
98         } catch (Exception JavaDoc e) {}
99         throw new WfException("Source is not a WfActivity object");
100
101     }
102
103     /**
104      * @see org.ofbiz.workflow.WfEventAudit#processKey()
105      */

106     public String JavaDoc processKey() throws WfException {
107         try {
108             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess"))
109                 return object.key();
110         } catch (Exception JavaDoc e) {}
111         throw new WfException("Source is not a WfProcess object");
112
113     }
114
115     /**
116      * @see org.ofbiz.workflow.WfEventAudit#processName()
117      */

118     public String JavaDoc processName() throws WfException {
119         try {
120             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess"))
121                 return object.name();
122         } catch (Exception JavaDoc e) {}
123         throw new WfException("Source is not a WfProcess object");
124
125     }
126
127     /**
128      * @see org.ofbiz.workflow.WfEventAudit#processMgrName()
129      */

130     public String JavaDoc processMgrName() throws WfException {
131         try {
132             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess"))
133                 return ((WfProcess) object).manager().name();
134             else if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity"))
135                 return ((WfActivity) object).container().manager().name();
136         } catch (Exception JavaDoc e) {}
137         throw new WfException("Illegal source object");
138     }
139
140     /**
141      * @see org.ofbiz.workflow.WfEventAudit#processMgrVersion()
142      */

143     public String JavaDoc processMgrVersion() throws WfException {
144         try {
145             if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess"))
146                 return ((WfProcess) object).manager().version();
147             else if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity"))
148                 return ((WfActivity) object).container().manager().version();
149         } catch (Exception JavaDoc e) {}
150         throw new WfException("Illegal source object");
151     }
152 }
153
154
Popular Tags