From: Eric C. <ecr...@us...> - 2006-09-17 17:30:12
|
User: ecrutchfield Date: 06/09/17 10:30:11 Added: andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades AspControllerLogicImpl.java AspFinalStateLogicImpl.java .cvsignore AspActionLogicImpl.java AspActivityGraphLogicImpl.java AspParameterLogicImpl.java AspControllerOperationLogicImpl.java AspWebFormLogicImpl.java AspTransitionLogicImpl.java AspForwardLogicImpl.java AspEventLogicImpl.java AspSessionObjectLogicImpl.java AspUseCaseLogicImpl.java andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet MenuGroup.java AspProfile.java CommonProperties.java Log: initial version Revision Changes Path 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspControllerLogicImpl.java Index: AspControllerLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; import org.andromda.metafacades.uml.DependencyFacade; import org.andromda.metafacades.uml.ModelElementFacade; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspController. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspController */ public class AspControllerLogicImpl extends AspControllerLogic { public AspControllerLogicImpl(Object metaObject, String context) { super(metaObject, context); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspController#getFullyQualifiedImplementationName() */ protected String handleGetFullyQualifiedImplementationName() { final StringBuffer fullyQualifiedName = new StringBuffer(); final String packageName = this.getPackageName(); if (StringUtils.isNotBlank(packageName)) { fullyQualifiedName.append(packageName + '.'); } return fullyQualifiedName.append(this.getImplementationName()).toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspController#getFullyQualifiedImplementationPath() */ protected String handleGetFullyQualifiedImplementationPath() { return this.getFullyQualifiedImplementationName().replace('.', '/'); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspController#getImplementationName() */ protected java.lang.String handleGetImplementationName() { //final String pattern = ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.CONTROLLER_IMPLEMENTATION_PATTERN)); // @todo add CONTROLLER_IMPLEMENTATION_PATTERN to namespace and profile, then use here final String pattern = "{0}Impl"; return pattern.replaceFirst("\\{0\\}", StringUtils.capitalize(this.getName())); } protected java.util.List handleGetSessionObjects() { final List references = new ArrayList(this.getSourceDependencies()); for (final Iterator iterator = references.iterator(); iterator.hasNext();) { final ModelElementFacade targetElement = ((DependencyFacade)iterator.next()).getTargetElement(); if (!(targetElement instanceof AspSessionObject)) { iterator.remove(); } } return references; } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspFinalStateLogicImpl.java Index: AspFinalStateLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspFinalState. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspFinalState */ public class AspFinalStateLogicImpl extends AspFinalStateLogic { public AspFinalStateLogicImpl(Object metaObject, String context) { super(metaObject, context); } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/.cvsignore Index: .cvsignore =================================================================== *.bak 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspActionLogicImpl.java Index: AspActionLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.andromda.cartridges.aspdotnet.AspProfile; import org.andromda.cartridges.aspdotnet.CommonProperties; import org.andromda.metafacades.uml.EventFacade; import org.andromda.utils.StringUtilsHelper; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Predicate; import org.apache.commons.lang.StringUtils; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspAction. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction */ public class AspActionLogicImpl extends AspActionLogic { public AspActionLogicImpl (Object metaObject, String context) { super (metaObject, context); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#isHyperlink() */ protected boolean handleIsHyperlink() { final Object value = findTaggedValue(AspProfile.TAGGEDVALUE_ACTION_TYPE); return CommonProperties.WEB_ACTION_HYPERLINK.equalsIgnoreCase(value == null ? null : value.toString()); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#isTableLink() */ protected boolean handleIsTableLink() { return this.getTableLinkParameter() != null; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#isTableAction() */ protected boolean handleIsTableAction() { return CommonProperties.ACTION_TYPE_TABLE.equals(this.findTaggedValue(AspProfile.TAGGEDVALUE_ACTION_TYPE)); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFormImplementationName() */ protected java.lang.String handleGetFormImplementationName() { //final String pattern = ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.FORM_IMPLEMENTATION_PATTERN)); //@todo add FORM_IMPLEMENTATION_PATTERN to CommonProperties, then use here final String pattern = "{0}FormImpl"; return pattern.replaceFirst( "\\{0\\}", StringUtils.capitalize(this.getTriggerName())); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFullyQualifiedFormImplementationName() */ protected java.lang.String handleGetFullyQualifiedFormImplementationName() { final StringBuffer fullyQualifiedName = new StringBuffer(); final String packageName = this.getPackageName(); if (StringUtils.isNotBlank(packageName)) { fullyQualifiedName.append(packageName + '.'); } return fullyQualifiedName.append(this.getFormImplementationName()).toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFullyQualifiedFormImplementationPath() */ protected java.lang.String handleGetFullyQualifiedFormImplementationPath() { return this.getFullyQualifiedFormImplementationName().replace( '.', '/'); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getHiddenParameters() */ protected List handleGetHiddenParameters() { final List hiddenParameters = new ArrayList(this.getParameters()); CollectionUtils.filter( hiddenParameters, new Predicate() { public boolean evaluate(final Object object) { boolean valid = false; if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; valid = parameter.isHidden(); } return valid; } }); return hiddenParameters; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getTableLinkColumnName() */ protected String handleGetTableLinkColumnName() { String tableLink = null; final Object value = findTaggedValue(AspProfile.TAGGEDVALUE_ACTION_TABLELINK); if (value != null) { tableLink = StringUtils.trimToNull(value.toString()); if (tableLink != null) { final int columnOffset = tableLink.indexOf('.'); tableLink = (columnOffset == -1 || columnOffset == tableLink.length() - 1) ? null : tableLink.substring(columnOffset + 1); } } return tableLink; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getTableLinkName() */ protected String handleGetTableLinkName() { String tableLink = null; final Object value = findTaggedValue(AspProfile.TAGGEDVALUE_ACTION_TABLELINK); if (value != null) { tableLink = StringUtils.trimToNull(value.toString()); if (tableLink != null) { final int columnOffset = tableLink.indexOf('.'); tableLink = columnOffset == -1 ? tableLink : tableLink.substring( 0, columnOffset); } } return tableLink; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getTableLinkParameter() */ protected Object handleGetTableLinkParameter() { AspParameter tableLinkParameter = null; final String tableLinkName = this.getTableLinkName(); if (tableLinkName != null) { final AspWebForm view = (AspWebForm)this.getInput(); if (view != null) { final List tables = view.getTables(); for (int ctr = 0; ctr < tables.size() && tableLinkParameter == null; ctr++) { final Object object = tables.get(ctr); if (object instanceof AspParameter) { final AspParameter table = (AspParameter)object; if (tableLinkName.equals(table.getName())) { tableLinkParameter = table; } } } } } return tableLinkParameter; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getTriggerName() */ protected String handleGetTriggerName() { String name = null; if (this.isExitingInitialState()) { final AspUseCase useCase = (AspUseCase)this.getUseCase(); if (useCase != null) { name = useCase.getNormalizedName(); } } else { final EventFacade trigger = this.getTrigger(); final String suffix = trigger == null ? this.getTarget().getName() : trigger.getName(); name = this.getSource().getName() + ' ' + suffix; } return StringUtilsHelper.lowerCamelCaseName(name); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFormImplementationPropertyName() */ protected String handleGetFormImplementationPropertyName() { return StringUtilsHelper.upperCamelCaseName(this.getTriggerName()) + "FormData"; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFormImplementationInterfaceList() */ protected String handleGetFormImplementationInterfaceList() { final List deferredOperations = this.getDeferredOperations(); for (final Iterator iterator = deferredOperations.iterator(); iterator.hasNext();) { // - remove any forms that don't have arguments final AspControllerOperation operation = (AspControllerOperation)iterator.next(); if (operation.getArguments().isEmpty()) { iterator.remove(); } } final StringBuffer list = new StringBuffer(); for (final Iterator iterator = deferredOperations.iterator(); iterator.hasNext();) { final AspControllerOperation operation = (AspControllerOperation)iterator.next(); list.append("I" + operation.getFormName()); if (iterator.hasNext()) { list.append(", "); } } return list.toString(); } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspActivityGraphLogicImpl.java Index: AspActivityGraphLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspActivityGraph. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspActivityGraph */ public class AspActivityGraphLogicImpl extends AspActivityGraphLogic { public AspActivityGraphLogicImpl(Object metaObject, String context) { super(metaObject, context); } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspParameterLogicImpl.java Index: AspParameterLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; import org.andromda.cartridges.aspdotnet.CommonProperties; import org.andromda.cartridges.aspdotnet.AspProfile; import org.andromda.metafacades.uml.ClassifierFacade; import org.andromda.metafacades.uml.FrontEndView; import org.andromda.metafacades.uml.FrontEndAction; import org.andromda.metafacades.uml.FrontEndActivityGraph; import org.andromda.metafacades.uml.TransitionFacade; import org.andromda.metafacades.uml.UMLMetafacadeUtils; import org.andromda.metafacades.uml.UMLProfile; import org.andromda.metafacades.uml.UseCaseFacade; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspParameter. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter */ public class AspParameterLogicImpl extends AspParameterLogic { public AspParameterLogicImpl(Object metaObject, String context) { super(metaObject, context); } /** * The logger instance that can be used by all decendant classes. */ protected Logger logger = Logger.getLogger(this.getClass()); /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getViewType() */ protected java.lang.String handleGetViewType() { return handleGetWidgetType(); /* String taggedValue = new String(); if (this.findTaggedValue(CommonProperties.FIELD_TYPE) != null) { taggedValue = this.findTaggedValue(CommonProperties.FIELD_TYPE) .toString(); } if (taggedValue.equals(CommonProperties.FIELD_TYPE_SELECT)) { return "DropDownList"; } else if (taggedValue.equals(CommonProperties.FIELD_TYPE_CHECKBOX)) { return "CheckBox"; } else if (taggedValue.equals(CommonProperties.FIELD_TYPE_RADIO)) { return "RadioButton"; } else if (taggedValue.equals(CommonProperties.FIELD_TYPE_LABEL)) { return "Label"; } else if (taggedValue.equals(CommonProperties.FIELD_TYPE_HIDDEN)) { return "Hidden"; } else if (this.getType().getName().equals("Blob")) { return "Image"; } else if (this.getType().getName().equals("File")) { return "file"; } else { return "TextBox"; } */ } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getWidgetType() */ protected String handleGetWidgetType() { Object value = findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE); String fieldType = value == null ? null : value.toString(); if (fieldType != null) logger.debug("[" + this.getFullyQualifiedName() + "] TAGGEDVALUE_INPUT_TYPE = " + fieldType.toString()); else logger.debug("[" + this.getFullyQualifiedName() + "] TAGGEDVALUE_INPUT_TYPE = null"); String widgetType = null; // if (isActionParameter()) // { // logger.debug("parameter is an action parameter"); if (fieldType == null) { // no widget type has been specified final ClassifierFacade type = getType(); if (type != null) { logger.debug("fieldType = " + type.getFullyQualifiedName().toString()); //@todo Input types for files are not handled correctly in getViewType() if (type.isFileType()) fieldType = AspProfile.TAGGEDVALUE_INPUT_TYPE_FILE.toString(); else if (isValidatorBoolean()) fieldType = AspProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX.toString(); else if (isMultiple()) fieldType = AspProfile.TAGGEDVALUE_INPUT_TYPE_SELECT.toString(); else fieldType = AspProfile.TAGGEDVALUE_INPUT_TYPE_TEXT.toString(); } } if (AspProfile.TAGGEDVALUE_INPUT_TYPE_SELECT.equalsIgnoreCase(fieldType)) { if (this.isMultiple()) widgetType = "ListBox"; else widgetType = "DropDownList"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD.equalsIgnoreCase(fieldType)) { widgetType = "TextBox"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_TEXTAREA.equalsIgnoreCase(fieldType)) { widgetType = "TextBox"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_HIDDEN.equalsIgnoreCase(fieldType)) { widgetType = "Hidden"; } else if (fieldType.toLowerCase().startsWith(AspProfile.TAGGEDVALUE_INPUT_TYPE_RADIO)) { widgetType = "RadioButton"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX.equalsIgnoreCase(fieldType)) { widgetType = "CheckBox"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_PLAINTEXT.equalsIgnoreCase(fieldType)) { widgetType = "Label"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_TEXT.equalsIgnoreCase(fieldType)) { widgetType = "TextBox"; } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_MULTIBOX.equalsIgnoreCase(fieldType)) { //TODO add getMultiboxPropertyName() method //if (getMultiboxPropertyName() != null) //{ widgetType = "CheckBoxList"; //} } else if (AspProfile.TAGGEDVALUE_INPUT_TYPE_LINK.equalsIgnoreCase(fieldType)) { final FrontEndAction action = this.getAction(); if (action != null) { //TODO add action.isTableLink() method //if (action.isTableLink()) //{ widgetType = "HyperLink"; //} } } else { widgetType = (isMultiple()) ? "DropDownList" : "TextBox"; } // } if (widgetType == null) widgetType = "TextBox"; logger.debug("widgetType = " + widgetType.toString()); return widgetType; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isMultiple() */ protected boolean handleIsMultiple() { boolean multiple = false; ClassifierFacade type = getType(); if (type != null) { multiple = type.isCollectionType() || type.isArrayType(); } return multiple; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getBackingListName() */ protected String handleGetBackingListName() { return ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.BACKING_LIST_PATTERN)).replaceAll( "\\{0\\}", this.getName()); } /** * @see org.andromda.cartridges.jsf.metafacades.JSFParameter#getBackingValueName() */ protected String handleGetBackingValueName() { return ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.BACKING_VALUE_PATTERN)).replaceAll( "\\{0\\}", this.getName()); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getValueListName() */ protected String handleGetValueListName() { return ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.VALUE_LIST_PATTERN)).replaceAll( "\\{0\\}", this.getName()); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getLabelListName() */ protected String handleGetLabelListName() { return ObjectUtils.toString(this.getConfiguredProperty(CommonProperties.LABEL_LIST_PATTERN)).replaceAll( "\\{0\\}", this.getName()); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getInputTableIdentifierColumns() */ protected String handleGetInputTableIdentifierColumns() { return ObjectUtils.toString(this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TABLE_IDENTIFIER_COLUMNS)).trim(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getInputValueAccessor() */ protected String handleGetInputValueAccessor() { String viewType = this.getViewType(); String valueAccessor = "UNKNOWN"; if (viewType.equalsIgnoreCase("TextBox")) valueAccessor = "Text"; else if (viewType.equalsIgnoreCase("CheckBox") || viewType.equalsIgnoreCase("RadioButton")) valueAccessor = "Checked"; else if (viewType.equalsIgnoreCase("DropDownList") || viewType.equalsIgnoreCase("CheckBoxList") || viewType.equalsIgnoreCase("RadioButtonList")) valueAccessor = "Items"; //@todo Input types for files are not handled correctly in getViewType() //else if (viewType.equalsIgnoreCase("Html)) // valueAccessor = "PostedFile"; logger.debug("[param:" + this.getName() + "] Using viewType = " + viewType + " the value accessor will be " + valueAccessor); return valueAccessor; } protected String handleGetCapitalisedName() { return StringUtils.capitalize(this.getName()); } protected boolean handleIsMandatoryField() { return !((this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_REQUIRED) == null) || this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_REQUIRED).equals("false")); } protected String handleGetRadioButtonGroup() { return this.findTaggedValue(CommonProperties.RADIO_BUTTON_GROUP) .toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getTableColumnActions(java.lang.String) */ protected List handleGetTableColumnActions(final String columnName) { final List columnActions = new ArrayList(); if (columnName != null) { final Set actions = new LinkedHashSet(this.getTableHyperlinkActions()); actions.addAll(this.getTableFormActions()); for (final Iterator iterator = actions.iterator(); iterator.hasNext();) { final AspAction action = (AspAction)iterator.next(); if (columnName.equals(action.getTableLinkColumnName())) { columnActions.add(action); } } } return columnActions; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getTableFormActions() */ protected List handleGetTableFormActions() { return this.getTableActions(false); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getTableHyperlinkActions() */ protected List handleGetTableHyperlinkActions() { return this.getTableActions(true); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getComparatorType() */ protected String handleGetComparatorType() { String type = this.getType().getName(); if (type.equals("int") || type.equals("Integer")) { return "Integer"; } else if (type.equals("double") || type.equals("Double")) { return "Double"; } else if (type.equals("float") || type.equals("Float")) { return "Double"; } else if (type.equals("long") || type.equals("Long")) { return "Integer"; } else if (type.equals("Date")) { return "Date"; } return "String"; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isReadOnly() */ protected boolean handleIsReadOnly() { return !((this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_READONLY) == null) || this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_READONLY).equals("false")); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isSelectable() */ protected boolean handleIsSelectable() { boolean selectable = false; if (this.isActionParameter()) { selectable = this.isInputMultibox() || this.isInputSelect() || this.isInputRadio(); final ClassifierFacade type = this.getType(); if (!selectable && type != null) { final String name = this.getName(); final String typeName = type.getFullyQualifiedName(); // - if the parameter is not selectable but on a targetting page it IS selectable we must // allow the user to set the backing list too final Collection views = this.getAction().getTargetViews(); for (final Iterator iterator = views.iterator(); iterator.hasNext() && !selectable;) { final FrontEndView view = (FrontEndView)iterator.next(); final Collection parameters = view.getAllActionParameters(); for (final Iterator parameterIterator = parameters.iterator(); parameterIterator.hasNext() && !selectable;) { final Object object = parameterIterator.next(); if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; final String parameterName = parameter.getName(); final ClassifierFacade parameterType = parameter.getType(); if (parameterType != null) { final String parameterTypeName = parameterType.getFullyQualifiedName(); if (name.equals(parameterName) && typeName.equals(parameterTypeName)) { selectable = parameter.isInputMultibox() || parameter.isInputSelect() || parameter.isInputRadio(); } } } } } } } else if (this.isControllerOperationArgument()) { final String name = this.getName(); final Collection actions = this.getControllerOperation().getDeferringActions(); for (final Iterator actionIterator = actions.iterator(); actionIterator.hasNext();) { final AspAction action = (AspAction)actionIterator.next(); final Collection formFields = action.getFormFields(); for (final Iterator fieldIterator = formFields.iterator(); fieldIterator.hasNext() && !selectable;) { final Object object = fieldIterator.next(); if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; if (!parameter.equals(this)) { if (name.equals(parameter.getName())) { selectable = parameter.isSelectable(); } } } } } } return selectable; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isPassword() */ protected boolean handleIsPassword() { return (this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE) != null) && this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE).equals(AspProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isTextarea() */ protected boolean handleIsTextarea() { return (this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE) != null) && this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE).equals(AspProfile.TAGGEDVALUE_INPUT_TYPE_TEXTAREA); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isInputRadio() */ protected boolean handleIsInputRadio() { return this.isInputType(CommonProperties.FIELD_TYPE_RADIO); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isInputSelect() */ protected boolean handleIsInputSelect() { return this.isInputType(CommonProperties.FIELD_TYPE_SELECT); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isInputTable() */ protected boolean handleIsInputTable() { return this.getInputTableIdentifierColumns().length() > 0 || this.isInputType(CommonProperties.INPUT_TABLE); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isInputText() */ protected boolean handleIsInputText() { return this.isInputType(CommonProperties.FIELD_TYPE_TEXT); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isInputMultibox() */ protected boolean handleIsInputMultibox() { return this.isInputType(CommonProperties.FIELD_TYPE_MULTIBOX); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isValidator() */ protected boolean handleIsValidator() { return this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_VALIDATORS) != null; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getValidator() */ protected String handleGetValidator() { if (this.isValidator()) { return this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_VALIDATORS) .toString(); } return null; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#getColumns() */ protected Collection handleGetColumns() { Collection columns = new LinkedList(); if (this.findTaggedValue(AspProfile.TAGGEDVALUE_TABLE_COLUMNS) != null) { String[] columnArray = StringUtils.split(this.findTaggedValue( AspProfile.TAGGEDVALUE_TABLE_COLUMNS).toString(), ','); for (int i = 0; i < columnArray.length; i++) { columns.add(columnArray[i]); } } return columns; } /** * @see org.andromda.metafacades.uml.FrontEndParameter#getTableColumns() */ public Collection getTableColumns() { final Collection tableColumns = super.getTableColumns(); if (tableColumns.isEmpty()) { // try to preserve the order of the elements encountered final Map tableColumnsMap = new LinkedHashMap(); // order is important final List actions = new ArrayList(); // all table actions need the exact same parameters, just not always all of them actions.addAll(this.getTableFormActions()); // if there are any actions that are hyperlinks then their parameters get priority // the user should not have modeled it that way (constraints will warn him/her) actions.addAll(this.getTableHyperlinkActions()); for (final Iterator actionIterator = actions.iterator(); actionIterator.hasNext();) { final AspAction action = (AspAction)actionIterator.next(); final Collection actionParameters = action.getParameters(); for (final Iterator parameterIterator = actionParameters.iterator(); parameterIterator.hasNext();) { final Object object = parameterIterator.next(); if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; final String parameterName = parameter.getName(); if (parameterName != null) { // never overwrite column specific table links // the hyperlink table links working on a real column get priority final Object existingObject = tableColumnsMap.get(parameterName); if (existingObject instanceof AspParameter) { final AspParameter existingParameter = (AspParameter)existingObject; if (existingParameter == null || (action.isHyperlink() && parameterName.equals(action.getTableLinkColumnName()))) { tableColumnsMap.put( parameterName, parameter); } } } } } } // for any missing parameters we just add the name of the column final Collection columnNames = this.getTableColumnNames(); for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();) { final String columnName = (String)columnNameIterator.next(); if (!tableColumnsMap.containsKey(columnName)) { tableColumnsMap.put( columnName, columnName); } } // return everything in the same order as it has been modeled (using the table tagged value) for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator.hasNext();) { final Object columnObject = columnNameIterator.next(); tableColumns.add(tableColumnsMap.get(columnObject)); } } return tableColumns; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isHidden() */ protected boolean handleIsHidden() { return (this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE) != null) && this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_TYPE).equals(AspProfile.TAGGEDVALUE_INPUT_TYPE_HIDDEN); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isEqualValidator() */ protected boolean handleIsBackingValueRequired() { boolean required = false; if (this.isActionParameter()) { logger.debug("[param:" + this.getName() + "] is an action parameter."); required = this.isInputTable(); final ClassifierFacade type = this.getType(); if (!required && type != null) { logger.debug("[param:" + this.getName() + "] not a table"); final String name = this.getName(); final String typeName = type.getFullyQualifiedName(); // - if the backing value is not required for this parameter but on // a targetting page it IS selectable we must allow the user to set the backing value as well final Collection views = this.getAction().getTargetViews(); for (final Iterator iterator = views.iterator(); iterator.hasNext() && !required;) { final FrontEndView view = (FrontEndView)iterator.next(); final Collection parameters = view.getAllActionParameters(); for (final Iterator parameterIterator = parameters.iterator(); parameterIterator.hasNext() && !required;) { final Object object = parameterIterator.next(); if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; final String parameterName = parameter.getName(); final ClassifierFacade parameterType = parameter.getType(); if (parameterType != null) { final String parameterTypeName = parameterType.getFullyQualifiedName(); if (name.equals(parameterName) && typeName.equals(parameterTypeName)) { required = parameter.isInputTable(); } } } } } } } else if (this.isControllerOperationArgument()) { logger.debug("[param:" + this.getName() + "] is an argument on a controller op"); final String name = this.getName(); final Collection actions = this.getControllerOperation().getDeferringActions(); for (final Iterator actionIterator = actions.iterator(); actionIterator.hasNext();) { final AspAction action = (AspAction)actionIterator.next(); final Collection formFields = action.getFormFields(); for (final Iterator fieldIterator = formFields.iterator(); fieldIterator.hasNext() && !required;) { final Object object = fieldIterator.next(); if (object instanceof AspParameter) { final AspParameter parameter = (AspParameter)object; if (!parameter.equals(this)) { logger.debug("[param:" + this.getName() + "] not a table"); if (name.equals(parameter.getName())) { required = parameter.isBackingValueRequired(); } } } } } } return required; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isCalendar() */ protected boolean handleIsCalendar() { return (this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_CALENDAR) != null) && this.findTaggedValue(AspProfile.TAGGEDVALUE_INPUT_CALENDAR).equals("true"); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspParameter#isComplex() */ protected boolean handleIsComplex() { boolean complex = false; final ClassifierFacade type = this.getType(); if (type != null) { complex = !type.getAttributes().isEmpty(); if (!complex) { complex = !type.getAssociationEnds().isEmpty(); } } return complex; } /** * @return <code>true</code> if the type of this field is a boolean, <code>false</code> otherwise */ private boolean isValidatorBoolean() { return UMLMetafacadeUtils.isType(this.getType(), UMLProfile.BOOLEAN_TYPE_NAME); } /** * 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()); } /** * If this is a table this method returns all those actions that are declared to work * on this table. * * @param hyperlink denotes on which type of actions to filter */ private final List getTableActions(boolean hyperlink) { final Set actions = new LinkedHashSet(); final String name = StringUtils.trimToNull(getName()); if (name != null && isTable()) { final AspWebForm view = (AspWebForm)this.getView(); final Collection allUseCases = getModel().getAllUseCases(); for (final Iterator useCaseIterator = allUseCases.iterator(); useCaseIterator.hasNext();) { final UseCaseFacade useCase = (UseCaseFacade)useCaseIterator.next(); if (useCase instanceof AspUseCase) { final FrontEndActivityGraph graph = ((AspUseCase)useCase).getActivityGraph(); if (graph != null) { final Collection transitions = graph.getTransitions(); for (final Iterator transitionIterator = transitions.iterator(); transitionIterator.hasNext();) { final TransitionFacade transition = (TransitionFacade)transitionIterator.next(); if (transition.getSource().equals(view) && transition instanceof AspAction) { final AspAction action = (AspAction)transition; if (action.isTableLink() && name.equals(action.getTableLinkName())) { if (hyperlink == action.isHyperlink()) { actions.add(action); } } } } } } } } return new ArrayList(actions); } /** * 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(AspProfile.TAGGEDVALUE_INPUT_TYPE)).trim(); } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspControllerOperationLogicImpl.java Index: AspControllerOperationLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; import org.apache.commons.lang.StringUtils; import org.andromda.metafacades.uml.ModelElementFacade; import org.andromda.utils.StringUtilsHelper; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation */ public class AspControllerOperationLogicImpl extends AspControllerOperationLogic { public AspControllerOperationLogicImpl(Object metaObject, String context) { super(metaObject, context); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getFormName() */ protected java.lang.String handleGetFormName() { //final String pattern = ObjectUtils.toString(this.getConfiguredProperty(AspGlobals.FORM_PATTERN)); //@todo Add this to the namespace and profile, then read this value from there. final String pattern = "{0}Form"; return pattern.replaceFirst("\\{0\\}", StringUtils.capitalize(this.getName())); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getFormSignature() */ protected String handleGetFormSignature() { return this.getFormSignature(true); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getFullyQualifiedFormName() */ protected java.lang.String handleGetFullyQualifiedFormName() { final StringBuffer fullyQualifiedName = new StringBuffer(); final String packageName = this.getOwner().getPackageName(); if (StringUtils.isNotBlank(packageName)) { fullyQualifiedName.append(packageName + '.'); } return fullyQualifiedName.append(StringUtils.capitalize(this.getFormName())).toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getFullyQualifiedFormPath() */ protected java.lang.String handleGetFullyQualifiedFormPath() { final StringBuffer fullyQualifiedPath = new StringBuffer(); final String packageName = this.getOwner().getPackageName(); if (StringUtils.isNotBlank(packageName)) { fullyQualifiedPath.append(packageName.replace('.', '/')); } return fullyQualifiedPath.toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getFormCall() */ protected String handleGetFormCall() { final StringBuffer call = new StringBuffer(); call.append(StringUtilsHelper.upperCamelCaseName(this.getName())); call.append("("); if (!this.getFormFields().isEmpty()) { call.append("form"); } call.append(")"); return call.toString(); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspControllerOperation#getmplementationFormSignature() */ protected String handleGetImplementationFormSignature() { return this.getFormSignature(false); } /** * Constructs the signature that takes the form for this operation. * * @param isAbstract whether or not the signature is abstract. * @return the appropriate signature. */ private final String getFormSignature(boolean isAbstract) { final StringBuffer signature = new StringBuffer(); signature.append(this.getVisibility() + ' '); if (isAbstract) { signature.append("abstract "); } else { signature.append("override "); } final ModelElementFacade returnType = this.getReturnType(); signature.append(returnType != null ? returnType.getFullyQualifiedName() : null); signature.append(" " + StringUtilsHelper.upperCamelCaseName(this.getName()) + "("); if (!this.getFormFields().isEmpty()) { signature.append("I" + this.getFormName() + " form"); } signature.append(")"); return signature.toString(); } } 1.1 cartridges/andromda-aspdotnet/src/main/java/org/andromda/cartridges/aspdotnet/metafacades/AspWebFormLogicImpl.java Index: AspWebFormLogicImpl.java =================================================================== package org.andromda.cartridges.aspdotnet.metafacades; import org.andromda.metafacades.uml.FrontEndParameter; import org.andromda.metafacades.uml.FrontEndAction; import org.andromda.utils.StringUtilsHelper; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * MetafacadeLogic implementation for org.andromda.cartridges.aspdotnet.metafacades.AspWebForm. * * @see org.andromda.cartridges.aspdotnet.metafacades.AspWebForm */ public class AspWebFormLogicImpl extends AspWebFormLogic { public AspWebFormLogicImpl(Object metaObject, String context) { super(metaObject, context); } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getActionForwards() */ protected List handleGetActionForwards() { final List actionForwards = new ArrayList(this.getForwards()); for (final Iterator iterator = actionForwards.iterator(); iterator.hasNext();) { if (!(iterator.next() instanceof AspAction)) { iterator.remove(); } } return actionForwards; } /** * @see org.andromda.cartridges.aspdotnet.metafacades.AspAction#getFormActions() */ protected List handleGetFormActions() { final List actions = new ArrayList(this.getActions()); for (final Iterator iterator = actions.iterator(); iterator.hasNext();) { final AspAction action = (AspAction)iterator.next(); if (action.getFormFields().isEmpty()) { iterator.remove(); } } return actions; } protected java.util.List handleGetForwards() { final Map forwards = new LinkedHashMap(); for (final Iterator iterator = this.getActions().iterator(); iterator.hasNext();) { final FrontEndAction action = (FrontEndAction)iterator.next(); if (action != null && !action.isUseCaseStart()) { for (final Iterator forwardIterator = action.getActionForwards().iterator(); forwardIterator.hasNext();) { final Object forward = forwardIterator.next(); if (forward instanceof AspForward) { forwards.put(((AspForward)forward).getName(), forward); } else if (forward instanceof AspAction) { forwards.put(((AspAction)forward).getName(), forward); } } } } return new ArrayList(forwards.values()); } protected String handleGetNormalizedName() { return StringUtilsHelper.upperCamelCaseName(this.getName()); } protected String handleGetFullyQualifiedPath() { return StringUtils.replaceChars(this.getPackageName(), '.', '/'); } protected Object handleGetController() { return this.getUseCase().getController(); } protected Collection handleGetTextBoxes() { /* Collection textBoxes = new LinkedList(); Collection transitions = this.getOutgoing(); for (Iterator iter = transitions.iterator(); iter.hasNext();) { AspAction transition = (AspAction) iter.next(); textBoxes.addAll(transition.getTextBoxes()); } return textBoxes; */ return null; } protected Collection handleGetDropDownLists() { /* Collection dropDownLists = new LinkedList(); Collection transitions = this.getOutgoing(); for (Iterator iter = transitions.iterator(); iter.hasNext();) { AspAction transition = (AspAction) iter.next(); dropDownLists.addAll(transition.getDropDownLists()); } return dropDownLists;*/ return null; } protected Collection handleGetCheckBoxes() { /* Collection checkBoxes = new LinkedList(); Collection transitions = this.getOutgoing(); for (Iterator iter = transitions.iterator(); iter.hasNext();) { AspAction transition = (AspAction) iter.next(); checkBoxes.addAll(transition.getCheckBoxes()); } return checkBoxes;*/ return null; } protected Collection handleGetRadioButtons() { /* Collection radioButtons = new LinkedList(); Collection transitions = this.getOutgoing(); for (Iterator iter = transitions.iterator(); iter.hasNext();) { AspAction transition = (AspAction) iter.next(); radioButtons.addAll(transition.getRadioButtons()); } return radioButtons; */ return null; } protected String handleGetLayoutPath() { StringBuffer path = new StringBuffer(); String[] arrayPath = this.getFullyQualifiedPath().split("/"); path.append("../"); for (int i = 0; i <= arrayPath.length; i++) { path.append("../"); } path.append("layout/"); return path.toString(); } protected Collection handleGetIncomingWithTable() { Collection incoming = this.getIncoming(); Collection incomingWithTable = new LinkedList(); Iterator iterator = incoming.iterator(); while (iterator.hasNext()) { Object forward = iterator.next(); if (forward != null && forward instanceof FrontEndAction) { FrontEndAction action = (FrontEndAction)forward; Iterator parameters = action.getParameters().iterator(); while (parameters.hasNext()) { FrontEndParameter param = (FrontEndParameter)parameters.next(); if (param.isTable()) incomingWithTable.add(action); } } } return incomingWithTable; } protected boolean handleIsAnHyperlinkColumns(String columnName) { /* Collection outgoings = this.getOutgoing(); Iterator iterator = outgoings.iterator(); while (iterator.hasNext()) { AspAction transition = (AspAction) iterator.next(); if (transition.isHyperlink() && (transition.findTaggedValue(CommonProperties.WEB_TABLE_LINK) != null)) { String linkName = transition.findTaggedValue(CommonProperties.WEB_TABLE_LINK) .toString(); if (columnName.equals(StringUtils.substringAfter(linkName, "."))) { return true; } } } */ return false; } protected Collection handleGetHiddenFields() { /* Collection hiddenFields = new LinkedList(); Collection transitions = this.getOutgoing(); for (Iterator iter = transitions.iterator(); iter.hasNext();) { AspAction transition = (AspAction) iter.next(); hiddenFields.addAll(transition.getHiddenFields()); } return hiddenFields; */ return null; } protected Collection handleGetAllSessionObjects() { Collection sessionObjects = new LinkedList(); Collection classes = this.getModel().getAllClasses(); Iterator iterator = classes.iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof AspSessionObject) { sessionObjects.add(obj); } } return sessionObjects; } protected Collection handleGetSessionObjects() { return ((AspController) this.getUseCase().getController()) .getSessionObjects(); } /** * @see org.andromda.cartridges.as... [truncated message content] |