01: package org.andromda.metafacades.emf.uml2;
02:
03: import java.util.ArrayList;
04: import java.util.Collection;
05: import java.util.Iterator;
06: import java.util.LinkedHashSet;
07: import java.util.List;
08:
09: import org.andromda.metafacades.uml.ActivityGraphFacade;
10: import org.andromda.metafacades.uml.FrontEndAction;
11: import org.andromda.metafacades.uml.FrontEndActivityGraph;
12: import org.andromda.metafacades.uml.FrontEndUseCase;
13: import org.andromda.metafacades.uml.StateMachineFacade;
14: import org.andromda.metafacades.uml.TransitionFacade;
15: import org.andromda.metafacades.uml.UseCaseFacade;
16:
17: /**
18: * MetafacadeLogic implementation for
19: * org.andromda.metafacades.uml.FrontEndPseudostate.
20: *
21: * @see org.andromda.metafacades.uml.FrontEndPseudostate
22: */
23: public class FrontEndPseudostateLogicImpl extends
24: FrontEndPseudostateLogic {
25: public FrontEndPseudostateLogicImpl(final Object metaObject,
26: final String context) {
27: super (metaObject, context);
28: }
29:
30: /**
31: * @see org.andromda.metafacades.uml.FrontEndPseudostate#isContainedInFrontEndUseCase()
32: */
33: protected boolean handleIsContainedInFrontEndUseCase() {
34: return this .getStateMachine() instanceof FrontEndActivityGraph;
35: }
36:
37: /**
38: * @see org.andromda.metafacades.uml.FrontEndPseudostate#getContainerActions()
39: */
40: protected List handleGetContainerActions() {
41: final Collection actionSet = new LinkedHashSet();
42: final StateMachineFacade graphContext = this .getStateMachine();
43:
44: if (graphContext instanceof ActivityGraphFacade) {
45: final UseCaseFacade useCase = ((ActivityGraphFacade) graphContext)
46: .getUseCase();
47:
48: if (useCase instanceof FrontEndUseCase) {
49: for (final Iterator actionIterator = ((FrontEndUseCase) useCase)
50: .getActions().iterator(); actionIterator
51: .hasNext();) {
52: final FrontEndAction action = (FrontEndAction) actionIterator
53: .next();
54: final Collection transitions = action
55: .getTransitions();
56: for (final Iterator transitionIterator = transitions
57: .iterator(); transitionIterator.hasNext();) {
58: TransitionFacade transition = (TransitionFacade) transitionIterator
59: .next();
60: if (this .equals(transition.getTarget())) {
61: actionSet.add(action);
62: }
63: }
64: }
65: }
66: }
67: return new ArrayList(actionSet);
68: }
69: }
|