svn commit: r12799 - trunk/src/model-euml/src/org/argouml/model/euml

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-06-08 12:36:59-0700
New Revision: 12799

Modified:
   trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
   trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java
   trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java
   trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java

Log:
Add some UseCases implementations

Modified: trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java?view=diff&rev=12799&p1=trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&p2=trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java&r1=12798&r2=12799
==============================================================================
--- trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	(original)
+++ trunk/src/model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java	2007-06-08 12:36:59-0700
@@ -71,7 +71,6 @@
      */
     private EUMLModelImplementation modelImpl;
 
-
     /**
      * Constructor.
      *

Modified: trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java?view=diff&rev=12799&p1=trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java&p2=trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java&r1=12798&r2=12799
==============================================================================
--- trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java	(original)
+++ trunk/src/model-euml/src/org/argouml/model/euml/FacadeEUMLImpl.java	2007-06-08 12:36:59-0700
@@ -238,6 +238,9 @@
     }
 
     public Object getBase(Object handle) {
+        if (handle instanceof Extend) {
+            return ((Extend) handle).getExtendedCase();
+        }
         throw new NotYetImplementedException();
 
     }
@@ -524,7 +527,13 @@
     }
 
     public List<ExtensionPoint> getExtensionPoints(Object handle) {
-        return ((UseCase) handle).getExtensionPoints();
+        if (handle instanceof UseCase) {
+            return ((UseCase) handle).getExtensionPoints();
+        } else if (handle instanceof Extend) {
+            return ((Extend) handle).getExtensionLocations();
+        } 
+        throw new IllegalArgumentException(
+                "Expected UseCase or Extend : " + handle); //$NON-NLS-1$
     }
 
     public List<Feature> getFeatures(Object handle) {
@@ -1741,8 +1750,9 @@
         return handle instanceof UseCase;
     }
 
+    @SuppressWarnings("deprecation")
     public boolean isAUseCaseInstance(Object handle) {
-        throw new NotYetImplementedException();
+        throw new NotImplementedException();
     }
 
     public boolean isAVisibilityKind(Object handle) {

Modified: trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java?view=diff&rev=12799&p1=trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java&p2=trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java&r1=12798&r2=12799
==============================================================================
--- trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java	(original)
+++ trunk/src/model-euml/src/org/argouml/model/euml/UseCasesFactoryEUMLImpl.java	2007-06-08 12:36:59-0700
@@ -26,6 +26,7 @@
 
 package org.argouml.model.euml;
 
+import org.argouml.model.NotImplementedException;
 import org.argouml.model.UseCasesFactory;
 import org.eclipse.uml2.uml.Actor;
 import org.eclipse.uml2.uml.Extend;
@@ -79,9 +80,10 @@
             ep = buildExtensionPoint((UseCase) abase);
         } else {
             ep = (ExtensionPoint) apoint;
-            if (ep.getUseCase().equals(abase)) {
+            if (!ep.getUseCase().equals(abase)) {
                 throw new IllegalArgumentException(
-                        "extension point must belong to extended use case");
+                        "extension point must belong to " + //$NON-NLS-1$
+                        "extended use case"); //$NON-NLS-1$
             }
         }
         Extend extend =
@@ -118,9 +120,9 @@
         return UMLFactory.eINSTANCE.createUseCase();
     }
 
+    @SuppressWarnings("deprecation")
     public InstanceSpecification createUseCaseInstance() {
-        // TODO: double check this - tfm 
-        return UMLFactory.eINSTANCE.createInstanceSpecification();
+        throw new NotImplementedException();
     }
 
 }

Modified: trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java?view=diff&rev=12799&p1=trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java&p2=trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java&r1=12798&r2=12799
==============================================================================
--- trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java	(original)
+++ trunk/src/model-euml/src/org/argouml/model/euml/UseCasesHelperEUMLImpl.java	2007-06-08 12:36:59-0700
@@ -27,8 +27,16 @@
 package org.argouml.model.euml;
 
 import java.util.Collection;
+import java.util.HashSet;
 
+import org.argouml.model.NotImplementedException;
 import org.argouml.model.UseCasesHelper;
+import org.eclipse.uml2.uml.Actor;
+import org.eclipse.uml2.uml.Extend;
+import org.eclipse.uml2.uml.ExtensionPoint;
+import org.eclipse.uml2.uml.Include;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UseCase;
 
 /**
  * The implementation of the UseCasesHelper for EUML2.
@@ -50,60 +58,81 @@
         modelImpl = implementation;
     }
 
-    public void addExtend(Object elem, Object extend) {
-        // TODO Auto-generated method stub
-
+    public void addExtend(Object handle, Object extend) {
+        if (handle instanceof UseCase) {
+            ((UseCase) handle).getExtends().add(
+                    (Extend) extend);
+        } else if (handle instanceof ExtensionPoint) {
+            ((Extend) extend).getExtensionLocations().add(
+                    (ExtensionPoint) handle);
+        }
     }
 
     public void addExtensionPoint(Object handle, Object extensionPoint) {
-        // TODO Auto-generated method stub
-
+        if (handle instanceof UseCase) {
+            ((UseCase) handle).getExtensionPoints().add(
+                    (ExtensionPoint) extensionPoint);
+        } else if (handle instanceof Extend) {
+            ((Extend) handle).getExtensionLocations().add(
+                    (ExtensionPoint) extensionPoint);
+        }
+        throw new IllegalArgumentException(
+                "Must be UseCase or Extend : " //$NON-NLS-1$
+                + handle);
     }
 
     public void addExtensionPoint(Object handle, int position,
             Object extensionPoint) {
-        // TODO Auto-generated method stub
-
+        ((Extend) handle).getExtensionLocations().add(position,
+                (ExtensionPoint) extensionPoint);
     }
 
     public void addInclude(Object usecase, Object include) {
-        // TODO Auto-generated method stub
-
+        ((UseCase) usecase).getIncludes().add((Include) include);
     }
 
     public Collection getAllActors(Object ns) {
-        // TODO Auto-generated method stub
-        return null;
+        return getAllOfType((org.eclipse.uml2.uml.Package) ns, Actor.class);
     }
 
     public Collection getAllUseCases(Object ns) {
-        // TODO Auto-generated method stub
-        return null;
+        return getAllOfType((org.eclipse.uml2.uml.Package) ns, UseCase.class);
+    }
+    
+    private Collection<Type> getAllOfType(org.eclipse.uml2.uml.Package pkg,
+            Class type) {
+        return modelImpl.getModelManagementHelper().getAllModelElementsOfKind(
+                pkg, type);
     }
 
     public Collection getExtendedUseCases(Object ausecase) {
-        // TODO Auto-generated method stub
-        return null;
+        Collection<UseCase> result = new HashSet<UseCase>();
+        for (Extend extend : ((UseCase) ausecase).getExtends()) {
+            result.add(extend.getExtension());
+        }
+        return result;
     }
 
-    public Collection getExtendingUseCases(Object usecase) {
-        // TODO Auto-generated method stub
-        return null;
+    @SuppressWarnings("deprecation")
+    public Collection<UseCase> getExtendingUseCases(Object usecase) {
+        // TODO: association is not navigable in this direction
+        throw new NotImplementedException();
     }
 
-    public Object getExtends(Object abase, Object anextension) {
-        // TODO Auto-generated method stub
-        return null;
+    public Extend getExtends(Object abase, Object anextension) {
+        return ((UseCase) anextension).getExtend(null, (UseCase) abase);
     }
 
-    public Collection getIncludedUseCases(Object ausecase) {
-        // TODO Auto-generated method stub
-        return null;
+    public Collection<UseCase> getIncludedUseCases(Object ausecase) {
+        Collection<UseCase> result = new HashSet<UseCase>();
+        for (Include include : ((UseCase) ausecase).getIncludes() ) {
+            result.add(include.getAddition());
+        }
+        return result;
     }
 
-    public Object getIncludes(Object abase, Object aninclusion) {
-        // TODO Auto-generated method stub
-        return null;
+    public Include getIncludes(Object abase, Object aninclusion) {
+        return ((UseCase) abase).getInclude(null, (UseCase) aninclusion);
     }
 
     public Collection getSpecificationPath(Object ausecase) {
@@ -113,7 +142,6 @@
 
     public void removeExtend(Object elem, Object extend) {
         // TODO Auto-generated method stub
-
     }
 
     public void removeExtensionPoint(Object elem, Object ep) {
@@ -122,13 +150,11 @@
     }
 
     public void removeInclude(Object usecase, Object include) {
-        // TODO Auto-generated method stub
-
+        ((UseCase) usecase).getIncludes().remove((Include) include);
     }
 
     public void setAddition(Object handle, Object useCase) {
-        // TODO Auto-generated method stub
-
+        ((Include) handle).setAddition((UseCase) useCase);
     }
 
     public void setBase(Object extend, Object base) {
@@ -142,13 +168,22 @@
     }
 
     public void setExtension(Object handle, Object ext) {
-        // TODO Auto-generated method stub
-
     }
 
     public void setExtensionPoints(Object handle, Collection extensionPoints) {
-        // TODO Auto-generated method stub
-
+        if (handle instanceof Extend) {
+            ((Extend) handle).getExtensionLocations().clear();
+            ((Extend) handle).getExtensionLocations().addAll(
+                    (Collection<ExtensionPoint>) extensionPoints);
+        } else if (handle instanceof UseCase) {
+            ((UseCase) handle).getExtensionPoints().clear();
+            ((UseCase) handle).getExtensionPoints().addAll(
+                    (Collection<ExtensionPoint>) extensionPoints);
+        } else {
+            throw new IllegalArgumentException(
+                    "Expected Extend or UseCase : "  //$NON-NLS-1$
+                    + handle);
+        }
     }
 
     public void setIncludes(Object handle, Collection includes) {
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.