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