01: package org.andromda.metafacades.uml14;
02:
03: import java.util.Collection;
04: import java.util.Iterator;
05:
06: import org.omg.uml.behavioralelements.statemachines.State;
07: import org.omg.uml.behavioralelements.statemachines.Transition;
08:
09: /**
10: * MetafacadeLogic implementation.
11: *
12: * @see org.andromda.metafacades.uml.EventFacade
13: */
14: public class EventFacadeLogicImpl extends EventFacadeLogic {
15: public EventFacadeLogicImpl(
16: org.omg.uml.behavioralelements.statemachines.Event metaObject,
17: java.lang.String context) {
18: super (metaObject, context);
19: }
20:
21: /**
22: * @see org.andromda.metafacades.uml.EventFacade#getParameters()
23: */
24: protected Collection handleGetParameters() {
25: return metaObject.getParameter();
26: }
27:
28: /**
29: * @see org.andromda.metafacades.uml.EventFacade#getTransition()
30: */
31: protected Object handleGetTransition() {
32: Transition eventTransition = null;
33:
34: final Collection allTransitions = UML14MetafacadeUtils
35: .getModel().getStateMachines().getTransition()
36: .refAllOfType();
37: for (final Iterator iterator = allTransitions.iterator(); iterator
38: .hasNext()
39: && eventTransition == null;) {
40: final Transition transition = (Transition) iterator.next();
41: if (metaObject.equals(transition.getTrigger())) {
42: eventTransition = transition;
43: }
44: }
45:
46: return eventTransition;
47: }
48:
49: /**
50: * @see org.andromda.metafacades.uml.EventFacade#getState()
51: */
52: protected Object handleGetState() {
53: State eventState = null;
54:
55: final Collection allStates = UML14MetafacadeUtils.getModel()
56: .getStateMachines().getState().refAllOfType();
57: for (final Iterator stateIterator = allStates.iterator(); stateIterator
58: .hasNext()
59: && eventState == null;) {
60: final State state = (State) stateIterator.next();
61: if (state.getDeferrableEvent().contains(metaObject)) {
62: eventState = state;
63: }
64: }
65:
66: return eventState;
67: }
68:
69: /**
70: * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
71: */
72: public Object getValidationOwner() {
73: Object validationOwner = this.getTransition();
74: if (validationOwner == null) {
75: validationOwner = this.getState();
76: }
77: return validationOwner;
78: }
79: }
|