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.ActivityGraphFacade;
012import org.andromda.metafacades.uml.PartitionFacade;
013import org.andromda.metafacades.uml.StateVertexFacade;
014import org.apache.log4j.Logger;
015import org.omg.uml.behavioralelements.activitygraphs.Partition;
016
017/**
018 * A representation of the model object 'Region'. An orthogonal part of either a composite state or
019 * a state machine. It contains states and transitions.
020 * MetafacadeLogic for PartitionFacade
021 *
022 * @see PartitionFacade
023 */
024public abstract class PartitionFacadeLogic
025    extends ModelElementFacadeLogicImpl
026    implements PartitionFacade
027{
028    /**
029     * The underlying UML object
030     * @see Partition
031     */
032    protected Partition metaObject;
033
034    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
035     * @param metaObjectIn
036     * @param context
037     */
038    protected PartitionFacadeLogic(Partition metaObjectIn, String context)
039    {
040        super(metaObjectIn, getContext(context));
041        this.metaObject = metaObjectIn;
042    }
043
044    /**
045     * The logger instance.
046     */
047    private static final Logger logger = Logger.getLogger(PartitionFacadeLogic.class);
048
049    /**
050     * Gets the context for this metafacade logic instance.
051     * @param context String. Set to PartitionFacade if null
052     * @return context String
053     */
054    private static String getContext(String context)
055    {
056        if (context == null)
057        {
058            context = "org.andromda.metafacades.uml.PartitionFacade";
059        }
060        return context;
061    }
062
063    /** Reset context only for non-root metafacades
064     * @param context
065     */
066    @Override
067    public void resetMetafacadeContext(String context)
068    {
069        if (!this.contextRoot) // reset context only for non-root metafacades
070        {
071            context = getContext(context);  // to have same value as in original constructor call
072            setMetafacadeContext (context);
073        }
074    }
075
076    /**
077     * @return boolean true always
078     * @see PartitionFacade
079     */
080    public boolean isPartitionFacadeMetaType()
081    {
082        return true;
083    }
084
085    // ------------- associations ------------------
086
087    private Collection<StateVertexFacade> __getVertices1r;
088    private boolean __getVertices1rSet = false;
089
090    /**
091     * The partition (if any) to which this vertex belongs.
092     * @return (Collection<StateVertexFacade>)handleGetVertices()
093     */
094    public final Collection<StateVertexFacade> getVertices()
095    {
096        Collection<StateVertexFacade> getVertices1r = this.__getVertices1r;
097        if (!this.__getVertices1rSet)
098        {
099            // partition has no pre constraints
100            Collection result = handleGetVertices();
101            List shieldedResult = this.shieldedElements(result);
102            try
103            {
104                getVertices1r = (Collection<StateVertexFacade>)shieldedResult;
105            }
106            catch (ClassCastException ex)
107            {
108                // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
109                PartitionFacadeLogic.logger.warn("incorrect metafacade cast for PartitionFacadeLogic.getVertices Collection<StateVertexFacade> " + result + ": " + shieldedResult);
110            }
111            // partition has no post constraints
112            this.__getVertices1r = getVertices1r;
113            if (isMetafacadePropertyCachingEnabled())
114            {
115                this.__getVertices1rSet = true;
116            }
117        }
118        return getVertices1r;
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 handleGetVertices();
126
127    /**
128     * The set of partitions contained in this activity graph. Partitions are also known as
129     * swimlanes in UML.
130     * @return (ActivityGraphFacade)handleGetActivityGraph()
131     */
132    public final ActivityGraphFacade getActivityGraph()
133    {
134        ActivityGraphFacade getActivityGraph2r = null;
135        // partitions has no pre constraints
136        Object result = handleGetActivityGraph();
137        MetafacadeBase shieldedResult = this.shieldedElement(result);
138        try
139        {
140            getActivityGraph2r = (ActivityGraphFacade)shieldedResult;
141        }
142        catch (ClassCastException ex)
143        {
144            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
145            PartitionFacadeLogic.logger.warn("incorrect metafacade cast for PartitionFacadeLogic.getActivityGraph ActivityGraphFacade " + result + ": " + shieldedResult);
146        }
147        // partitions has no post constraints
148        return getActivityGraph2r;
149    }
150
151    /**
152     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
153     * @return Object
154     */
155    protected abstract Object handleGetActivityGraph();
156
157    /**
158     * @param validationMessages Collection<ModelValidationMessage>
159     * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
160     */
161    @Override
162    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
163    {
164        super.validateInvariants(validationMessages);
165    }
166}