User: cwbrandon
Date: 05/04/03 13:20:50
Modified: uml/uml14/src/java/org/andromda/metafacades/uml14
ModelElementFacadeLogicImpl.java
EventFacadeLogicImpl.java
PackageFacadeLogicImpl.java
ClassifierFacadeLogicImpl.java EntityLogicImpl.java
ActionFacadeLogicImpl.java
ActivityGraphFacadeLogicImpl.java
ParameterFacadeLogicImpl.java
DependencyFacadeLogicImpl.java
GeneralizableElementFacadeLogicImpl.java
ModelFacadeLogicImpl.java
ConstraintFacadeLogicImpl.java
AttributeFacadeLogicImpl.java
uml/uml14/src/test/java/org/andromda/metafacades/uml14
UMLMetafacadeUtilsTest.java
uml/common/src/java/org/andromda/metafacades/uml
UMLProfile.java
andromda-bpm4struts/src/META-INF andromda-profile.xml
andromda-bpm4struts/src/test/expected cartridge-output.zip
andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts/metafacades
StrutsParameterLogicImpl.java
andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts
Bpm4StrutsProfile.java
Added: uml/uml14/src/java/org/andromda/metafacades/uml14
UML14MetafacadeUtils.java
uml/common/src/java/org/andromda/metafacades/uml
UMLMetafacadeUtils.java
Removed: uml/uml14/src/java/org/andromda/metafacades/uml14
UMLMetafacadeUtils.java
Log:
renamed UMLMetafacadeUtils in the uml14 package to UML14MetafacadeUtils. Create a UMLMetafacadeUtils to provide utilties for the common UML metafacades. Refactor StrutsParameterLogicImpl not to use hard coded datatype names and instead use the UMLMetafacadeUtils#isType(ClassifierFacade, String).
Revision Changes Path
1.62 +6 -6 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ModelElementFacadeLogicImpl.java
Index: ModelElementFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ModelElementFacadeLogicImpl.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -w -r1.61 -r1.62
--- ModelElementFacadeLogicImpl.java 3 Apr 2005 18:47:35 -0000 1.61
+++ ModelElementFacadeLogicImpl.java 3 Apr 2005 20:19:35 -0000 1.62
@@ -63,7 +63,7 @@
*/
public String handleGetPackageName(boolean modelName)
{
- return UMLMetafacadeUtils.getPackageName(this.metaObject,
+ return UML14MetafacadeUtils.getPackageName(this.metaObject,
String.valueOf(this.getConfiguredProperty(this.getNamespaceScopeProperty(modelName))));
}
@@ -495,7 +495,7 @@
*/
protected Object handleGetRootPackage()
{
- return UMLMetafacadeUtils.getRootPackage();
+ return UML14MetafacadeUtils.getRootPackage();
}
/**
@@ -504,7 +504,7 @@
protected java.util.Collection handleGetSourceDependencies()
{
Collection dependencies = new ArrayList();
- Collection clientDependencies = UMLMetafacadeUtils.getCorePackage()
+ Collection clientDependencies = UML14MetafacadeUtils.getCorePackage()
.getAClientClientDependency().getClientDependency(this.metaObject);
if (clientDependencies != null)
{
@@ -527,7 +527,7 @@
protected Collection handleGetTargetDependencies()
{
Collection dependencies = new ArrayList();
- Collection supplierDependencies = UMLMetafacadeUtils.getCorePackage()
+ Collection supplierDependencies = UML14MetafacadeUtils.getCorePackage()
.getASupplierSupplierDependency().getSupplierDependency(
this.metaObject);
if (supplierDependencies != null)
@@ -687,7 +687,7 @@
public boolean evaluate(Object object)
{
ConstraintFacade constraint = (ConstraintFacade)object;
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
constraint.getBody(),
kind);
}
@@ -702,7 +702,7 @@
{
ActivityGraph graphContext = null;
- Collection graphs = UMLMetafacadeUtils.getModel().getActivityGraphs()
+ Collection graphs = UML14MetafacadeUtils.getModel().getActivityGraphs()
.getActivityGraph().refAllOfType();
for (Iterator graphIterator = graphs.iterator(); graphIterator
.hasNext();)
1.10 +2 -2 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/EventFacadeLogicImpl.java
Index: EventFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/EventFacadeLogicImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- EventFacadeLogicImpl.java 13 Feb 2005 05:03:48 -0000 1.9
+++ EventFacadeLogicImpl.java 3 Apr 2005 20:19:35 -0000 1.10
@@ -32,7 +32,7 @@
{
Transition eventTransition = null;
- Collection allTransitions = UMLMetafacadeUtils.getModel()
+ Collection allTransitions = UML14MetafacadeUtils.getModel()
.getStateMachines().getTransition().refAllOfType();
for (Iterator iterator = allTransitions.iterator(); iterator.hasNext()
&& eventTransition == null;)
@@ -51,7 +51,7 @@
{
ActionState eventState = null;
- Collection allActionStates = UMLMetafacadeUtils.getModel()
+ Collection allActionStates = UML14MetafacadeUtils.getModel()
.getActivityGraphs().getActionState().refAllOfType();
for (Iterator iterator = allActionStates.iterator(); iterator.hasNext()
&& eventState == null;)
1.14 +1 -1 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/PackageFacadeLogicImpl.java
Index: PackageFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/PackageFacadeLogicImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- PackageFacadeLogicImpl.java 3 Apr 2005 18:59:01 -0000 1.13
+++ PackageFacadeLogicImpl.java 3 Apr 2005 20:19:35 -0000 1.14
@@ -68,7 +68,7 @@
final String fullyQualifiedName)
{
return (ModelElementFacade)this.shieldedElement(
- UMLMetafacadeUtils.findByFullyQualifiedName(
+ UML14MetafacadeUtils.findByFullyQualifiedName(
fullyQualifiedName,
String.valueOf(this.getConfiguredProperty(
MetafacadeProperties.METAFACADE_NAMESPACE_SCOPE_OPERATOR))));
1.71 +4 -3 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ClassifierFacadeLogicImpl.java
Index: ClassifierFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ClassifierFacadeLogicImpl.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -w -r1.70 -r1.71
--- ClassifierFacadeLogicImpl.java 3 Apr 2005 18:47:35 -0000 1.70
+++ ClassifierFacadeLogicImpl.java 3 Apr 2005 20:19:35 -0000 1.71
@@ -11,6 +11,7 @@
import org.andromda.metafacades.uml.OperationFacade;
import org.andromda.metafacades.uml.TypeMappings;
import org.andromda.metafacades.uml.UMLMetafacadeProperties;
+import org.andromda.metafacades.uml.UMLMetafacadeUtils;
import org.andromda.metafacades.uml.UMLProfile;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
@@ -83,7 +84,7 @@
*/
protected java.util.Collection handleGetAssociationEnds()
{
- return UMLMetafacadeUtils.getCorePackage().getAParticipantAssociation()
+ return UML14MetafacadeUtils.getCorePackage().getAParticipantAssociation()
.getAssociation(metaObject);
}
@@ -404,10 +405,10 @@
String fullyQualifiedType,
String visibility)
{
- CorePackage corePackage = UMLMetafacadeUtils.getCorePackage();
+ CorePackage corePackage = UML14MetafacadeUtils.getCorePackage();
Attribute attribute = corePackage.getAttribute().createAttribute();
attribute.setName(name);
- attribute.setVisibility(UMLMetafacadeUtils
+ attribute.setVisibility(UML14MetafacadeUtils
.getVisibilityKind(visibility));
this.metaObject.getFeature().add(attribute);
}
1.3 +3 -3 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/EntityLogicImpl.java
Index: EntityLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/EntityLogicImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- EntityLogicImpl.java 3 Apr 2005 18:47:35 -0000 1.2
+++ EntityLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.3
@@ -147,9 +147,9 @@
{
// only create the identifier if an identifer with the name doesn't
// already exist
- if (!UMLMetafacadeUtils.attributeExists(this.metaObject, name))
+ if (!UML14MetafacadeUtils.attributeExists(this.metaObject, name))
{
- Attribute identifier = UMLMetafacadeUtils
+ Attribute identifier = UML14MetafacadeUtils
.createAttribute(
name,
type,
@@ -157,7 +157,7 @@
String.valueOf(this.getConfiguredProperty(MetafacadeProperties.METAFACADE_NAMESPACE_SCOPE_OPERATOR)));
identifier.getStereotype().add(
- UMLMetafacadeUtils
+ UML14MetafacadeUtils
.findOrCreateStereotype(UMLProfile.STEREOTYPE_IDENTIFIER));
((Classifier)this.metaObject).getFeature().add(identifier);
1.7 +2 -2 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ActionFacadeLogicImpl.java
Index: ActionFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ActionFacadeLogicImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- ActionFacadeLogicImpl.java 13 Feb 2005 05:03:48 -0000 1.6
+++ ActionFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.7
@@ -27,7 +27,7 @@
{
Transition effectTransition = null;
- Collection allTransitions = UMLMetafacadeUtils.getModel()
+ Collection allTransitions = UML14MetafacadeUtils.getModel()
.getStateMachines().getTransition().refAllOfType();
for (Iterator iterator = allTransitions.iterator(); iterator.hasNext()
&& effectTransition == null;)
@@ -46,7 +46,7 @@
{
ActionState entryState = null;
- Collection allActionStates = UMLMetafacadeUtils.getModel()
+ Collection allActionStates = UML14MetafacadeUtils.getModel()
.getActivityGraphs().getActionState().refAllOfType();
for (Iterator iterator = allActionStates.iterator(); iterator.hasNext()
&& entryState == null;)
1.8 +1 -1 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ActivityGraphFacadeLogicImpl.java
Index: ActivityGraphFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ActivityGraphFacadeLogicImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- ActivityGraphFacadeLogicImpl.java 19 Mar 2005 12:18:42 -0000 1.7
+++ ActivityGraphFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.8
@@ -132,7 +132,7 @@
{
UseCase stateMachineUseCase = null;
- Collection useCases = UMLMetafacadeUtils.getModel().getUseCases()
+ Collection useCases = UML14MetafacadeUtils.getModel().getUseCases()
.getUseCase().refAllOfType();
for (Iterator useCaseIterator = useCases.iterator(); useCaseIterator
.hasNext()
1.18 +2 -2 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ParameterFacadeLogicImpl.java
Index: ParameterFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ParameterFacadeLogicImpl.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -w -r1.17 -r1.18
--- ParameterFacadeLogicImpl.java 29 Mar 2005 22:41:07 -0000 1.17
+++ ParameterFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.18
@@ -88,7 +88,7 @@
protected Object handleGetOperation()
{
Operation parameterOperation = null;
- Collection allOperations = UMLMetafacadeUtils.getModel().getCore()
+ Collection allOperations = UML14MetafacadeUtils.getModel().getCore()
.getOperation().refAllOfType();
for (Iterator iterator = allOperations.iterator(); iterator.hasNext()
&& parameterOperation == null;)
@@ -108,7 +108,7 @@
protected Object handleGetEvent()
{
SignalEvent parameterSignalEvent = null;
- Collection allSignalEvents = UMLMetafacadeUtils.getModel()
+ Collection allSignalEvents = UML14MetafacadeUtils.getModel()
.getStateMachines().getSignalEvent().refAllOfType();
for (Iterator iterator = allSignalEvents.iterator(); iterator.hasNext()
&& parameterSignalEvent == null;)
1.6 +2 -2 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/DependencyFacadeLogicImpl.java
Index: DependencyFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/DependencyFacadeLogicImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- DependencyFacadeLogicImpl.java 13 Feb 2005 05:03:48 -0000 1.5
+++ DependencyFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.6
@@ -61,7 +61,7 @@
public Object handleGetTargetElement()
{
Object targetElement = null;
- Collection suppliers = UMLMetafacadeUtils.getCorePackage()
+ Collection suppliers = UML14MetafacadeUtils.getCorePackage()
.getASupplierSupplierDependency().getSupplier(this.metaObject);
if (!suppliers.isEmpty())
{
@@ -76,7 +76,7 @@
protected Object handleGetSourceElement()
{
Object sourceElement = null;
- Collection clients = UMLMetafacadeUtils.getCorePackage()
+ Collection clients = UML14MetafacadeUtils.getCorePackage()
.getAClientClientDependency().getClient(this.metaObject);
if (!clients.isEmpty())
{
1.7 +1 -1 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/GeneralizableElementFacadeLogicImpl.java
Index: GeneralizableElementFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/GeneralizableElementFacadeLogicImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- GeneralizableElementFacadeLogicImpl.java 19 Mar 2005 04:19:45 -0000 1.6
+++ GeneralizableElementFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.7
@@ -77,7 +77,7 @@
*/
public Collection handleGetSpecializations()
{
- Collection specializations = new ArrayList(UMLMetafacadeUtils
+ Collection specializations = new ArrayList(UML14MetafacadeUtils
.getCorePackage().getAParentSpecialization().getSpecialization(
this.metaObject));
CollectionUtils.transform(specializations, new Transformer()
1.13 +10 -10 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ModelFacadeLogicImpl.java
Index: ModelFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ModelFacadeLogicImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- ModelFacadeLogicImpl.java 13 Feb 2005 05:03:48 -0000 1.12
+++ ModelFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.13
@@ -58,7 +58,7 @@
String tag,
String value)
{
- return (UseCaseFacade)shieldedElement(UMLMetafacadeUtils
+ return (UseCaseFacade)shieldedElement(UML14MetafacadeUtils
.findUseCaseWithTaggedValueOrHyperlink(tag, value));
}
@@ -66,13 +66,13 @@
String tag,
String value)
{
- return (ClassifierFacade)shieldedElement(UMLMetafacadeUtils
+ return (ClassifierFacade)shieldedElement(UML14MetafacadeUtils
.findClassWithTaggedValueOrHyperlink(tag, value));
}
protected ActivityGraphFacade handleFindActivityGraphByName(String name)
{
- return (ActivityGraphFacade)shieldedElement(UMLMetafacadeUtils
+ return (ActivityGraphFacade)shieldedElement(UML14MetafacadeUtils
.findFirstActivityGraphWithName(name));
}
@@ -80,13 +80,13 @@
String name,
String stereotypeName)
{
- return (ActivityGraphFacade)shieldedElement(UMLMetafacadeUtils
+ return (ActivityGraphFacade)shieldedElement(UML14MetafacadeUtils
.findFirstActivityGraphWithNameAndStereotype(name, stereotypeName));
}
protected UseCaseFacade handleFindUseCaseByName(String name)
{
- return (UseCaseFacade)shieldedElement(UMLMetafacadeUtils
+ return (UseCaseFacade)shieldedElement(UML14MetafacadeUtils
.findFirstUseCaseWithName(name));
}
@@ -94,15 +94,15 @@
String name,
String stereotypeName)
{
- return (UseCaseFacade)shieldedElement(UMLMetafacadeUtils
+ return (UseCaseFacade)shieldedElement(UML14MetafacadeUtils
.findFirstUseCaseWithNameAndStereotype(name, stereotypeName));
}
protected Collection handleFindFinalStatesWithNameOrHyperlink(
UseCaseFacade useCase)
{
- UseCase useCaseMetaClass = UMLMetafacadeUtils.getMetaClass(useCase);
- return shieldedElements(UMLMetafacadeUtils
+ UseCase useCaseMetaClass = UML14MetafacadeUtils.getMetaClass(useCase);
+ return shieldedElements(UML14MetafacadeUtils
.findFinalStatesWithNameOrHyperlink(useCaseMetaClass));
}
@@ -110,7 +110,7 @@
ActivityGraphFacade activityGraph,
String stereotypeName)
{
- ActivityGraph activityGraphMetaClass = UMLMetafacadeUtils
+ ActivityGraph activityGraphMetaClass = UML14MetafacadeUtils
.getMetaClass(activityGraph);
CompositeState compositeState = (CompositeState)activityGraphMetaClass
@@ -134,7 +134,7 @@
public boolean evaluate(Object o)
{
return (o instanceof ActionState)
- && UMLMetafacadeUtils.isStereotypePresent(
+ && UML14MetafacadeUtils.isStereotypePresent(
(ModelElement)o,
stereotypeName);
}
1.13 +5 -5 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ConstraintFacadeLogicImpl.java
Index: ConstraintFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/ConstraintFacadeLogicImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- ConstraintFacadeLogicImpl.java 12 Mar 2005 17:55:09 -0000 1.12
+++ ConstraintFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.13
@@ -59,7 +59,7 @@
*/
public boolean handleIsInvariant()
{
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
getBody(),
ExpressionKinds.INV);
}
@@ -69,7 +69,7 @@
*/
public boolean handleIsPreCondition()
{
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
getBody(),
ExpressionKinds.PRE);
}
@@ -79,7 +79,7 @@
*/
public boolean handleIsPostCondition()
{
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
getBody(),
ExpressionKinds.POST);
}
@@ -89,7 +89,7 @@
*/
public boolean handleIsDefinition()
{
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
getBody(),
ExpressionKinds.DEF);
}
@@ -99,7 +99,7 @@
*/
public boolean handleIsBodyExpression()
{
- return UMLMetafacadeUtils.isConstraintKind(
+ return UML14MetafacadeUtils.isConstraintKind(
getBody(),
ExpressionKinds.BODY);
}
1.39 +1 -0 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/AttributeFacadeLogicImpl.java
Index: AttributeFacadeLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/AttributeFacadeLogicImpl.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -w -r1.38 -r1.39
--- AttributeFacadeLogicImpl.java 3 Apr 2005 07:30:45 -0000 1.38
+++ AttributeFacadeLogicImpl.java 3 Apr 2005 20:19:36 -0000 1.39
@@ -8,6 +8,7 @@
import org.andromda.metafacades.uml.NameMasker;
import org.andromda.metafacades.uml.TypeMappings;
import org.andromda.metafacades.uml.UMLMetafacadeProperties;
+import org.andromda.metafacades.uml.UMLMetafacadeUtils;
import org.andromda.metafacades.uml.UMLProfile;
import org.apache.commons.lang.StringUtils;
import org.omg.uml.foundation.datatypes.ChangeableKindEnum;
1.1 metafacades/uml/uml14/src/java/org/andromda/metafacades/uml14/UML14MetafacadeUtils.java
Index: UML14MetafacadeUtils.java
===================================================================
package org.andromda.metafacades.uml14;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.andromda.core.metafacade.MetafacadeFactory;
import org.andromda.metafacades.uml.ActivityGraphFacade;
import org.andromda.metafacades.uml.EventFacade;
import org.andromda.metafacades.uml.ModelElementFacade;
import org.andromda.metafacades.uml.ParameterFacade;
import org.andromda.metafacades.uml.UseCaseFacade;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
import org.omg.uml.behavioralelements.activitygraphs.ActivityGraph;
import org.omg.uml.behavioralelements.statemachines.Event;
import org.omg.uml.behavioralelements.statemachines.FinalState;
import org.omg.uml.behavioralelements.usecases.UseCase;
import org.omg.uml.foundation.core.Attribute;
import org.omg.uml.foundation.core.Classifier;
import org.omg.uml.foundation.core.CorePackage;
import org.omg.uml.foundation.core.ModelElement;
import org.omg.uml.foundation.core.Parameter;
import org.omg.uml.foundation.core.Stereotype;
import org.omg.uml.foundation.core.TaggedValue;
import org.omg.uml.foundation.core.UmlClass;
import org.omg.uml.foundation.datatypes.VisibilityKind;
import org.omg.uml.foundation.datatypes.VisibilityKindEnum;
import org.omg.uml.modelmanagement.Model;
import org.omg.uml.modelmanagement.UmlPackage;
/**
* Utilities for dealing with UML 1.4 metafacades
*
* @author Chad Brandon
*/
public class UML14MetafacadeUtils
{
/**
* Finds a given model element in the model having the specified
* <code>fullyQualifiedName</code>. If the model element can <strong>NOT
* </strong> be found, <code>null</code> will be returned instead.
*
* @param fullyQualifiedName the fully qualified name of the element to
* search for.
* @param separator the separator used for qualifying the name (example
* '::').
* @return the found model element
*/
static Object findByFullyQualifiedName(
final String fullyQualifiedName,
final String separator)
{
Object modelElement = null;
Collection elements = ((org.omg.uml.UmlPackage)MetafacadeFactory
.getInstance().getModel().getModel()).getCore().getModelElement()
.refAllOfType();
modelElement = CollectionUtils.find(elements, new Predicate()
{
public boolean evaluate(Object object)
{
ModelElement element = (ModelElement)object;
StringBuffer fullName = new StringBuffer(getPackageName(
element,
separator));
String name = element.getName();
if (StringUtils.isNotBlank(name))
{
fullName.append(separator);
fullName.append(name);
}
return fullName.toString().equals(fullyQualifiedName);
}
});
return modelElement;
}
/**
* Constructs the package name for the given <code>metaObject</code>,
* seperating the package name by the given <code>separator</code>.
*
* @param metaObject the Model Element
* @return
*/
static String getPackageName(ModelElement metaObject, String separator)
{
String packageName = "";
for (ModelElement namespace = metaObject.getNamespace(); (namespace instanceof UmlPackage)
&& !(namespace instanceof Model); namespace = namespace
.getNamespace())
{
packageName = packageName.equals("")
? namespace.getName()
: namespace.getName() + separator + packageName;
}
return packageName;
}
/**
* Basically just checks to make sure the <code>model</code> is of type
* <code>org.omg.uml.UmlPackage</code> and retrieves the
* <code>CorePackage</code> from it.
*
* @param model the model form which to retrieve the core package.
* @return the <code>model</code> as a <code>org.omg.uml.UmlPackage</code>
*/
static CorePackage getCorePackage()
{
return ((org.omg.uml.UmlPackage)MetafacadeFactory.getInstance()
.getModel().getModel()).getCore();
}
/**
* Finds and returns the first model element having the given
* <code>name</code> in the <code>modelPackage</code>, returns
* <code>null</code> if not found.
*
* @param modelPackage The modelPackage to search
* @param name the name to find.
* @return the found model element.
*/
static Object findByName(final String name)
{
Object modelElement = null;
if (StringUtils.isNotBlank(name))
{
modelElement = CollectionUtils.find(getModel().getCore()
.getModelElement().refAllOfType(), new Predicate()
{
public boolean evaluate(Object object)
{
return StringUtils.trimToEmpty(
((ModelElement)object).getName()).equals(name);
}
});
}
return modelElement;
}
/**
* Gets the root package in the model.
*
* @return the root package as a UmlPackage.
*/
static UmlPackage getRootPackage()
{
Object rootPackage = null;
Collection rootPackages = UML14MetafacadeUtils.getModel()
.getModelManagement().getModel().refAllOfType();
Iterator packageIt = rootPackages.iterator();
while (packageIt.hasNext())
{
rootPackage = packageIt.next();
// get the first package that's a ModelElement
// instance
if (rootPackage instanceof ModelElement)
{
break;
}
}
return (UmlPackage)rootPackage;
}
/**
* Returns the entire model.
*
* @return org.omg.uml.UmlPackage model instance.
*/
static org.omg.uml.UmlPackage getModel()
{
return (org.omg.uml.UmlPackage)MetafacadeFactory.getInstance()
.getModel().getModel();
}
/**
* Gets the correct meta model visibility kind for the given
* <code>visibility</code> string.
*
* @param visibility the visibility to retrieve.
* @return the VisibilityKind
*/
static VisibilityKind getVisibilityKind(String visibility)
{
VisibilityKind visibilityKind = null;
visibility = StringUtils.trimToEmpty(visibility);
if (visibility.equals("public"))
{
visibilityKind = VisibilityKindEnum.VK_PUBLIC;
}
else if (visibility.equals("private"))
{
visibilityKind = VisibilityKindEnum.VK_PRIVATE;
}
else if (visibility.equals(""))
{
visibilityKind = VisibilityKindEnum.VK_PACKAGE;
}
else if (visibility.equals("protected"))
{
visibilityKind = VisibilityKindEnum.VK_PROTECTED;
}
return visibilityKind;
}
/**
* Creates an attribute having the give <code>name</code> and the type
* having the given <code>fullyQualifiedTypeName</code>, with the
* specified visibility, if no type can be found with the given name, no
* type is set.
*
* @param name the new name
* @param fullyQualifiedTypeName the name of the fully qualified type
* @param visibility the visibility name
* @param the separator used for qualifying the name.
* @return the new Attribute.
*/
static Attribute createAttribute(
String name,
String fullyQualifiedTypeName,
String visibility,
String separator)
{
Attribute attribute = UML14MetafacadeUtils.getCorePackage()
.getAttribute().createAttribute();
attribute.setName(name);
attribute.setVisibility(UML14MetafacadeUtils
.getVisibilityKind(visibility));
Object type = UML14MetafacadeUtils.findByFullyQualifiedName(
fullyQualifiedTypeName,
separator);
if (type != null && Classifier.class.isAssignableFrom(type.getClass()))
{
attribute.setType((Classifier)type);
}
return attribute;
}
/**
* Indicates whether or not the attribute exists on the given
* </code>classifier</code>.
*
* @param classifier the classifier to check
* @param name the name of the attribute
* @return
*/
static boolean attributeExists(Object classifier, String name)
{
boolean exists = false;
if (Classifier.class.isAssignableFrom(classifier.getClass()))
{
List features = ((Classifier)classifier).getFeature();
if (features != null && !features.isEmpty())
{
for (Iterator featureIterator = features.iterator(); featureIterator.hasNext();)
{
Object feature = featureIterator.next();
if (feature != null && Attribute.class.isAssignableFrom(feature.getClass()))
{
exists = StringUtils.trimToEmpty(((Attribute)feature).getName()).equals(name);
}
}
}
}
return exists;
}
/**
* Finds or creates a stereotype with the given name. If the stereotype
* isn't found, it will be created.
*
* @param name the name of the stereotype.
* @return the new Stereotype.
*/
static Stereotype findOrCreateStereotype(String name)
{
Object stereotype = UML14MetafacadeUtils.findByName(name);
if (stereotype == null
|| !Stereotype.class.isAssignableFrom(stereotype.getClass()))
{
stereotype = UML14MetafacadeUtils.getCorePackage().getStereotype()
.createStereotype();
((Stereotype)stereotype).setName(name);
}
return (Stereotype)stereotype;
}
/**
* Returns true if the passed in constraint <code>expression</code> is of
* type <code>kind</code>, false otherwise.
*
* @param expression the expression to check.
* @param kind the constraint kind (i.e. <em>inv</em>,<em>pre</em>,
* <em>body</em>, etc).
* @return boolean
*/
static boolean isConstraintKind(String expression, String kind)
{
Pattern pattern = Pattern
.compile(".*\\s*" + StringUtils.trimToEmpty(kind)
+ "\\s*\\w*\\s*:.*", Pattern.DOTALL);
Matcher matcher = pattern.matcher(StringUtils.trimToEmpty(expression));
return matcher.matches();
}
/**
* Returns the first use-case it can find with the given name.
*/
static UseCase findFirstUseCaseWithName(String name)
{
return findFirstUseCaseWithNameAndStereotype(name, null);
}
/**
* Returns the first use-case it can find with the given name and
* stereotype, if the stereotype is not specified (it is null) it will be
* ignored and the returned use-case may have any arbitrary stereotype.
*/
static UseCase findFirstUseCaseWithNameAndStereotype(
String name,
String stereotypeName)
{
UseCase useCaseWithNameAndStereotype = null;
Collection useCases = getModel().getUseCases().getUseCase()
.refAllOfType();
for (Iterator useCaseIterator = useCases.iterator(); useCaseIterator
.hasNext()
&& useCaseWithNameAndStereotype == null;)
{
UseCase useCase = (UseCase)useCaseIterator.next();
if (name.equals(useCase.getName()))
{
if (stereotypeName == null
|| isStereotypePresent(useCase, stereotypeName))
{
useCaseWithNameAndStereotype = useCase;
}
}
}
return useCaseWithNameAndStereotype;
}
/**
* Returns the first activity graph it can find with the given name.
*/
static ActivityGraph findFirstActivityGraphWithName(String name)
{
return findFirstActivityGraphWithNameAndStereotype(name, null);
}
/**
* Returns the first activity graph it can find with the given name and
* stereotype, if the stereotype is not specified (it is null) it will be
* ignored and the returned activity graph may have any arbitrary
* stereotype.
*/
static ActivityGraph findFirstActivityGraphWithNameAndStereotype(
String name,
String stereotypeName)
{
ActivityGraph graphWithNameAndStereotype = null;
Collection graphs = getModel().getActivityGraphs().getActivityGraph()
.refAllOfType();
for (Iterator graphIterator = graphs.iterator(); graphIterator
.hasNext()
&& graphWithNameAndStereotype == null;)
{
ActivityGraph graph = (ActivityGraph)graphIterator.next();
if (name.equals(graph.getName()))
{
if (stereotypeName == null
|| isStereotypePresent(graph, stereotypeName))
{
graphWithNameAndStereotype = graph;
}
}
}
return graphWithNameAndStereotype;
}
/**
* Returns true if the given model element has a tag with the given name and
* value, returns false otherwise.
*/
static boolean isTagPresent(ModelElement element, String tag, Object value)
{
boolean tagPresent = false;
Collection taggedValues = element.getTaggedValue();
for (Iterator taggedValueIterator = taggedValues.iterator(); taggedValueIterator
.hasNext()
&& !tagPresent;)
{
TaggedValue taggedValue = (TaggedValue)taggedValueIterator.next();
if (tag.equals(taggedValue.getName()))
{
for (Iterator valueIterator = taggedValue.getDataValue()
.iterator(); valueIterator.hasNext() && !tagPresent;)
{
Object dataValue = valueIterator.next();
if (value.equals(dataValue))
{
tagPresent = true;
}
}
for (Iterator valueIterator = taggedValue.getReferenceValue()
.iterator(); valueIterator.hasNext() && !tagPresent;)
{
Object referenceValue = valueIterator.next();
if (value.equals(referenceValue))
{
tagPresent = true;
}
}
}
}
return tagPresent;
}
/**
* Returns true if the given model element has a hyperlink with the given
* value, returns false otherwise.
*/
static boolean isHyperlinkPresent(ModelElement element, Object value)
{
return isTagPresent(element, "hyperlinkModel", value);
}
static boolean isStereotypePresent(
ModelElement element,
String stereotypeName)
{
boolean stereotypePresent = false;
Collection stereotypes = element.getStereotype();
for (Iterator stereotypeIterator = stereotypes.iterator(); stereotypeIterator
.hasNext()
&& !stereotypePresent;)
{
Stereotype stereotype = (Stereotype)stereotypeIterator.next();
if (stereotypeName.equals(stereotype.getName()))
{
stereotypePresent = true;
}
}
return stereotypePresent;
}
/**
* Returns the first use-case this method can find with the given tagged
* value or hyperlink. Both arguments are used to look for the tagged value
* but only <code>value</code> is used to search for the hyperlink.
*/
static UseCase findUseCaseWithTaggedValueOrHyperlink(
String tag,
String value)
{
UseCase useCaseWithTaggedValue = null;
Collection useCases = getModel().getUseCases().getUseCase()
.refAllOfType();
for (Iterator useCaseIterator = useCases.iterator(); useCaseIterator
.hasNext()
&& useCaseWithTaggedValue == null;)
{
// loop over all use-cases
UseCase useCase = (UseCase)useCaseIterator.next();
if (isTagPresent(useCase, tag, value)
|| isHyperlinkPresent(useCase, value))
{
useCaseWithTaggedValue = useCase;
}
}
return useCaseWithTaggedValue;
}
/**
* Returns the first class this method can find with the given tagged value
* or hyperlink. Both arguments are used to look for the tagged value but
* only <code>value</code> is used to search for the hyperlink.
*/
static UmlClass findClassWithTaggedValueOrHyperlink(String tag, String value)
{
UmlClass classWithTaggedValue = null;
Collection classes = getModel().getCore().getUmlClass().refAllOfType();
for (Iterator classIterator = classes.iterator(); classIterator
.hasNext()
&& classWithTaggedValue == null;)
{
// loop over all use-cases
UmlClass clazz = (UmlClass)classIterator.next();
if (isTagPresent(clazz, tag, value)
|| isHyperlinkPresent(clazz, value))
{
classWithTaggedValue = clazz;
}
}
return classWithTaggedValue;
}
static Collection findFinalStatesWithNameOrHyperlink(UseCase useCase)
{
List finalStates = new ArrayList();
if (useCase != null && useCase.getName() != null)
{
String useCaseName = useCase.getName();
Collection allFinalStates = getModel().getStateMachines()
.getFinalState().refAllOfType();
for (Iterator iterator = allFinalStates.iterator(); iterator
.hasNext();)
{
FinalState finalState = (FinalState)iterator.next();
if (useCaseName != null)
{
if (useCaseName.equals(finalState.getName()))
{
finalStates.add(finalState);
}
else
{
if (isHyperlinkPresent(finalState, useCase))
{
finalStates.add(finalState);
}
}
}
else
{
if (isHyperlinkPresent(finalState, useCase))
{
finalStates.add(finalState);
}
}
}
}
return finalStates;
}
/**
* Finds the given metafacade class for the passed in <code>facade</code>.
*
* @param facade the model element facade for which to find the meta class.
* @return the meta model element
*/
static ActivityGraph getMetaClass(ActivityGraphFacade facade)
{
ActivityGraph activityGraph = null;
if (facade != null)
{
String id = facade.getId();
Collection graphs = getModel().getActivityGraphs()
.getActivityGraph().refAllOfType();
for (Iterator iterator = graphs.iterator(); iterator.hasNext()
&& activityGraph == null;)
{
ModelElement element = (ModelElement)iterator.next();
if (id.equals(element.refMofId()))
{
activityGraph = (ActivityGraph)element;
}
}
}
return activityGraph;
}
/**
* Finds the given metafacade class for the passed in <code>facade</code>.
*
* @param facade the model element facade for which to find the meta class.
* @return the meta model element
*/
static UseCase getMetaClass(UseCaseFacade facade)
{
UseCase useCase = null;
if (facade != null)
{
String id = facade.getId();
Collection useCases = getModel().getUseCases().getUseCase()
.refAllOfType();
for (Iterator iterator = useCases.iterator(); iterator.hasNext()
&& useCase == null;)
{
ModelElement element = (ModelElement)iterator.next();
if (id.equals(element.refMofId()))
{
useCase = (UseCase)element;
}
}
}
return useCase;
}
/**
* Finds the given metafacade class for the passed in <code>facade</code>.
*
* @param facade the model element facade for which to find the meta class.
* @return the meta model element
*/
static Parameter getMetaClass(ParameterFacade facade)
{
Parameter parameter = null;
if (facade != null)
{
String id = facade.getId();
Collection parameters = getModel().getCore().getParameter()
.refAllOfType();
for (Iterator iterator = parameters.iterator(); iterator.hasNext()
&& parameter == null;)
{
ModelElement element = (ModelElement)iterator.next();
if (id.equals(element.refMofId()))
{
parameter = (Parameter)element;
}
}
}
return parameter;
}
/**
* Finds the given metafacade class for the passed in <code>facade</code>.
*
* @param facade the model element facade for which to find the meta class.
* @return the meta model element
*/
static Event getMetaClass(EventFacade facade)
{
Event event = null;
if (facade != null)
{
String id = facade.getId();
Collection events = getModel().getStateMachines().getEvent()
.refAllOfType();
for (Iterator iterator = events.iterator(); iterator.hasNext()
&& event == null;)
{
ModelElement element = (ModelElement)iterator.next();
if (id.equals(element.refMofId()))
{
event = (Event)element;
}
}
}
return event;
}
/**
* Finds the given metafacade class for the passed in <code>facade</code>.
*
* @param facade the model element facade for which to find the meta class.
* @return the meta model element
*/
static ModelElement getMetaClass(ModelElementFacade facade)
{
ModelElement modelElement = null;
if (facade != null)
{
String id = facade.getId();
Collection modelElements = getModel().getCore().getModelElement()
.refAllOfType();
for (Iterator iterator = modelElements.iterator(); iterator
.hasNext()
&& modelElement == null;)
{
ModelElement element = (ModelElement)iterator.next();
if (id.equals(element.refMofId()))
{
modelElement = element;
}
}
}
return modelElement;
}
}
1.3 +5 -5 metafacades/uml/uml14/src/test/java/org/andromda/metafacades/uml14/UMLMetafacadeUtilsTest.java
Index: UMLMetafacadeUtilsTest.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/uml14/src/test/java/org/andromda/metafacades/uml14/UMLMetafacadeUtilsTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- UMLMetafacadeUtilsTest.java 12 Mar 2005 17:54:44 -0000 1.2
+++ UMLMetafacadeUtilsTest.java 3 Apr 2005 20:19:37 -0000 1.3
@@ -13,24 +13,24 @@
public void testIsConstraintKind()
{
final String emptyExpression = "";
- assertFalse(UMLMetafacadeUtils.isConstraintKind(
+ assertFalse(UML14MetafacadeUtils.isConstraintKind(
emptyExpression,
ExpressionKinds.BODY));
final String bodyExpressionWithName = "context DecisionItem::findRoot():Collection(DecisionItem) body findByRootBody : allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
- assertTrue(UMLMetafacadeUtils.isConstraintKind(
+ assertTrue(UML14MetafacadeUtils.isConstraintKind(
bodyExpressionWithName,
ExpressionKinds.BODY));
final String bodyExpressionNoName = "context DecisionItem::findRoot():Collection(DecisionItem) body : allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
- assertTrue(UMLMetafacadeUtils.isConstraintKind(
+ assertTrue(UML14MetafacadeUtils.isConstraintKind(
bodyExpressionNoName,
ExpressionKinds.BODY));
final String bodyExpressionNoColon = "context DecisionItem::findRoot():Collection(DecisionItem) body allInstances() -> select (decisionItem | decisionItem.rootItem = true)";
- assertFalse(UMLMetafacadeUtils.isConstraintKind(
+ assertFalse(UML14MetafacadeUtils.isConstraintKind(
bodyExpressionNoColon,
ExpressionKinds.BODY));
final String invExpressionNoName = "context CustomerCard\r\n" +
"inv: validFrom.isBefore(goodThru)";
- assertTrue(UMLMetafacadeUtils.isConstraintKind(
+ assertTrue(UML14MetafacadeUtils.isConstraintKind(
invExpressionNoName,
ExpressionKinds.INV));
}
1.42 +4 -4 metafacades/uml/common/src/java/org/andromda/metafacades/uml/UMLProfile.java
Index: UMLProfile.java
===================================================================
RCS file: /cvsroot/andromda/metafacades/uml/common/src/java/org/andromda/metafacades/uml/UMLProfile.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- UMLProfile.java 26 Mar 2005 19:14:47 -0000 1.41
+++ UMLProfile.java 3 Apr 2005 20:19:37 -0000 1.42
@@ -198,25 +198,25 @@
public static final String DATE_TYPE_NAME = profile.get("DATE_TYPE");
/**
- * Used to indentify a boolean type in the model, any other type that will
+ * Used to identify a boolean type in the model, any other type that will
* be identified as a boolean type must specialize this type.
*/
public static final String BOOLEAN_TYPE_NAME = profile.get("BOOLEAN_TYPE");
/**
- * Used to indentify a file type in the model, any other type that will be
+ * Used to identify a file type in the model, any other type that will be
* identified as a file type must specialize this type.
*/
public static final String FILE_TYPE_NAME = profile.get("FILE_TYPE");
/**
- * Used to indentify a map type in the model, any other type that will be
+ * Used to identify a map type in the model, any other type that will be
* identified as a map type must specialize this type.
*/
public static final String MAP_TYPE_NAME = profile.get("MAP_TYPE");
/**
- * Used to indentify a string type in the model, any other type that will be
+ * Used to identify a string type in the model, any other type that will be
* identified as a string type must specialize this type.
*/
public static final String STRING_TYPE_NAME = profile.get("STRING_TYPE");
1.1 metafacades/uml/common/src/java/org/andromda/metafacades/uml/UMLMetafacadeUtils.java
Index: UMLMetafacadeUtils.java
===================================================================
package org.andromda.metafacades.uml;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.StringUtils;
/**
* Contains utilities that are common to the UML
* metafacades.
*
* @author Chad Brandon
*/
public class UMLMetafacadeUtils
{
/**
* Returns true or false depending on whether or not this Classifier or any
* of its specializations is of the given type having the specified
* <code>typeName</code>
*
* @param typeName the name of the type (i.e. datatype::Collection)
* @return true/false
*/
public static boolean isType(ClassifierFacade classifier, String typeName)
{
boolean isType = false;
if (classifier == null || typeName == null)
{
final String type = StringUtils.trimToEmpty(typeName);
String name = StringUtils.trimToEmpty(classifier.getFullyQualifiedName(true));
isType = name.equals(type);
// if this isn't a type defined by typeName, see if we can find any
// types that inherit from the type.
if (!isType)
{
isType = CollectionUtils.find(
classifier.getAllGeneralizations(),
new Predicate()
{
public boolean evaluate(Object object)
{
String name = StringUtils.trimToEmpty(
((ModelElementFacade)object).getFullyQualifiedName(true));
return name.equals(type);
}
}) != null;
}
}
return isType;
}
}
1.9 +33 -0 cartridges/andromda-bpm4struts/src/META-INF/andromda-profile.xml
Index: andromda-profile.xml
===================================================================
RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/META-INF/andromda-profile.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- andromda-profile.xml 21 Mar 2005 23:11:23 -0000 1.8
+++ andromda-profile.xml 3 Apr 2005 20:19:38 -0000 1.9
@@ -133,4 +133,37 @@
<from>ACTION_REDIRECT</from>
<to>@andromda.struts.action.redirect</to>
</mapping>
+ <!-- datatype mappings -->
+ <mapping>
+ <from>CHARACTER_TYPE</from>
+ <to>datatype::char</to>
+ </mapping>
+ <mapping>
+ <from>BYTE_TYPE</from>
+ <to>datatype::byte</to>
+ </mapping>
+ <mapping>
+ <from>SHORT_TYPE</from>
+ <to>datatype::short</to>
+ </mapping>
+ <mapping>
+ <from>INTEGER_TYPE</from>
+ <to>datatype::int</to>
+ </mapping>
+ <mapping>
+ <from>LONG_TYPE</from>
+ <to>datatype::long</to>
+ </mapping>
+ <mapping>
+ <from>FLOAT_TYPE</from>
+ <to>datatype::float</to>
+ </mapping>
+ <mapping>
+ <from>DOUBLE_TYPE</from>
+ <to>datatype::double</to>
+ </mapping>
+ <mapping>
+ <from>URL_TYPE</from>
+ <to>datatype::URL</to>
+ </mapping>
</mappings>
\ No newline at end of file
1.197 +1207 -1017cartridges/andromda-bpm4struts/src/test/expected/cartridge-output.zip
<<Binary file>>
1.92 +69 -71 cartridges/andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts/metafacades/StrutsParameterLogicImpl.java
Index: StrutsParameterLogicImpl.java
===================================================================
RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts/metafacades/StrutsParameterLogicImpl.java,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -w -r1.91 -r1.92
--- StrutsParameterLogicImpl.java 3 Apr 2005 18:47:47 -0000 1.91
+++ StrutsParameterLogicImpl.java 3 Apr 2005 20:20:49 -0000 1.92
@@ -7,6 +7,8 @@
import org.andromda.metafacades.uml.ClassifierFacade;
import org.andromda.metafacades.uml.EventFacade;
import org.andromda.metafacades.uml.TransitionFacade;
+import org.andromda.metafacades.uml.UMLMetafacadeUtils;
+import org.andromda.metafacades.uml.UMLProfile;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
@@ -120,7 +122,7 @@
*/
protected java.lang.String handleGetGetterName()
{
- String prefix = isValidatorBoolean(getFullyQualifiedName(true)) ? "is" : "get";
+ String prefix = isValidatorBoolean() ? "is" : "get";
return StringUtils.trimToEmpty(prefix) + StringUtilsHelper.capitalize(this.getName());
}
@@ -169,8 +171,7 @@
}
else
{
- final String typeName = type.getFullyQualifiedName(true);
- resetRequired = isValidatorBoolean(typeName);
+ resetRequired = isValidatorBoolean();
}
}
}
@@ -366,64 +367,63 @@
buffer.append(crlf);
}
- String datatype = getFullyQualifiedName(true);
- if (isValidatorBoolean(datatype))
+ if (isValidatorBoolean())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">boolean</a> value");
buffer.append(crlf);
}
- else if (isValidatorByte(datatype))
+ else if (isValidatorByte())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">byte</a> value");
buffer.append(crlf);
}
- else if (isValidatorChar(datatype))
+ else if (isValidatorChar())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">character</a> value");
buffer.append(crlf);
}
- else if (isValidatorDouble(datatype))
+ else if (isValidatorDouble())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">double precision integer</a> value");
buffer.append(crlf);
}
- else if (isValidatorFloat(datatype))
+ else if (isValidatorFloat())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">floating point</a> value");
buffer.append(crlf);
}
- else if (isValidatorInteger(datatype))
+ else if (isValidatorInteger())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">integer</a> value");
buffer.append(crlf);
}
- else if (isValidatorLong(datatype))
+ else if (isValidatorLong())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">long integer</a> value");
buffer.append(crlf);
}
- else if (isValidatorShort(datatype))
+ else if (isValidatorShort())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" " +
"target=\"_jdk\">short integer</a> value");
buffer.append(crlf);
}
- else if (isValidatorUrl(datatype))
+ else if (isValidatorUrl())
{
buffer.append("The value of this field should reflect a " +
"<a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html\" " +
@@ -781,7 +781,7 @@
{
if (type.isFileType())
widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_FILE;
- else if (isValidatorBoolean(parameterType))
+ else if (isValidatorBoolean())
widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX;
else if (isMultiple())
widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_SELECT;
@@ -1041,32 +1041,31 @@
if (type != null)
{
final String name = getName();
- final String typeName = type.getFullyQualifiedName(true);
- if (isValidatorString(typeName)) return "\"" + name + "-test" + "\"";
- if (isValidatorDate(typeName)) return "new java.util.Date()";
+ if (isValidatorString()) return "\"" + name + "-test" + "\"";
+ if (isValidatorDate()) return "new java.util.Date()";
if (type.isPrimitive())
{
- if (isValidatorInteger(typeName)) return "(int)" + name.hashCode();
- if (isValidatorBoolean(typeName)) return "false";
- if (isValidatorLong(typeName)) return "(long)" + name.hashCode();
- if (isValidatorChar(typeName)) return "(char)" + name.hashCode();
- if (isValidatorFloat(typeName)) return "(float)" + name.hashCode() / hashCode();
- if (isValidatorDouble(typeName)) return "(double)" + name.hashCode() / hashCode();
- if (isValidatorShort(typeName)) return "(short)" + name.hashCode();
- if (isValidatorByte(typeName)) return "(byte)" + name.hashCode();
+ if (isValidatorInteger()) return "(int)" + name.hashCode();
+ if (isValidatorBoolean()) return "false";
+ if (isValidatorLong()) return "(long)" + name.hashCode();
+ if (isValidatorChar()) return "(char)" + name.hashCode();
+ if (isValidatorFloat()) return "(float)" + name.hashCode() / hashCode();
+ if (isValidatorDouble()) return "(double)" + name.hashCode() / hashCode();
+ if (isValidatorShort()) return "(short)" + name.hashCode();
+ if (isValidatorByte()) return "(byte)" + name.hashCode();
}
else
{
- if (isValidatorInteger(typeName)) return "new Integer((int)" + name.hashCode() + ")";
- if (isValidatorBoolean(typeName)) return "Boolean.FALSE";
- if (isValidatorLong(typeName)) return "new Long((long)" + name.hashCode() + ")";
- if (isValidatorChar(typeName)) return "new Character(char)" + name.hashCode() + ")";
- if (isValidatorFloat(typeName)) return "new Float((float)" + name.hashCode() / hashCode() + ")";
- if (isValidatorDouble(typeName)) return "new Double((double)" + name.hashCode() / hashCode() + ")";
- if (isValidatorShort(typeName)) return "new Short((short)" + name.hashCode() + ")";
- if (isValidatorByte(typeName)) return "new Byte((byte)" + name.hashCode() + ")";
+ if (isValidatorInteger()) return "new Integer((int)" + name.hashCode() + ")";
+ if (isValidatorBoolean()) return "Boolean.FALSE";
+ if (isValidatorLong()) return "new Long((long)" + name.hashCode() + ")";
+ if (isValidatorChar()) return "new Character(char)" + name.hashCode() + ")";
+ if (isValidatorFloat()) return "new Float((float)" + name.hashCode() / hashCode() + ")";
+ if (isValidatorDouble()) return "new Double((double)" + name.hashCode() / hashCode() + ")";
+ if (isValidatorShort()) return "new Short((short)" + name.hashCode() + ")";
+ if (isValidatorByte()) return "new Byte((byte)" + name.hashCode() + ")";
}
if (type.isArrayType()) return constructArray();
@@ -1100,37 +1099,36 @@
ClassifierFacade type = getType();
if (type != null)
{
- final String typeName = type.getFullyQualifiedName(true);
final String format = getValidatorFormat();
final boolean isRangeFormat = (format == null) ? false : isRangeFormat(format);
if (isRequired()) validatorTypesList.add("required");
- if (isValidatorByte(typeName))
+ if (isValidatorByte())
validatorTypesList.add("byte");
- else if (isValidatorShort(typeName))
+ else if (isValidatorShort())
validatorTypesList.add("short");
- else if (isValidatorInteger(typeName))
+ else if (isValidatorInteger())
validatorTypesList.add("integer");
- else if (isValidatorLong(typeName))
+ else if (isValidatorLong())
validatorTypesList.add("long");
- else if (isValidatorFloat(typeName))
+ else if (isValidatorFloat())
validatorTypesList.add("float");
- else if (isValidatorDouble(typeName))
+ else if (isValidatorDouble())
validatorTypesList.add("double");
- else if (isValidatorDate(typeName))
+ else if (isValidatorDate())
validatorTypesList.add("date");
- else if (isValidatorUrl(typeName))
+ else if (isValidatorUrl())
validatorTypesList.add("url");
if (isRangeFormat)
{
- if (isValidatorInteger(typeName)) validatorTypesList.add("intRange");
- if (isValidatorFloat(typeName)) validatorTypesList.add("floatRange");
- if (isValidatorDouble(typeName)) validatorTypesList.add("doubleRange");
+ if (isValidatorInteger()) validatorTypesList.add("intRange");
+ if (isValidatorFloat()) validatorTypesList.add("floatRange");
+ if (isValidatorDouble()) validatorTypesList.add("doubleRange");
}
- if (format != null && isValidatorString(typeName))
+ if (format != null && isValidatorString())
{
if (isEmailFormat(format))
validatorTypesList.add("email");
@@ -1239,12 +1237,12 @@
{
final boolean isRangeFormat = isRangeFormat(format);
- if (isRangeFormat && (isValidatorInteger(typeName) || isValidatorFloat(typeName) || isValidatorDouble(typeName)))
+ if (isRangeFormat && (isValidatorInteger() || isValidatorFloat() || isValidatorDouble()))
{
vars.put("min",Arrays.asList(new Object[]{"min", getRangeStart(format)}));
vars.put("max",Arrays.asList(new Object[]{"max", getRangeEnd(format)}));
}
- else if (isValidatorString(typeName))
+ else if (isValidatorString())
{
Collection formats = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
for (Iterator formatIterator = formats.iterator(); formatIterator.hasNext();)
@@ -1259,7 +1257,7 @@
}
}
}
- if (isValidatorDate(typeName))
+ if (isValidatorDate())
{
if (format != null && isStrictDateFormat(format))
{
@@ -1401,59 +1399,59 @@
return Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD.equals(getWidgetType());
}
- private boolean isValidatorBoolean(String type)
+ private boolean isValidatorBoolean()
{
- return "datatype::boolean".equals(type) || "datatype::Boolean".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), UMLProfile.BOOLEAN_TYPE_NAME);
}
- private boolean isValidatorChar(String type)
+ private boolean isValidatorChar()
{
- return "datatype::char".equals(type) || "datatype::Char".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.CHARACTER_TYPE_NAME);
}
- private boolean isValidatorByte(String type)
+ private boolean isValidatorByte()
{
- return "datatype::byte".equals(type) || "datatype::Byte".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.BYTE_TYPE_NAME);
}
- private boolean isValidatorShort(String type)
+ private boolean isValidatorShort()
{
- return "datatype::short".equals(type) || "datatype::Short".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.SHORT_TYPE_NAME);
}
- private boolean isValidatorInteger(String type)
+ private boolean isValidatorInteger()
{
- return "datatype::int".equals(type) || "datatype::Integer".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.INTEGER_TYPE_NAME);
}
- private boolean isValidatorLong(String type)
+ private boolean isValidatorLong()
{
- return "datatype::long".equals(type) || "datatype::Long".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.LONG_TYPE_NAME);
}
- private boolean isValidatorFloat(String type)
+ private boolean isValidatorFloat()
{
- return "datatype::float".equals(type) || "datatype::Float".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.FLOAT_TYPE_NAME);
}
- private boolean isValidatorDouble(String type)
+ private boolean isValidatorDouble()
{
- return "datatype::double".equals(type) || "datatype::Double".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.DOUBLE_TYPE_NAME);
}
- private boolean isValidatorDate(String type)
+ private boolean isValidatorDate()
{
- return "datatype::Date".equals(type);
+ return this.getType() != null ? this.getType().isDateType() : false;
}
- private boolean isValidatorUrl(String type)
+ private boolean isValidatorUrl()
{
- return "datatype::URL".equals(type);
+ return UMLMetafacadeUtils.isType(this.getType(), Bpm4StrutsProfile.URL_TYPE_NAME);
}
- private boolean isValidatorString(String type)
+ private boolean isValidatorString()
{
- return "datatype::String".equals(type);
+ return this.getType() != null ? this.getType().isStringType() : false;
}
private boolean isEmailFormat(String format)
1.37 +11 -0 cartridges/andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts/Bpm4StrutsProfile.java
Index: Bpm4StrutsProfile.java
===================================================================
RCS file: /cvsroot/andromda/cartridges/andromda-bpm4struts/src/java/org/andromda/cartridges/bpm4struts/Bpm4StrutsProfile.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -w -r1.36 -r1.37
--- Bpm4StrutsProfile.java 21 Mar 2005 23:11:23 -0000 1.36
+++ Bpm4StrutsProfile.java 3 Apr 2005 20:20:50 -0000 1.37
@@ -55,6 +55,17 @@
public static final String TAGGEDVALUE_USECASE_ACTIVITY = profile.get("USECASE_ACTIVITY");
public static final String TAGGEDVALUE_ACTION_REDIRECT = profile.get("ACTION_REDIRECT");
+ /* ----------------- Data Types -------------------- */
+
+ public static final String CHARACTER_TYPE_NAME = profile.get("CHARACTER_TYPE");
+ public static final String BYTE_TYPE_NAME = profile.get("BYTE_TYPE");
+ public static final String SHORT_TYPE_NAME = profile.get("SHORT_TYPE");
+ public static final String INTEGER_TYPE_NAME = profile.get("INTEGER_TYPE");
+ public static final String LONG_TYPE_NAME = profile.get("LONG_TYPE");
+ public static final String FLOAT_TYPE_NAME = profile.get("FLOAT_TYPE");
+ public static final String DOUBLE_TYPE_NAME = profile.get("DOUBLE_TYPE");
+ public static final String URL_TYPE_NAME = profile.get("URL_TYPE");
+
/* ----------------- Default Values ------------------- */
public static final String TAGGEDVALUE_INPUT_DEFAULT_REQUIRED = "true";
public static final String TAGGEDVALUE_EXCEPTION_DEFAULT_TYPE = "java.lang.Exception";
|