001: /*--
002:
003: Copyright (C) 2002 Anthony Eden.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: me@anthonyeden.com.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Anthony Eden (me@anthonyeden.com).
027:
028: In addition, I request (but do not require) that you include in the
029: end-user documentation provided with the redistribution and/or in the
030: software itself an acknowledgement equivalent to the following:
031: "This product includes software developed by
032: Anthony Eden (http://www.anthonyeden.com/)."
033:
034: THIS SOFTWARE IS PROVIdED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
038: INDIRECT, INCIdENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
039: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
040: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
041: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
042: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
043: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
044: POSSIBILITY OF SUCH DAMAGE.
045:
046: For more information on OBE, please see <http://obe.sourceforge.net/>.
047:
048: */
049:
050: package org.wfmc.audit;
051:
052: import org.wfmc.wapi.WMProcessInstanceState;
053:
054: import java.util.Date;
055:
056: /**
057: * @author Antony Lodge
058: * @author Adrian Price
059: */
060: public abstract class WMAAuditEntry implements CWADPrefix {
061: private static final long serialVersionUID = 4644455394179703302L;
062: public static final String WFMC = "WfMC";
063:
064: // CWADPrefix fields.
065: private String _processDefinitionId;
066: private String _activityDefinitionId;
067: private String _initialProcessInstanceId;
068: private String _currentProcessInstanceId;
069: private String _activityInstanceId;
070: private String _workItemId;
071: private int _processState;
072: private WMAEventCode _eventCode;
073: private String _domainId;
074: private String _nodeId;
075: private String _userId;
076: private String _roleId;
077: private Date _timestamp;
078: private String _informationId = WFMC;
079:
080: protected static String valueOf(int state) {
081: return state == -1 ? null : WMProcessInstanceState.valueOf(
082: state).toString();
083: }
084:
085: protected static int valueOf(String state) {
086: return state == null ? -1 : WMProcessInstanceState.valueOf(
087: state).value();
088: }
089:
090: protected WMAAuditEntry() {
091: }
092:
093: /**
094: * Constructor that takes a CWADPrefix object.
095: *
096: * @param p The prefix.
097: */
098: protected WMAAuditEntry(CWADPrefix p) {
099: setCwadPrefix(p);
100: }
101:
102: /**
103: * Constructor that takes all the CWADPrefix fields.
104: *
105: * @param processDefinitionId
106: * @param activityDefinitionId
107: * @param initialProcessInstanceId
108: * @param currentProcessInstanceId
109: * @param activityInstanceId
110: * @param workItemId
111: * @param processState
112: * @param eventCode
113: * @param domainId
114: * @param nodeId
115: * @param userId
116: * @param roleId
117: * @param timestamp
118: */
119: protected WMAAuditEntry(String processDefinitionId,
120: String activityDefinitionId,
121: String initialProcessInstanceId,
122: String currentProcessInstanceId, String activityInstanceId,
123: String workItemId, int processState,
124: WMAEventCode eventCode, String domainId, String nodeId,
125: String userId, String roleId, Date timestamp) {
126:
127: _processDefinitionId = processDefinitionId;
128: _activityDefinitionId = activityDefinitionId;
129: _initialProcessInstanceId = initialProcessInstanceId;
130: _currentProcessInstanceId = currentProcessInstanceId;
131: _activityInstanceId = activityInstanceId;
132: _workItemId = workItemId;
133: _processState = processState;
134: _eventCode = eventCode;
135: _domainId = domainId;
136: _nodeId = nodeId;
137: _userId = userId;
138: _roleId = roleId;
139: _timestamp = timestamp;
140: }
141:
142: public final CWADPrefix getCwadPrefix() {
143: return this ;
144: }
145:
146: public final void setCwadPrefix(CWADPrefix p) {
147: _processDefinitionId = p.getProcessDefinitionId();
148: _activityDefinitionId = p.getActivityDefinitionId();
149: _initialProcessInstanceId = p.getInitialProcessInstanceId();
150: _currentProcessInstanceId = p.getCurrentProcessInstanceId();
151: _activityInstanceId = p.getActivityInstanceId();
152: _workItemId = p.getWorkItemId();
153: _processState = valueOf(p.getProcessState());
154: _eventCode = p.getEventCode();
155: _domainId = p.getDomainId();
156: _nodeId = p.getNodeId();
157: _userId = p.getUserId();
158: _roleId = p.getRoleId();
159: _timestamp = p.getTimestamp();
160: _informationId = p.getInformationId();
161: }
162:
163: public String getProcessDefinitionId() {
164: return _processDefinitionId;
165: }
166:
167: public void setProcessDefinitionId(String processDefinitionId) {
168: _processDefinitionId = processDefinitionId;
169: }
170:
171: public String getActivityDefinitionId() {
172: return _activityDefinitionId;
173: }
174:
175: public void setActivityDefinitionId(String activityDefinitionId) {
176: _activityDefinitionId = activityDefinitionId;
177: }
178:
179: /**
180: * Returns the initial (root) process instance Id.
181: *
182: * @return The initial process instance Id
183: */
184: public String getInitialProcessInstanceId() {
185: return _initialProcessInstanceId;
186: }
187:
188: /**
189: * Set the initial (root) process instance Id.
190: *
191: * @param initialProcessInstanceId The initial process instance Id
192: */
193: public void setInitialProcessInstanceId(
194: String initialProcessInstanceId) {
195:
196: _initialProcessInstanceId = initialProcessInstanceId;
197: }
198:
199: /**
200: * Returns the current process instance Id.
201: *
202: * @return The current process instance Id
203: */
204: public String getCurrentProcessInstanceId() {
205: return _currentProcessInstanceId;
206: }
207:
208: /**
209: * Set the current process instance Id. The string is limited to 64
210: * characters according to the WfMC Interface 5 specification.
211: *
212: * @param currentProcessInstanceId The current process instance Id
213: */
214: public void setCurrentProcessInstanceId(
215: String currentProcessInstanceId) {
216:
217: // checkLength(currentProcessInstanceId);
218: _currentProcessInstanceId = currentProcessInstanceId;
219: }
220:
221: /**
222: * Returns the activity instance Id. The activity instance Id is optional so
223: * this method may return <code>null</code>.
224: *
225: * @return The activity instance Id
226: */
227: public String getActivityInstanceId() {
228: return _activityInstanceId;
229: }
230:
231: /**
232: * Set the activity instance Id. The value can be null if the activity
233: * instance Id is not specified.
234: *
235: * @param activityInstanceId The activity instance Id
236: */
237: public void setActivityInstanceId(String activityInstanceId) {
238: _activityInstanceId = activityInstanceId;
239: }
240:
241: /**
242: * Returns the work item Id. The work item Id is optional so this method
243: * may return <code>null</code>.
244: *
245: * @return The work item Id.
246: */
247: public String getWorkItemId() {
248: return _workItemId;
249: }
250:
251: /**
252: * Set the work item Id.
253: *
254: * @param workItemId Work item Id.
255: */
256: public void setWorkItemId(String workItemId) {
257: _workItemId = workItemId;
258: }
259:
260: /**
261: * Returns the process state.
262: *
263: * @return The process state
264: */
265: public String getProcessState() {
266: return valueOf(_processState);
267: }
268:
269: /**
270: * Set the process state.
271: *
272: * @param processState The process state
273: */
274: public void setProcessState(String processState) {
275: _processState = valueOf(processState);
276: }
277:
278: /**
279: * Returns the event code.
280: *
281: * @return The event code
282: */
283: public WMAEventCode getEventCode() {
284: return _eventCode;
285: }
286:
287: /**
288: * Set the event code.
289: *
290: * @param eventCode The new event code
291: */
292: public void setEventCode(WMAEventCode eventCode) {
293: _eventCode = eventCode;
294: }
295:
296: public String getDomainId() {
297: return _domainId;
298: }
299:
300: public void setDomainId(String domainId) {
301: _domainId = domainId;
302: }
303:
304: public String getNodeId() {
305: return _nodeId;
306: }
307:
308: public void setNodeId(String nodeId) {
309: _nodeId = nodeId;
310: }
311:
312: public String getUserId() {
313: return _userId;
314: }
315:
316: public void setUserId(String userId) {
317: _userId = userId;
318: }
319:
320: public String getRoleId() {
321: return _roleId;
322: }
323:
324: public void setRoleId(String roleId) {
325: _roleId = roleId;
326: }
327:
328: public Date getTimestamp() {
329: return _timestamp;
330: }
331:
332: public void setTimestamp(Date timestamp) {
333: _timestamp = timestamp;
334: }
335:
336: public final String getInformationId() {
337: return _informationId;
338: }
339:
340: public final void setInformationId(String informationId) {
341: _informationId = informationId;
342: }
343:
344: public String formatCwadPrefix() {
345: return "CWADPrefix[processDefinitionId=" + _processDefinitionId
346: + ", activityDefinitionId=" + _activityDefinitionId
347: + ", initialProcessInstanceId="
348: + _initialProcessInstanceId
349: + ", currentProcessInstanceId="
350: + _currentProcessInstanceId + ", activityInstanceId="
351: + _activityInstanceId + ", workItemId=" + _workItemId
352: + ", processState=" + getProcessState()
353: + ", eventCode=" + _eventCode + ", domainId="
354: + _domainId + ", nodeId=" + _nodeId + ", userId="
355: + _userId + ", roleId=" + _roleId + ", timestamp="
356: + _timestamp + ", informationId=" + _informationId
357: + ']';
358: }
359: }
|