001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
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: adrianprice@sourceforge.net.
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: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.engine.persistence.memory;
046:
047: import org.obe.spi.model.ActivityInstance;
048: import org.obe.spi.model.ProcessInstance;
049: import org.obe.client.api.model.ProcessInstanceAttributes;
050: import org.wfmc.wapi.WMProcessInstanceState;
051:
052: import java.util.ArrayList;
053: import java.util.Collection;
054: import java.util.Date;
055: import java.util.List;
056:
057: /**
058: * Holds the persistent state of a workflow process instance.
059: *
060: * @author Adrian Price
061: */
062: public class BasicProcessInstance extends BasicAttributedEntity
063: implements ProcessInstance {
064:
065: private Date _completedDate;
066: private Date _createdDate;
067: private Date _startedDate;
068: private Date _targetDate;
069: private Date _dueDate;
070: private Date _activityTargetDate;
071: private Date _activityDueDate;
072: private String _name;
073: private int _priority;
074: private int _state;
075: private final List _participants = new ArrayList();
076: private final ActivityInstance _parentActivityInstance;
077: private final Collection _activityInstances = new ArrayList();
078:
079: public BasicProcessInstance(String processInstanceId,
080: String processDefinitionId,
081: ActivityInstance parentActivityInstance) {
082:
083: super (ProcessInstanceAttributes.SYSTEM_PROPERTIES,
084: processDefinitionId, processInstanceId,
085: processInstanceId);
086: _parentActivityInstance = parentActivityInstance;
087: }
088:
089: protected int getType() {
090: return PROCESS_INSTANCE_TYPE;
091: }
092:
093: public Date getCompletedDate() {
094: return _completedDate;
095: }
096:
097: public void setCompletedDate(Date completedDate) {
098: _completedDate = completedDate;
099: }
100:
101: public Date getCreatedDate() {
102: return _createdDate;
103: }
104:
105: public void setCreatedDate(Date createdDate) {
106: _createdDate = createdDate;
107: }
108:
109: public Date getActivityTargetDate() {
110: return _activityTargetDate;
111: }
112:
113: public void setActivityTargetDate(Date targetDate) {
114: _activityTargetDate = targetDate;
115: }
116:
117: public Date getActivityDueDate() {
118: return _activityDueDate;
119: }
120:
121: public void setActivityDueDate(Date dueDate) {
122: _activityDueDate = dueDate;
123: }
124:
125: public Date getTargetDate() {
126: return _targetDate;
127: }
128:
129: public void setTargetDate(Date targetDate) {
130: _targetDate = targetDate;
131: }
132:
133: public Date getDueDate() {
134: return _dueDate;
135: }
136:
137: public void setDueDate(Date dueDate) {
138: _dueDate = dueDate;
139: }
140:
141: public String getName() {
142: return _name;
143: }
144:
145: public void setName(String name) {
146: _name = name;
147: }
148:
149: public ActivityInstance getParentActivityInstance() {
150: return _parentActivityInstance;
151: }
152:
153: public String getParentActivityInstanceId() {
154: return _parentActivityInstance == null ? null
155: : _parentActivityInstance.getActivityInstanceId();
156: }
157:
158: public String[] getParticipants() {
159: return (String[]) _participants
160: .toArray(new String[_participants.size()]);
161: }
162:
163: public void setParticipants(String[] participants) {
164: _participants.clear();
165: for (int i = 0; i < participants.length; i++)
166: _participants.add(participants[i]);
167: }
168:
169: public int getPriority() {
170: return _priority;
171: }
172:
173: public void setPriority(int priority) {
174: _priority = priority;
175: }
176:
177: public Date getStartedDate() {
178: return _startedDate;
179: }
180:
181: public void setStartedDate(Date startedDate) {
182: _startedDate = startedDate;
183: }
184:
185: public int getState() {
186: return _state;
187: }
188:
189: public void setState(int state) {
190: _state = state;
191: }
192:
193: public Collection getActivityInstances() {
194: return _activityInstances;
195: }
196:
197: public void addActivityInstance(ActivityInstance activityInstance) {
198: _activityInstances.add(activityInstance);
199: }
200:
201: public String toString() {
202: return "ProcessInstance[processInstanceId='"
203: + _processInstanceId + "', processDefinitionId='"
204: + _processDefinitionId
205: + "', parentActivityInstanceId='"
206: + getParentActivityInstanceId() + "', name='" + _name
207: + "', state="
208: + WMProcessInstanceState.valueOf(_state).stringValue()
209: + ", priority=" + _priority + ", createdDate="
210: + _createdDate + ", startedDate=" + _startedDate
211: + ", completedDate=" + _completedDate + "']";
212: }
213: }
|