01: package org.andromda.metafacades.uml14;
02:
03: import java.util.Collection;
04:
05: import org.andromda.metafacades.uml.FrontEndController;
06: import org.andromda.metafacades.uml.FrontEndUseCase;
07: import org.andromda.metafacades.uml.ModelElementFacade;
08: import org.andromda.metafacades.uml.PseudostateFacade;
09: import org.andromda.metafacades.uml.UMLProfile;
10: import org.andromda.metafacades.uml.UseCaseFacade;
11:
12: /**
13: * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndActivityGraph.
14: *
15: * @see org.andromda.metafacades.uml.FrontEndActivityGraph
16: */
17: public class FrontEndActivityGraphLogicImpl extends
18: FrontEndActivityGraphLogic {
19:
20: public FrontEndActivityGraphLogicImpl(Object metaObject,
21: String context) {
22: super (metaObject, context);
23: }
24:
25: /**
26: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#isContainedInFrontEndUseCase()
27: */
28: protected boolean handleIsContainedInFrontEndUseCase() {
29: return this .getUseCase() instanceof FrontEndUseCase;
30: }
31:
32: /**
33: * Retrieves the usecase that owns this activity.
34: *
35: * @see org.andromda.metafacades.uml14.ActivityGraphFacadeLogic#handleGetUseCase()
36: */
37: protected Object handleGetUseCase() {
38: Object useCase = super .handleGetUseCase();
39: if (useCase == null) {
40: useCase = getModel()
41: .findUseCaseWithTaggedValueOrHyperlink(
42: UMLProfile.TAGGEDVALUE_PRESENTATION_USECASE_ACTIVITY,
43: getName());
44: }
45: return useCase;
46: }
47:
48: /**
49: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#getInitialAction()
50: */
51: protected Object handleGetInitialAction() {
52: Object firstAction = null;
53: final Collection initialStates = getInitialStates();
54: if (!initialStates.isEmpty()) {
55: final PseudostateFacade initialState = (PseudostateFacade) initialStates
56: .iterator().next();
57: final Collection outgoing = initialState.getOutgoing();
58: firstAction = outgoing.isEmpty() ? null : outgoing
59: .iterator().next();
60: }
61: return firstAction;
62: }
63:
64: /**
65: * @see org.andromda.metafacades.uml.FrontEndActivityGraph#getController()
66: */
67: protected java.lang.Object handleGetController() {
68: Object controller = null;
69:
70: final ModelElementFacade contextElement = this
71: .getContextElement();
72: if (contextElement instanceof FrontEndController) {
73: controller = contextElement;
74: }
75:
76: // - for those tools not supporting setting the context of an activity graph (such as Poseidon)
77: // an alternative is implemented: a tagged value on the controller, specifying the name of the use-case
78: //
79: // It is also allowed to set a hyperlink from the controller to the usecase
80: if (controller == null) {
81: final UseCaseFacade useCase = this .getUseCase();
82: if (useCase != null) {
83: final String useCaseName = useCase.getName();
84: controller = this
85: .getModel()
86: .findClassWithTaggedValueOrHyperlink(
87: UMLProfile.TAGGEDVALUE_PRESENTATION_CONTROLLER_USECASE,
88: useCaseName);
89: }
90: }
91: return controller;
92: }
93:
94: }
|