1 package org.andromda.cartridges.bpm4struts.metafacades;
2
3 import org.andromda.cartridges.bpm4struts.Bpm4StrutsGlobals;
4 import org.andromda.metafacades.uml.TransitionFacade;
5 import org.andromda.utils.StringUtilsHelper;
6
7
8
9
10
11
12 public class StrutsTriggerLogicImpl
13 extends StrutsTriggerLogic
14 {
15 private static final long serialVersionUID = 34L;
16
17
18
19
20 public StrutsTriggerLogicImpl(
21 Object metaObject,
22 String context)
23 {
24 super(metaObject, context);
25 }
26
27
28
29
30
31 protected String handleGetNotAllowedTitleKey()
32 {
33 return getTitleKey() + ".notallowed";
34 }
35
36
37
38
39
40 protected String handleGetTitleKey()
41 {
42 return getTriggerKey() + ".title";
43 }
44
45
46
47
48
49 protected String handleGetResetTitleKey()
50 {
51 return getTitleKey() + ".reset";
52 }
53
54
55
56
57 protected String handleGetResetMessageKey()
58 {
59 return getResetTitleKey() + ".message";
60 }
61
62
63
64
65
66 protected String handleGetResetNotAllowedTitleKey()
67 {
68 return getResetTitleKey() + ".not.allowed";
69 }
70
71
72
73
74
75 protected String handleGetTriggerKey()
76 {
77 String triggerKey = StringUtilsHelper.toResourceMessageKey(getName());
78
79 if (!normalizeMessages())
80 {
81 final StrutsAction action = getStrutsAction();
82 if (action != null)
83 {
84 final StrutsJsp page = action.getInput();
85 if (page != null)
86 {
87 triggerKey = page.getMessageKey() + '.' + triggerKey;
88 }
89 }
90 }
91
92 return triggerKey;
93 }
94
95
96
97
98 protected String handleGetTriggerValue()
99 {
100 return StringUtilsHelper.toPhrase(getName());
101 }
102
103
104
105
106 protected String handleGetTitleValue()
107 {
108 return getTriggerValue();
109 }
110
111
112
113
114 protected String handleGetResetTitleValue()
115 {
116 return "Reset";
117 }
118
119
120
121
122 protected String handleGetResetMessageValue()
123 {
124 return "Reset";
125 }
126
127
128
129
130 protected String handleGetResetNotAllowedTitleValue()
131 {
132 return "You are not allowed to reset";
133 }
134
135
136
137
138 protected String handleGetNotAllowedTitleValue()
139 {
140 return "You are not allowed to call this action";
141 }
142
143
144
145
146 protected boolean handleIsActionTrigger()
147 {
148 return this.getStrutsAction() != null;
149 }
150
151
152
153
154 protected Object handleGetStrutsAction()
155 {
156 StrutsAction triggerAction = null;
157
158 TransitionFacade transition = getTransition();
159 if (transition instanceof StrutsAction)
160 {
161 triggerAction = (StrutsAction)transition;
162 }
163 return triggerAction;
164 }
165
166 private boolean normalizeMessages()
167 {
168 final String normalizeMessages = (String)getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_NORMALIZE_MESSAGES);
169 return Boolean.valueOf(normalizeMessages).booleanValue();
170 }
171 }