1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
package org.argouml.model.mdr; |
41 | |
|
42 | |
import java.util.Collection; |
43 | |
|
44 | |
import org.argouml.model.ActivityGraphsFactory; |
45 | |
import org.omg.uml.behavioralelements.activitygraphs.ActionState; |
46 | |
import org.omg.uml.behavioralelements.activitygraphs.ActivityGraph; |
47 | |
import org.omg.uml.behavioralelements.activitygraphs.CallState; |
48 | |
import org.omg.uml.behavioralelements.activitygraphs.ClassifierInState; |
49 | |
import org.omg.uml.behavioralelements.activitygraphs.ObjectFlowState; |
50 | |
import org.omg.uml.behavioralelements.activitygraphs.Partition; |
51 | |
import org.omg.uml.behavioralelements.activitygraphs.SubactivityState; |
52 | |
import org.omg.uml.behavioralelements.statemachines.CompositeState; |
53 | |
import org.omg.uml.behavioralelements.statemachines.State; |
54 | |
import org.omg.uml.foundation.core.BehavioralFeature; |
55 | |
import org.omg.uml.foundation.core.Classifier; |
56 | |
import org.omg.uml.foundation.core.ModelElement; |
57 | |
import org.omg.uml.foundation.core.Namespace; |
58 | |
import org.omg.uml.foundation.core.UmlClass; |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | 19 | class ActivityGraphsFactoryMDRImpl extends AbstractUmlModelFactoryMDR |
70 | |
implements ActivityGraphsFactory { |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
private MDRModelImplementation modelImpl; |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | 900 | ActivityGraphsFactoryMDRImpl(MDRModelImplementation implementation) { |
84 | 900 | modelImpl = implementation; |
85 | 900 | } |
86 | |
|
87 | |
|
88 | |
public ActionState createActionState() { |
89 | 0 | ActionState myActionState = modelImpl.getUmlPackage() |
90 | |
.getActivityGraphs().getActionState().createActionState(); |
91 | 0 | super.initialize(myActionState); |
92 | 0 | return myActionState; |
93 | |
} |
94 | |
|
95 | |
|
96 | |
public ActivityGraph createActivityGraph() { |
97 | 19 | ActivityGraph myActivityGraph = modelImpl.getUmlPackage(). |
98 | |
getActivityGraphs().getActivityGraph().createActivityGraph(); |
99 | 19 | super.initialize(myActivityGraph); |
100 | 19 | return myActivityGraph; |
101 | |
} |
102 | |
|
103 | |
|
104 | |
public CallState createCallState() { |
105 | 0 | CallState myCallState = modelImpl.getUmlPackage().getActivityGraphs(). |
106 | |
getCallState().createCallState(); |
107 | 0 | super.initialize(myCallState); |
108 | 0 | return myCallState; |
109 | |
} |
110 | |
|
111 | |
|
112 | |
public ClassifierInState createClassifierInState() { |
113 | 0 | ClassifierInState myClassifierInState = modelImpl.getUmlPackage(). |
114 | |
getActivityGraphs().getClassifierInState(). |
115 | |
createClassifierInState(); |
116 | 0 | super.initialize(myClassifierInState); |
117 | 0 | return myClassifierInState; |
118 | |
} |
119 | |
|
120 | |
|
121 | |
public ObjectFlowState createObjectFlowState() { |
122 | 0 | ObjectFlowState myObjectFlowState = modelImpl.getUmlPackage(). |
123 | |
getActivityGraphs().getObjectFlowState(). |
124 | |
createObjectFlowState(); |
125 | 0 | super.initialize(myObjectFlowState); |
126 | 0 | return myObjectFlowState; |
127 | |
} |
128 | |
|
129 | |
|
130 | |
public Partition createPartition() { |
131 | 0 | Partition myPartition = modelImpl.getUmlPackage().getActivityGraphs(). |
132 | |
getPartition().createPartition(); |
133 | 0 | super.initialize(myPartition); |
134 | 0 | return myPartition; |
135 | |
} |
136 | |
|
137 | |
|
138 | |
public SubactivityState createSubactivityState() { |
139 | 0 | SubactivityState mySubactivityState = |
140 | |
modelImpl.getUmlPackage().getActivityGraphs() |
141 | |
.getSubactivityState().createSubactivityState(); |
142 | 0 | super.initialize(mySubactivityState); |
143 | 0 | return mySubactivityState; |
144 | |
} |
145 | |
|
146 | |
|
147 | |
public ActivityGraph buildActivityGraph(Object theContext) { |
148 | 19 | if (theContext instanceof ModelElement) { |
149 | 19 | ActivityGraph myActivityGraph = createActivityGraph(); |
150 | 19 | ModelElement modelelement = (ModelElement) theContext; |
151 | 19 | myActivityGraph.setContext(modelelement); |
152 | |
|
153 | 19 | if (modelelement instanceof BehavioralFeature) { |
154 | 0 | modelelement = ((BehavioralFeature) modelelement).getOwner(); |
155 | |
} |
156 | 19 | if (modelelement instanceof Namespace) { |
157 | 19 | Namespace namespace = (Namespace) modelelement; |
158 | |
|
159 | |
|
160 | |
|
161 | 19 | while (namespace instanceof UmlClass) { |
162 | 0 | Namespace pns = namespace.getNamespace(); |
163 | 0 | if (pns == null) break; |
164 | 0 | namespace = pns; |
165 | 0 | } |
166 | 19 | myActivityGraph.setNamespace(namespace); |
167 | |
} |
168 | 19 | State top = |
169 | |
(CompositeState) modelImpl.getStateMachinesFactory() |
170 | |
.buildCompositeStateOnStateMachine(myActivityGraph); |
171 | 19 | myActivityGraph.setTop(top); |
172 | 19 | return myActivityGraph; |
173 | |
} |
174 | 0 | throw new IllegalArgumentException( |
175 | |
"Cannot create an ActivityGraph with context " + theContext); |
176 | |
} |
177 | |
|
178 | |
|
179 | |
public ObjectFlowState buildObjectFlowState(Object compositeState) { |
180 | 0 | if (!(compositeState instanceof CompositeState)) { |
181 | 0 | throw new IllegalArgumentException(); |
182 | |
} |
183 | |
|
184 | 0 | ObjectFlowState state = createObjectFlowState(); |
185 | 0 | state.setContainer((CompositeState) compositeState); |
186 | 0 | return state; |
187 | |
} |
188 | |
|
189 | |
|
190 | |
public ClassifierInState buildClassifierInState(Object classifier, |
191 | |
Collection state) { |
192 | 0 | if (!(classifier instanceof Classifier)) { |
193 | 0 | throw new IllegalArgumentException(); |
194 | |
} |
195 | 0 | if (state.size() < 1) { |
196 | 0 | throw new IllegalArgumentException( |
197 | |
"Collection of states must have at least one element"); |
198 | |
} |
199 | |
|
200 | 0 | ClassifierInState c = createClassifierInState(); |
201 | 0 | c.setType((Classifier) classifier); |
202 | 0 | c.getInState().addAll(state); |
203 | 0 | c.setNamespace(((Classifier) classifier).getNamespace()); |
204 | |
|
205 | |
|
206 | 0 | c.setName(((Classifier) classifier).getName() |
207 | |
+ "inState[" |
208 | |
+ ((State) state.iterator().next()).getName() |
209 | |
+ "]"); |
210 | 0 | return c; |
211 | |
} |
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
void deleteActionState(Object elem) { |
218 | 0 | if (!(elem instanceof ActionState)) { |
219 | 0 | throw new IllegalArgumentException(); |
220 | |
} |
221 | 0 | } |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
void deleteActivityGraph(Object elem) { |
228 | 0 | if (!(elem instanceof ActivityGraph)) { |
229 | 0 | throw new IllegalArgumentException(); |
230 | |
} |
231 | |
|
232 | |
|
233 | 0 | } |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
void deleteCallState(Object elem) { |
240 | 0 | if (!(elem instanceof CallState)) { |
241 | 0 | throw new IllegalArgumentException(); |
242 | |
} |
243 | 0 | } |
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
void deleteClassifierInState(Object elem) { |
250 | 0 | if (!(elem instanceof ClassifierInState)) { |
251 | 0 | throw new IllegalArgumentException(); |
252 | |
} |
253 | 0 | } |
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
void deleteObjectFlowState(Object elem) { |
260 | 0 | if (!(elem instanceof ObjectFlowState)) { |
261 | 0 | throw new IllegalArgumentException(); |
262 | |
} |
263 | 0 | } |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
void deletePartition(Object elem) { |
270 | 0 | if (!(elem instanceof Partition)) { |
271 | 0 | throw new IllegalArgumentException(); |
272 | |
} |
273 | 0 | } |
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
void deleteSubactivityState(Object elem) { |
280 | 0 | if (!(elem instanceof SubactivityState)) { |
281 | 0 | throw new IllegalArgumentException(); |
282 | |
} |
283 | 0 | } |
284 | |
|
285 | |
} |