1 package org.andromda.cartridges.bpm4struts.metafacades;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Iterator;
6 import java.util.LinkedHashSet;
7 import java.util.List;
8 import org.andromda.metafacades.uml.DependencyFacade;
9 import org.andromda.metafacades.uml.FrontEndAction;
10 import org.andromda.metafacades.uml.ModelElementFacade;
11 import org.andromda.metafacades.uml.OperationFacade;
12 import org.andromda.metafacades.uml.ParameterFacade;
13
14
15
16
17
18
19 public class StrutsControllerLogicImpl
20 extends StrutsControllerLogic
21 {
22 private static final long serialVersionUID = 34L;
23
24
25
26
27 public StrutsControllerLogicImpl(
28 Object metaObject,
29 String context)
30 {
31 super(metaObject, context);
32 }
33
34
35
36
37
38 protected String handleGetFullPath()
39 {
40 return '/' + getPackageName().replace('.', '/') + '/' + getName();
41 }
42
43
44
45
46 public List<FrontEndAction> getDeferringActions()
47 {
48 final Collection<FrontEndAction> deferringActions = new LinkedHashSet<FrontEndAction>();
49
50 final Collection<OperationFacade> operations = getOperations();
51 for (final Iterator<OperationFacade> operationIterator = operations.iterator(); operationIterator.hasNext();)
52 {
53 final StrutsControllerOperation operation = (StrutsControllerOperation)operationIterator.next();
54 deferringActions.addAll(operation.getDeferringActions());
55 }
56 return new ArrayList<FrontEndAction>(deferringActions);
57 }
58
59
60
61
62
63 protected List<StrutsSessionObject> handleGetSessionObjects()
64 {
65 final List<StrutsSessionObject> objectsList = new ArrayList<StrutsSessionObject>();
66
67 for (final DependencyFacade dependency : this.getSourceDependencies())
68 {
69 final ModelElementFacade modelElement = dependency.getTargetElement();
70 if (modelElement instanceof StrutsSessionObject)
71 {
72 objectsList.add((StrutsSessionObject)modelElement);
73 }
74 }
75
76 return objectsList;
77 }
78
79
80
81
82
83 protected List<ParameterFacade> handleGetAllArguments()
84 {
85 final List<ParameterFacade> allArguments = new ArrayList<ParameterFacade>();
86 for (final OperationFacade operationFacade : this.getOperations())
87 {
88 for (final ParameterFacade parameterFacade : operationFacade.getArguments())
89 {
90 allArguments.add(parameterFacade);
91 }
92 }
93
94 return allArguments;
95 }
96 }