Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 36914 Details for
Bug 80307
Validation Rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
more validation rules
validationPatch_060324.txt (text/plain), 41.84 KB, created by
James Bruck
on 2006-03-24 16:18:48 EST
(
hide
)
Description:
more validation rules
Filename:
MIME Type:
Creator:
James Bruck
Created:
2006-03-24 16:18:48 EST
Size:
41.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.uml2.uml >Index: src/org/eclipse/uml2/uml/internal/operations/ClassOperations.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ClassOperations.java,v >retrieving revision 1.16 >diff -u -r1.16 ClassOperations.java >--- src/org/eclipse/uml2/uml/internal/operations/ClassOperations.java 7 Mar 2006 20:25:18 -0000 1.16 >+++ src/org/eclipse/uml2/uml/internal/operations/ClassOperations.java 24 Mar 2006 20:53:47 -0000 >@@ -34,6 +34,7 @@ > import org.eclipse.uml2.uml.NamedElement; > import org.eclipse.uml2.uml.Property; > import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.UMLPlugin; > > import org.eclipse.uml2.uml.RedefinableElement; > import org.eclipse.uml2.uml.UMLPackage; >@@ -76,30 +77,25 @@ > * A passive class may not own receptions. > * not self.isActive implies self.ownedReception.isEmpty() > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validatePassiveClass( > org.eclipse.uml2.uml.Class class_, DiagnosticChain diagnostics, > Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >+ >+ boolean result = true; >+ if (!class_.isActive() && !(class_.getOwnedReceptions().isEmpty())) { >+ result = false; > if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CLASS__PASSIVE_CLASS, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validatePassiveClass", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(class_, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{class_})); >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.CLASS__PASSIVE_CLASS, UMLPlugin.INSTANCE >+ .getString("_UI_Class_PassiveClass_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, class_)), >+ new Object[]{class_})); > } >- return false; > } >- return true; >+ return result; > } > > /** >Index: src/org/eclipse/uml2/uml/internal/operations/ConnectorOperations.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ConnectorOperations.java,v >retrieving revision 1.4 >diff -u -r1.4 ConnectorOperations.java >--- src/org/eclipse/uml2/uml/internal/operations/ConnectorOperations.java 5 Jan 2006 22:43:26 -0000 1.4 >+++ src/org/eclipse/uml2/uml/internal/operations/ConnectorOperations.java 24 Mar 2006 20:53:48 -0000 >@@ -12,14 +12,25 @@ > */ > package org.eclipse.uml2.uml.internal.operations; > >+import java.util.Collection; >+import java.util.Iterator; > import java.util.Map; > > import org.eclipse.emf.common.util.BasicDiagnostic; > import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.DiagnosticChain; >- >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.uml2.uml.Association; >+import org.eclipse.uml2.uml.BehavioredClassifier; >+import org.eclipse.uml2.uml.ConnectableElement; > import org.eclipse.uml2.uml.Connector; >- >+import org.eclipse.uml2.uml.ConnectorEnd; >+import org.eclipse.uml2.uml.ConnectorKind; >+import org.eclipse.uml2.uml.Element; >+import org.eclipse.uml2.uml.Port; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.UMLPlugin; > import org.eclipse.uml2.uml.util.UMLValidator; > > /** >@@ -62,29 +73,42 @@ > * The types of the connectable elements that the ends of a connector are attached to must conform to the types of the association ends of the association that types the connector, if any. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateTypes(Connector connector, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CONNECTOR__TYPES, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateTypes", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{connector})); >+ >+ boolean result = true; >+ Association connectorType = connector.getType(); >+ if (connectorType != null) { >+ EList ends = connector.getEnds(); >+ if (ends.size() == 2) { >+ ConnectableElement fromRole = ((ConnectorEnd) ends.get(0)) >+ .getRole(); >+ ConnectableElement toRole = ((ConnectorEnd) ends.get(1)) >+ .getRole(); >+ >+ Type fromType = fromRole.getType(); >+ Type toType = toRole.getType(); >+ >+ EList endTypes = connectorType.getEndTypes(); >+ >+ if (!TypeOperations.conformsToAny(endTypes, fromType) >+ || !TypeOperations.conformsToAny(endTypes, toType)) { >+ result = false; >+ if (diagnostics != null) { >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.CONNECTOR__TYPES, >+ UMLPlugin.INSTANCE.getString( >+ "_UI_Connector_Types_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, connector)), >+ new Object[]{connector})); >+ } >+ } > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -126,29 +150,50 @@ > * The ConnectableElements attached as roles to each ConnectorEnd owned by a Connector must be roles of the Classifier that owned the Connector, or they must be ports of such roles. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateRoles(Connector connector, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >+ >+ boolean result = true; >+ >+ EList ends = connector.getEnds(); >+ if (ends.size() == 2) { >+ ConnectorEnd fromEnd = (ConnectorEnd) ends.get(0); >+ ConnectorEnd toEnd = (ConnectorEnd) ends.get(1); >+ ConnectableElement fromRole = fromEnd.getRole(); >+ ConnectableElement toRole = toEnd.getRole(); >+ >+ Element connectorOwner = connector.getOwner(); >+ Element fromOwner = null; >+ Element toOwner = null; >+ >+ if (fromRole instanceof Port) { >+ fromOwner = fromEnd.getPartWithPort().getOwner(); >+ } else { >+ fromOwner = fromRole.getOwner(); >+ } >+ if (toRole instanceof Port) { >+ toOwner = toEnd.getPartWithPort().getOwner(); >+ } else { >+ toOwner = toRole.getOwner(); >+ } >+ >+ if ((connectorOwner != fromOwner) || (connectorOwner != toOwner)) { >+ result = false; >+ if (diagnostics != null) { >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, > UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CONNECTOR__ROLES, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >+ UMLValidator.CONNECTOR__ROLES, UMLPlugin.INSTANCE > .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateRoles", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >+ "_UI_Connector_Roles_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, connector)), > new Object[]{connector})); >+ } > } >- return false; > } >- return true; >+ >+ return result; > } > > /** >@@ -158,29 +203,45 @@ > * A delegation connector must only be defined between used Interfaces or Ports of the same kind, e.g. between two provided Ports or between two required Ports. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateBetweenInterfacesPorts(Connector connector, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CONNECTOR__BETWEEN_INTERFACES_PORTS, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateBetweenInterfacesPorts", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{connector})); >+ >+ boolean result = true; >+ >+ EList ends = connector.getEnds(); >+ >+ if ((connector.getKind() == ConnectorKind.DELEGATION_LITERAL) >+ && (ends.size() == 2)) { >+ ConnectableElement fromRole = ((ConnectorEnd) ends.get(0)) >+ .getRole(); >+ ConnectableElement toRole = ((ConnectorEnd) ends.get(1)).getRole(); >+ >+ Collection fromRequired = ConnectableElementOperations.getRequiredInterfaces(fromRole); >+ Collection fromProvided = ConnectableElementOperations.getProvidedInterfaces(fromRole); >+ >+ Collection toRequired = ConnectableElementOperations.getRequiredInterfaces(toRole); >+ Collection toProvided = ConnectableElementOperations.getProvidedInterfaces(toRole); >+ >+ if (intersect(toProvided, fromRequired) >+ || intersect(fromProvided, toRequired)) { >+ result = false; >+ if (diagnostics != null) { >+ diagnostics >+ .add(new BasicDiagnostic( >+ Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.CONNECTOR__BETWEEN_INTERFACES_PORTS, >+ UMLPlugin.INSTANCE >+ .getString( >+ "_UI_Connector_BetweenInterfacesPorts_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, connector)), >+ new Object[]{connector})); >+ } > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -190,29 +251,53 @@ > * If a delegation connector is defined between a used Interface or Port and an internal Part Classifier, then that Classifier must have an 'implements' relationship to the Interface type of that Port. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateBetweenInterfacePortImplements( > Connector connector, DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CONNECTOR__BETWEEN_INTERFACE_PORT_IMPLEMENTS, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateBetweenInterfacePortImplements", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{connector})); >+ >+ boolean result = true; >+ >+ EList ends = connector.getEnds(); >+ if ((connector.getKind() == ConnectorKind.DELEGATION_LITERAL) >+ && (ends.size() == 2)) { >+ >+ ConnectorEnd fromEnd = (ConnectorEnd) ends.get(0); >+ ConnectorEnd toEnd = (ConnectorEnd) ends.get(1); >+ >+ ConnectableElement fromRole = fromEnd.getRole(); >+ ConnectableElement toRole = toEnd.getRole(); >+ >+ Collection fromProvided = ConnectableElementOperations.getProvidedInterfaces(fromRole); >+ >+ if (!fromProvided.isEmpty() && !(toRole instanceof Port) >+ && (toRole instanceof Property)) { >+ Type toType = ((Property) toRole).getType(); >+ >+ if ((toType instanceof BehavioredClassifier) >+ && (!((BehavioredClassifier) toType) >+ .getAllImplementedInterfaces() >+ .containsAll(fromProvided))) { >+ >+ result = false; >+ if (diagnostics != null) { >+ diagnostics >+ .add(new BasicDiagnostic( >+ Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.CONNECTOR__BETWEEN_INTERFACE_PORT_IMPLEMENTS, >+ UMLPlugin.INSTANCE >+ .getString( >+ "_UI_Connector_BetweenInterfacePortImplements_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, >+ connector)), >+ new Object[]{connector})); >+ } >+ } >+ > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -222,29 +307,45 @@ > * If a delegation connector is defined between a source Interface or Port and a target Interface or Port, then the target Interface must support a signature compatible subset of Operations of the source Interface or Port. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ >+ > public static boolean validateBetweenInterfacePortSignature( > Connector connector, DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.CONNECTOR__BETWEEN_INTERFACE_PORT_SIGNATURE, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateBetweenInterfacePortSignature", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{connector})); >+ >+ boolean result = true; >+ >+ EList ends = connector.getEnds(); >+ >+ if ((connector.getKind() == ConnectorKind.DELEGATION_LITERAL) >+ && (ends.size() == 2)) { >+ ConnectableElement fromRole = ((ConnectorEnd) ends.get(0)) >+ .getRole(); >+ ConnectableElement toRole = ((ConnectorEnd) ends.get(1)).getRole(); >+ >+ Collection fromRequired = ConnectableElementOperations.getRequiredInterfaces(fromRole); >+ Collection fromProvided = ConnectableElementOperations.getProvidedInterfaces(fromRole); >+ >+ Collection toRequired = ConnectableElementOperations.getRequiredInterfaces(toRole); >+ Collection toProvided = ConnectableElementOperations.getProvidedInterfaces(toRole); >+ >+ if (!fromProvided.isEmpty() && !toProvided.isEmpty()) { >+ result = result && intersect(fromProvided, toProvided); >+ } >+ if (!fromRequired.isEmpty() && !toRequired.isEmpty()) { >+ result = result && intersect(fromRequired, toRequired); >+ } >+ if (!result && diagnostics != null) { >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.CONNECTOR__BETWEEN_INTERFACE_PORT_SIGNATURE, >+ UMLPlugin.INSTANCE.getString( >+ "_UI_Connector_BetweenInterfacePortSignature_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, connector)), >+ new Object[]{connector})); > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -286,29 +387,63 @@ > * An assembly connector must only be defined from a required Interface or Ports to a provided Interface or Port. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateAssemblyConnector(Connector connector, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >+ >+ boolean result = true; >+ >+ EList ends = connector.getEnds(); >+ if ((connector.getKind() == ConnectorKind.ASSEMBLY_LITERAL) >+ && (ends.size() == 2)) { >+ >+ ConnectableElement fromRole = ((ConnectorEnd) ends.get(0)) >+ .getRole(); >+ ConnectableElement toRole = ((ConnectorEnd) ends.get(1)).getRole(); >+ >+ Collection fromRequired = ConnectableElementOperations.getRequiredInterfaces(fromRole); >+ Collection fromProvided = ConnectableElementOperations.getProvidedInterfaces(fromRole); >+ >+ Collection toRequired = ConnectableElementOperations.getRequiredInterfaces(toRole); >+ Collection toProvided = ConnectableElementOperations.getProvidedInterfaces(toRole); >+ >+ if (!intersect(fromProvided, toRequired) >+ && !intersect(toProvided, fromRequired)) { >+ >+ if (diagnostics != null) { >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, > UMLValidator.DIAGNOSTIC_SOURCE, > UMLValidator.CONNECTOR__ASSEMBLY_CONNECTOR, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateAssemblyConnector", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(connector, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >+ UMLPlugin.INSTANCE.getString( >+ "_UI_Connector_AssemblyConnector_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, connector)), > new Object[]{connector})); >+ } > } >- return false; > } >- return true; >+ return result; >+ } >+ >+ /** >+ * Computes whether two collections intersect >+ * >+ * @param a >+ * one collection >+ * @param b >+ * another collection >+ * @return whether <code>a</code> and <code>b</code> have any element in >+ * common >+ */ >+ private static boolean intersect(Collection a, Collection b) { >+ boolean result = false; >+ if (!(a.isEmpty() || b.isEmpty())) { >+ for (Iterator iter = a.iterator(); !result && iter.hasNext();) { >+ result = b.contains(iter.next()); >+ } >+ } >+ return result; > } >+ > > } // ConnectorOperations >\ No newline at end of file >Index: src/org/eclipse/uml2/uml/internal/operations/DecisionNodeOperations.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/DecisionNodeOperations.java,v >retrieving revision 1.4 >diff -u -r1.4 DecisionNodeOperations.java >--- src/org/eclipse/uml2/uml/internal/operations/DecisionNodeOperations.java 5 Jan 2006 22:43:25 -0000 1.4 >+++ src/org/eclipse/uml2/uml/internal/operations/DecisionNodeOperations.java 24 Mar 2006 20:53:48 -0000 >@@ -17,9 +17,8 @@ > import org.eclipse.emf.common.util.BasicDiagnostic; > import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.DiagnosticChain; >- > import org.eclipse.uml2.uml.DecisionNode; >- >+import org.eclipse.uml2.uml.UMLPlugin; > import org.eclipse.uml2.uml.util.UMLValidator; > > /** >@@ -57,29 +56,26 @@ > * A decision node has one incoming edge. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateOneIncomingEdge(DecisionNode decisionNode, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >+ >+ boolean result = true; >+ >+ if (decisionNode.getIncomings().size() != 1) { >+ result = false; > if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.DECISION_NODE__ONE_INCOMING_EDGE, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateOneIncomingEdge", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(decisionNode, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{decisionNode})); >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.DECISION_NODE__ONE_INCOMING_EDGE, >+ UMLPlugin.INSTANCE.getString( >+ "_UI_DecisionNode_OneIncomingEdge_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, decisionNode)), >+ new Object[]{decisionNode})); > } >- return false; > } >- return true; >+ return result; > } > > /** >Index: src/org/eclipse/uml2/uml/internal/operations/UseCaseOperations.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/UseCaseOperations.java,v >retrieving revision 1.6 >diff -u -r1.6 UseCaseOperations.java >--- src/org/eclipse/uml2/uml/internal/operations/UseCaseOperations.java 27 Jan 2006 04:55:56 -0000 1.6 >+++ src/org/eclipse/uml2/uml/internal/operations/UseCaseOperations.java 24 Mar 2006 20:53:48 -0000 >@@ -20,11 +20,12 @@ > import org.eclipse.emf.common.util.DiagnosticChain; > import org.eclipse.emf.common.util.ECollections; > import org.eclipse.emf.common.util.EList; >- > import org.eclipse.emf.common.util.UniqueEList; >- >+import org.eclipse.uml2.uml.Association; >+import org.eclipse.uml2.uml.Type; >+import org.eclipse.uml2.uml.UMLPackage; >+import org.eclipse.uml2.uml.UMLPlugin; > import org.eclipse.uml2.uml.UseCase; >- > import org.eclipse.uml2.uml.util.UMLValidator; > > /** >@@ -64,29 +65,25 @@ > * A UseCase must have a name. > * self.name -> notEmpty () > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateMustHaveName(UseCase useCase, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >+ >+ boolean result = true; >+ >+ if (isEmpty(useCase.getName())) { >+ result = false; > if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.USE_CASE__MUST_HAVE_NAME, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateMustHaveName", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(useCase, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{useCase})); >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.USE_CASE__MUST_HAVE_NAME, UMLPlugin.INSTANCE >+ .getString("_UI_UseCase_MustHaveName_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, useCase)), >+ new Object[]{useCase})); > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -96,29 +93,34 @@ > * UseCases can only be involved in binary Associations. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateBinaryAssociations(UseCase useCase, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >+ >+ boolean result = true; >+ >+ EList useCaseRelationships = useCase.getAssociations(); >+ >+ for (Iterator iter = useCaseRelationships.iterator(); iter.hasNext();) { >+ Association assoc = (Association) iter.next(); >+ if (!assoc.isBinary()) { >+ result = false; >+ if (diagnostics != null) { >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, > UMLValidator.DIAGNOSTIC_SOURCE, > UMLValidator.USE_CASE__BINARY_ASSOCIATIONS, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateBinaryAssociations", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(useCase, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >+ UMLPlugin.INSTANCE.getString( >+ "_UI_UseCase_BinaryAssociations_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, useCase)), > new Object[]{useCase})); >+ } >+ break; > } >- return false; > } >- return true; >+ >+ return result; >+ > } > > /** >@@ -128,29 +130,49 @@ > * UseCases can not have Associations to UseCases specifying the same subject. > * true > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateNoAssociationToUseCase(UseCase useCase, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >- if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.USE_CASE__NO_ASSOCIATION_TO_USE_CASE, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateNoAssociationToUseCase", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(useCase, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{useCase})); >+ >+ boolean result = true; >+ EList useCaseRelationships = useCase >+ .getRelationships(UMLPackage.Literals.ASSOCIATION); >+ >+ for (Iterator iter = useCaseRelationships.iterator(); iter.hasNext();) { >+ Association assoc = (Association) iter.next(); >+ >+ EList endTypes = assoc.getEndTypes(); >+ if (endTypes.size() == 2) { >+ Type end1 = (Type) endTypes.get(0); >+ Type end2 = (Type) endTypes.get(1); >+ if ((end1 instanceof UseCase) && (end2 instanceof UseCase)) { >+ >+ UseCase uc1 = (UseCase) end1; >+ UseCase uc2 = (UseCase) end2; >+ EList subjects = new UniqueEList.FastCompare(); >+ subjects.addAll(uc1.getSubjects()); >+ subjects.retainAll(uc2.getSubjects()); >+ >+ if (!subjects.isEmpty()) { >+ result = false; >+ if (diagnostics != null) { >+ diagnostics >+ .add(new BasicDiagnostic( >+ Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.USE_CASE__NO_ASSOCIATION_TO_USE_CASE, >+ UMLPlugin.INSTANCE.getString( >+ "_UI_UseCase_NoAssociationToUseCase_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, uc1, >+ uc2)), new Object[]{uc1, uc2})); >+ } >+ break; >+ } >+ } > } >- return false; > } >- return true; >+ return result; > } > > /** >@@ -160,29 +182,26 @@ > * A use case cannot include use cases that directly or indirectly include it. > * not self.allIncludedUseCases()->includes(self) > * <!-- end-model-doc --> >- * @generated >+ * @generated NOT > */ > public static boolean validateCannotIncludeSelf(UseCase useCase, > DiagnosticChain diagnostics, Map context) { >- // TODO: implement this method >- // -> specify the condition that violates the invariant >- // -> verify the details of the diagnostic, including severity and message >- // Ensure that you remove @generated or mark it @generated NOT >- if (false) { >+ >+ boolean result = true; >+ if (useCase.allIncludedUseCases().contains(useCase)) { >+ result = false; > if (diagnostics != null) { >- diagnostics >- .add(new BasicDiagnostic( >- Diagnostic.ERROR, >- UMLValidator.DIAGNOSTIC_SOURCE, >- UMLValidator.USE_CASE__CANNOT_INCLUDE_SELF, >- org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE >- .getString( >- "_UI_GenericInvariant_diagnostic", new Object[]{"validateCannotIncludeSelf", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(useCase, context)}), //$NON-NLS-1$ //$NON-NLS-2$ >- new Object[]{useCase})); >+ diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, >+ UMLValidator.DIAGNOSTIC_SOURCE, >+ UMLValidator.USE_CASE__CANNOT_INCLUDE_SELF, >+ UMLPlugin.INSTANCE.getString( >+ "_UI_UseCase_CannotIncludeSelf_diagnostic", //$NON-NLS-1$ >+ getMessageSubstitutions(context, useCase)), >+ new Object[]{useCase})); > } >- return false; >+ > } >- return true; >+ return result; > } > > /** >@@ -206,4 +225,4 @@ > return ECollections.unmodifiableEList(allIncludedUseCases); > } > >-} // UseCaseOperations >\ No newline at end of file >+} // UseCaseOperations >Index: src/org/eclipse/uml2/uml/internal/operations/TypeOperations.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/TypeOperations.java,v >retrieving revision 1.12 >diff -u -r1.12 TypeOperations.java >--- src/org/eclipse/uml2/uml/internal/operations/TypeOperations.java 7 Mar 2006 20:25:17 -0000 1.12 >+++ src/org/eclipse/uml2/uml/internal/operations/TypeOperations.java 24 Mar 2006 20:53:48 -0000 >@@ -12,6 +12,7 @@ > */ > package org.eclipse.uml2.uml.internal.operations; > >+import java.util.Collection; > import java.util.Iterator; > > import org.eclipse.emf.common.util.ECollections; >@@ -274,6 +275,23 @@ > * <!-- begin-user-doc --> > * <!-- end-user-doc --> > * <!-- begin-model-doc --> >+ * The query conformsToAny() gives true for a type that conforms to any other in the collection. >+ * <!-- end-model-doc --> >+ * @generated NOT >+ */ >+ public static boolean conformsToAny(Collection types, Type type){ >+ for(Iterator iter = types.iterator();iter.hasNext();){ >+ if(type.conformsTo((Type)iter.next())){ >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * <!-- begin-model-doc --> > * The query conformsTo() gives true for a type that conforms to another. By default, two types do not conform to each other. This query is intended to be redefined for specific conformance situations. > * result = false > * <!-- end-model-doc --> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/plugin.properties,v >retrieving revision 1.3 >diff -u -r1.3 plugin.properties >--- plugin.properties 22 Dec 2005 20:21:23 -0000 1.3 >+++ plugin.properties 24 Mar 2006 20:53:47 -0000 >@@ -91,3 +91,48 @@ > _UI_Ecore2UMLConverter_ReportSubsetsAnnotation_diagnostic = ''{0}'' should subset ''{1}'' based on an annotation. > _UI_Ecore2UMLConverter_ReportUnionAnnotation_diagnostic = ''{0}'' should be a union based on an annotation. > _UI_Ecore2UMLConverter_ReportAnnotationDetails_diagnostic = Element ''{0}'' should be annotated with details from source ''{1}''. >+ >+ >+_UI_Classifier_NoCyclesInGeneralization_diagnostic = Classifier ''{0}'' is both a transitively general and transitively specific classifier of the same classifier. >+_UI_Classifier_SpecializeType_diagnostic = Classifier ''{0}'' specializes classifier ''{1}'' of invalid type. >+_UI_Constraint_NotApplyToSelf_diagnostic = Constraint ''{0}'' is applied to itself. >+_UI_ElementImport_ImportedElementIsPublic_diagnostic = Imported element ''{0}'' has non-public visibility. >+_UI_ElementImport_VisibilityPublicOrPrivate_diagnostic = The visibility of element import ''{0}'' is neither public nor private. >+_UI_Element_HasOwner_diagnostic = Element ''{0}'' must be owned, but it has no owner. >+_UI_Element_NotOwnSelf_diagnostic = Element ''{0}'' directly or indirectly owns itself. >+_UI_MultiplicityElement_LowerGE0_diagnostic = The lower bound of multiplicity element ''{0}'' is not a non-negative integer literal. >+_UI_MultiplicityElement_UpperGT0_diagnostic = Multiplicity element ''{0}'' does not define at least one valid cardinality that is greater than zero. >+_UI_MultiplicityElement_UpperGELower_diagnostic = The upper bound of multiplicity element ''{0}'' is not greater than or equal to its lower bound. >+_UI_NamedElement_VisibilityNeedsOwnership_diagnostic = Named element ''{0}'' is not owned by a namespace, but it has visibility. >+_UI_Namespace_MembersDistinguishable_diagnostic = Not all the members of namespace ''{0}'' are distinguishable within it. >+_UI_Operation_OnlyBodyForQuery_diagnostic = A body condition is specified for operation ''{0}'', but it is not a query. >+_UI_PackageImport_PublicOrPrivate_diagnostic = The visibility of package import ''{0}'' is neither public nor private. >+_UI_Package_ElementsPublicOrPrivate_diagnostic = Element ''{0}'', owned by package ''{1}'', has visibility that is neither public nor private. >+_UI_Property_SubsettingContextConforms_diagnostic = The context of the subsetting property ''{0}'' does not conform to the context of subsetted property ''{1}''. >+_UI_Property_NavigableReadOnly_diagnostic = Non-navigable property ''{0}'' is marked as read-only. >+_UI_Property_DerivedUnionIsDerived_diagnostic = Derived union ''{0}'' is not derived. >+_UI_Property_SubsettingRules_diagnostic = Subsetting property ''{0}'' either weakens the type of subsetted property ''{1}'', or its upper bound is greater. >+_UI_Property_DeploymentTarget_diagnostic = Property ''{0}''is acting as a DeploymentTarget but is not a structural element of a Node. >+_UI_Property_SubsettingPropertyNames_diagnostic = Subsetting property ''{0}'' subsets property ''{1}'' of the same name. >+_UI_Property_DerivedUnionIsReadOnly_diagnostic = Derived union ''{0}'' is not read only. >+_UI_Property_MultiplicityOfComposite_diagnostic = The multiplicity of composite aggregation ''{0}'' has an upper bound greater than 1. >+_UI_RedefinableElement_RedefinitionConsistent_diagnostic = Redefining element ''{0}'' is not consistent with redefined element ''{1}''. >+_UI_RedefinableElement_RedefinitionContextValid_diagnostic = None of the redefinition contexts of redefining element ''{0}'' is a specialization of at least one of the redefinition contexts for redefined element ''{1}''. >+ >+ >+_UI_Connector_BetweenInterfacesPorts_diagnostic = Delegation connector ''{0}'' must only be defined between used Interfaces or Ports of the same kind. >+_UI_Connector_BetweenInterfacePortImplements_diagnostic = Delegation connector ''{0}'' to Classifier must have an 'implements' relationship to the Interface type of that Port. >+_UI_Connector_BetweenInterfacePortSignature_diagnostic = Target interface of delegation connector ''{0}''does not support a signature compatible with a subset of operations defined by source. >+_UI_Connector_AssemblyConnector_diagnostic = Assembly connector ''{0}'' must only be defined from a port supporting a required interface to one with a provided interface. >+_UI_Connector_Types_diagnostic = The connector ''{0}'' must be typed by an association with compatible end types. >+_UI_Connector_Roles_diagnostic = The owner of connector ''{0}'' must also own the connected roles. >+ >+ _UI_Class_PassiveClass_diagnostic = The passive class ''{0}'' must not be the owner of any receptions. >+ >+ _UI_UseCase_MustHaveName_diagnostic = The use case ''{0}'' must have a name. >+ _UI_UseCase_BinaryAssociations_diagnostic = The use case ''{0}''can only be involved in binary associations. >+ _UI_UseCase_NoAssociationToUseCase_diagnostic = The use case ''{0}'' is involved in an association with another usecase ''{1}'' having the same subject. >+ _UI_UseCase_CannotIncludeSelf_diagnostic = The use case ''{0}'' cannot include itself. >+ >+ _UI_DecisionNode_OneIncomingEdge_diagnostic = The decision node ''{0}'' has to have one incoming edge. >+ >\ No newline at end of file >Index: src/org/eclipse/uml2/uml/internal/operations/ConnectableElementOperations.java >=================================================================== >RCS file: src/org/eclipse/uml2/uml/internal/operations/ConnectableElementOperations.java >diff -N src/org/eclipse/uml2/uml/internal/operations/ConnectableElementOperations.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/uml2/uml/internal/operations/ConnectableElementOperations.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,141 @@ >+/* >+ * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - initial API and implementation >+ * >+ * $Id: ConnectableElementOperations.java,v 1.13 2006/02/22 20:48:22 khussey Exp $ >+ */ >+package org.eclipse.uml2.uml.internal.operations; >+ >+import java.util.Collection; >+import java.util.Collections; >+import java.util.Iterator; >+ >+import org.eclipse.uml2.uml.BehavioredClassifier; >+import org.eclipse.uml2.uml.Classifier; >+import org.eclipse.uml2.uml.Component; >+import org.eclipse.uml2.uml.ConnectableElement; >+import org.eclipse.uml2.uml.Interface; >+import org.eclipse.uml2.uml.Port; >+import org.eclipse.uml2.uml.Property; >+import org.eclipse.uml2.uml.Type; >+ >+public class ConnectableElementOperations >+ extends NamedElementOperations { >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated NOT >+ */ >+ public ConnectableElementOperations() { >+ super(); >+ } >+ >+ /** >+ * Get the required interfaces of a >+ * <code>connectable</code> element, if it is of a type that supports >+ * required interfaces. >+ * >+ * @param connectable a connect element. May be <code>null</code> >+ * @return its required interfaces, which may be an empty collection if >+ * either it doesn't have any or it is of a type that does not support >+ * the required interfaces feature (or is <code>null</code>) >+ * @generated NOT >+ */ >+ public static Collection getRequiredInterfaces( >+ ConnectableElement connectable) { >+ Collection result; >+ >+ if (connectable instanceof Port) { >+ Port port = (Port) connectable; >+ >+ Collection portRequireds = port.getRequireds(); >+ result = new java.util.HashSet(portRequireds); >+ >+ for (Iterator iter = portRequireds.iterator(); iter.hasNext();) { >+ result.addAll(((Interface) iter.next()).allParents()); >+ } >+ } else if (connectable instanceof Property) { >+ // parts of a component are implemented as properties, typed >+ // by a component or some other classifier >+ Property part = (Property) connectable; >+ Type type = part.getType(); >+ >+ if (type instanceof Component) { >+ result = ((Component) type).getRequireds(); >+ } else if (type instanceof Classifier) { >+ // the part requires all interfaces that are used by its type >+ result = ((Classifier) type).getAllUsedInterfaces(); >+ } else { >+ result = Collections.EMPTY_SET; >+ } >+ } else { >+ // also covers the case of connectable == null >+ result = Collections.EMPTY_SET; >+ } >+ return result; >+ } >+ >+ /** >+ * Get the provided interfaces of a >+ * <code>connectable</code> element, if it is of a type that supports >+ * provided interfaces. >+ * >+ * @param connectable a connect element. May be <code>null</code> >+ * @return its provided interfaces, which may be an empty collection if >+ * either it doesn't have any or it is of a type that does not support >+ * the provided interfaces feature (or is <code>null</code>) >+ * >+ * @generated NOT >+ */ >+ public static Collection getProvidedInterfaces( >+ ConnectableElement connectable) { >+ Collection result; >+ >+ if (connectable instanceof Port) { >+ // ports have required or provided interfaces >+ Port port = (Port) connectable; >+ >+ Collection portProvideds = port.getProvideds(); >+ result = new java.util.HashSet(portProvideds); >+ >+ for (Iterator iter = portProvideds.iterator(); iter.hasNext();) { >+ result.addAll(((Interface) iter.next()).allParents()); >+ } >+ } else if (connectable instanceof Property) { >+ // parts of a component are implemented as properties, typed >+ // by a component or some other classifier >+ Property part = (Property) connectable; >+ Type type = part.getType(); >+ >+ if (type instanceof Component) { >+ Collection compProvideds = ((Component) type).getProvideds(); >+ result = new java.util.HashSet(compProvideds); >+ >+ for (Iterator iter = compProvideds.iterator(); iter.hasNext();) { >+ result.addAll(((Interface) iter.next()).allParents()); >+ } >+ } else if (type instanceof Interface) { >+ result = new java.util.HashSet(); >+ result.add(type); >+ result.addAll(((Interface) type).allParents()); >+ } else if (type instanceof BehavioredClassifier) { >+ result = ((BehavioredClassifier) type) >+ .getAllImplementedInterfaces(); >+ } else { >+ result = Collections.EMPTY_SET; >+ } >+ } else { >+ // also covers the case of connectable == null >+ result = Collections.EMPTY_SET; >+ } >+ return result; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
Kenn.Hussey
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 80307
:
35921
|
36338
| 36914 |
37131
|
37153
|
37217
|
37236
|
37419
|
40586
|
41343
|
84050
|
85114
|
85115
|
85127
|
228168