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.ActionFacade;
011import org.andromda.metafacades.uml.ActionStateFacade;
012import org.andromda.metafacades.uml.TransitionFacade;
013import org.apache.log4j.Logger;
014import org.omg.uml.behavioralelements.commonbehavior.Action;
015
016/**
017 * An action is a named element that is the fundamental unit of executable functionality. The
018 * execution of an action represents some transformation or processing in the modeled system, be it
019 * a computer system or otherwise. An action represents a single step within an activity, that is,
020 * one that is not further decomposed within the activity. An action has pre- and post-conditions.
021 * MetafacadeLogic for ActionFacade
022 *
023 * @see ActionFacade
024 */
025public abstract class ActionFacadeLogic
026    extends ModelElementFacadeLogicImpl
027    implements ActionFacade
028{
029    /**
030     * The underlying UML object
031     * @see Action
032     */
033    protected Action metaObject;
034
035    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
036     * @param metaObjectIn
037     * @param context
038     */
039    protected ActionFacadeLogic(Action 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(ActionFacadeLogic.class);
049
050    /**
051     * Gets the context for this metafacade logic instance.
052     * @param context String. Set to ActionFacade 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.ActionFacade";
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 ActionFacade
080     */
081    public boolean isActionFacadeMetaType()
082    {
083        return true;
084    }
085
086    // ------------- associations ------------------
087
088    private ActionStateFacade __getActionState1r;
089    private boolean __getActionState1rSet = false;
090
091    /**
092     * The entry action for this action state (if any).
093     * @return (ActionStateFacade)handleGetActionState()
094     */
095    public final ActionStateFacade getActionState()
096    {
097        ActionStateFacade getActionState1r = this.__getActionState1r;
098        if (!this.__getActionState1rSet)
099        {
100            // entry has no pre constraints
101            Object result = handleGetActionState();
102            MetafacadeBase shieldedResult = this.shieldedElement(result);
103            try
104            {
105                getActionState1r = (ActionStateFacade)shieldedResult;
106            }
107            catch (ClassCastException ex)
108            {
109                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
110                ActionFacadeLogic.logger.warn("incorrect metafacade cast for ActionFacadeLogic.getActionState ActionStateFacade " + result + ": " + shieldedResult);
111            }
112            // entry has no post constraints
113            this.__getActionState1r = getActionState1r;
114            if (isMetafacadePropertyCachingEnabled())
115            {
116                this.__getActionState1rSet = true;
117            }
118        }
119        return getActionState1r;
120    }
121
122    /**
123     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
124     * @return Object
125     */
126    protected abstract Object handleGetActionState();
127
128    /**
129     * An action is a named element that is the fundamental unit of executable functionality. The
130     * execution
131     * of an action represents some transformation or processing in the modeled system, be it a
132     * computer
133     * system or otherwise. An action represents a single step within an activity, that is, one that
134     * is not
135     * further decomposed within the activity. An action has pre- and post-conditions.
136     * @return (TransitionFacade)handleGetTransition()
137     */
138    public final TransitionFacade getTransition()
139    {
140        TransitionFacade getTransition2r = null;
141        // effect has no pre constraints
142        Object result = handleGetTransition();
143        MetafacadeBase shieldedResult = this.shieldedElement(result);
144        try
145        {
146            getTransition2r = (TransitionFacade)shieldedResult;
147        }
148        catch (ClassCastException ex)
149        {
150            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
151            ActionFacadeLogic.logger.warn("incorrect metafacade cast for ActionFacadeLogic.getTransition TransitionFacade " + result + ": " + shieldedResult);
152        }
153        // effect has no post constraints
154        return getTransition2r;
155    }
156
157    /**
158     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
159     * @return Object
160     */
161    protected abstract Object handleGetTransition();
162
163    /**
164     * @param validationMessages Collection<ModelValidationMessage>
165     * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
166     */
167    @Override
168    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
169    {
170        super.validateInvariants(validationMessages);
171    }
172}