svn commit: r18767 - trunk/src: argouml-core-model argouml-core-model-mdr/src/org/argouml/model/mdr

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2010-09-18 16:19:19-0700
New Revision: 18767

Added:
   trunk/src/argouml-core-model/Notation tests.launch
Modified:
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java

Log:
RESOLVED - task 6156: Review and fix all uses of datatypes which are not deleting unused values (esp. Expressions) 
http://argouml.tigris.org/issues/show_bug.cgi?id=6156

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java?view=diff&pathrev=18767&r1=18766&r2=18767
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java	2010-09-18 16:19:19-0700
@@ -50,6 +50,7 @@
 
 import org.apache.log4j.Logger;
 import org.argouml.model.CoreFactory;
+import org.argouml.model.Model;
 import org.argouml.model.ModelCommand;
 import org.argouml.model.ModelManagementHelper;
 import org.argouml.model.NotImplementedException;
@@ -104,6 +105,7 @@
 import org.omg.uml.foundation.datatypes.CallConcurrencyKindEnum;
 import org.omg.uml.foundation.datatypes.ChangeableKind;
 import org.omg.uml.foundation.datatypes.ChangeableKindEnum;
+import org.omg.uml.foundation.datatypes.Expression;
 import org.omg.uml.foundation.datatypes.Multiplicity;
 import org.omg.uml.foundation.datatypes.MultiplicityRange;
 import org.omg.uml.foundation.datatypes.OrderingKind;
@@ -191,7 +193,6 @@
     }
     
 
-    @SuppressWarnings("deprecation")
     @Deprecated
     public UmlAssociation createAssociation() {
         return createAssociation(modelImpl.getUmlPackage());
@@ -333,7 +334,6 @@
         return myFlow;
     }
 
-    @SuppressWarnings("deprecation")
     @Deprecated
     public Generalization createGeneralization() {
         return createGeneralization(modelImpl.getUmlPackage());
@@ -385,7 +385,6 @@
     }
 
 
-    @SuppressWarnings("deprecation")
     @Deprecated
     public Permission createPermission() {
         return createPackageImport();
@@ -493,7 +492,6 @@
         return assoc;
     }
 
-    @SuppressWarnings("deprecation")
     @Deprecated
     public UmlAssociation buildAssociation(Object fromClassifier,
             Object aggregationKind1, Object toClassifier,
@@ -2292,22 +2290,36 @@
      */
     void doCopyMethod(Method source, Method target) {
         ProcedureExpression pe = source.getBody();
-        if (pe != null) {
+        ProcedureExpression oldPe = target.getBody();
+        if (!equal(oldPe,pe)) {
             target.setBody((ProcedureExpression) 
                     modelImpl.getDataTypesFactory().createProcedureExpression(
                             pe.getLanguage(), pe.getBody()));
+            if (oldPe != null) {
+                Model.getUmlFactory().delete(oldPe);
+            }
         }
 
         doCopyBehavioralFeature(source, target);
     }
 
 
-
+    private boolean equal(Expression expr1, Expression expr2) {
+        if (expr1 == null) {
+            if (expr2 == null) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return expr1.equals(expr2);
+        }
+    }
     
     /**
      * Copy the attributes of one Reception to another.
      * 
-     * @param source the rception to copy attributes from
+     * @param source the reception to copy attributes from
      * @param target the reception to be adapted
      */
     void doCopyReception(Reception source, Reception target) {

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java?view=diff&pathrev=18767&r1=18766&r2=18767
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	2010-09-18 16:19:19-0700
@@ -2682,13 +2682,25 @@
     public void setBody(Object handle, Object expr) {
         if (handle instanceof Method
                 && (expr == null || expr instanceof ProcedureExpression)) {
-            ((Method) handle).setBody((ProcedureExpression) expr);
+            ProcedureExpression oldPe = ((Method)handle).getBody();
+            if (!equal(oldPe, (ProcedureExpression) expr)) {
+                ((Method) handle).setBody((ProcedureExpression) expr);
+                if (oldPe != null) {
+                    Model.getUmlFactory().delete(oldPe);
+                }
+            }
             return;
         }
 
         if (handle instanceof Constraint
                 && (expr == null || expr instanceof BooleanExpression)) {
-            ((Constraint) handle).setBody((BooleanExpression) expr);
+            BooleanExpression oldBe = ((Constraint)handle).getBody();
+            if (!equal(oldBe, (BooleanExpression) expr)) {
+                ((Constraint) handle).setBody((BooleanExpression) expr);
+                if (oldBe != null) {
+                    Model.getUmlFactory().delete(oldBe);
+                }
+            }
             return;
         }
 
@@ -2696,6 +2708,19 @@
                 + expr);
     }
 
+
+    private boolean equal(Expression expr1, Expression expr2) {
+        if (expr1 == null) {
+            if (expr2 == null) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return expr1.equals(expr2);
+        }
+    }
+    
     @Deprecated
     public void setChangeability(Object handle, Object ck) {
         if (ck == null || ck instanceof ChangeableKind) {
@@ -2778,7 +2803,13 @@
     public void setDefaultValue(Object handle, Object expr) {
         if (handle instanceof Parameter
                 && (expr == null || expr instanceof Expression)) {
-            ((Parameter) handle).setDefaultValue((Expression) expr);
+            Expression oldExp = ((Parameter) handle).getDefaultValue();
+            if (!equal(oldExp, (Expression) expr)) {
+                ((Parameter) handle).setDefaultValue((Expression) expr);
+                if (oldExp != null) {
+                    Model.getUmlFactory().delete(oldExp);
+                }
+            }
             return;
         }
         throw new IllegalArgumentException("handle: " + handle + " or expr: "
@@ -2842,7 +2873,13 @@
     public void setInitialValue(Object at, Object expr) {
         if (at instanceof Attribute
                 && (expr == null || expr instanceof Expression)) {
-            ((Attribute) at).setInitialValue((Expression) expr);
+            Expression oldExp = ((Attribute) at).getInitialValue();
+            if (!equal(oldExp, (Expression) expr)) {
+                ((Attribute) at).setInitialValue((Expression) expr);
+                if (oldExp != null) {
+                    Model.getUmlFactory().delete(oldExp);
+                }
+            }
             return;
         }
         throw new IllegalArgumentException("at: " + at + " or expr: " + expr);

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java?view=diff&pathrev=18767&r1=18766&r2=18767
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java	2010-09-18 16:19:19-0700
@@ -192,7 +192,6 @@
     }
 
 
-    @SuppressWarnings("deprecation")
     @Deprecated
     public String getMetaModelName(Object m) {
         return modelImpl.getMetaTypes().getName(m);

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java?view=diff&pathrev=18767&r1=18766&r2=18767
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java	2010-09-18 16:19:19-0700
@@ -57,6 +57,7 @@
 import org.omg.uml.foundation.core.Namespace;
 import org.omg.uml.foundation.core.UmlClass;
 import org.omg.uml.foundation.datatypes.BooleanExpression;
+import org.omg.uml.foundation.datatypes.Expression;
 import org.omg.uml.modelmanagement.Subsystem;
 
 /**
@@ -396,15 +397,33 @@
         if (handle instanceof Extend
                 && (booleanExpression == null
                         || booleanExpression instanceof BooleanExpression)) {
-            ((Extend) handle)
-                    .setCondition((BooleanExpression) booleanExpression);
+            Expression oldExp = ((Extend) handle).getCondition();
+            if (!equal(oldExp, (Expression) booleanExpression)) {
+                ((Extend) handle)
+                        .setCondition((BooleanExpression) booleanExpression);
+                if (oldExp != null) {
+                    Model.getUmlFactory().delete(oldExp);
+                }
+            }
             return;
         }
         throw new IllegalArgumentException("handle: " + handle
                 + " or booleanExpression: " + booleanExpression);
     }
 
-
+    private boolean equal(Expression expr1, Expression expr2) {
+        if (expr1 == null) {
+            if (expr2 == null) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return expr1.equals(expr2);
+        }
+    }
+    
+    
     public void setExtension(Object handle, Object useCase) {
         if (!(useCase instanceof UseCase)) {
             throw new IllegalArgumentException("A use case must be supplied");

Added: trunk/src/argouml-core-model/Notation tests.launch
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/Notation%20tests.launch?view=markup&pathrev=18767
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-model/Notation tests.launch	2010-09-18 16:19:19-0700
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/argouml-app/tests/org/argouml/notation/providers/uml"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="2"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=argouml-app/tests&lt;org.argouml.notation.providers.uml"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5&quot; javaProject=&quot;argouml-app&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;argouml-app&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;argouml-core-model&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;argouml-core-model-mdr&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/jmi.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/jmiutils.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/mdrapi.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/mof.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/nbmdr.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-model-mdr/lib/openide-util.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;argouml-core-tools&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-tools/junit-3.8.2/junit.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-tools/lib/easymock12.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/argouml-core-tools/apache-ant-1.7.0/lib/ant.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Dargouml.model.implementation=&quot;org.argouml.model.mdr.MDRModelImplementation&quot;"/>
+</launchConfiguration>

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2661801

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.