001// license-header java merge-point
002//
003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
004//
005package org.andromda.metafacades.uml14;
006
007import java.util.Collection;
008import java.util.List;
009import org.andromda.core.common.Introspector;
010import org.andromda.core.metafacade.MetafacadeBase;
011import org.andromda.core.metafacade.ModelValidationMessage;
012import org.andromda.metafacades.uml.ActionStateFacade;
013import org.andromda.metafacades.uml.ActivityGraphFacade;
014import org.andromda.metafacades.uml.ActorFacade;
015import org.andromda.metafacades.uml.ClassifierFacade;
016import org.andromda.metafacades.uml.FinalStateFacade;
017import org.andromda.metafacades.uml.ModelFacade;
018import org.andromda.metafacades.uml.ObjectFlowStateFacade;
019import org.andromda.metafacades.uml.PackageFacade;
020import org.andromda.metafacades.uml.TransitionFacade;
021import org.andromda.metafacades.uml.UseCaseFacade;
022import org.apache.log4j.Logger;
023import org.omg.uml.UmlPackage;
024
025/**
026 * Captures a view of a physical system. It is an abstraction of the physical system, with a certain
027 * purpose. This purpose determines what is to be included in the model and what is irrelevant. Thus
028 * the model completely describes those aspects of the physical system that are relevant to the
029 * purpose of the model, at the appropriate level of detail. May be a UML2 model or package.
030 * MetafacadeLogic for ModelFacade
031 *
032 * @see ModelFacade
033 */
034public abstract class ModelFacadeLogic
035    extends MetafacadeBase
036    implements ModelFacade
037{
038    /**
039     * The underlying UML object
040     * @see UmlPackage
041     */
042    protected UmlPackage metaObject;
043
044    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
045     * @param metaObjectIn
046     * @param context
047     */
048    protected ModelFacadeLogic(UmlPackage metaObjectIn, String context)
049    {
050        super(metaObjectIn, getContext(context));
051        this.metaObject = metaObjectIn;
052    }
053
054    /**
055     * The logger instance.
056     */
057    private static final Logger logger = Logger.getLogger(ModelFacadeLogic.class);
058
059    /**
060     * Gets the context for this metafacade logic instance.
061     * @param context String. Set to ModelFacade if null
062     * @return context String
063     */
064    private static String getContext(String context)
065    {
066        if (context == null)
067        {
068            context = "org.andromda.metafacades.uml.ModelFacade";
069        }
070        return context;
071    }
072
073    /** Reset context only for non-root metafacades
074     * @param context
075     */
076    @Override
077    public void resetMetafacadeContext(String context)
078    {
079        if (!this.contextRoot) // reset context only for non-root metafacades
080        {
081            context = getContext(context);  // to have same value as in original constructor call
082            setMetafacadeContext (context);
083        }
084    }
085
086    /**
087     * @return boolean true always
088     * @see ModelFacade
089     */
090    public boolean isModelFacadeMetaType()
091    {
092        return true;
093    }
094
095    // ---------------- business methods ----------------------
096
097    /**
098     * Method to be implemented in descendants
099     * 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}