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.util.AbstractBean;
048: import org.obe.xpdl.model.XPDLProperties;
049:
050: import java.beans.PropertyVetoException;
051:
052: /**
053: * A split represents a location in a workflow process where execution can split
054: * or change paths based on the outcome of a condition. Two types of splits are
055: * supported: AND and XOR. AND splits result in multiple threads executing at
056: * the same time. XOR splits result in a continuation of the current thread,
057: * albeit on one of several possible paths. Non-exclusive splits are also
058: * possible by using an AND split in conjuction with conditions.
059: *
060: * @author Adrian Price
061: */
062: public final class Split extends AbstractBean {
063: private static final long serialVersionUID = 7654247142688505300L;
064: public static final String TRANSITION_REFERENCE = XPDLProperties.TRANSITION_REFERENCE;
065: public static final String TYPE = XPDLProperties.TYPE;
066: private static final String[] EMPTY_TRANS_REF = {};
067: private static final String[] _indexedPropertyNames = { TRANSITION_REFERENCE };
068: private static final Object[] _indexedPropertyValues = { EMPTY_TRANS_REF };
069: private static final int TRANSITION_REFERENCE_IDX = 0;
070:
071: private SplitType _type;
072: private String[] _transitionReference = EMPTY_TRANS_REF;
073:
074: /**
075: * Construct a new Split.
076: */
077: public Split() {
078: super (_indexedPropertyNames, _indexedPropertyValues);
079: }
080:
081: /**
082: * Gets the split type.
083: *
084: * @return The split type
085: */
086: public SplitType getType() {
087: return _type;
088: }
089:
090: /**
091: * Sets the split type.
092: *
093: * @param type The split type
094: */
095: public void setType(SplitType type) {
096: _type = type;
097: }
098:
099: public void add(String transitionReference)
100: throws PropertyVetoException {
101: _transitionReference = (String[]) add(TRANSITION_REFERENCE_IDX,
102: transitionReference);
103: }
104:
105: public void remove(String transitionReference)
106: throws PropertyVetoException {
107:
108: _transitionReference = (String[]) remove(
109: TRANSITION_REFERENCE_IDX, transitionReference);
110: }
111:
112: /**
113: * Get a list of transition references. Transition references are used in
114: * XOR splits to determine which transitions are part of the possible
115: * threads.
116: *
117: * @return The transition references
118: */
119: public String[] getTransitionReference() {
120: return (String[]) get(TRANSITION_REFERENCE_IDX);
121: }
122:
123: public String getTransitionReference(int i) {
124: return _transitionReference[i];
125: }
126:
127: public void setTransitionReference(String[] transitionReferences)
128: throws PropertyVetoException {
129:
130: set(
131: TRANSITION_REFERENCE_IDX,
132: _transitionReference = transitionReferences == null ? EMPTY_TRANS_REF
133: : transitionReferences);
134: }
135:
136: public void setTransitionReference(int i, String transitionReference)
137: throws PropertyVetoException {
138:
139: set(TRANSITION_REFERENCE_IDX, i, transitionReference);
140: }
141:
142: public String toString() {
143: return "Split[type=" + _type + ", transitionReference="
144: + _transitionReference + ']';
145: }
146: }
|