1 package org.andromda.metafacades.emf.uml22;
2
3 import java.util.Collection;
4 import java.util.Iterator;
5 import org.andromda.metafacades.uml.ActionStateFacade;
6 import org.andromda.metafacades.uml.FinalStateFacade;
7 import org.andromda.metafacades.uml.PseudostateFacade;
8 import org.andromda.metafacades.uml.StateVertexFacade;
9 import org.eclipse.uml2.uml.Action;
10 import org.eclipse.uml2.uml.Behavior;
11 import org.eclipse.uml2.uml.ConnectableElement;
12 import org.eclipse.uml2.uml.Constraint;
13 import org.eclipse.uml2.uml.Transition;
14 import org.eclipse.uml2.uml.Vertex;
15
16
17
18
19
20
21
22 public class TransitionFacadeLogicImpl
23 extends TransitionFacadeLogic
24 {
25 private static final long serialVersionUID = 34L;
26
27
28
29
30 public TransitionFacadeLogicImpl(
31 final Transition metaObject,
32 final String context)
33 {
34 super(metaObject, context);
35 }
36
37
38
39
40 @Override
41 protected Action handleGetEffect()
42 {
43
44
45 Action effectAction = null;
46 final Behavior effect = this.metaObject.getEffect();
47 if (effect != null)
48 {
49 final Collection<ConnectableElement> nodes = effect.getRoles();
50 for (final Iterator<ConnectableElement> nodesIt = nodes.iterator(); nodesIt.hasNext() && effectAction == null;)
51 {
52 final Object nextNode = nodesIt.next();
53 if (nextNode instanceof Action)
54 {
55 effectAction = (Action)nextNode;
56 }
57 }
58 }
59 return effectAction;
60 }
61
62
63
64
65 @Override
66 protected Vertex handleGetSource()
67 {
68 return this.metaObject.getSource();
69 }
70
71
72
73
74 @Override
75 protected Vertex handleGetTarget()
76 {
77 return this.metaObject.getTarget();
78 }
79
80
81
82
83 @Override
84 protected Behavior handleGetTrigger()
85 {
86
87
88 return this.metaObject.getEffect();
89 }
90
91
92
93
94 @Override
95 protected Constraint handleGetGuard()
96 {
97 return this.metaObject.getGuard();
98 }
99
100
101
102
103 @Override
104 protected boolean handleIsTriggerPresent()
105 {
106 return this.metaObject.getEffect() != null;
107 }
108
109
110
111
112 @Override
113 protected boolean handleIsExitingDecisionPoint()
114 {
115 final StateVertexFacade sourceVertex = this.getSource();
116 return sourceVertex instanceof PseudostateFacade && ((PseudostateFacade)sourceVertex).isDecisionPoint();
117 }
118
119
120
121
122 @Override
123 protected boolean handleIsEnteringDecisionPoint()
124 {
125 final StateVertexFacade target = this.getTarget();
126 return target instanceof PseudostateFacade && ((PseudostateFacade)target).isDecisionPoint();
127 }
128
129
130
131
132
133
134
135 @Override
136 protected boolean handleIsExitingActionState()
137 {
138 return this.getSource() instanceof ActionStateFacade;
139 }
140
141
142
143
144 @Override
145 protected boolean handleIsEnteringActionState()
146 {
147 return this.getTarget() instanceof ActionStateFacade;
148 }
149
150
151
152
153 @Override
154 protected boolean handleIsExitingInitialState()
155 {
156 final StateVertexFacade sourceVertex = this.getSource();
157 return sourceVertex instanceof PseudostateFacade && ((PseudostateFacade)sourceVertex).isInitialState();
158 }
159
160
161
162
163 @Override
164 protected boolean handleIsEnteringFinalState()
165 {
166 return this.getTarget() instanceof FinalStateFacade;
167 }
168
169
170
171
172
173 public Object handleGetValidationOwner()
174 {
175 return this.getTarget().getStateMachine();
176 }
177 }