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.CallEventFacade;
012import org.andromda.metafacades.uml.OperationFacade;
013import org.apache.log4j.Logger;
014import org.omg.uml.behavioralelements.statemachines.CallEvent;
015
016/**
017 * A representation of the model object 'Activity'. The specification of parameterized behavior as
018 * the coordinated sequencing of subordinate units whose individual elements are actions.
019 * MetafacadeLogic for CallEventFacade
020 *
021 * @see CallEventFacade
022 */
023public abstract class CallEventFacadeLogic
024    extends EventFacadeLogicImpl
025    implements CallEventFacade
026{
027    /**
028     * The underlying UML object
029     * @see CallEvent
030     */
031    protected CallEvent metaObject;
032
033    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
034     * @param metaObjectIn
035     * @param context
036     */
037    protected CallEventFacadeLogic(CallEvent metaObjectIn, String context)
038    {
039        super(metaObjectIn, getContext(context));
040        this.metaObject = metaObjectIn;
041    }
042
043    /**
044     * The logger instance.
045     */
046    private static final Logger logger = Logger.getLogger(CallEventFacadeLogic.class);
047
048    /**
049     * Gets the context for this metafacade logic instance.
050     * @param context String. Set to CallEventFacade if null
051     * @return context String
052     */
053    private static String getContext(String context)
054    {
055        if (context == null)
056        {
057            context = "org.andromda.metafacades.uml.CallEventFacade";
058        }
059        return context;
060    }
061
062    /** Reset context only for non-root metafacades
063     * @param context
064     */
065    @Override
066    public void resetMetafacadeContext(String context)
067    {
068        if (!this.contextRoot) // reset context only for non-root metafacades
069        {
070            context = getContext(context);  // to have same value as in original constructor call
071            setMetafacadeContext (context);
072        }
073    }
074
075    /**
076     * @return boolean true always
077     * @see CallEventFacade
078     */
079    public boolean isCallEventFacadeMetaType()
080    {
081        return true;
082    }
083
084    // ------------- associations ------------------
085
086    /**
087     * A representation of the model object 'Activity'. The specification of parameterized behavior
088     * as the
089     * coordinated sequencing of subordinate units whose individual elements are actions.
090     * @return (OperationFacade)handleGetOperation()
091     */
092    public final OperationFacade getOperation()
093    {
094        OperationFacade getOperation1r = null;
095        // callEventFacade has no pre constraints
096        Object result = handleGetOperation();
097        MetafacadeBase shieldedResult = this.shieldedElement(result);
098        try
099        {
100            getOperation1r = (OperationFacade)shieldedResult;
101        }
102        catch (ClassCastException ex)
103        {
104            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
105            CallEventFacadeLogic.logger.warn("incorrect metafacade cast for CallEventFacadeLogic.getOperation OperationFacade " + result + ": " + shieldedResult);
106        }
107        // callEventFacade has no post constraints
108        return getOperation1r;
109    }
110
111    /**
112     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
113     * @return Object
114     */
115    protected abstract Object handleGetOperation();
116
117    /**
118     * A representation of the model object 'Activity'. The specification of parameterized behavior
119     * as the
120     * coordinated sequencing of subordinate units whose individual elements are actions.
121     * @return (Collection<OperationFacade>)handleGetOperations()
122     */
123    public final Collection<OperationFacade> getOperations()
124    {
125        Collection<OperationFacade> getOperations2r = null;
126        // callEventFacade has no pre constraints
127        Collection result = handleGetOperations();
128        List shieldedResult = this.shieldedElements(result);
129        try
130        {
131            getOperations2r = (Collection<OperationFacade>)shieldedResult;
132        }
133        catch (ClassCastException ex)
134        {
135            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
136            CallEventFacadeLogic.logger.warn("incorrect metafacade cast for CallEventFacadeLogic.getOperations Collection<OperationFacade> " + result + ": " + shieldedResult);
137        }
138        // callEventFacade has no post constraints
139        return getOperations2r;
140    }
141
142    /**
143     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
144     * @return  Collection
145     */
146    protected abstract Collection handleGetOperations();
147
148    /**
149     * @param validationMessages Collection<ModelValidationMessage>
150     * @see EventFacadeLogicImpl#validateInvariants(Collection validationMessages)
151     */
152    @Override
153    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
154    {
155        super.validateInvariants(validationMessages);
156    }
157}