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 org.andromda.core.metafacade.MetafacadeBase;
009import org.andromda.core.metafacade.ModelValidationMessage;
010import org.andromda.metafacades.uml.StateMachineFacade;
011import org.andromda.metafacades.uml.SubactivityStateFacade;
012import org.apache.log4j.Logger;
013import org.omg.uml.behavioralelements.activitygraphs.SubactivityState;
014
015/**
016 * State machines can be used to express the behavior of part of a system. Behavior is modeled as a
017 * traversal of a graph of state nodes interconnected by one or more joined transition arcs that are
018 * triggered by the dispatching of series of (event) occurrences. During this traversal, the state
019 * machine executes a series of activities associated with various elements of the state machine.
020 * Not implmented for UML2.
021 * MetafacadeLogic for SubactivityStateFacade
022 *
023 * @see SubactivityStateFacade
024 */
025public abstract class SubactivityStateFacadeLogic
026    extends StateFacadeLogicImpl
027    implements SubactivityStateFacade
028{
029    /**
030     * The underlying UML object
031     * @see SubactivityState
032     */
033    protected SubactivityState metaObject;
034
035    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
036     * @param metaObjectIn
037     * @param context
038     */
039    protected SubactivityStateFacadeLogic(SubactivityState metaObjectIn, String context)
040    {
041        super(metaObjectIn, getContext(context));
042        this.metaObject = metaObjectIn;
043    }
044
045    /**
046     * The logger instance.
047     */
048    private static final Logger logger = Logger.getLogger(SubactivityStateFacadeLogic.class);
049
050    /**
051     * Gets the context for this metafacade logic instance.
052     * @param context String. Set to SubactivityStateFacade if null
053     * @return context String
054     */
055    private static String getContext(String context)
056    {
057        if (context == null)
058        {
059            context = "org.andromda.metafacades.uml.SubactivityStateFacade";
060        }
061        return context;
062    }
063
064    /** Reset context only for non-root metafacades
065     * @param context
066     */
067    @Override
068    public void resetMetafacadeContext(String context)
069    {
070        if (!this.contextRoot) // reset context only for non-root metafacades
071        {
072            context = getContext(context);  // to have same value as in original constructor call
073            setMetafacadeContext (context);
074        }
075    }
076
077    /**
078     * @return boolean true always
079     * @see SubactivityStateFacade
080     */
081    public boolean isSubactivityStateFacadeMetaType()
082    {
083        return true;
084    }
085
086    // --------------- attributes ---------------------
087
088   /**
089    * @see SubactivityStateFacade#isDynamic()
090    * @return boolean
091    */
092    protected abstract boolean handleIsDynamic();
093
094    private boolean __dynamic1a;
095    private boolean __dynamic1aSet = false;
096
097    /**
098     * TODO: Model Documentation for SubactivityStateFacade.dynamic
099     * @return (boolean)handleIsDynamic()
100     */
101    public final boolean isDynamic()
102    {
103        boolean dynamic1a = this.__dynamic1a;
104        if (!this.__dynamic1aSet)
105        {
106            // dynamic has no pre constraints
107            dynamic1a = handleIsDynamic();
108            // dynamic has no post constraints
109            this.__dynamic1a = dynamic1a;
110            if (isMetafacadePropertyCachingEnabled())
111            {
112                this.__dynamic1aSet = true;
113            }
114        }
115        return dynamic1a;
116    }
117
118    // ------------- associations ------------------
119
120    /**
121     * State machines can be used to express the behavior of part of a system. Behavior is modeled
122     * as a
123     * traversal of a graph of state nodes interconnected by one or more joined transition arcs that
124     * are
125     * triggered by the dispatching of series of (event) occurrences. During this traversal, the
126     * state
127     * machine executes a series of activities associated with various elements of the state
128     * machine. Not
129     * implmented for UML2.
130     * @return (StateMachineFacade)handleGetSubmachine()
131     */
132    public final StateMachineFacade getSubmachine()
133    {
134        StateMachineFacade getSubmachine1r = null;
135        // subactivityStateFacade has no pre constraints
136        Object result = handleGetSubmachine();
137        MetafacadeBase shieldedResult = this.shieldedElement(result);
138        try
139        {
140            getSubmachine1r = (StateMachineFacade)shieldedResult;
141        }
142        catch (ClassCastException ex)
143        {
144            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
145            SubactivityStateFacadeLogic.logger.warn("incorrect metafacade cast for SubactivityStateFacadeLogic.getSubmachine StateMachineFacade " + result + ": " + shieldedResult);
146        }
147        // subactivityStateFacade has no post constraints
148        return getSubmachine1r;
149    }
150
151    /**
152     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
153     * @return Object
154     */
155    protected abstract Object handleGetSubmachine();
156
157    /**
158     * @param validationMessages Collection<ModelValidationMessage>
159     * @see StateFacadeLogicImpl#validateInvariants(Collection validationMessages)
160     */
161    @Override
162    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
163    {
164        super.validateInvariants(validationMessages);
165    }
166}