1 package org.andromda.metafacades.emf.uml22;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Iterator;
6 import java.util.LinkedHashMap;
7 import java.util.List;
8 import java.util.Map;
9 import org.andromda.metafacades.uml.FrontEndActivityGraph;
10 import org.andromda.metafacades.uml.FrontEndForward;
11 import org.andromda.metafacades.uml.FrontEndParameter;
12 import org.andromda.metafacades.uml.FrontEndUseCase;
13 import org.andromda.metafacades.uml.TransitionFacade;
14 import org.andromda.metafacades.uml.UMLProfile;
15 import org.andromda.metafacades.uml.UseCaseFacade;
16 import org.apache.commons.lang.StringUtils;
17
18
19
20
21
22
23
24
25 public class FrontEndFinalStateLogicImpl
26 extends FrontEndFinalStateLogic
27 {
28 private static final long serialVersionUID = 8189139931299534798L;
29
30
31
32
33
34 public FrontEndFinalStateLogicImpl(
35 final Object metaObject,
36 final String context)
37 {
38 super(metaObject, context);
39 }
40
41
42
43
44 @Override
45 protected boolean handleIsContainedInFrontEndUseCase()
46 {
47 return this.getStateMachine() instanceof FrontEndActivityGraph;
48 }
49
50
51
52
53 @Override
54 public String handleGetName()
55 {
56 String name = super.handleGetName();
57 if (name == null)
58 {
59 final FrontEndUseCase useCase = this.getTargetUseCase();
60 if (useCase != null)
61 {
62 name = useCase.getName();
63 }
64 }
65 return name;
66 }
67
68
69
70
71 @Override
72 protected Object handleGetTargetUseCase()
73 {
74 Object targetUseCase = null;
75
76
77
78 final Object taggedValue = this.findTaggedValue(UMLProfile.TAGGEDVALUE_MODEL_HYPERLINK);
79 if (taggedValue != null)
80 {
81 if (taggedValue instanceof FrontEndActivityGraph)
82 {
83 targetUseCase = ((FrontEndActivityGraph)taggedValue).getUseCase();
84 }
85 else if (taggedValue instanceof FrontEndUseCase)
86 {
87 targetUseCase = taggedValue;
88 }
89 }
90
91
92 if (targetUseCase == null)
93 {
94 final String name = super.handleGetName();
95 if (StringUtils.isNotBlank(name))
96 {
97 final UseCaseFacade useCase = this.getModel().findUseCaseByName(name);
98 if (useCase instanceof FrontEndUseCase)
99 {
100 targetUseCase = useCase;
101 }
102 }
103 }
104 return targetUseCase;
105 }
106
107
108
109
110 @Override
111 protected List<FrontEndParameter> handleGetInterUseCaseParameters()
112 {
113
114 final Map<String, FrontEndParameter> parameterMap = new LinkedHashMap<String, FrontEndParameter>();
115
116 final Collection<TransitionFacade> transitions = this.getIncomings();
117 for (final Iterator<TransitionFacade> transitionIterator = transitions.iterator(); transitionIterator.hasNext();)
118 {
119 final FrontEndForward forward = (FrontEndForward)transitionIterator.next();
120 final List<FrontEndParameter> forwardParameters = forward.getForwardParameters();
121 for (int i = 0; i < forwardParameters.size(); i++)
122 {
123 final FrontEndParameter parameter = forwardParameters.get(i);
124 parameterMap.put(
125 parameter.getName(),
126 parameter);
127 }
128 }
129
130 return new ArrayList<FrontEndParameter>(parameterMap.values());
131 }
132 }