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.xpdl.model.transition;
046:
047: import org.obe.xpdl.PackageVisitor;
048: import org.obe.xpdl.model.activity.Activity;
049: import org.obe.xpdl.model.condition.Condition;
050: import org.obe.xpdl.model.ext.Event;
051: import org.obe.xpdl.model.misc.AbstractWFElement;
052: import org.obe.xpdl.model.misc.ExecutionType;
053:
054: /**
055: * Implementation of a transition.
056: *
057: * @author Adrian Price
058: */
059: public final class Transition extends AbstractWFElement {
060: private static final long serialVersionUID = -6489182908053659185L;
061:
062: private Activity _toActivity;
063: private Activity _fromActivity;
064: private Event _event;
065: private ExecutionType _executionType;
066: private Condition _condition;
067: private String _from;
068: private String _to;
069:
070: public Transition() {
071: }
072:
073: /**
074: * Construct a new Transition.
075: *
076: * @param id The transition ID
077: * @param name The transition name
078: * @param from The activity ID where the transition starts
079: * @param to The activity ID where the transition ends
080: */
081: public Transition(String id, String name, String from, String to) {
082: super (id, name);
083:
084: setFrom(from);
085: setTo(to);
086: }
087:
088: public void accept(PackageVisitor visitor) {
089: visitor.visit(this );
090: if (_event != null)
091: _event.accept(visitor);
092: }
093:
094: /**
095: * Get the condition which is used to determine whether or not the
096: * transition should be executed.
097: *
098: * @return The condition
099: */
100: public Condition getCondition() {
101: return _condition;
102: }
103:
104: /**
105: * Set the condition which is used to determine whether or not the
106: * transition should be executed.
107: *
108: * @param condition The condition
109: */
110: public void setCondition(Condition condition) {
111: _condition = condition;
112: }
113:
114: public Event getEvent() {
115: return _event;
116: }
117:
118: public void setEvent(Event event) {
119: _event = event;
120: }
121:
122: /**
123: * Get the start activity ID
124: *
125: * @return The start activity ID
126: */
127: public String getFrom() {
128: return _from;
129: }
130:
131: /**
132: * Set the start activity ID.
133: *
134: * @param from The new start activity ID
135: */
136: public void setFrom(String from) {
137: if (from == null)
138: throw new IllegalArgumentException(
139: "'from' attribute required");
140: if (!from.equals(_from)) {
141: _from = from;
142: _fromActivity = null;
143: }
144: }
145:
146: /**
147: * Get the end activity ID.
148: *
149: * @return The end activity ID
150: */
151: public String getTo() {
152: return _to;
153: }
154:
155: /**
156: * Set the end activity ID.
157: *
158: * @param to The end activty ID
159: */
160: public void setTo(String to) {
161: if (to == null)
162: throw new IllegalArgumentException(
163: "'to' attribute required");
164: if (!to.equals(_to)) {
165: _to = to;
166: _toActivity = null;
167: }
168: }
169:
170: public Activity getToActivity() {
171: return _toActivity;
172: }
173:
174: public void setToActivity(Activity toActivity) {
175: _toActivity = toActivity;
176: _to = toActivity.getId();
177: }
178:
179: public Activity getFromActivity() {
180: return _fromActivity;
181: }
182:
183: public void setFromActivity(Activity fromActivity) {
184: _fromActivity = fromActivity;
185: _from = fromActivity.getId();
186: }
187:
188: public ExecutionType getExecution() {
189: return _executionType;
190: }
191:
192: public void setExecutionType(ExecutionType executionType) {
193: _executionType = executionType;
194: }
195:
196: public String toString() {
197: return "Transition[id='" + getId() + "', executionType="
198: + _executionType + ", condition=" + _condition
199: + ", from='" + _from + '\'' + ", to='" + _to + '\''
200: + ']';
201: }
202: }
|