1 package org.andromda.cartridges.bpm4struts.metafacades;
2
3 import java.util.ArrayList;
4 import java.util.LinkedHashSet;
5 import java.util.List;
6 import java.util.Set;
7 import org.andromda.metafacades.uml.ActivityGraphFacade;
8 import org.andromda.metafacades.uml.StateMachineFacade;
9 import org.andromda.metafacades.uml.UseCaseFacade;
10 import org.andromda.utils.StringUtilsHelper;
11
12
13
14
15
16
17 public class StrutsPseudostateLogicImpl
18 extends StrutsPseudostateLogic
19 {
20 private static final long serialVersionUID = 34L;
21
22
23
24
25 public StrutsPseudostateLogicImpl(
26 Object metaObject,
27 String context)
28 {
29 super(metaObject, context);
30 }
31
32
33
34
35 protected boolean handleIsContainedInFrontEndUseCase()
36 {
37 return this.getStateMachine() instanceof StrutsActivityGraph;
38 }
39
40
41
42
43
44 protected String handleGetActionMethodName()
45 {
46 final String methodName = getName();
47 return (methodName == null) ?
48 "a" + System.currentTimeMillis() : StringUtilsHelper.lowerCamelCaseName(methodName);
49 }
50
51
52
53
54
55
56 public List getContainerActions()
57 {
58 final Set<StrutsAction> actionSet = new LinkedHashSet<StrutsAction>();
59 final StateMachineFacade graphContext = getStateMachine();
60
61 if (graphContext instanceof ActivityGraphFacade)
62 {
63 final UseCaseFacade useCase = ((ActivityGraphFacade)graphContext).getUseCase();
64
65 if (useCase instanceof StrutsUseCase)
66 {
67
68 for (final Object action : ((StrutsUseCaseLogicImpl)useCase).getActions())
69 {
70 for (final StrutsForward transition : ((StrutsAction)action).getTransitions())
71 {
72 if (this.equals(transition.getTarget()))
73 {
74 actionSet.add((StrutsAction)action);
75 }
76 }
77 }
78 }
79 }
80
81 return new ArrayList<StrutsAction>(actionSet);
82 }
83 }