001package org.andromda.cartridges.jbpm.metafacades;
002
003import java.util.ArrayList;
004import java.util.List;
005import org.andromda.metafacades.uml.EventFacade;
006
007/**
008 * MetafacadeLogic implementation for org.andromda.cartridges.jbpm.metafacades.JBpmEventState.
009 *
010 * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventState
011 * @author Bob Fields
012 */
013public class JBpmEventStateLogicImpl
014    extends JBpmEventStateLogic
015{
016    private static final long serialVersionUID = 34L;
017    /**
018     * @param metaObject
019     * @param context
020     */
021    public JBpmEventStateLogicImpl(Object metaObject, String context)
022    {
023        super(metaObject, context);
024    }
025
026    /**
027     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetBeforeSignals()
028     */
029    protected List<JBpmAction> handleGetBeforeSignals()
030    {
031        final List<JBpmAction> beforeSignals = new ArrayList<JBpmAction>();
032        for (final EventFacade eventObject : this.getDeferrableEvents())
033        {
034            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isBeforeSignal())
035            {
036                beforeSignals.add((JBpmAction)eventObject);
037            }
038        }
039        return beforeSignals;
040    }
041
042    /**
043     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetAfterSignals()
044     */
045    protected List<JBpmAction> handleGetAfterSignals()
046    {
047        final List<JBpmAction> afterSignals = new ArrayList<JBpmAction>();
048        for (final EventFacade eventObject : this.getDeferrableEvents())
049        {
050            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isAfterSignal())
051            {
052                afterSignals.add((JBpmAction)eventObject);
053            }
054        }
055        return afterSignals;
056    }
057
058    /**
059     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetNodeEnters()
060     */
061    protected List<JBpmAction> handleGetNodeEnters()
062    {
063        final List<JBpmAction> nodeEnters = new ArrayList<JBpmAction>();
064        for (final EventFacade eventObject : this.getDeferrableEvents())
065        {
066            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isNodeEnter())
067            {
068                nodeEnters.add((JBpmAction)eventObject);
069            }
070        }
071        return nodeEnters;
072    }
073
074    /**
075     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetNodeLeaves()
076     */
077    protected List<JBpmAction> handleGetNodeLeaves()
078    {
079        final List<JBpmAction> nodeLeaves = new ArrayList<JBpmAction>();
080        for (final EventFacade eventObject : this.getDeferrableEvents())
081        {
082            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isNodeLeave())
083            {
084                nodeLeaves.add((JBpmAction)eventObject);
085            }
086        }
087        return nodeLeaves;
088    }
089
090    /**
091     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetTasks()
092     */
093    protected List<JBpmAction> handleGetTasks()
094    {
095        final List<JBpmAction> tasks = new ArrayList<JBpmAction>();
096        for (final EventFacade eventObject : this.getDeferrableEvents())
097        {
098            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isTask())
099            {
100                tasks.add((JBpmAction)eventObject);
101            }
102        }
103        return tasks;
104    }
105
106    /**
107     * @see org.andromda.cartridges.jbpm.metafacades.JBpmEventStateLogic#handleGetTimers()
108     */
109    protected List<JBpmAction> handleGetTimers()
110    {
111        final List<JBpmAction> timers = new ArrayList<JBpmAction>();
112        for (final EventFacade eventObject : this.getDeferrableEvents())
113        {
114            if (eventObject instanceof JBpmAction && ((JBpmAction)eventObject).isTimer())
115            {
116                timers.add((JBpmAction)eventObject);
117            }
118        }
119        return timers;
120    }
121}