svn commit: r15423 - branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-07-31 06:08:18-0700
New Revision: 15423

Modified:
   branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java

Log:
implementing core package or uml spec in ocl model interpreter



Modified: branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java?view=diff&rev=15423&p1=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java&p2=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java&r1=15422&r2=15423
==============================================================================
--- branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java	(original)
+++ branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java	2008-07-31 06:08:18-0700
@@ -25,9 +25,9 @@
 package org.argouml.profile.internal.ocl.uml14;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.argouml.model.Facade;
@@ -47,7 +47,7 @@
     private static final Logger LOG = Logger
             .getLogger(ModelAccessModelInterpreter.class);
 
-    /**
+    /*
      * @see org.argouml.profile.internal.ocl.ModelInterpreter#invokeFeature(java.util.HashMap,
      *      java.lang.Object, java.lang.String, java.lang.String,
      *      java.lang.Object[])
@@ -68,17 +68,245 @@
             }
         }
 
+        /* 4.5.2.1 Abstraction */  
+        // TODO investigate: Abstraction.mapping is not in the Model Sybsystem
+
+        /* 4.5.2.3 Association */  
+        
+        if (Model.getFacade().isAAssociation(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("connection")) {
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getConnections(subject));
+                }
+            }
+        }
+
+        /* 4.5.2.5 AssociationEnd */  
+        
+        if (Model.getFacade().isAAssociationEnd(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("aggregation")) {
+                    return Model.getFacade().getAggregation(subject);
+                }
+                if (feature.equals("changeability")) {
+                    return Model.getFacade().getChangeability(subject);
+                }
+                if (feature.equals("ordering")) {
+                    return Model.getFacade().getOrdering(subject);
+                }
+                if (feature.equals("isNavigable")) {
+                    return Model.getFacade().isNavigable(subject);
+                }
+                if (feature.equals("multiplicity")) {
+                    return Model.getFacade().getMultiplicity(subject);
+                }
+                if (feature.equals("targetScope")) {
+                    return Model.getFacade().getTargetScope(subject);
+                }
+                if (feature.equals("visibility")) {
+                    return Model.getFacade().getVisibility(subject);
+                }
+                if (feature.equals("qualifier")) {
+                    return Model.getFacade().getQualifiers(subject);
+                }
+                if (feature.equals("specification")) {
+                    return Model.getFacade().getSpecification(subject);
+                }                
+                if (feature.equals("participant")) {
+                    return Model.getFacade().getClassifier(subject);
+                }
+                
+                // TODO investigate the "unnamed opposite end"
+            }
+        }
+
+        /* 4.5.2.6 Attribute */  
+        
+        if (Model.getFacade().isAAttribute(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("initialValue")) {
+                    return Model.getFacade().getInitialValue(subject);
+                }
+                if (feature.equals("associationEnd")) {
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getAssociationEnds(subject));
+                }
+            }
+        }
+
+        /* 4.5.2.7 BehavioralFeature */  
+        
+        if (Model.getFacade().isABehavioralFeature(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("isQuery")) {
+                    return Model.getFacade().isQuery(subject);
+                }
+                if (feature.equals("parameter")) {
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getParameters(subject));
+                }
+            }
+        }
+
+        /* 4.5.2.8 Binding */  
+        
+        if (Model.getFacade().isABinding(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("argument")) {
+                    return Model.getFacade().getArguments(subject);
+                }
+            }
+        }        
+
+        /* 4.5.2.9 Class */  
+        
         if (Model.getFacade().isAClass(subject)) {
             if (type.equals(".")) {
+                if (feature.equals("isActive")) {
+                    return Model.getFacade().isActive(subject);
+                }
+            }
+        }        
+
+        /* 4.5.2.10 Classifier */  
+        
+        if (Model.getFacade().isAClassifier(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("feature")) {
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getFeatures(subject));
+                }
                 if (feature.equals("feature")) {
-                    Set<Object> ret = new HashSet<Object>();
-                    ret.addAll(Model.getCoreHelper().getAllAttributes(subject));
-                    ret.addAll(Model.getCoreHelper().getOperationsInh(subject));
-                    return ret;
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getFeatures(subject));
+                }
+                if (feature.equals("association")) {
+                    // TODO verify if this is the corrected semantics
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getAssociatedClasses(subject));
+                }                
+                if (feature.equals("powertypeRange")) {
+                    return new HashSet<Object>(Model.getFacade()
+                            .getPowertypeRanges(subject));
+                }
+                // TODO specifiedEnd??
+                if (feature.equals("feature")) {
+                    return new ArrayList<Object>(Model.getFacade()
+                            .getFeatures(subject));
+                }
+            }
+        }        
+
+        /* 4.5.2.11 Comment */  
+        
+        if (Model.getFacade().isAComment(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("body")) {
+                    return Model.getFacade().getBody(subject);
+                }
+                if (feature.equals("annotatedElement")) {
+                    return new HashSet<Object>(Model.getFacade()
+                            .getAnnotatedElements(subject));
                 }
             }
         }
+        
+        /* 4.5.2.12 Component */  
+        
+        if (Model.getFacade().isAComponent(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("deploymentLocation")) {
+                    return new HashSet<Object>(Model.getFacade()
+                            .getDeploymentLocations(subject));
+                }
+                if (feature.equals("resident")) {
+                    // TODO check this
+                    return new HashSet<Object>(Model.getFacade()
+                            .getResidents(subject));
+                }
+                
+                // TODO implementation?
+            }
+        }        
+
+        /* 4.5.2.13 Constraint */  
+        
+        if (Model.getFacade().isAConstraint(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("body")) {
+                    return Model.getFacade().getBody(subject);
+                }
+                if (feature.equals("constrainedElement")) {
+                    // TODO check this
+                    return new HashSet<Object>(Model.getFacade()
+                            .getConstrainedElements(subject));
+                }
+            }
+        }        
 
+        /* 4.5.2.14 Dependency */  
+        
+        if (Model.getFacade().isADependency(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("client")) {
+                    return new HashSet<Object>(Model.getFacade()
+                            .getClients(subject));
+                }
+                if (feature.equals("supplier")) {
+                    return new HashSet<Object>(Model.getFacade()
+                            .getSuppliers(subject));
+                }
+            }
+        }        
+
+        // TODO ElementOwnership is not in ModelSubsys!!
+
+        /* 4.5.2.18 ElementOwnership */          
+        
+        if (Model.getFacade().isAElementResidence(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("visibility")) {
+                    return Model.getFacade().getVisibility(subject);
+                }
+            }
+        }
+
+        /* 4.5.2.19 Enumeration */          
+        
+        if (Model.getFacade().isAEnumeration(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("literal")) {
+                    return Model.getFacade().getEnumerationLiterals(subject);
+                }
+            }
+        }
+
+        /* 4.5.2.20 EnumerationLiteral */          
+        
+        if (Model.getFacade().isAEnumerationLiteral(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("enumeration")) {
+                    return Model.getFacade().getEnumeration(subject);
+                }
+            }
+        }
+        
+        /* 4.5.2.21 Feature */          
+        
+        if (Model.getFacade().isAEnumeration(subject)) {
+            if (type.equals(".")) {
+                if (feature.equals("ownerScope")) {
+                    return Model.getFacade().getOwnerScope(subject);
+                }
+                if (feature.equals("visibility")) {
+                    return Model.getFacade().getVisibility(subject);
+                }
+                if (feature.equals("owner")) {
+                    return Model.getFacade().getOwner(subject);
+                }                
+            }
+        }        
         return null;
     }
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.