svn commit: r15576 - branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-08-17 11:36:46-0700
New Revision: 15576

Modified:
   branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java

Log:
adding ocl to ProfileMeta to enforce constraints on profile models



Modified: branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java?view=diff&rev=15576&p1=branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java&p2=branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java&r1=15575&r2=15576
==============================================================================
--- branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java	(original)
+++ branches/gsoc2008/work_issue5042_merged15552_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java	2008-08-17 11:36:46-0700
@@ -27,7 +27,11 @@
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 
+import org.argouml.cognitive.Critic;
+import org.argouml.cognitive.ToDoItem;
 import org.argouml.model.Model;
 import org.argouml.profile.CoreProfileReference;
 import org.argouml.profile.Profile;
@@ -35,6 +39,8 @@
 import org.argouml.profile.ProfileModelLoader;
 import org.argouml.profile.ProfileReference;
 import org.argouml.profile.ResourceModelLoader;
+import org.argouml.profile.internal.ocl.CrOCL;
+import org.argouml.profile.internal.ocl.InvalidOclException;
 
 /**
  * Meta Profile which defines the TaggedValues to be used in User defined
@@ -70,8 +76,67 @@
             model.add(Model.getModelManagementFactory().createModel());
         }
 
+        loadWellFormednessRules();
     }
 
+    private void loadWellFormednessRules() {
+        Set<Critic> critics = new HashSet<Critic>();
+                
+        try {
+            critics.add(new CrOCL("context ModelElement inv: "
+                    + "self.taggedValue->" 
+                    + "exists(x|x.type.name='Dependency') implies "
+                              + "self.stereotype->exists(x|x.name = 'Profile')",
+                 "The 'Dependency' tag definition should be applied"
+                                + " only to profiles.", null,
+                    ToDoItem.MED_PRIORITY, null, null,
+                    "http://argouml.tigris.org/"));
+        } catch (InvalidOclException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            critics.add(new CrOCL("context ModelElement inv: "
+                    + "self.taggedValue->" 
+                    + "exists(x|x.type.name='Figure') or "
+                    + "exists(x|x.type.name='Description') or "
+                    + "exists(x|x.type.name='i18n') or "
+                    + "exists(x|x.type.name='KnowledgeType') or "
+                    + "exists(x|x.type.name='MoreInfoURL') or "
+                    + "exists(x|x.type.name='Priority') or "
+                    + "exists(x|x.type.name='Description') or "
+                    + "exists(x|x.type.name='SupportedDecision') or "
+                    + "exists(x|x.type.name='Headline') "
+                    + "implies "
+                              + "self.stereotype->exists(x|x.name = 'Critic')",
+                              
+                    "Misuse of Metaprofile TaggedValues",
+                    "The 'Figure', 'i18n', 'KnowledgeType', 'MoreInfoURL', " 
+                    + "'Priority', 'SupportedDecision', 'Description' " 
+                    + "and 'Headline' tag definitions "
+                    + "should be applied only to OCL critics.",
+                    
+                    ToDoItem.MED_PRIORITY, null, null,
+                    "http://argouml.tigris.org/"));
+        } catch (InvalidOclException e) {
+            e.printStackTrace();
+        }
+        
+        try {
+            critics.add(new CrOCL("context Stereotype inv: "
+                    + "self.namespace.stereotype->exists(x|x.name = 'Profile')",
+                            "Stereotypes should be declared inside a Profile. ",
+                            "Please add the <<Profile>> stereotype to "
+                                   + "the containing Namespace",
+                    ToDoItem.MED_PRIORITY, null, null,
+                    "http://argouml.tigris.org/"));
+        } catch (InvalidOclException e) {
+            e.printStackTrace();
+        }
+
+        setCritics(critics);
+    }
+    
     @Override
     public String getDisplayName() {
         return "MetaProfile";
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.