User: walterim Date: 07/02/20 02:12:08 Modified: andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades JSFManageableEntityAssociationEndLogicImpl.java JSFManageableEntityLogicImpl.java JSFManageableEntityAttributeLogicImpl.java Log: Code cleaning and small bug fixes. Revision Changes Path 1.2 +16 -19 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAssociationEndLogicImpl.java Index: JSFManageableEntityAssociationEndLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAssociationEndLogicImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- JSFManageableEntityAssociationEndLogicImpl.java 11 Dec 2006 13:43:57 -0000 1.1 +++ JSFManageableEntityAssociationEndLogicImpl.java 20 Feb 2007 10:12:05 -0000 1.2 @@ -9,7 +9,6 @@ import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; - /** * MetafacadeLogic implementation for org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd. * @@ -18,9 +17,8 @@ public class JSFManageableEntityAssociationEndLogicImpl extends JSFManageableEntityAssociationEndLogic { - public JSFManageableEntityAssociationEndLogicImpl( - Object metaObject, - String context) + + public JSFManageableEntityAssociationEndLogicImpl (Object metaObject, String context) { super(metaObject, context); } @@ -64,26 +62,25 @@ return StringUtilsHelper.toPhrase(messageValue); } - protected boolean handleIsSafeNamePresent() - { - return true; - // TODO será que precisa desse método ? - //return JSFUtils.isSafeName(this.getName()); - } - - protected String handleGetOnlineHelpKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpKey() + */ + protected java.lang.String handleGetOnlineHelpKey() { return this.getMessageKey() + ".online.help"; } - protected String handleGetOnlineHelpValue() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpValue() + */ + protected java.lang.String handleGetOnlineHelpValue() { final String value = StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false)); return (value == null) ? "No field documentation has been specified" : value; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getBackingListName(org.andromda.metafacades.uml.ParameterFacade) + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getBackingListName() */ protected String handleGetBackingListName() { @@ -96,9 +93,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getValueListName() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getValueListName() */ - protected String handleGetValueListName() + protected java.lang.String handleGetValueListName() { return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.VALUE_LIST_PATTERN)).replaceAll( "\\{0\\}", @@ -106,9 +103,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getLabelListName() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getLabelListName() */ - protected String handleGetLabelListName() + protected java.lang.String handleGetLabelListName() { return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.LABEL_LIST_PATTERN)).replaceAll( "\\{0\\}", 1.2 +317 -197 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityLogicImpl.java Index: JSFManageableEntityLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityLogicImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- JSFManageableEntityLogicImpl.java 11 Dec 2006 13:43:57 -0000 1.1 +++ JSFManageableEntityLogicImpl.java 20 Feb 2007 10:12:05 -0000 1.2 @@ -23,138 +23,210 @@ public class JSFManageableEntityLogicImpl extends JSFManageableEntityLogic { - /** - * @return the configured property denoting the character sequence to use for the separation of namespaces - */ - private String getNamespaceProperty() + + public JSFManageableEntityLogicImpl (Object metaObject, String context) { - return (String)this.getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR); + super (metaObject, context); } - public JSFManageableEntityLogicImpl( - Object metaObject, - String context) + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getViewName() + */ + protected java.lang.String handleGetViewName() { - super(metaObject, context); + return this.getName().toLowerCase() + "-crud"; } - protected String handleGetFormBeanType() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getViewTitleKey() + */ + protected java.lang.String handleGetViewTitleKey() { - return this.getManageablePackageName() + this.getNamespaceProperty() + this.getFormBeanClassName(); + return StringUtilsHelper.toResourceMessageKey(this.getName()) + ".view.title"; } - protected String handleGetFormBeanClassName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getViewTitleValue() + */ + protected java.lang.String handleGetViewTitleValue() { - return this.getName() + JSFGlobals.FORM_SUFFIX; + return StringUtilsHelper.toPhrase(getName()); } - protected String handleGetFormBeanFullPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getListName() + */ + protected java.lang.String handleGetListName() { - return StringUtils.replace(this.getFormBeanType(), this.getNamespaceProperty(), "/"); + return "manageableList"; } - protected java.lang.String handleGetMessageKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormBeanType() + */ + protected java.lang.String handleGetFormBeanType() { - return StringUtilsHelper.toResourceMessageKey(this.getName()); + return this.getManageablePackageName() + this.getNamespaceProperty() + this.getFormBeanClassName(); } - protected java.lang.String handleGetMessageValue() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormBeanName() + */ + protected java.lang.String handleGetFormBeanName() { - return StringUtilsHelper.toPhrase(this.getName()); + return "manage" + this.getName() + JSFGlobals.FORM_SUFFIX; } - protected java.lang.String handleGetViewTitleKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getExceptionKey() + */ + protected java.lang.String handleGetExceptionKey() { - return StringUtilsHelper.toResourceMessageKey(this.getName()) + ".view.title"; + return StringUtilsHelper.toResourceMessageKey(this.getName()); } - protected java.lang.String handleGetViewTitleValue() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getActionType() + */ + protected java.lang.String handleGetActionType() { - return StringUtilsHelper.toPhrase(getName()); + return this.getManageablePackageName() + this.getNamespaceProperty() + this.getActionClassName(); } - protected java.lang.String handleGetListName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getActionFullPath() + */ + protected java.lang.String handleGetActionFullPath() { - return "manageableList"; + return '/' + StringUtils.replace(this.getActionType(), this.getNamespaceProperty(), "/"); } - protected java.lang.String handleGetListGetterName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getActionPath() + */ + protected java.lang.String handleGetActionPath() { - return "getManageableList"; + return '/' + this.getName() + "/Manage"; } - protected java.lang.String handleGetListSetterName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getActionClassName() + */ + protected java.lang.String handleGetActionClassName() { - return "setManageableList"; + return "Manage" + getName(); } - protected java.lang.String handleGetActionPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getExceptionPath() + */ + protected java.lang.String handleGetExceptionPath() { - return '/' + this.getName() + "/Manage"; + return this.getViewFullPath(); } - protected java.lang.String handleGetFormBeanName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#isPreload() + */ + protected boolean handleIsPreload() { - return "manage" + this.getName() + JSFGlobals.FORM_SUFFIX; + return false; //TODO think about... +// return this.isCreate() || this.isRead() || this.isUpdate() || this.isDelete(); } - protected java.lang.String handleGetActionType() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormBeanClassName() + */ + protected java.lang.String handleGetFormBeanClassName() { - return this.getManageablePackageName() + this.getNamespaceProperty() + this.getActionClassName(); + return this.getName() + JSFGlobals.FORM_SUFFIX; } - protected java.lang.String handleGetExceptionKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormBeanFullPath() + */ + protected java.lang.String handleGetFormBeanFullPath() { - return StringUtilsHelper.toResourceMessageKey(this.getName()) + ".exception"; + return StringUtils.replace(this.getFormBeanType(), this.getNamespaceProperty(), "/"); } - protected java.lang.String handleGetExceptionPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getListGetterName() + */ + protected java.lang.String handleGetListGetterName() { - return this.getViewFullPath(); + return "getManageableList"; } - protected java.lang.String handleGetActionFullPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getListSetterName() + */ + protected java.lang.String handleGetListSetterName() { - return '/' + StringUtils.replace(this.getActionType(), this.getNamespaceProperty(), "/"); + return "setManageableList"; } - protected java.lang.String handleGetActionClassName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getMessageKey() + */ + protected java.lang.String handleGetMessageKey() { - return "Manage" + getName(); + return StringUtilsHelper.toResourceMessageKey(this.getName()); } - protected boolean handleIsPreload() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getMessageValue() + */ + protected java.lang.String handleGetMessageValue() { - return this.isCreate() || this.isRead() || this.isUpdate() || this.isDelete(); + return StringUtilsHelper.toPhrase(this.getName()); } - protected String handleGetOnlineHelpKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getOnlineHelpKey() + */ + protected java.lang.String handleGetOnlineHelpKey() { return this.getMessageKey() + ".online.help"; } - protected String handleGetOnlineHelpValue() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getOnlineHelpValue() + */ + protected java.lang.String handleGetOnlineHelpValue() { final String value = StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false)); return (value == null) ? "No entity documentation has been specified" : value; } - protected String handleGetOnlineHelpActionPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getOnlineHelpActionPath() + */ + protected java.lang.String handleGetOnlineHelpActionPath() { return this.getActionPath() + "Help"; } - protected String handleGetOnlineHelpPagePath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getOnlineHelpPagePath() + */ + protected java.lang.String handleGetOnlineHelpPagePath() { return '/' + this.getManageablePackagePath() + '/' + this.getName().toLowerCase() + "_help"; } + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#isTableExportable() + */ protected boolean handleIsTableExportable() { return this.getTableExportTypes().indexOf("none") == -1; } - protected String handleGetTableExportTypes() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getTableExportTypes() + */ + protected java.lang.String handleGetTableExportTypes() { return null; //TODO a resolver @@ -163,14 +235,9 @@ // (String)getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_TABLE_EXPORT_TYPES) ); } - protected boolean handleIsTableSortable() - { - final Object taggedValue = this.findTaggedValue(JSFProfile.TAGGEDVALUE_TABLE_SORTABLE); - return (taggedValue == null) - ? JSFProfile.TAGGEDVALUE_TABLE_SORTABLE_DEFAULT_VALUE - : Boolean.valueOf(String.valueOf(taggedValue)).booleanValue(); - } - + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getTableMaxRows() + */ protected int handleGetTableMaxRows() { final Object taggedValue = this.findTaggedValue(JSFProfile.TAGGEDVALUE_TABLE_MAXROWS); @@ -189,7 +256,18 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getControllerFullyQualifiedName() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#isTableSortable() + */ + protected boolean handleIsTableSortable() + { + final Object taggedValue = this.findTaggedValue(JSFProfile.TAGGEDVALUE_TABLE_SORTABLE); + return (taggedValue == null) + ? JSFProfile.TAGGEDVALUE_TABLE_SORTABLE_DEFAULT_VALUE + : Boolean.valueOf(String.valueOf(taggedValue)).booleanValue(); + } + + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getControllerType() */ protected java.lang.String handleGetControllerType(){ return this.getManageablePackageName() + this.getNamespaceProperty() + this.getControllerName(); @@ -198,72 +276,39 @@ /** * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getControllerBeanName() */ - protected java.lang.String handleGetControllerBeanName(){ + protected java.lang.String handleGetControllerBeanName() + { return StringUtils.uncapitalize(this.getName()) + "Controller"; } + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getControllerFullPath() + */ protected java.lang.String handleGetControllerFullPath() { return "/" + StringUtils.replace(this.getControllerType(), this.getNamespaceProperty(), "/"); } + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getControllerName() + */ protected java.lang.String handleGetControllerName() { return this.getName() + "Controller"; } + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getValueObjectClassName() + */ protected java.lang.String handleGetValueObjectClassName() { - return this.getName() + "ValueObject"; -//TODO rever return getName() + this.getConfiguredProperty(SpringGlobals.CRUD_VALUE_OBJECT_SUFFIX); - } - - private void addSerialUIDData(StringBuffer buffer){ - for (final Iterator iterator = this.getManageableAttributes().iterator(); iterator.hasNext();) - { - final ModelElementFacade parameter = (ModelElementFacade)iterator.next(); - buffer.append(parameter.getName()); - } - for (final Iterator iterator = this.getManageableAssociationEnds().iterator(); iterator.hasNext();) - { - final ModelElementFacade parameter = (ModelElementFacade)iterator.next(); - buffer.append(parameter.getName()); - } - - } - - private String calcSerialVersionUID(StringBuffer buffer){ - final String signature = buffer.toString(); - String serialVersionUID = String.valueOf(0L); - try - { - MessageDigest md = MessageDigest.getInstance("SHA"); - byte[] hashBytes = md.digest(signature.getBytes()); - - long hash = 0; - for (int ctr = Math.min( - hashBytes.length, - 8) - 1; ctr >= 0; ctr--) - { - hash = (hash << 8) | (hashBytes[ctr] & 0xFF); - } - serialVersionUID = String.valueOf(hash); - } - catch (final NoSuchAlgorithmException exception) - { - final String message = "Error performing JSFAction.getFormSerialVersionUID"; - logger.error( - message, - exception); - } - - return serialVersionUID; + return getName() + this.getConfiguredProperty(JSFGlobals.CRUD_VALUE_OBJECT_SUFFIX); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#getFormSerialVersionUID() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormSerialVersionUID() */ - protected String handleGetFormSerialVersionUID() + protected java.lang.String handleGetFormSerialVersionUID() { final StringBuffer buffer = new StringBuffer(); @@ -275,9 +320,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#getFormSerialVersionUID() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getActionSerialVersionUID() */ - protected String handleGetActionSerialVersionUID() + protected java.lang.String handleGetActionSerialVersionUID() { final StringBuffer buffer = new StringBuffer(); @@ -289,9 +334,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#getPopulator() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getPopulatorName() */ - protected String handleGetPopulatorName() + protected java.lang.String handleGetPopulatorName() { return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.VIEW_POPULATOR_PATTERN)).replaceAll( "\\{0\\}", @@ -299,43 +344,41 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#getPopulator() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getPopulatorFullPath() */ - protected String handleGetPopulatorType() + protected java.lang.String handleGetPopulatorFullPath() { - return this.getManageablePackageName() + this.getNamespaceProperty() + this.getPopulatorName(); + return "/" + StringUtils.replace(this.getPopulatorType(), this.getNamespaceProperty(), "/"); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#getPopulator() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getPopulatorType() */ - protected String handleGetPopulatorFullPath() + protected java.lang.String handleGetPopulatorType() { - return "/" + StringUtils.replace(this.getPopulatorType(), this.getNamespaceProperty(), "/"); + return this.getManageablePackageName() + this.getNamespaceProperty() + this.getPopulatorName(); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFView#getFormKey() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getFormKey() */ - protected String handleGetFormKey() + protected java.lang.String handleGetFormKey() { final Object formKeyValue = this.findTaggedValue(JSFProfile.TAGGEDVALUE_ACTION_FORM_KEY); return formKeyValue == null ? ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.ACTION_FORM_KEY)) : String.valueOf(formKeyValue); } - protected String handleGetViewName() - { - return this.getName().toLowerCase() + "-crud"; - } - - protected String handleGetViewFullPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getViewFullPath() + */ + protected java.lang.String handleGetViewFullPath() { return '/' + this.getManageablePackagePath() + '/' + this.getViewName(); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAction#handleGetHiddenParameters() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#isValidationRequired() */ protected boolean handleIsValidationRequired() { @@ -350,27 +393,43 @@ return false; } - protected String handleGetSearchFormBeanType() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getSearchFormBeanName() + */ + protected java.lang.String handleGetSearchFormBeanName() { - return this.getManageablePackageName() + this.getNamespaceProperty() + this.getSearchFormBeanClassName(); + return "manage" + this.getName() + "Search" + JSFGlobals.FORM_SUFFIX; } - protected String handleGetSearchFormBeanClassName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getSearchFormBeanType() + */ + protected java.lang.String handleGetSearchFormBeanType() { - return this.getName() + "Search" + JSFGlobals.FORM_SUFFIX; + return this.getManageablePackageName() + this.getNamespaceProperty() + this.getSearchFormBeanClassName(); } - protected String handleGetSearchFormBeanFullPath() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getSearchFormBeanFullPath() + */ + protected java.lang.String handleGetSearchFormBeanFullPath() { return StringUtils.replace(this.getSearchFormBeanType(), this.getNamespaceProperty(), "/"); } - protected java.lang.String handleGetSearchFormBeanName() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getSearchFormBeanClassName() + */ + protected java.lang.String handleGetSearchFormBeanClassName() { - return "manage" + this.getName() + "Search" + JSFGlobals.FORM_SUFFIX; + return this.getName() + "Search" + JSFGlobals.FORM_SUFFIX; } - protected java.util.Collection handleGetManageableSearchAttributes(){ + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getManageableSearchAttributes() + */ + protected java.util.Collection handleGetManageableSearchAttributes() + { final Collection coll=new java.util.ArrayList(); for(final java.util.Iterator it=getManageableAttributes().iterator(); it.hasNext(); ){ final JSFManageableEntityAttribute attr=(JSFManageableEntityAttribute)it.next(); @@ -380,12 +439,19 @@ return coll; } - protected java.util.Collection handleGetManageableSearchAssociationEnds(){ + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#getManageableSearchAssociationEnds() + */ + protected java.util.Collection handleGetManageableSearchAssociationEnds() + { return getManageableAssociationEnds(); } - protected boolean handleIsSearchable(Object element){ - + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntity#isSearchable(java.lang.Object) + */ + protected boolean handleIsSearchable(java.lang.Object element) + { // if(element instanceof JSFManageableEntityAttribute) // return getManageableSearchAttributes().contains(element); // else @@ -398,4 +464,58 @@ else return true; } + + /** + * @return the configured property denoting the character sequence to use for the separation of namespaces + */ + private String getNamespaceProperty() + { + return (String)this.getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR); + } + + private void addSerialUIDData(StringBuffer buffer){ + for (final Iterator iterator = this.getManageableAttributes().iterator(); iterator.hasNext();) + { + final ModelElementFacade parameter = (ModelElementFacade)iterator.next(); + buffer.append(parameter.getName()); + } + for (final Iterator iterator = this.getManageableAssociationEnds().iterator(); iterator.hasNext();) + { + final ModelElementFacade parameter = (ModelElementFacade)iterator.next(); + buffer.append(parameter.getName()); + } + + } + + /** + * @return the calculated SerialVersionUID + */ + private String calcSerialVersionUID(StringBuffer buffer){ + final String signature = buffer.toString(); + String serialVersionUID = String.valueOf(0L); + try + { + MessageDigest md = MessageDigest.getInstance("SHA"); + byte[] hashBytes = md.digest(signature.getBytes()); + + long hash = 0; + for (int ctr = Math.min( + hashBytes.length, + 8) - 1; ctr >= 0; ctr--) + { + hash = (hash << 8) | (hashBytes[ctr] & 0xFF); + } + serialVersionUID = String.valueOf(hash); + } + catch (final NoSuchAlgorithmException exception) + { + final String message = "Error performing JSFAction.getFormSerialVersionUID"; + logger.error( + message, + exception); + } + + return serialVersionUID; + } + } \ No newline at end of file 1.2 +197 -173 cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAttributeLogicImpl.java Index: JSFManageableEntityAttributeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/java/org/andromda/cartridges/jsf2/metafacades/JSFManageableEntityAttributeLogicImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- JSFManageableEntityAttributeLogicImpl.java 11 Dec 2006 13:43:57 -0000 1.1 +++ JSFManageableEntityAttributeLogicImpl.java 20 Feb 2007 10:12:05 -0000 1.2 @@ -9,7 +9,6 @@ import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; - /** * MetafacadeLogic implementation for org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute. * @@ -18,15 +17,14 @@ public class JSFManageableEntityAttributeLogicImpl extends JSFManageableEntityAttributeLogic { - public JSFManageableEntityAttributeLogicImpl( - Object metaObject, - String context) + + public JSFManageableEntityAttributeLogicImpl (Object metaObject, String context) { super(metaObject, context); } /** - * @see JSFManageableEntityAttribute#getMessageKey() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getMessageKey() */ protected java.lang.String handleGetMessageKey() { @@ -42,33 +40,16 @@ } /** - * @see JSFManageableEntityAttribute#getMessageValue() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getMessageValue() */ protected java.lang.String handleGetMessageValue() { return StringUtilsHelper.toPhrase(getName()); } - private String internalGetDateFormat() - { - String dateFormat = null; - - if (this.getType() != null && this.getType().isDateType()) - { - final Object taggedValueObject = this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_FORMAT); - if (taggedValueObject == null) - { - dateFormat = (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_DATEFORMAT); - } - else - { - dateFormat = taggedValueObject.toString(); - } - } - - return dateFormat; - } - + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getDateFormat() + */ protected java.lang.String handleGetDateFormat() { String dateFormat = this.internalGetDateFormat(); @@ -90,43 +71,61 @@ return dateFormat; } - protected boolean handleIsStrictDateFormat() - { - final String dateFormat = this.internalGetDateFormat(); - return (dateFormat != null && dateFormat.trim().startsWith("strict")); - } - + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isNeedsFileUpload() + */ protected boolean handleIsNeedsFileUpload() { return this.getType() != null && this.getType().isBlobType(); } + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isHidden() + */ protected boolean handleIsHidden() { return !this.isDisplay() || JSFProfile.TAGGEDVALUE_INPUT_TYPE_HIDDEN.equals(this.getWidgetType()); } - protected String handleGetWidgetType() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getWidgetType() + */ + protected java.lang.String handleGetWidgetType() { final Object widgetTag = findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TYPE); return (widgetTag == null) ? JSFProfile.TAGGEDVALUE_INPUT_TYPE_TEXT : widgetTag.toString(); } - protected String handleGetOnlineHelpKey() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isStrictDateFormat() + */ + protected boolean handleIsStrictDateFormat() + { + final String dateFormat = this.internalGetDateFormat(); + return (dateFormat != null && dateFormat.trim().startsWith("strict")); + } + + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getOnlineHelpKey() + */ + protected java.lang.String handleGetOnlineHelpKey() { return this.getMessageKey() + ".online.help"; } - protected String handleGetOnlineHelpValue() + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getOnlineHelpValue() + */ + protected java.lang.String handleGetOnlineHelpValue() { final String value = StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false)); return (value == null) ? "No field documentation has been specified" : value; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getFormat() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getFormat() */ - protected String handleGetFormat() + protected java.lang.String handleGetFormat() { return JSFUtils.getFormat( (ModelElementFacade)this.THIS(), @@ -136,43 +135,43 @@ } /** - * @return the default time format pattern as defined using the configured property + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getDefaultDateFormat() */ - protected String handleGetDefaultTimeFormat() + protected java.lang.String handleGetDefaultDateFormat() { - return (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_TIMEFORMAT); + return (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_DATEFORMAT); } /** - * @return the default date format pattern as defined using the configured property + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getDefaultTimeFormat() */ - protected String handleGetDefaultDateFormat() + protected java.lang.String handleGetDefaultTimeFormat() { - return (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_DATEFORMAT); + return (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_TIMEFORMAT); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getDateFormatter(org.andromda.cartridges.jsf2.metafacades.JSFParameter) + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getDateFormatter() */ - protected String handleGetDateFormatter() + protected java.lang.String handleGetDateFormatter() { final ClassifierFacade type = this.getType(); return type != null && type.isDateType() ? this.getName() + "DateFormatter" : null; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getTimeFormatter(org.andromda.cartridges.jsf2.metafacades.JSFParameter) + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getTimeFormatter() */ - protected String handleGetTimeFormatter() + protected java.lang.String handleGetTimeFormatter() { final ClassifierFacade type = this.getType(); return type != null && type.isTimeType() ? this.getName() + "TimeFormatter" : null; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getBackingListName(org.andromda.metafacades.uml.ParameterFacade) + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getBackingListName() */ - protected String handleGetBackingListName() + protected java.lang.String handleGetBackingListName() { final String backingListName = StringUtils.replace( @@ -183,9 +182,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getValueListName() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValueListName() */ - protected String handleGetValueListName() + protected java.lang.String handleGetValueListName() { return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.VALUE_LIST_PATTERN)).replaceAll( "\\{0\\}", @@ -193,9 +192,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getLabelListName() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getLabelListName() */ - protected String handleGetLabelListName() + protected java.lang.String handleGetLabelListName() { return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.LABEL_LIST_PATTERN)).replaceAll( "\\{0\\}", @@ -203,25 +202,25 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isValidationRequired() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValidatorTypes() */ - protected boolean handleIsValidationRequired() + protected java.util.Collection handleGetValidatorTypes() { - return !this.getValidatorTypes().isEmpty(); + return JSFUtils.getValidatorTypes( + (ModelElementFacade)this.THIS(), + this.getType()); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getValidatorTypes() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isValidationRequired() */ - protected java.util.Collection handleGetValidatorTypes() + protected boolean handleIsValidationRequired() { - return JSFUtils.getValidatorTypes( - (ModelElementFacade)this.THIS(), - this.getType()); + return !this.getValidatorTypes().isEmpty(); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFParameter#getValidatorVars() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValidatorVars() */ protected java.util.Collection handleGetValidatorVars() { @@ -231,7 +230,7 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getValidWhen() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValidWhen() */ protected java.lang.String handleGetValidWhen() { @@ -239,41 +238,35 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getValidatorArgs(java.lang.String) + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputCheckbox() */ - protected java.util.Collection handleGetValidatorArgs(final String validatorType) + protected boolean handleIsInputCheckbox() { - return JSFUtils.getValidatorArgs( - (ModelElementFacade)this.THIS(), - validatorType); - } - - /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputTextarea() - */ - protected boolean handleIsInputTextarea() + boolean checkbox = this.isInputType(JSFGlobals.INPUT_CHECKBOX); + if (!checkbox && this.getInputType().length() == 0) { - return this.isInputType(JSFGlobals.INPUT_TEXTAREA); + final ClassifierFacade type = this.getType(); + checkbox = type != null ? type.isBooleanType() : false; } - - /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputSelect() - */ - protected boolean handleIsInputSelect() - { - return this.isInputType(JSFGlobals.INPUT_SELECT); + return checkbox; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputSecret() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputFile() */ - protected boolean handleIsInputSecret() + protected boolean handleIsInputFile() { - return this.isInputType(JSFGlobals.INPUT_PASSWORD); + boolean file = false; + ClassifierFacade type = getType(); + if (type != null) + { + file = type.isFileType() || type.isBlobType(); + } + return file; } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputHidden() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputHidden() */ protected boolean handleIsInputHidden() { @@ -281,15 +274,15 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isPlaintext() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputMultibox() */ - protected boolean handleIsPlaintext() + protected boolean handleIsInputMultibox() { - return this.isInputType(JSFGlobals.PLAIN_TEXT); + return this.isInputType(JSFGlobals.INPUT_MULTIBOX); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputRadio() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputRadio() */ protected boolean handleIsInputRadio() { @@ -297,23 +290,23 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputText() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputSecret() */ - protected boolean handleIsInputText() + protected boolean handleIsInputSecret() { - return this.isInputType(JSFGlobals.INPUT_TEXT); + return this.isInputType(JSFGlobals.INPUT_PASSWORD); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputMultibox() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputSelect() */ - protected boolean handleIsInputMultibox() + protected boolean handleIsInputSelect() { - return this.isInputType(JSFGlobals.INPUT_MULTIBOX); + return this.isInputType(JSFGlobals.INPUT_SELECT); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputTable() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputTable() */ protected boolean handleIsInputTable() { @@ -321,84 +314,31 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputCheckbox() - */ - protected boolean handleIsInputCheckbox() - { - boolean checkbox = this.isInputType(JSFGlobals.INPUT_CHECKBOX); - if (!checkbox && this.getInputType().length() == 0) - { - final ClassifierFacade type = this.getType(); - checkbox = type != null ? type.isBooleanType() : false; - } - return checkbox; - } - - /** - * Gets the current value of the specified input type (or an empty string - * if one isn't specified). - * - * @return the input type name. + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getInputTableIdentifierColumns() */ - private final String getInputType() + protected java.lang.String handleGetInputTableIdentifierColumns() { - return ObjectUtils.toString(this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TYPE)).trim(); - } - - /** - * Indicates whether or not this parameter is of the given input type. - * - * @param inputType the name of the input type to check for. - * @return true/false - */ - private final boolean isInputType(final String inputType) - { - return inputType.equalsIgnoreCase(this.getInputType()); - } - - /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputFile() - */ - protected boolean handleIsInputFile() - { - boolean file = false; - ClassifierFacade type = getType(); - if (type != null) - { - file = type.isFileType() || type.isBlobType(); - } - return file; - } - - /** - * Overridden to provide consistent behavior with {@link JSFParameter#isReadOnly()}. - * - * @see org.andromda.metafacades.uml.AttributeFacade#isReadOnly() - */ - public boolean isReadOnly() - { - return JSFUtils.isReadOnly(this); + return ObjectUtils.toString(this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TABLE_IDENTIFIER_COLUMNS)).trim(); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getValueListDummyValue() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputText() */ - protected String handleGetValueListDummyValue() + protected boolean handleIsInputText() { - return this.constructDummyArray(); + return this.isInputType(JSFGlobals.INPUT_TEXT); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isEqualValidator() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputTextarea() */ - protected boolean handleIsEqualValidator() + protected boolean handleIsInputTextarea() { - final String equal = JSFUtils.getEqual((ModelElementFacade)this.THIS()); - return equal != null && equal.trim().length() > 0; + return this.isInputType(JSFGlobals.INPUT_TEXTAREA); } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#isInputTypePresent() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isInputTypePresent() */ protected boolean handleIsInputTypePresent() { @@ -414,16 +354,9 @@ } /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttributer#getInputTableIdentifierColumns() - */ - protected String handleGetInputTableIdentifierColumns() - { - return ObjectUtils.toString(this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TABLE_IDENTIFIER_COLUMNS)).trim(); - } - /** - * @see org.andromda.cartridges.jsf2.metafacades.JSFAttribute#getDummyValue() + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getDummyValue() */ - protected String handleGetDummyValue() + protected java.lang.String handleGetDummyValue() { final ClassifierFacade type = this.getType(); if (type != null) @@ -531,6 +464,73 @@ } /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isEqualValidator() + */ + protected boolean handleIsEqualValidator() + { + final String equal = JSFUtils.getEqual((ModelElementFacade)this.THIS()); + return equal != null && equal.trim().length() > 0; + } + + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#isPlaintext() + */ + protected boolean handleIsPlaintext() + { + return this.isInputType(JSFGlobals.PLAIN_TEXT); + } + + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValueListDummyValue() + */ + protected java.lang.String handleGetValueListDummyValue() + { + return this.constructDummyArray(); + } + + /** + * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAttribute#getValidatorArgs(java.lang.String) + */ + protected java.util.Collection handleGetValidatorArgs(java.lang.String validatorType) + { + return JSFUtils.getValidatorArgs( + (ModelElementFacade)this.THIS(), + validatorType); + } + + /** + * Gets the current value of the specified input type (or an empty string + * if one isn't specified). + * + * @return the input type name. + */ + private final String getInputType() + { + return ObjectUtils.toString(this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_TYPE)).trim(); + } + + /** + * Indicates whether or not this parameter is of the given input type. + * + * @param inputType the name of the input type to check for. + * @return true/false + */ + private final boolean isInputType(final String inputType) + { + return inputType.equalsIgnoreCase(this.getInputType()); + } + + /** + * Overridden to provide consistent behavior with {@link JSFParameter#isReadOnly()}. + * + * @see org.andromda.metafacades.uml.AttributeFacade#isReadOnly() + */ + public boolean isReadOnly() + { + return JSFUtils.isReadOnly(this); + } + + /** * Constructs a string representing an array initialization in Java. * * @return A String representing Java code for the initialization of an array. @@ -541,4 +541,28 @@ this.getName(), JSFGlobals.DUMMY_ARRAY_COUNT); } + + private String internalGetDateFormat() + { + String dateFormat = null; + + if (this.getType() != null && this.getType().isDateType()) + { + final Object taggedValueObject = this.findTaggedValue(JSFProfile.TAGGEDVALUE_INPUT_FORMAT); + if (taggedValueObject == null) + { + dateFormat = (String)this.getConfiguredProperty(JSFGlobals.PROPERTY_DEFAULT_DATEFORMAT); + } + else + { + dateFormat = taggedValueObject.toString(); + } + } + + return dateFormat; + } + + + + } \ No newline at end of file |