View Javadoc
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    * MetafacadeLogic implementation.
9    *
10   * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger
11   */
12  public class StrutsTriggerLogicImpl
13      extends StrutsTriggerLogic
14  {
15      private static final long serialVersionUID = 34L;
16      /**
17       * @param metaObject
18       * @param context
19       */
20      public StrutsTriggerLogicImpl(
21          Object metaObject,
22          String context)
23      {
24          super(metaObject, context);
25      }
26  
27      /**
28       * @return getTitleKey() + ".notallowed"
29       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getNotAllowedTitleKey()
30       */
31      protected String handleGetNotAllowedTitleKey()
32      {
33          return getTitleKey() + ".notallowed";
34      }
35  
36      /**
37       * @return getTriggerKey() + ".title"
38       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getTitleKey()
39       */
40      protected String handleGetTitleKey()
41      {
42          return getTriggerKey() + ".title";
43      }
44  
45      /**
46       * @return getTitleKey() + ".reset"
47       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getResetTitleKey()
48       */
49      protected String handleGetResetTitleKey()
50      {
51          return getTitleKey() + ".reset";
52      }
53  
54      /**
55       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetResetMessageKey()
56       */
57      protected String handleGetResetMessageKey()
58      {
59          return getResetTitleKey() + ".message";
60      }
61  
62      /**
63       * @return getResetTitleKey() + ".not.allowed"
64       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getResetNotAllowedTitleKey()
65       */
66      protected String handleGetResetNotAllowedTitleKey()
67      {
68          return getResetTitleKey() + ".not.allowed";
69      }
70  
71      /**
72       * @return triggerKey
73       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getTriggerKey()
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       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetTriggerValue()
97       */
98      protected String handleGetTriggerValue()
99      {
100         return StringUtilsHelper.toPhrase(getName());
101     }
102 
103     /**
104      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetTitleValue()
105      */
106     protected String handleGetTitleValue()
107     {
108         return getTriggerValue();
109     }
110 
111     /**
112      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetResetTitleValue()
113      */
114     protected String handleGetResetTitleValue()
115     {
116         return "Reset";
117     }
118 
119     /**
120      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetResetMessageValue()
121      */
122     protected String handleGetResetMessageValue()
123     {
124         return "Reset";
125     }
126 
127     /**
128      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetResetNotAllowedTitleValue()
129      */
130     protected String handleGetResetNotAllowedTitleValue()
131     {
132         return "You are not allowed to reset";
133     }
134 
135     /**
136      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetNotAllowedTitleValue()
137      */
138     protected String handleGetNotAllowedTitleValue()
139     {
140         return "You are not allowed to call this action";
141     }
142 
143     /**
144      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleIsActionTrigger()
145      */
146     protected boolean handleIsActionTrigger()
147     {
148         return this.getStrutsAction() != null;
149     }
150 
151     /**
152      * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetStrutsAction()
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 }