1 // license-header java merge-point
2 //
3 // Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
4 //
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import java.util.List;
9 import org.andromda.core.common.Introspector;
10 import org.andromda.core.metafacade.MetafacadeBase;
11 import org.andromda.core.metafacade.ModelValidationMessage;
12 import org.andromda.metafacades.uml.ActionStateFacade;
13 import org.andromda.metafacades.uml.ActivityGraphFacade;
14 import org.andromda.metafacades.uml.ActorFacade;
15 import org.andromda.metafacades.uml.ClassifierFacade;
16 import org.andromda.metafacades.uml.FinalStateFacade;
17 import org.andromda.metafacades.uml.ModelFacade;
18 import org.andromda.metafacades.uml.ObjectFlowStateFacade;
19 import org.andromda.metafacades.uml.PackageFacade;
20 import org.andromda.metafacades.uml.TransitionFacade;
21 import org.andromda.metafacades.uml.UseCaseFacade;
22 import org.apache.log4j.Logger;
23 import org.omg.uml.UmlPackage;
24
25 /**
26 * Captures a view of a physical system. It is an abstraction of the physical system, with a certain
27 * purpose. This purpose determines what is to be included in the model and what is irrelevant. Thus
28 * the model completely describes those aspects of the physical system that are relevant to the
29 * purpose of the model, at the appropriate level of detail. May be a UML2 model or package.
30 * MetafacadeLogic for ModelFacade
31 *
32 * @see ModelFacade
33 */
34 public abstract class ModelFacadeLogic
35 extends MetafacadeBase
36 implements ModelFacade
37 {
38 /**
39 * The underlying UML object
40 * @see UmlPackage
41 */
42 protected UmlPackage metaObject;
43
44 /** Create Metafacade implementation instance using the MetafacadeFactory from the context
45 * @param metaObjectIn
46 * @param context
47 */
48 protected ModelFacadeLogic(UmlPackage metaObjectIn, String context)
49 {
50 super(metaObjectIn, getContext(context));
51 this.metaObject = metaObjectIn;
52 }
53
54 /**
55 * The logger instance.
56 */
57 private static final Logger logger = Logger.getLogger(ModelFacadeLogic.class);
58
59 /**
60 * Gets the context for this metafacade logic instance.
61 * @param context String. Set to ModelFacade if null
62 * @return context String
63 */
64 private static String getContext(String context)
65 {
66 if (context == null)
67 {
68 context = "org.andromda.metafacades.uml.ModelFacade";
69 }
70 return context;
71 }
72
73 /** Reset context only for non-root metafacades
74 * @param context
75 */
76 @Override
77 public void resetMetafacadeContext(String context)
78 {
79 if (!this.contextRoot) // reset context only for non-root metafacades
80 {
81 context = getContext(context); // to have same value as in original constructor call
82 setMetafacadeContext (context);
83 }
84 }
85
86 /**
87 * @return boolean true always
88 * @see ModelFacade
89 */
90 public boolean isModelFacadeMetaType()
91 {
92 return true;
93 }
94
95 // ---------------- business methods ----------------------
96
97 /**
98 * Method to be implemented in descendants
99 * Return the UseCase belonging to this model with the tagged value or hyperlink.
100 * @param tag
101 * @param value
102 * @return UseCaseFacade
103 */
104 protected abstract UseCaseFacade handleFindUseCaseWithTaggedValueOrHyperlink(String tag, String value);
105
106 /**
107 * Return the UseCase belonging to this model with the tagged value or hyperlink.
108 * @param tag String
109 * TODO: Model Documentation for
110 * ModelFacade.findUseCaseWithTaggedValueOrHyperlink(tag)
111 * @param value String
112 * TODO: Model Documentation for
113 * ModelFacade.findUseCaseWithTaggedValueOrHyperlink(value)
114 * @return handleFindUseCaseWithTaggedValueOrHyperlink(tag, value)
115 */
116 public UseCaseFacade findUseCaseWithTaggedValueOrHyperlink(String tag, String value)
117 {
118 // findUseCaseWithTaggedValueOrHyperlink has no pre constraints
119 UseCaseFacade returnValue = handleFindUseCaseWithTaggedValueOrHyperlink(tag, value);
120 // findUseCaseWithTaggedValueOrHyperlink has no post constraints
121 return returnValue;
122 }
123
124 /**
125 * Method to be implemented in descendants
126 * Return the Class belonging to this model with the tagged value or hyperlink.
127 * @param tag
128 * @param value
129 * @return ClassifierFacade
130 */
131 protected abstract ClassifierFacade handleFindClassWithTaggedValueOrHyperlink(String tag, String value);
132
133 /**
134 * Return the Class belonging to this model with the tagged value or hyperlink.
135 * @param tag String
136 * TODO: Model Documentation for
137 * ModelFacade.findClassWithTaggedValueOrHyperlink(tag)
138 * @param value String
139 * TODO: Model Documentation for
140 * ModelFacade.findClassWithTaggedValueOrHyperlink(value)
141 * @return handleFindClassWithTaggedValueOrHyperlink(tag, value)
142 */
143 public ClassifierFacade findClassWithTaggedValueOrHyperlink(String tag, String value)
144 {
145 // findClassWithTaggedValueOrHyperlink has no pre constraints
146 ClassifierFacade returnValue = handleFindClassWithTaggedValueOrHyperlink(tag, value);
147 // findClassWithTaggedValueOrHyperlink has no post constraints
148 return returnValue;
149 }
150
151 /**
152 * Method to be implemented in descendants
153 * Finds the ActivityGraph with the Name.
154 * @param name
155 * @return ActivityGraphFacade
156 */
157 protected abstract ActivityGraphFacade handleFindActivityGraphByName(String name);
158
159 /**
160 * Finds the ActivityGraph with the Name.
161 * @param name String
162 * TODO: Model Documentation for
163 * ModelFacade.findActivityGraphByName(name)
164 * @return handleFindActivityGraphByName(name)
165 */
166 public ActivityGraphFacade findActivityGraphByName(String name)
167 {
168 // findActivityGraphByName has no pre constraints
169 ActivityGraphFacade returnValue = handleFindActivityGraphByName(name);
170 // findActivityGraphByName has no post constraints
171 return returnValue;
172 }
173
174 /**
175 * Method to be implemented in descendants
176 * Finds the ActivityGraph with the Name and Stereotype.
177 * @param name
178 * @param stereotypeName
179 * @return ActivityGraphFacade
180 */
181 protected abstract ActivityGraphFacade handleFindActivityGraphByNameAndStereotype(String name, String stereotypeName);
182
183 /**
184 * Finds the ActivityGraph with the Name and Stereotype.
185 * @param name String
186 * TODO: Model Documentation for
187 * ModelFacade.findActivityGraphByNameAndStereotype(name)
188 * @param stereotypeName String
189 * TODO: Model Documentation for
190 * ModelFacade.findActivityGraphByNameAndStereotype(stereotypeName)
191 * @return handleFindActivityGraphByNameAndStereotype(name, stereotypeName)
192 */
193 public ActivityGraphFacade findActivityGraphByNameAndStereotype(String name, String stereotypeName)
194 {
195 // findActivityGraphByNameAndStereotype has no pre constraints
196 ActivityGraphFacade returnValue = handleFindActivityGraphByNameAndStereotype(name, stereotypeName);
197 // findActivityGraphByNameAndStereotype has no post constraints
198 return returnValue;
199 }
200
201 /**
202 * Method to be implemented in descendants
203 * Finds the UseCase with the Name.
204 * @param name
205 * @return UseCaseFacade
206 */
207 protected abstract UseCaseFacade handleFindUseCaseByName(String name);
208
209 /**
210 * Finds the UseCase with the Name.
211 * @param name String
212 * TODO: Model Documentation for
213 * ModelFacade.findUseCaseByName(name)
214 * @return handleFindUseCaseByName(name)
215 */
216 public UseCaseFacade findUseCaseByName(String name)
217 {
218 // findUseCaseByName has no pre constraints
219 UseCaseFacade returnValue = handleFindUseCaseByName(name);
220 // findUseCaseByName has no post constraints
221 return returnValue;
222 }
223
224 /**
225 * Method to be implemented in descendants
226 * Finds the UseGraph with the Name and Stereotype.
227 * @param name
228 * @param stereotypeName
229 * @return UseCaseFacade
230 */
231 protected abstract UseCaseFacade handleFindUseCaseWithNameAndStereotype(String name, String stereotypeName);
232
233 /**
234 * Finds the UseGraph with the Name and Stereotype.
235 * @param name String
236 * TODO: Model Documentation for
237 * ModelFacade.findUseCaseWithNameAndStereotype(name)
238 * @param stereotypeName String
239 * TODO: Model Documentation for
240 * ModelFacade.findUseCaseWithNameAndStereotype(stereotypeName)
241 * @return handleFindUseCaseWithNameAndStereotype(name, stereotypeName)
242 */
243 public UseCaseFacade findUseCaseWithNameAndStereotype(String name, String stereotypeName)
244 {
245 // findUseCaseWithNameAndStereotype has no pre constraints
246 UseCaseFacade returnValue = handleFindUseCaseWithNameAndStereotype(name, stereotypeName);
247 // findUseCaseWithNameAndStereotype has no post constraints
248 return returnValue;
249 }
250
251 /**
252 * Method to be implemented in descendants
253 * Finds the FinalState with the Name or Hyperlink.
254 * @param useCase
255 * @return Collection<FinalStateFacade>
256 */
257 protected abstract Collection<FinalStateFacade> handleFindFinalStatesWithNameOrHyperlink(UseCaseFacade useCase);
258
259 /**
260 * Finds the FinalState with the Name or Hyperlink.
261 * @param useCase UseCaseFacade
262 * TODO: Model Documentation for
263 * ModelFacade.findFinalStatesWithNameOrHyperlink(useCase)
264 * @return handleFindFinalStatesWithNameOrHyperlink(useCase)
265 */
266 public Collection<FinalStateFacade> findFinalStatesWithNameOrHyperlink(UseCaseFacade useCase)
267 {
268 // findFinalStatesWithNameOrHyperlink has no pre constraints
269 Collection<FinalStateFacade> returnValue = handleFindFinalStatesWithNameOrHyperlink(useCase);
270 // findFinalStatesWithNameOrHyperlink has no post constraints
271 return returnValue;
272 }
273
274 /**
275 * Method to be implemented in descendants
276 * Finds all ActionStates with the Stereotype.
277 * @param activityGraph
278 * @param stereotypeName
279 * @return Collection<ActionStateFacade>
280 */
281 protected abstract Collection<ActionStateFacade> handleGetAllActionStatesWithStereotype(ActivityGraphFacade activityGraph, String stereotypeName);
282
283 /**
284 * Finds all ActionStates with the Stereotype.
285 * @param activityGraph ActivityGraphFacade
286 * TODO: Model Documentation for
287 * ModelFacade.getAllActionStatesWithStereotype(activityGraph)
288 * @param stereotypeName String
289 * TODO: Model Documentation for
290 * ModelFacade.getAllActionStatesWithStereotype(stereotypeName)
291 * @return handleGetAllActionStatesWithStereotype(activityGraph, stereotypeName)
292 */
293 public Collection<ActionStateFacade> getAllActionStatesWithStereotype(ActivityGraphFacade activityGraph, String stereotypeName)
294 {
295 // getAllActionStatesWithStereotype has no pre constraints
296 Collection<ActionStateFacade> returnValue = handleGetAllActionStatesWithStereotype(activityGraph, stereotypeName);
297 // getAllActionStatesWithStereotype has no post constraints
298 return returnValue;
299 }
300
301 // ------------- associations ------------------
302
303 private Collection<ClassifierFacade> __getAllClasses1r;
304 private boolean __getAllClasses1rSet = false;
305
306 /**
307 * Captures a view of a physical system. It is an abstraction of the physical system, with a
308 * certain
309 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
310 * Thus
311 * the model completely describes those aspects of the physical system that are relevant to the
312 * purpose
313 * of the model, at the appropriate level of detail. May be a UML2 model or package.
314 * @return (Collection<ClassifierFacade>)handleGetAllClasses()
315 */
316 public final Collection<ClassifierFacade> getAllClasses()
317 {
318 Collection<ClassifierFacade> getAllClasses1r = this.__getAllClasses1r;
319 if (!this.__getAllClasses1rSet)
320 {
321 // modelFacade has no pre constraints
322 Collection result = handleGetAllClasses();
323 List shieldedResult = this.shieldedElements(result);
324 try
325 {
326 getAllClasses1r = (Collection<ClassifierFacade>)shieldedResult;
327 }
328 catch (ClassCastException ex)
329 {
330 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
331 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllClasses Collection<ClassifierFacade> " + result + ": " + shieldedResult);
332 }
333 // modelFacade has no post constraints
334 this.__getAllClasses1r = getAllClasses1r;
335 if (isMetafacadePropertyCachingEnabled())
336 {
337 this.__getAllClasses1rSet = true;
338 }
339 }
340 return getAllClasses1r;
341 }
342
343 /**
344 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
345 * @return Collection
346 */
347 protected abstract Collection handleGetAllClasses();
348
349 /**
350 * Captures a view of a physical system. It is an abstraction of the physical system, with a
351 * certain
352 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
353 * Thus
354 * the model completely describes those aspects of the physical system that are relevant to the
355 * purpose
356 * of the model, at the appropriate level of detail. May be a UML2 model or package.
357 * @return (PackageFacade)handleGetRootPackage()
358 */
359 public final PackageFacade getRootPackage()
360 {
361 PackageFacade getRootPackage2r = null;
362 // modelFacade has no pre constraints
363 Object result = handleGetRootPackage();
364 MetafacadeBase shieldedResult = this.shieldedElement(result);
365 try
366 {
367 getRootPackage2r = (PackageFacade)shieldedResult;
368 }
369 catch (ClassCastException ex)
370 {
371 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
372 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getRootPackage PackageFacade " + result + ": " + shieldedResult);
373 }
374 // modelFacade has no post constraints
375 return getRootPackage2r;
376 }
377
378 /**
379 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
380 * @return Object
381 */
382 protected abstract Object handleGetRootPackage();
383
384 private Collection<TransitionFacade> __getAllTransitions3r;
385 private boolean __getAllTransitions3rSet = false;
386
387 /**
388 * Captures a view of a physical system. It is an abstraction of the physical system, with a
389 * certain
390 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
391 * Thus
392 * the model completely describes those aspects of the physical system that are relevant to the
393 * purpose
394 * of the model, at the appropriate level of detail. May be a UML2 model or package.
395 * @return (Collection<TransitionFacade>)handleGetAllTransitions()
396 */
397 public final Collection<TransitionFacade> getAllTransitions()
398 {
399 Collection<TransitionFacade> getAllTransitions3r = this.__getAllTransitions3r;
400 if (!this.__getAllTransitions3rSet)
401 {
402 // modelFacade has no pre constraints
403 Collection result = handleGetAllTransitions();
404 List shieldedResult = this.shieldedElements(result);
405 try
406 {
407 getAllTransitions3r = (Collection<TransitionFacade>)shieldedResult;
408 }
409 catch (ClassCastException ex)
410 {
411 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
412 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllTransitions Collection<TransitionFacade> " + result + ": " + shieldedResult);
413 }
414 // modelFacade has no post constraints
415 this.__getAllTransitions3r = getAllTransitions3r;
416 if (isMetafacadePropertyCachingEnabled())
417 {
418 this.__getAllTransitions3rSet = true;
419 }
420 }
421 return getAllTransitions3r;
422 }
423
424 /**
425 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
426 * @return Collection
427 */
428 protected abstract Collection handleGetAllTransitions();
429
430 /**
431 * Captures a view of a physical system. It is an abstraction of the physical system, with a
432 * certain
433 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
434 * Thus
435 * the model completely describes those aspects of the physical system that are relevant to the
436 * purpose
437 * of the model, at the appropriate level of detail. May be a UML2 model or package.
438 * @return (Collection<ActorFacade>)handleGetAllActors()
439 */
440 public final Collection<ActorFacade> getAllActors()
441 {
442 Collection<ActorFacade> getAllActors4r = null;
443 // modelFacade has no pre constraints
444 Collection result = handleGetAllActors();
445 List shieldedResult = this.shieldedElements(result);
446 try
447 {
448 getAllActors4r = (Collection<ActorFacade>)shieldedResult;
449 }
450 catch (ClassCastException ex)
451 {
452 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
453 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllActors Collection<ActorFacade> " + result + ": " + shieldedResult);
454 }
455 // modelFacade has no post constraints
456 return getAllActors4r;
457 }
458
459 /**
460 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
461 * @return Collection
462 */
463 protected abstract Collection handleGetAllActors();
464
465 /**
466 * Captures a view of a physical system. It is an abstraction of the physical system, with a
467 * certain
468 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
469 * Thus
470 * the model completely describes those aspects of the physical system that are relevant to the
471 * purpose
472 * of the model, at the appropriate level of detail. May be a UML2 model or package.
473 * @return (Collection<UseCaseFacade>)handleGetAllUseCases()
474 */
475 public final Collection<UseCaseFacade> getAllUseCases()
476 {
477 Collection<UseCaseFacade> getAllUseCases5r = null;
478 // modelFacade has no pre constraints
479 Collection result = handleGetAllUseCases();
480 List shieldedResult = this.shieldedElements(result);
481 try
482 {
483 getAllUseCases5r = (Collection<UseCaseFacade>)shieldedResult;
484 }
485 catch (ClassCastException ex)
486 {
487 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
488 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllUseCases Collection<UseCaseFacade> " + result + ": " + shieldedResult);
489 }
490 // modelFacade has no post constraints
491 return getAllUseCases5r;
492 }
493
494 /**
495 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
496 * @return Collection
497 */
498 protected abstract Collection handleGetAllUseCases();
499
500 /**
501 * Captures a view of a physical system. It is an abstraction of the physical system, with a
502 * certain
503 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
504 * Thus
505 * the model completely describes those aspects of the physical system that are relevant to the
506 * purpose
507 * of the model, at the appropriate level of detail. May be a UML2 model or package.
508 * @return (Collection<ActionStateFacade>)handleGetAllActionStates()
509 */
510 public final Collection<ActionStateFacade> getAllActionStates()
511 {
512 Collection<ActionStateFacade> getAllActionStates6r = null;
513 // modelFacade has no pre constraints
514 Collection result = handleGetAllActionStates();
515 List shieldedResult = this.shieldedElements(result);
516 try
517 {
518 getAllActionStates6r = (Collection<ActionStateFacade>)shieldedResult;
519 }
520 catch (ClassCastException ex)
521 {
522 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
523 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllActionStates Collection<ActionStateFacade> " + result + ": " + shieldedResult);
524 }
525 // modelFacade has no post constraints
526 return getAllActionStates6r;
527 }
528
529 /**
530 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
531 * @return Collection
532 */
533 protected abstract Collection handleGetAllActionStates();
534
535 private Collection<ObjectFlowStateFacade> __getAllObjectFlowStates7r;
536 private boolean __getAllObjectFlowStates7rSet = false;
537
538 /**
539 * Captures a view of a physical system. It is an abstraction of the physical system, with a
540 * certain
541 * purpose. This purpose determines what is to be included in the model and what is irrelevant.
542 * Thus
543 * the model completely describes those aspects of the physical system that are relevant to the
544 * purpose
545 * of the model, at the appropriate level of detail. May be a UML2 model or package.
546 * @return (Collection<ObjectFlowStateFacade>)handleGetAllObjectFlowStates()
547 */
548 public final Collection<ObjectFlowStateFacade> getAllObjectFlowStates()
549 {
550 Collection<ObjectFlowStateFacade> getAllObjectFlowStates7r = this.__getAllObjectFlowStates7r;
551 if (!this.__getAllObjectFlowStates7rSet)
552 {
553 // modelFacade has no pre constraints
554 Collection result = handleGetAllObjectFlowStates();
555 List shieldedResult = this.shieldedElements(result);
556 try
557 {
558 getAllObjectFlowStates7r = (Collection<ObjectFlowStateFacade>)shieldedResult;
559 }
560 catch (ClassCastException ex)
561 {
562 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
563 ModelFacadeLogic.logger.warn("incorrect metafacade cast for ModelFacadeLogic.getAllObjectFlowStates Collection<ObjectFlowStateFacade> " + result + ": " + shieldedResult);
564 }
565 // modelFacade has no post constraints
566 this.__getAllObjectFlowStates7r = getAllObjectFlowStates7r;
567 if (isMetafacadePropertyCachingEnabled())
568 {
569 this.__getAllObjectFlowStates7rSet = true;
570 }
571 }
572 return getAllObjectFlowStates7r;
573 }
574
575 /**
576 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
577 * @return Collection
578 */
579 protected abstract Collection handleGetAllObjectFlowStates();
580
581 /**
582 * @param validationMessages Collection<ModelValidationMessage>
583 * @see MetafacadeBase#validateInvariants(Collection validationMessages)
584 */
585 @Override
586 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
587 {
588 }
589
590 /**
591 * The property that stores the name of the metafacade.
592 */
593 private static final String NAME_PROPERTY = "name";
594 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
595
596 /**
597 * @see Object#toString()
598 */
599 @Override
600 public String toString()
601 {
602 final StringBuilder toString = new StringBuilder(this.getClass().getName());
603 toString.append("[");
604 try
605 {
606 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
607 }
608 catch (final Throwable tryAgain)
609 {
610 try
611 {
612 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
613 }
614 catch (final Throwable ignore)
615 {
616 // - just ignore when the metafacade doesn't have a name or fullyQualifiedName property
617 }
618 }
619 toString.append("]");
620 return toString.toString();
621 }
622 }