01: package org.andromda.metafacades.emf.uml2;
02:
03: import java.util.Collection;
04: import java.util.Iterator;
05:
06: import org.andromda.metafacades.uml.FrontEndUseCase;
07: import org.andromda.metafacades.uml.PseudostateFacade;
08: import org.andromda.metafacades.uml.UMLProfile;
09: import org.eclipse.uml2.Class;
10: import org.eclipse.uml2.StateMachine;
11:
12: /**
13: * MetafacadeLogic implementation for
14: * org.andromda.metafacades.uml.FrontEndActivityGraph.
15: *
16: * @see org.andromda.metafacades.uml.FrontEndActivityGraph
17: */
18: public class FrontEndActivityGraphLogicImpl extends
19: FrontEndActivityGraphLogic {
20: /**
21: * @param metaObject
22: * @param context
23: */
24: public FrontEndActivityGraphLogicImpl(final Object metaObject,
25: final String context) {
26: super (metaObject, context);
27: }
28:
29: /**
30: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#isContainedInFrontEndUseCase()
31: */
32: protected boolean handleIsContainedInFrontEndUseCase() {
33: return this .getUseCase() instanceof FrontEndUseCase;
34: }
35:
36: /**
37: * Retrieves the usecase that owns this activity.
38: *
39: * @see org.andromda.metafacades.emf.uml2.ActivityGraphFacadeLogic#handleGetUseCase()
40: */
41: protected Object handleGetUseCase() {
42: Object useCase = super .handleGetUseCase();
43: if (useCase == null) {
44: useCase = this
45: .getModel()
46: .findUseCaseWithTaggedValueOrHyperlink(
47: UMLProfile.TAGGEDVALUE_PRESENTATION_USECASE_ACTIVITY,
48: this .getName());
49: }
50: return useCase;
51: }
52:
53: /**
54: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#getInitialAction()
55: */
56: protected Object handleGetInitialAction() {
57: Object firstAction = null;
58: final Collection initialStates = this .getInitialStates();
59: if (!initialStates.isEmpty()) {
60: final PseudostateFacade initialState = (PseudostateFacade) initialStates
61: .iterator().next();
62: final Collection outgoing = initialState.getOutgoing();
63: firstAction = outgoing.isEmpty() ? null : outgoing
64: .iterator().next();
65: }
66: return firstAction;
67: }
68:
69: /**
70: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#getController()
71: */
72: protected java.lang.Object handleGetController() {
73: // Take the frist class inside the FSM
74: Class controller = null;
75: for (Iterator it = ((StateMachine) this .metaObject)
76: .getOwnedMembers().iterator(); it.hasNext()
77: && controller == null;) {
78: Object next = it.next();
79: if (next instanceof Class) {
80: controller = (Class) next;
81: }
82: }
83: return controller;
84: }
85: }
|