01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.domains.enterprisemodel.impl;
16:
17: import com.metaboss.enterprise.bo.BOException;
18: import com.metaboss.enterprise.bo.BOIllegalArgumentException;
19: import com.metaboss.enterprise.bo.BOUnexpectedProgramConditionException;
20: import com.metaboss.sdlctools.domains.enterprisemodel.BOEntity;
21: import com.metaboss.sdlctools.domains.enterprisemodel.BOState;
22: import com.metaboss.sdlctools.domains.enterprisemodel.BOStateTransition;
23: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STStateTransition;
24: import com.oldboss.framework.bo.impl.BOObjectImpl;
25:
26: public class BOStateTransitionImpl extends BOObjectImpl implements
27: BOStateTransition {
28: protected BOMetaBossDomainImpl mMetaBossDomainImpl = null;
29: private BOEntity mOwnerEntity = null;
30: private BOState mStartingState = null;
31: private BOState mDestinationState = null;
32: protected STStateTransition mDetails = null;
33:
34: /* Instance creator */
35: public static BOStateTransition createInstanceForExisting(
36: BOMetaBossDomainImpl pMetaBossDomainImpl,
37: BOEntity pOwnerEntity, BOState pStartingState,
38: STStateTransition pDetails) throws BOException {
39: if (pDetails == null)
40: throw new BOIllegalArgumentException(
41: "Empty details structure");
42: BOStateTransitionImpl lImpl = new BOStateTransitionImpl();
43: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
44: lImpl.mOwnerEntity = pOwnerEntity;
45: lImpl.mStartingState = pStartingState;
46: lImpl.mDetails = pDetails;
47: // Immediately load destination state
48: if ((lImpl.mDestinationState = pOwnerEntity.getStates()
49: .getState(pDetails.DestinationStateName)) == null)
50: throw new BOUnexpectedProgramConditionException(
51: "Undefined destination state in the state transition");
52: lImpl.setupForExisting();
53: return lImpl;
54: }
55:
56: /* Returns entity which owns this attribute */
57: public BOEntity getEntity() throws BOException {
58: return mOwnerEntity;
59: }
60:
61: /* Returns the state, which entity has at the beginning of this transition */
62: public BOState getStartingState() throws BOException {
63: return mStartingState;
64: }
65:
66: /* Returns the state, which this transition is moving to (this is "to" state) */
67: public BOState getDestinationState() throws BOException {
68: return mDestinationState;
69: }
70:
71: /* Returns this transition's description */
72: public String getDescription() throws BOException {
73: return mDetails.Description;
74: }
75: }
|