001package org.andromda.metafacades.uml14;
002
003import java.lang.reflect.Method;
004import java.util.Collections;
005import java.util.List;
006import org.andromda.metafacades.uml.FrontEndAction;
007import org.andromda.metafacades.uml.FrontEndForward;
008import org.andromda.metafacades.uml.TransitionFacade;
009
010/**
011 * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndEvent.
012 *
013 * @see org.andromda.metafacades.uml.FrontEndEvent
014 * @author Bob Fields
015 */
016public class FrontEndEventLogicImpl
017    extends FrontEndEventLogic
018{
019    private static final long serialVersionUID = -7746762732086766084L;
020
021    /**
022     * @param metaObject
023     * @param context
024     */
025    public FrontEndEventLogicImpl (Object metaObject, String context)
026    {
027        super (metaObject, context);
028    }
029
030    /**
031     * @see org.andromda.metafacades.uml.FrontEndEvent#isContainedInFrontEndUseCase()
032     */
033    @Override
034    protected boolean handleIsContainedInFrontEndUseCase()
035    {
036        return this.getTransition() instanceof FrontEndForward;
037    }
038
039    /**
040     * @see org.andromda.metafacades.uml.FrontEndEvent#getControllerCall()
041     */
042    @Override
043    protected Object handleGetControllerCall()
044    {
045        // - hack until a solution is found to workaround the JMI multiple inheritance (through interfaces)
046        try
047        {
048            final Method method = metaObject.getClass().getMethod("getOperation", (Class[])null);
049            return method.invoke(metaObject, (Object[])null);
050        }
051        catch (Exception ex)
052        {
053            return null;
054        }
055    }
056
057    /**
058     * @see org.andromda.metafacades.uml.FrontEndEvent#getAction()
059     */
060    @Override
061    protected FrontEndAction handleGetAction()
062    {
063        FrontEndAction action = null;
064        TransitionFacade transition = getTransition();
065        if (transition instanceof FrontEndAction)
066        {
067            action = (FrontEndAction)transition;
068        }
069        return action;
070    }
071
072    /**
073     * @see org.andromda.metafacades.uml.FrontEndEvent#getControllerCalls()
074     */
075    @Override
076    protected List handleGetControllerCalls()
077    {
078        Object controllerCall = this.getControllerCall();
079        return controllerCall == null ? Collections.emptyList() : Collections.singletonList(controllerCall);
080    }
081
082}