### Eclipse Workspace Patch 1.0 #P org.eclipse.uml2.uml Index: src/org/eclipse/uml2/uml/internal/operations/AssociationOperations.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/AssociationOperations.java,v retrieving revision 1.12 diff -u -r1.12 AssociationOperations.java --- src/org/eclipse/uml2/uml/internal/operations/AssociationOperations.java 3 May 2007 21:11:52 -0000 1.12 +++ src/org/eclipse/uml2/uml/internal/operations/AssociationOperations.java 12 Dec 2007 21:53:07 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM - initial API and implementation + * Javier Muņoz (Integranova) - Implementation of some validations * * $Id: AssociationOperations.java,v 1.12 2007/05/03 21:11:52 khussey Exp $ */ @@ -18,16 +19,14 @@ import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; - import org.eclipse.emf.common.util.UniqueEList; import org.eclipse.emf.ecore.InternalEObject; - import org.eclipse.uml2.common.util.UnionEObjectEList; import org.eclipse.uml2.uml.Association; +import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; - import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -71,27 +70,33 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateSpecializedEndNumber(Association association, 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.ASSOCIATION__SPECIALIZED_END_NUMBER, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateSpecializedEndNumber", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(association, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{association})); + + for (Classifier parent : association.parents()) { + + if (parent instanceof Association) { + Association nextAssociation = (Association) parent; + + if (association.getMemberEnds().size() != nextAssociation + .getMemberEnds().size()) { + + if (diagnostics != null) { + diagnostics + .add(new BasicDiagnostic( + Diagnostic.ERROR, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.ASSOCIATION__SPECIALIZED_END_NUMBER, + org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE + .getString( + "_UI_Association_SpecializedEndNumber_diagnostic", new Object[]{"validateSpecializedEndNumber", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(association, context)}), //$NON-NLS-1$ //$NON-NLS-2$ + new Object[]{association})); + } + return false; + } } - return false; } return true; } @@ -141,27 +146,31 @@ * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * - * @generated + * @generated NOT */ public static boolean validateBinaryAssociations(Association association, 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.ASSOCIATION__BINARY_ASSOCIATIONS, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateBinaryAssociations", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(association, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{association})); + + for (Property memberEnd : association.getMemberEnds()) { + + if (memberEnd.getAggregation().getValue() != org.eclipse.uml2.uml.AggregationKind.NONE) { + + if (!association.isBinary()) { + + if (diagnostics != null) { + diagnostics + .add(new BasicDiagnostic( + Diagnostic.ERROR, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.ASSOCIATION__BINARY_ASSOCIATIONS, + org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE + .getString( + "_UI_Association_AggregationIsBinary_diagnostic", new Object[]{"validateBinaryAssociations", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(association, context)}), //$NON-NLS-1$ //$NON-NLS-2$ + new Object[]{association})); + } + return false; + } } - return false; } return true; }