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.metafacade.MetafacadeBase;
010import org.andromda.core.metafacade.ModelValidationMessage;
011import org.andromda.metafacades.uml.ActionStateFacade;
012import org.andromda.metafacades.uml.ActivityGraphFacade;
013import org.andromda.metafacades.uml.ObjectFlowStateFacade;
014import org.andromda.metafacades.uml.PartitionFacade;
015import org.andromda.metafacades.uml.UseCaseFacade;
016import org.apache.log4j.Logger;
017import org.omg.uml.behavioralelements.activitygraphs.ActivityGraph;
018
019/**
020 * State machines can be used to express the behavior of part of a system. Behavior is modeled as a
021 * traversal of a graph of state nodes interconnected by one or more joined transition arcs that are
022 * triggered by the dispatching of series of (event) occurrences. During this traversal, the state
023 * machine executes a series of activities associated with various elements of the state machine.
024 * MetafacadeLogic for ActivityGraphFacade
025 *
026 * @see ActivityGraphFacade
027 */
028public abstract class ActivityGraphFacadeLogic
029    extends StateMachineFacadeLogicImpl
030    implements ActivityGraphFacade
031{
032    /**
033     * The underlying UML object
034     * @see ActivityGraph
035     */
036    protected ActivityGraph metaObject;
037
038    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
039     * @param metaObjectIn
040     * @param context
041     */
042    protected ActivityGraphFacadeLogic(ActivityGraph metaObjectIn, String context)
043    {
044        super(metaObjectIn, getContext(context));
045        this.metaObject = metaObjectIn;
046    }
047
048    /**
049     * The logger instance.
050     */
051    private static final Logger logger = Logger.getLogger(ActivityGraphFacadeLogic.class);
052
053    /**
054     * Gets the context for this metafacade logic instance.
055     * @param context String. Set to ActivityGraphFacade if null
056     * @return context String
057     */
058    private static String getContext(String context)
059    {
060        if (context == null)
061        {
062            context = "org.andromda.metafacades.uml.ActivityGraphFacade";
063        }
064        return context;
065    }
066
067    /** Reset context only for non-root metafacades
068     * @param context
069     */
070    @Override
071    public void resetMetafacadeContext(String context)
072    {
073        if (!this.contextRoot) // reset context only for non-root metafacades
074        {
075            context = getContext(context);  // to have same value as in original constructor call
076            setMetafacadeContext (context);
077        }
078    }
079
080    /**
081     * @return boolean true always
082     * @see ActivityGraphFacade
083     */
084    public boolean isActivityGraphFacadeMetaType()
085    {
086        return true;
087    }
088
089    // ------------- associations ------------------
090
091    /**
092     * State machines can be used to express the behavior of part of a system. Behavior is modeled
093     * as a
094     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
095     * are
096     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
097     * state
098     * machine executes a series of activities associated with various elements of the state
099     * machine.
100     * @return (Collection<ObjectFlowStateFacade>)handleGetObjectFlowStates()
101     */
102    public final Collection<ObjectFlowStateFacade> getObjectFlowStates()
103    {
104        Collection<ObjectFlowStateFacade> getObjectFlowStates1r = null;
105        // activityGraphFacade has no pre constraints
106        Collection result = handleGetObjectFlowStates();
107        List shieldedResult = this.shieldedElements(result);
108        try
109        {
110            getObjectFlowStates1r = (Collection<ObjectFlowStateFacade>)shieldedResult;
111        }
112        catch (ClassCastException ex)
113        {
114            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
115            ActivityGraphFacadeLogic.logger.warn("incorrect metafacade cast for ActivityGraphFacadeLogic.getObjectFlowStates Collection<ObjectFlowStateFacade> " + result + ": " + shieldedResult);
116        }
117        // activityGraphFacade has no post constraints
118        return getObjectFlowStates1r;
119    }
120
121    /**
122     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
123     * @return  Collection
124     */
125    protected abstract Collection handleGetObjectFlowStates();
126
127    /**
128     * State machines can be used to express the behavior of part of a system. Behavior is modeled
129     * as a
130     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
131     * are
132     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
133     * state
134     * machine executes a series of activities associated with various elements of the state
135     * machine.
136     * @return (Collection<ActionStateFacade>)handleGetActionStates()
137     */
138    public final Collection<ActionStateFacade> getActionStates()
139    {
140        Collection<ActionStateFacade> getActionStates2r = null;
141        // activityGraphFacade has no pre constraints
142        Collection result = handleGetActionStates();
143        List shieldedResult = this.shieldedElements(result);
144        try
145        {
146            getActionStates2r = (Collection<ActionStateFacade>)shieldedResult;
147        }
148        catch (ClassCastException ex)
149        {
150            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
151            ActivityGraphFacadeLogic.logger.warn("incorrect metafacade cast for ActivityGraphFacadeLogic.getActionStates Collection<ActionStateFacade> " + result + ": " + shieldedResult);
152        }
153        // activityGraphFacade has no post constraints
154        return getActionStates2r;
155    }
156
157    /**
158     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
159     * @return  Collection
160     */
161    protected abstract Collection handleGetActionStates();
162
163    /**
164     * State machines can be used to express the behavior of part of a system. Behavior is modeled
165     * as a
166     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
167     * are
168     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
169     * state
170     * machine executes a series of activities associated with various elements of the state
171     * machine.
172     * @return (Collection<PartitionFacade>)handleGetPartitions()
173     */
174    public final Collection<PartitionFacade> getPartitions()
175    {
176        Collection<PartitionFacade> getPartitions3r = null;
177        // activityGraph has no pre constraints
178        Collection result = handleGetPartitions();
179        List shieldedResult = this.shieldedElements(result);
180        try
181        {
182            getPartitions3r = (Collection<PartitionFacade>)shieldedResult;
183        }
184        catch (ClassCastException ex)
185        {
186            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
187            ActivityGraphFacadeLogic.logger.warn("incorrect metafacade cast for ActivityGraphFacadeLogic.getPartitions Collection<PartitionFacade> " + result + ": " + shieldedResult);
188        }
189        // activityGraph has no post constraints
190        return getPartitions3r;
191    }
192
193    /**
194     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
195     * @return  Collection
196     */
197    protected abstract Collection handleGetPartitions();
198
199    /**
200     * The first activity graph directly owned by this use-case.
201     * @return (UseCaseFacade)handleGetUseCase()
202     */
203    public final UseCaseFacade getUseCase()
204    {
205        UseCaseFacade getUseCase4r = null;
206        // firstActivityGraph has no pre constraints
207        Object result = handleGetUseCase();
208        MetafacadeBase shieldedResult = this.shieldedElement(result);
209        try
210        {
211            getUseCase4r = (UseCaseFacade)shieldedResult;
212        }
213        catch (ClassCastException ex)
214        {
215            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
216            ActivityGraphFacadeLogic.logger.warn("incorrect metafacade cast for ActivityGraphFacadeLogic.getUseCase UseCaseFacade " + result + ": " + shieldedResult);
217        }
218        // firstActivityGraph has no post constraints
219        return getUseCase4r;
220    }
221
222    /**
223     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
224     * @return Object
225     */
226    protected abstract Object handleGetUseCase();
227
228    /**
229     * @param validationMessages Collection<ModelValidationMessage>
230     * @see StateMachineFacadeLogicImpl#validateInvariants(Collection validationMessages)
231     */
232    @Override
233    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
234    {
235        super.validateInvariants(validationMessages);
236    }
237}