001package org.andromda.cartridges.bpm4struts.metafacades; 002 003import org.andromda.cartridges.bpm4struts.Bpm4StrutsGlobals; 004import org.andromda.metafacades.uml.TransitionFacade; 005import org.andromda.utils.StringUtilsHelper; 006 007/** 008 * MetafacadeLogic implementation. 009 * 010 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger 011 */ 012public class StrutsTriggerLogicImpl 013 extends StrutsTriggerLogic 014{ 015 private static final long serialVersionUID = 34L; 016 /** 017 * @param metaObject 018 * @param context 019 */ 020 public StrutsTriggerLogicImpl( 021 Object metaObject, 022 String context) 023 { 024 super(metaObject, context); 025 } 026 027 /** 028 * @return getTitleKey() + ".notallowed" 029 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getNotAllowedTitleKey() 030 */ 031 protected String handleGetNotAllowedTitleKey() 032 { 033 return getTitleKey() + ".notallowed"; 034 } 035 036 /** 037 * @return getTriggerKey() + ".title" 038 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getTitleKey() 039 */ 040 protected String handleGetTitleKey() 041 { 042 return getTriggerKey() + ".title"; 043 } 044 045 /** 046 * @return getTitleKey() + ".reset" 047 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getResetTitleKey() 048 */ 049 protected String handleGetResetTitleKey() 050 { 051 return getTitleKey() + ".reset"; 052 } 053 054 /** 055 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetResetMessageKey() 056 */ 057 protected String handleGetResetMessageKey() 058 { 059 return getResetTitleKey() + ".message"; 060 } 061 062 /** 063 * @return getResetTitleKey() + ".not.allowed" 064 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getResetNotAllowedTitleKey() 065 */ 066 protected String handleGetResetNotAllowedTitleKey() 067 { 068 return getResetTitleKey() + ".not.allowed"; 069 } 070 071 /** 072 * @return triggerKey 073 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTrigger#getTriggerKey() 074 */ 075 protected String handleGetTriggerKey() 076 { 077 String triggerKey = StringUtilsHelper.toResourceMessageKey(getName()); 078 079 if (!normalizeMessages()) 080 { 081 final StrutsAction action = getStrutsAction(); 082 if (action != null) 083 { 084 final StrutsJsp page = action.getInput(); 085 if (page != null) 086 { 087 triggerKey = page.getMessageKey() + '.' + triggerKey; 088 } 089 } 090 } 091 092 return triggerKey; 093 } 094 095 /** 096 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsTriggerLogic#handleGetTriggerValue() 097 */ 098 protected String handleGetTriggerValue() 099 { 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}