svn commit: r15295 - branches/gsoc2008/work_midterm_maurelio1234: . src/org/argouml/profile tests/org/argouml/profile

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-07-16 23:22:51-0700
New Revision: 15295

Modified:
   branches/gsoc2008/work_midterm_maurelio1234/.classpath
   branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
   branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java

Log:
new features

Modified: branches/gsoc2008/work_midterm_maurelio1234/.classpath
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/.classpath?view=diff&rev=15295&p1=branches/gsoc2008/work_midterm_maurelio1234/.classpath&p2=branches/gsoc2008/work_midterm_maurelio1234/.classpath&r1=15294&r2=15295
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/.classpath	(original)
+++ branches/gsoc2008/work_midterm_maurelio1234/.classpath	2008-07-16 23:22:51-0700
@@ -7,7 +7,7 @@
 	<classpathentry exported="true" kind="lib" path="lib/antlr-2.7.7.jar"/>
 	<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.2.jar"/>
 	<classpathentry exported="true" kind="lib" path="lib/gef-0.12.4BETA3.jar" sourcepath="/gef/src"/>
-	<classpathentry exported="true" kind="lib" path="lib/ocl-argo-1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/ocl-argo-1.1.jar" sourcepath="/documents/workspace/gsoc/ocl1/src"/>
 	<classpathentry exported="true" kind="lib" path="lib/swidgets-0.1.4.jar" sourcepath="/swidgets/src"/>
 	<classpathentry exported="true" kind="lib" path="lib/toolbar-1.4.1-20071227.jar" sourcepath="/toolbar/src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>

Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=15295&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=15294&r2=15295
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java	(original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java	2008-07-16 23:22:51-0700
@@ -41,9 +41,14 @@
 import javax.swing.ImageIcon;
 
 import org.apache.log4j.Logger;
+import org.argouml.cognitive.Critic;
+import org.argouml.cognitive.Decision;
+import org.argouml.cognitive.ToDoItem;
 import org.argouml.cognitive.Translator;
 import org.argouml.model.Model;
 import org.argouml.profile.internal.ocl.CrOCL;
+import org.argouml.profile.internal.ocl.InvalidOclException;
+import org.argouml.uml.cognitive.UMLDecision;
 import org.argouml.uml.cognitive.critics.CrUML;
 
 /**
@@ -247,6 +252,11 @@
     private CrUML generateCriticFromComment(Object critique) {
         String ocl = ""+Model.getFacade().getBody(critique);
         String headline = null;
+        String description = null;
+        int    priority = ToDoItem.HIGH_PRIORITY;
+        Vector<Decision> supportedDecisions = new Vector<Decision>();
+        Vector<String>   knowledgeTypes = new Vector<String>();
+        String moreInfoURL = null;
         
         Collection tags = Model.getFacade().getTaggedValuesCollection(critique);
 
@@ -254,16 +264,115 @@
             if (Model.getFacade().getTag(tag).toLowerCase()
                     .equals("headline")) {                
                 headline = Model.getFacade().getValueOfTag(tag);                
-            }
+            } else if (Model.getFacade().getTag(tag).toLowerCase()
+                    .equals("description")) {                
+                description = Model.getFacade().getValueOfTag(tag);                
+            } else if (Model.getFacade().getTag(tag).toLowerCase()
+                    .equals("priority")) {
+                String prioStr = Model.getFacade().getValueOfTag(tag); 
+                
+                if (prioStr.toLowerCase().equals("high")) {
+                    priority = ToDoItem.HIGH_PRIORITY;
+                } else if (prioStr.toLowerCase().equals("med")) {
+                    priority = ToDoItem.MED_PRIORITY;
+                } else if (prioStr.toLowerCase().equals("low")) {
+                    priority = ToDoItem.LOW_PRIORITY;
+                } else if (prioStr.toLowerCase().equals("interruptive")) {
+                    priority = ToDoItem.INTERRUPTIVE_PRIORITY;
+                }
+            } else if (Model.getFacade().getTag(tag).toLowerCase()
+                    .equals("supporteddecision")) {                
+                String decStr = Model.getFacade().getValueOfTag(tag);
+                
+                StringTokenizer st = new StringTokenizer(decStr, ",;:");
+                
+                while (st.hasMoreTokens()) {
+                    String token = st.nextToken().trim().toLowerCase();
+
+                    if (token.equals("behavior"))
+                        supportedDecisions.add(UMLDecision.BEHAVIOR);
+                    if (token.equals("containment"))
+                        supportedDecisions.add(UMLDecision.CONTAINMENT);
+                    if (token.equals("classselection"))
+                        supportedDecisions.add(UMLDecision.CLASS_SELECTION);
+                    if (token.equals("codegen"))
+                        supportedDecisions.add(UMLDecision.CODE_GEN);
+                    if (token.equals("expectedusage"))
+                        supportedDecisions.add(UMLDecision.EXPECTED_USAGE);
+                    if (token.equals("inheritance"))
+                        supportedDecisions.add(UMLDecision.INHERITANCE);
+                    if (token.equals("instantiation"))
+                        supportedDecisions.add(UMLDecision.INSTANCIATION);
+                    if (token.equals("methods"))
+                        supportedDecisions.add(UMLDecision.METHODS);
+                    if (token.equals("modularity"))
+                        supportedDecisions.add(UMLDecision.MODULARITY);
+                    if (token.equals("naming"))
+                        supportedDecisions.add(UMLDecision.NAMING);
+                    if (token.equals("patterns"))
+                        supportedDecisions.add(UMLDecision.PATTERNS);
+                    if (token.equals("plannedextensions"))
+                        supportedDecisions.add(UMLDecision.PLANNED_EXTENSIONS);
+                    if (token.equals("relationships"))
+                        supportedDecisions.add(UMLDecision.RELATIONSHIPS);
+                    if (token.equals("statemachines"))
+                        supportedDecisions.add(UMLDecision.STATE_MACHINES);
+                    if (token.equals("stereotypes"))
+                        supportedDecisions.add(UMLDecision.STEREOTYPES);
+                    if (token.equals("storage"))
+                        supportedDecisions.add(UMLDecision.STORAGE);
+                }
+            } else if (Model.getFacade().getTag(tag).toLowerCase()
+                    .equals("knowledgetype")) {                
+                String ktStr = Model.getFacade().getValueOfTag(tag);
+                
+                StringTokenizer st = new StringTokenizer(ktStr, ",;:");
+                
+                while (st.hasMoreTokens()) {
+                    String token = st.nextToken().trim().toLowerCase();
+
+                    if (token.equals("completeness"))
+                        knowledgeTypes.add(Critic.KT_COMPLETENESS);
+                    if (token.equals("consistency"))
+                        knowledgeTypes.add(Critic.KT_CONSISTENCY);
+                    if (token.equals("correctness"))
+                        knowledgeTypes.add(Critic.KT_CORRECTNESS);
+                    if (token.equals("designers"))
+                        knowledgeTypes.add(Critic.KT_DESIGNERS);
+                    if (token.equals("experiencial"))
+                        knowledgeTypes.add(Critic.KT_EXPERIENCIAL);
+                    if (token.equals("optimization"))
+                        knowledgeTypes.add(Critic.KT_OPTIMIZATION);
+                    if (token.equals("organizational"))
+                        knowledgeTypes.add(Critic.KT_ORGANIZATIONAL);
+                    if (token.equals("presentation"))
+                        knowledgeTypes.add(Critic.KT_PRESENTATION);
+                    if (token.equals("semantics"))
+                        knowledgeTypes.add(Critic.KT_SEMANTICS);
+                    if (token.equals("syntax"))
+                        knowledgeTypes.add(Critic.KT_SYNTAX);
+                    if (token.equals("tool"))
+                        knowledgeTypes.add(Critic.KT_TOOL);
+                }
+            } else if (Model.getFacade().getTag(tag).toLowerCase()
+                    .equals("moreinfourl")) {                
+                moreInfoURL = Model.getFacade().getValueOfTag(tag);                                
+            } 
+            
+            
         }
         
         LOG.debug("OCL-Critic: "+ocl);
-
-        if (headline == null) {
-            return new CrOCL(ocl);
-        } else {
-            return new CrOCL(ocl, headline);            
+        
+        try {
+            return new CrOCL(ocl, headline, description, priority,
+                    supportedDecisions, knowledgeTypes, moreInfoURL);
+        } catch (InvalidOclException e) {
+            LOG.error("Invalid OCL in XMI!", e);
+            
+            return null;
         }
+        
     }
 
     @SuppressWarnings("unchecked")
@@ -276,6 +385,7 @@
             if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
                     "Critic")) {
                 CrUML cr = generateCriticFromComment(comment);
+                
                 if (cr!= null) {
                     ret.add(cr);                    
                 }

Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java?view=diff&rev=15295&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java&r1=15294&r2=15295
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java	(original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java	2008-07-16 23:22:51-0700
@@ -95,7 +95,8 @@
         File profileFile = new File(testDir, "testLoadingConstructor.xmi");
         profileMother.saveProfileModel(model, profileFile);
 
-        CrOCL critic = new CrOCL("context Class inv: 3 > 2");
+        CrOCL critic = new CrOCL("context Class inv: 3 > 2", null, null, null,
+                null, null, null);
         Set<CrUML> critics = new HashSet<CrUML>();
         critics.add(critic);
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.