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.LinkedHashMap;
7 import java.util.LinkedHashSet;
8 import java.util.List;
9 import java.util.Map;
10 import org.andromda.metafacades.uml.ActivityGraphFacade;
11 import org.andromda.metafacades.uml.StateMachineFacade;
12 import org.andromda.metafacades.uml.TransitionFacade;
13 import org.andromda.metafacades.uml.UseCaseFacade;
14
15
16
17
18
19
20
21 public class StrutsActionStateLogicImpl
22 extends StrutsActionStateLogic
23 {
24 private static final long serialVersionUID = 34L;
25
26
27
28
29 public StrutsActionStateLogicImpl(
30 Object metaObject,
31 String context)
32 {
33 super(metaObject, context);
34 }
35
36
37
38
39
40
41 public List getContainerActions()
42 {
43 final Collection<StrutsAction> actionSet = new LinkedHashSet<StrutsAction>();
44
45 final StateMachineFacade stateMachineFacade = this.getStateMachine();
46 if (stateMachineFacade instanceof ActivityGraphFacade)
47 {
48 final ActivityGraphFacade activityGraph = (ActivityGraphFacade)stateMachineFacade;
49 final UseCaseFacade useCase = activityGraph.getUseCase();
50
51 if (useCase instanceof StrutsUseCase)
52 {
53 final Collection actions = ((StrutsUseCase)useCase).getActions();
54 for (final Iterator<StrutsAction> actionIterator = actions.iterator(); actionIterator.hasNext();)
55 {
56 final StrutsAction action = actionIterator.next();
57 if (action.getActionStates().contains(this))
58 {
59 actionSet.add(action);
60 }
61 }
62 }
63 }
64 return new ArrayList<StrutsAction>(actionSet);
65 }
66
67
68
69
70 public List getExceptions()
71 {
72 final Map<String, TransitionFacade> exceptionsMap = new LinkedHashMap<String, TransitionFacade>();
73 for (final TransitionFacade transition : getOutgoings())
74 {
75 if (transition instanceof StrutsExceptionHandler)
76 {
77 exceptionsMap.put(((StrutsExceptionHandler)transition).getExceptionKey(), transition);
78 }
79 }
80 return new ArrayList<TransitionFacade>(exceptionsMap.values());
81 }
82 }