1 package org.andromda.metafacades.uml14;
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.ActivityGraphFacade;
10 import org.andromda.metafacades.uml.EventFacade;
11 import org.andromda.metafacades.uml.FrontEndAction;
12 import org.andromda.metafacades.uml.FrontEndParameter;
13 import org.andromda.metafacades.uml.FrontEndUseCase;
14 import org.andromda.metafacades.uml.ModelElementFacade;
15 import org.andromda.metafacades.uml.StateMachineFacade;
16 import org.andromda.metafacades.uml.TransitionFacade;
17 import org.andromda.metafacades.uml.UMLProfile;
18 import org.andromda.metafacades.uml.UseCaseFacade;
19
20
21
22
23
24
25
26 public class FrontEndViewLogicImpl
27 extends FrontEndViewLogic
28 {
29 private static final long serialVersionUID = 3878476296052353951L;
30
31
32
33
34
35 public FrontEndViewLogicImpl(
36 Object metaObject,
37 String context)
38 {
39 super(metaObject, context);
40 }
41
42
43
44
45 @Override
46 protected boolean handleIsFrontEndView()
47 {
48 return this.hasStereotype(UMLProfile.STEREOTYPE_FRONT_END_VIEW);
49 }
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 @Override
75 protected FrontEndUseCase handleGetUseCase()
76 {
77 UseCaseFacade useCase = null;
78 final StateMachineFacade graphContext = this.getStateMachine();
79 if (graphContext instanceof ActivityGraphFacade)
80 {
81 useCase = ((ActivityGraphFacade)graphContext).getUseCase();
82 if (!(useCase instanceof FrontEndUseCase))
83 {
84 useCase = null;
85 }
86 }
87 return (FrontEndUseCase)useCase;
88 }
89
90
91
92
93
94
95 @Override
96 public String handleGetPackageName()
97 {
98 String packageName = null;
99 final StateMachineFacade graphContext = this.getStateMachine();
100 if (graphContext instanceof ActivityGraphFacade)
101 {
102 final UseCaseFacade graphUseCase = ((ActivityGraphFacade)graphContext).getUseCase();
103 if (graphUseCase instanceof FrontEndUseCase)
104 {
105 final FrontEndUseCase useCase = (FrontEndUseCase)graphUseCase;
106 packageName = useCase.getPackageName();
107 }
108 }
109 return packageName;
110 }
111
112
113
114
115 @Override
116 protected List<ModelElementFacade> handleGetVariables()
117 {
118 final Map<String, ModelElementFacade> variablesMap = new LinkedHashMap<String, ModelElementFacade>();
119 final Collection<TransitionFacade> incoming = getIncomings();
120 for (final Iterator iterator = incoming.iterator(); iterator.hasNext();)
121 {
122 final TransitionFacade transition = (TransitionFacade)iterator.next();
123 final EventFacade trigger = transition.getTrigger();
124 if (trigger != null)
125 {
126 for (final Iterator parameterIterator = trigger.getParameters().iterator(); parameterIterator.hasNext();)
127 {
128 final ModelElementFacade modelElement = (ModelElementFacade)parameterIterator.next();
129 variablesMap.put(modelElement.getName(), modelElement);
130 }
131 }
132 }
133 return new ArrayList<ModelElementFacade>(variablesMap.values());
134 }
135
136
137
138
139 @Override
140 protected List<FrontEndParameter> handleGetAllActionParameters()
141 {
142 final List<FrontEndParameter> actionParameters = new ArrayList();
143 final Collection<FrontEndAction> actions = this.getActions();
144 for (final Iterator<FrontEndAction> iterator = actions.iterator(); iterator.hasNext();)
145 {
146 final FrontEndAction action = iterator.next();
147 actionParameters.addAll(action.getParameters());
148 }
149 return actionParameters;
150 }
151
152
153
154
155 @Override
156 protected List<FrontEndParameter> handleGetAllFormFields()
157 {
158 final List<FrontEndParameter> actionParameters = new ArrayList<FrontEndParameter>();
159 final Collection<FrontEndAction> actions = getActions();
160 for (final Iterator<FrontEndAction> iterator = actions.iterator(); iterator.hasNext();)
161 {
162 final FrontEndAction action = iterator.next();
163 actionParameters.addAll(action.getParameters());
164 }
165 return actionParameters;
166 }
167
168
169
170
171 @Override
172 protected List<FrontEndParameter> handleGetTables()
173 {
174 final List<FrontEndParameter> variables = new ArrayList<FrontEndParameter>(this.getVariables());
175 for (final Iterator<FrontEndParameter> iterator = variables.iterator(); iterator.hasNext();)
176 {
177 final FrontEndParameter parameter = iterator.next();
178 if (!parameter.isTable())
179 {
180 iterator.remove();
181 }
182 }
183 return variables;
184 }
185
186
187
188
189
190 @Override
191 protected List<FrontEndAction> handleGetActions()
192 {
193 final List<FrontEndAction> actions = new ArrayList<FrontEndAction>();
194 final Collection<TransitionFacade> outgoings = getOutgoings();
195 for (final Iterator<TransitionFacade> iterator = outgoings.iterator(); iterator.hasNext();)
196 {
197 final TransitionFacade object = iterator.next();
198 if (object instanceof FrontEndAction)
199 {
200 actions.add((FrontEndAction)object);
201 }
202 }
203
204
205
206
207
208
209
210
211
212
213 return actions;
214 }
215 }