001: package org.andromda.cartridges.bpm4struts.metafacades;
002:
003: import org.andromda.cartridges.bpm4struts.Bpm4StrutsGlobals;
004: import org.andromda.cartridges.bpm4struts.Bpm4StrutsUtils;
005: import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
006: import org.andromda.utils.StringUtilsHelper;
007: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
008: import org.andromda.metafacades.uml.AttributeFacade;
009: import org.apache.commons.lang.StringUtils;
010:
011: import java.util.Collection;
012: import java.util.Iterator;
013:
014: /**
015: * MetafacadeLogic implementation for org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntity.
016: *
017: * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntity
018: */
019: public class StrutsManageableEntityLogicImpl extends
020: StrutsManageableEntityLogic {
021: /**
022: * @return the configured property denoting the character sequence to use for the separation of namespaces
023: */
024: private String getNamespaceProperty() {
025: return (String) this
026: .getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR);
027: }
028:
029: public StrutsManageableEntityLogicImpl(Object metaObject,
030: String context) {
031: super (metaObject, context);
032: }
033:
034: protected boolean handleIsMultipartFormData() {
035: boolean multipartFormPost = false;
036:
037: final Collection formFields = this .getManageableAttributes();
038: for (final Iterator fieldIterator = formFields.iterator(); !multipartFormPost
039: && fieldIterator.hasNext();) {
040: final AttributeFacade field = (AttributeFacade) fieldIterator
041: .next();
042: if (field.getType().isFileType()) {
043: multipartFormPost = true;
044: }
045: }
046:
047: return multipartFormPost;
048: }
049:
050: protected String handleGetFormBeanType() {
051: return this .getManageablePackageName()
052: + this .getNamespaceProperty()
053: + this .getFormBeanClassName();
054: }
055:
056: protected String handleGetFormBeanClassName() {
057: return this .getName() + Bpm4StrutsGlobals.FORM_SUFFIX;
058: }
059:
060: protected String handleGetFormBeanFullPath() {
061: return StringUtils.replace(this .getFormBeanType(), this
062: .getNamespaceProperty(), "/");
063: }
064:
065: protected java.lang.String handleGetMessageKey() {
066: return StringUtilsHelper.toResourceMessageKey(this .getName());
067: }
068:
069: protected java.lang.String handleGetMessageValue() {
070: return StringUtilsHelper.toPhrase(this .getName());
071: }
072:
073: protected java.lang.String handleGetPageTitleKey() {
074: return StringUtilsHelper.toResourceMessageKey(this .getName())
075: + ".page.title";
076: }
077:
078: protected java.lang.String handleGetPageTitleValue() {
079: return StringUtilsHelper.toPhrase(getName());
080: }
081:
082: protected java.lang.String handleGetListName() {
083: return "manageableList";
084: }
085:
086: protected java.lang.String handleGetListGetterName() {
087: return "getManageableList";
088: }
089:
090: protected java.lang.String handleGetListSetterName() {
091: return "setManageableList";
092: }
093:
094: protected String handleGetPageName() {
095: return this .getName().toLowerCase() + "-crud.jsp";
096: }
097:
098: protected String handleGetPageFullPath() {
099: return '/' + this .getManageablePackagePath() + '/'
100: + this .getPageName();
101: }
102:
103: protected java.lang.String handleGetActionPath() {
104: return '/' + this .getName() + "/Manage";
105: }
106:
107: protected java.lang.String handleGetActionParameter() {
108: return "crud";
109: }
110:
111: protected java.lang.String handleGetFormBeanName() {
112: return "manage" + this .getName()
113: + Bpm4StrutsGlobals.FORM_SUFFIX;
114: }
115:
116: protected java.lang.String handleGetActionType() {
117: return this .getManageablePackageName()
118: + this .getNamespaceProperty()
119: + this .getActionClassName();
120: }
121:
122: protected java.lang.String handleGetExceptionKey() {
123: return StringUtilsHelper.toResourceMessageKey(this .getName())
124: + ".exception";
125: }
126:
127: protected java.lang.String handleGetExceptionPath() {
128: return this .getPageFullPath();
129: }
130:
131: protected java.lang.String handleGetActionFullPath() {
132: return '/' + StringUtils.replace(this .getActionType(), this
133: .getNamespaceProperty(), "/");
134: }
135:
136: protected java.lang.String handleGetActionClassName() {
137: return "Manage" + getName();
138: }
139:
140: protected boolean handleIsPreload() {
141: return this .isCreate() || this .isRead() || this .isUpdate()
142: || this .isDelete();
143: }
144:
145: protected String handleGetOnlineHelpKey() {
146: return this .getMessageKey() + ".online.help";
147: }
148:
149: protected String handleGetOnlineHelpValue() {
150: final String value = StringUtilsHelper.toResourceMessage(this
151: .getDocumentation("", 64, false));
152: return (value == null) ? "No entity documentation has been specified"
153: : value;
154: }
155:
156: protected String handleGetOnlineHelpActionPath() {
157: return this .getActionPath() + "Help";
158: }
159:
160: protected String handleGetOnlineHelpPagePath() {
161: return '/' + this .getManageablePackagePath() + '/'
162: + this .getName().toLowerCase() + "_help";
163: }
164:
165: protected boolean handleIsTableExportable() {
166: return this .getTableExportTypes().indexOf("none") == -1;
167: }
168:
169: protected String handleGetTableExportTypes() {
170: return Bpm4StrutsUtils
171: .getDisplayTagExportTypes(
172: this
173: .findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_EXPORT),
174: (String) getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_TABLE_EXPORT_TYPES));
175: }
176:
177: protected boolean handleIsTableSortable() {
178: final Object taggedValue = this
179: .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_SORTABLE);
180: return (taggedValue == null) ? Bpm4StrutsProfile.TAGGEDVALUE_TABLE_SORTABLE_DEFAULT_VALUE
181: : Bpm4StrutsUtils.isTrue(String.valueOf(taggedValue));
182: }
183:
184: protected int handleGetTableMaxRows() {
185: final Object taggedValue = this
186: .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_MAXROWS);
187: int pageSize;
188:
189: try {
190: pageSize = Integer.parseInt(String.valueOf(taggedValue));
191: } catch (Exception e) {
192: pageSize = Bpm4StrutsProfile.TAGGEDVALUE_TABLE_MAXROWS_DEFAULT_COUNT;
193: }
194:
195: return pageSize;
196: }
197: }
|