1
2
3
4
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import java.util.List;
9 import org.andromda.core.metafacade.MetafacadeBase;
10 import org.andromda.core.metafacade.ModelValidationMessage;
11 import org.andromda.metafacades.uml.FrontEndAction;
12 import org.andromda.metafacades.uml.FrontEndParameter;
13 import org.andromda.metafacades.uml.FrontEndUseCase;
14 import org.andromda.metafacades.uml.FrontEndView;
15 import org.andromda.translation.ocl.validation.OCLCollections;
16 import org.andromda.translation.ocl.validation.OCLExpressions;
17 import org.andromda.translation.ocl.validation.OCLIntrospector;
18 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
19 import org.apache.commons.collections.Transformer;
20 import org.apache.log4j.Logger;
21
22
23
24
25
26
27
28 public abstract class FrontEndViewLogic
29 extends FrontEndActionStateLogicImpl
30 implements FrontEndView
31 {
32
33
34
35
36 protected Object metaObject;
37
38
39
40
41
42 protected FrontEndViewLogic(Object metaObjectIn, String context)
43 {
44 super(metaObjectIn, getContext(context));
45 this.metaObject = metaObjectIn;
46 }
47
48
49
50
51 private static final Logger logger = Logger.getLogger(FrontEndViewLogic.class);
52
53
54
55
56
57
58 private static String getContext(String context)
59 {
60 if (context == null)
61 {
62 context = "org.andromda.metafacades.uml.FrontEndView";
63 }
64 return context;
65 }
66
67
68
69
70 @Override
71 public void resetMetafacadeContext(String context)
72 {
73 if (!this.contextRoot)
74 {
75 context = getContext(context);
76 setMetafacadeContext (context);
77 }
78 }
79
80
81
82
83
84 public boolean isFrontEndViewMetaType()
85 {
86 return true;
87 }
88
89
90
91
92
93
94
95 protected abstract boolean handleIsFrontEndView();
96
97 private boolean __frontEndView1a;
98 private boolean __frontEndView1aSet = false;
99
100
101
102
103
104 public final boolean isFrontEndView()
105 {
106 boolean frontEndView1a = this.__frontEndView1a;
107 if (!this.__frontEndView1aSet)
108 {
109
110 frontEndView1a = handleIsFrontEndView();
111
112 this.__frontEndView1a = frontEndView1a;
113 if (isMetafacadePropertyCachingEnabled())
114 {
115 this.__frontEndView1aSet = true;
116 }
117 }
118 return frontEndView1a;
119 }
120
121
122
123 private List<FrontEndParameter> __getAllActionParameters1r;
124 private boolean __getAllActionParameters1rSet = false;
125
126
127
128
129
130 public final List<FrontEndParameter> getAllActionParameters()
131 {
132 List<FrontEndParameter> getAllActionParameters1r = this.__getAllActionParameters1r;
133 if (!this.__getAllActionParameters1rSet)
134 {
135
136 List result = handleGetAllActionParameters();
137 List shieldedResult = this.shieldedElements(result);
138 try
139 {
140 getAllActionParameters1r = (List<FrontEndParameter>)shieldedResult;
141 }
142 catch (ClassCastException ex)
143 {
144
145 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getAllActionParameters List<FrontEndParameter> " + result + ": " + shieldedResult);
146 }
147
148 this.__getAllActionParameters1r = getAllActionParameters1r;
149 if (isMetafacadePropertyCachingEnabled())
150 {
151 this.__getAllActionParameters1rSet = true;
152 }
153 }
154 return getAllActionParameters1r;
155 }
156
157
158
159
160
161 protected abstract List handleGetAllActionParameters();
162
163 private List<FrontEndParameter> __getAllFormFields2r;
164 private boolean __getAllFormFields2rSet = false;
165
166
167
168
169
170 public final List<FrontEndParameter> getAllFormFields()
171 {
172 List<FrontEndParameter> getAllFormFields2r = this.__getAllFormFields2r;
173 if (!this.__getAllFormFields2rSet)
174 {
175
176 List result = handleGetAllFormFields();
177 List shieldedResult = this.shieldedElements(result);
178 try
179 {
180 getAllFormFields2r = (List<FrontEndParameter>)shieldedResult;
181 }
182 catch (ClassCastException ex)
183 {
184
185 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getAllFormFields List<FrontEndParameter> " + result + ": " + shieldedResult);
186 }
187
188 this.__getAllFormFields2r = getAllFormFields2r;
189 if (isMetafacadePropertyCachingEnabled())
190 {
191 this.__getAllFormFields2rSet = true;
192 }
193 }
194 return getAllFormFields2r;
195 }
196
197
198
199
200
201 protected abstract List handleGetAllFormFields();
202
203 private List<FrontEndParameter> __getVariables3r;
204 private boolean __getVariables3rSet = false;
205
206
207
208
209
210 public final List<FrontEndParameter> getVariables()
211 {
212 List<FrontEndParameter> getVariables3r = this.__getVariables3r;
213 if (!this.__getVariables3rSet)
214 {
215
216 List result = handleGetVariables();
217 List shieldedResult = this.shieldedElements(result);
218 try
219 {
220 getVariables3r = (List<FrontEndParameter>)shieldedResult;
221 }
222 catch (ClassCastException ex)
223 {
224
225 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getVariables List<FrontEndParameter> " + result + ": " + shieldedResult);
226 }
227
228 this.__getVariables3r = getVariables3r;
229 if (isMetafacadePropertyCachingEnabled())
230 {
231 this.__getVariables3rSet = true;
232 }
233 }
234 return getVariables3r;
235 }
236
237
238
239
240
241 protected abstract List handleGetVariables();
242
243 private FrontEndUseCase __getUseCase4r;
244 private boolean __getUseCase4rSet = false;
245
246
247
248
249
250 public final FrontEndUseCase getUseCase()
251 {
252 FrontEndUseCase getUseCase4r = this.__getUseCase4r;
253 if (!this.__getUseCase4rSet)
254 {
255
256 Object result = handleGetUseCase();
257 MetafacadeBase shieldedResult = this.shieldedElement(result);
258 try
259 {
260 getUseCase4r = (FrontEndUseCase)shieldedResult;
261 }
262 catch (ClassCastException ex)
263 {
264
265 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getUseCase FrontEndUseCase " + result + ": " + shieldedResult);
266 }
267
268 this.__getUseCase4r = getUseCase4r;
269 if (isMetafacadePropertyCachingEnabled())
270 {
271 this.__getUseCase4rSet = true;
272 }
273 }
274 return getUseCase4r;
275 }
276
277
278
279
280
281 protected abstract Object handleGetUseCase();
282
283 private List<FrontEndParameter> __getTables5r;
284 private boolean __getTables5rSet = false;
285
286
287
288
289
290 public final List<FrontEndParameter> getTables()
291 {
292 List<FrontEndParameter> getTables5r = this.__getTables5r;
293 if (!this.__getTables5rSet)
294 {
295
296 List result = handleGetTables();
297 List shieldedResult = this.shieldedElements(result);
298 try
299 {
300 getTables5r = (List<FrontEndParameter>)shieldedResult;
301 }
302 catch (ClassCastException ex)
303 {
304
305 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getTables List<FrontEndParameter> " + result + ": " + shieldedResult);
306 }
307
308 this.__getTables5r = getTables5r;
309 if (isMetafacadePropertyCachingEnabled())
310 {
311 this.__getTables5rSet = true;
312 }
313 }
314 return getTables5r;
315 }
316
317
318
319
320
321 protected abstract List handleGetTables();
322
323 private List<FrontEndAction> __getActions6r;
324 private boolean __getActions6rSet = false;
325
326
327
328
329
330 public final List<FrontEndAction> getActions()
331 {
332 List<FrontEndAction> getActions6r = this.__getActions6r;
333 if (!this.__getActions6rSet)
334 {
335
336 List result = handleGetActions();
337 List shieldedResult = this.shieldedElements(result);
338 try
339 {
340 getActions6r = (List<FrontEndAction>)shieldedResult;
341 }
342 catch (ClassCastException ex)
343 {
344
345 FrontEndViewLogic.logger.warn("incorrect metafacade cast for FrontEndViewLogic.getActions List<FrontEndAction> " + result + ": " + shieldedResult);
346 }
347
348 this.__getActions6r = getActions6r;
349 if (isMetafacadePropertyCachingEnabled())
350 {
351 this.__getActions6rSet = true;
352 }
353 }
354 return getActions6r;
355 }
356
357
358
359
360
361 protected abstract List handleGetActions();
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379 @Override
380 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
381 {
382 super.validateInvariants(validationMessages);
383 try
384 {
385 final Object contextElement = this.THIS();
386 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"useCase.views"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
387 if (!constraintValid)
388 {
389 validationMessages.add(
390 new ModelValidationMessage(
391 (MetafacadeBase)contextElement ,
392 "org::andromda::metafacades::uml::FrontEndView::unique view name per usecase",
393 "Each name of a view action state must be unique in the namespace of a front-end use-case."));
394 }
395 }
396 catch (Throwable th)
397 {
398 Throwable cause = th.getCause();
399 int depth = 0;
400 while (cause != null && depth < 7)
401 {
402 th = cause;
403 depth++;
404 }
405 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::unique view name per usecase' ON "
406 + this.THIS().toString() + ": " + th.getMessage(), th);
407 }
408 try
409 {
410 final Object contextElement = this.THIS();
411 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"variables"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
412 if (!constraintValid)
413 {
414 validationMessages.add(
415 new ModelValidationMessage(
416 (MetafacadeBase)contextElement ,
417 "org::andromda::metafacades::uml::FrontEndView::view variables must have unique names",
418 "Each view-variable should have a unique name within the context of a view."));
419 }
420 }
421 catch (Throwable th)
422 {
423 Throwable cause = th.getCause();
424 int depth = 0;
425 while (cause != null && depth < 7)
426 {
427 th = cause;
428 depth++;
429 }
430 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::view variables must have unique names' ON "
431 + this.THIS().toString() + ": " + th.getMessage(), th);
432 }
433 try
434 {
435 final Object contextElement = this.THIS();
436 boolean constraintValid = OCLResultEnsurer.ensure(OCLExpressions.equal(OCLCollections.size(OCLIntrospector.invoke(contextElement,"controllerCalls")),0));
437 if (!constraintValid)
438 {
439 validationMessages.add(
440 new ModelValidationMessage(
441 (MetafacadeBase)contextElement ,
442 "org::andromda::metafacades::uml::FrontEndView::front-end views cannot defer operations",
443 "Views cannot defer to operations. All deferrable events modeled on a front-end view will be ignored."));
444 }
445 }
446 catch (Throwable th)
447 {
448 Throwable cause = th.getCause();
449 int depth = 0;
450 while (cause != null && depth < 7)
451 {
452 th = cause;
453 depth++;
454 }
455 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::front-end views cannot defer operations' ON "
456 + this.THIS().toString() + ": " + th.getMessage(), th);
457 }
458 try
459 {
460 final Object contextElement = this.THIS();
461 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.isUnique(OCLIntrospector.invoke(contextElement,"actions"),new Transformer(){public Object transform(Object object){return OCLIntrospector.invoke(object,"name");}}));
462 if (!constraintValid)
463 {
464 validationMessages.add(
465 new ModelValidationMessage(
466 (MetafacadeBase)contextElement ,
467 "org::andromda::metafacades::uml::FrontEndView::each action going out of a front-end view must be unique",
468 "Each view must contain actions which each have a unique name, this view has actions with duplicate names."));
469 }
470 }
471 catch (Throwable th)
472 {
473 Throwable cause = th.getCause();
474 int depth = 0;
475 while (cause != null && depth < 7)
476 {
477 th = cause;
478 depth++;
479 }
480 logger.error("Error validating constraint 'org::andromda::metafacades::uml::FrontEndView::each action going out of a front-end view must be unique' ON "
481 + this.THIS().toString() + ": " + th.getMessage(), th);
482 }
483 }
484 }