Author: maurelio1234
Date: 2008-06-20 01:18:55-0700
New Revision: 15013
Added:
branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/
branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/argouml-wfr.jar (contents, props changed)
branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/jbeans.jar (contents, props changed)
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
Modified:
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
Log:
beginning ocl handling
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/argouml-wfr.jar
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/argouml-wfr.jar?view=auto&rev=15013
==============================================================================
Binary file. No diff available.
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/jbeans.jar
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/jbeans.jar?view=auto&rev=15013
==============================================================================
Binary file. No diff available.
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java 2008-06-20 01:18:55-0700
@@ -52,6 +52,7 @@
import org.argouml.application.api.AbstractArgoJPanel;
import org.argouml.application.api.Argo;
import org.argouml.i18n.Translator;
+import org.argouml.profile.Profile;
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
import org.argouml.profile.UserDefinedProfile;
@@ -639,7 +640,7 @@
Translator.addClassLoader(classloader);
classLoaderAlreadyLoaded = true;
}
- Set<CrUML> profiles = loadCritiquesForProfile(attr, classloader);
+ Set<CrUML> critics = loadCritiquesForProfile(attr, classloader);
String modelPath = attr.getValue("Model");
URL modelURL = null;
@@ -650,7 +651,8 @@
}
UserDefinedProfile udp = new UserDefinedProfile(entryName,
- modelURL, profiles);
+ modelURL, critics,
+ loadManifestDependenciesForProfile(attr));
ProfileFacade.getManager().registerProfile(udp);
LOG.debug("Registered Profile: " + udp.getDisplayName()
@@ -661,9 +663,31 @@
LOG.error("Exception", e);
}
}
+
}
}
+ private Set<Profile> loadManifestDependenciesForProfile(Attributes attr) {
+ Set<Profile> ret = new HashSet<Profile>();
+ String value = attr.getValue("Depends-on");
+ if (value != null) {
+ StringTokenizer st = new StringTokenizer(value, ",");
+
+ while (st.hasMoreElements()) {
+ String entry = st.nextToken().trim();
+ Profile p = ProfileFacade.getManager().lookForRegisteredProfile(
+ entry);
+ if (p!=null) {
+ ret.add(p);
+ } else {
+ LOG.debug("NULL profile?? " + entry);
+ }
+ }
+ }
+
+ return ret;
+ }
+
private Set<CrUML> loadCritiquesForProfile(Attributes attr, ClassLoader classloader) {
Set<CrUML> ret = new HashSet<CrUML>();
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/ProfileManager.java 2008-06-20 01:18:55-0700
@@ -113,4 +113,12 @@
* the standard.
*/
Profile getUMLProfile();
+
+ /**
+ * Looks for registered Profile
+ *
+ * @param profile name
+ * @return profile
+ */
+ Profile lookForRegisteredProfile(String profile);
}
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/URLModelLoader.java 2008-06-20 01:18:55-0700
@@ -27,7 +27,6 @@
import java.net.URL;
import java.util.Collection;
-import org.apache.log4j.Logger;
import org.argouml.model.Model;
import org.argouml.model.UmlException;
import org.argouml.model.XmiReader;
@@ -40,7 +39,7 @@
*/
public class URLModelLoader implements ProfileModelLoader {
- private static final Logger LOG = Logger.getLogger(URLModelLoader.class);
+ //private static final Logger LOG = Logger.getLogger(URLModelLoader.class);
/**
* @param url the url/system id to load
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java 2008-06-20 01:18:55-0700
@@ -35,7 +35,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -45,6 +44,7 @@
import org.apache.log4j.Logger;
import org.argouml.i18n.Translator;
import org.argouml.model.Model;
+import org.argouml.profile.internal.ocl.CrOCL;
import org.argouml.uml.cognitive.critics.CrUML;
/**
@@ -65,11 +65,8 @@
private Collection model;
- private boolean fromZargo;
-
private UserDefinedFigNodeStrategy figNodeStrategy
= new UserDefinedFigNodeStrategy();
-
private class UserDefinedFigNodeStrategy implements FigNodeStrategy {
@@ -124,7 +121,6 @@
"Failed to create the ProfileReference.", e);
}
model = new FileModelLoader().loadModel(reference);
- fromZargo = false;
finishLoading();
}
@@ -150,7 +146,6 @@
"Failed to create the ProfileReference.", e);
}
model = new ReaderModelLoader(reader).loadModel(reference);
- fromZargo = true;
finishLoading();
}
@@ -166,7 +161,6 @@
ProfileReference reference = null;
reference = new UserProfileReference(url.getPath(), url);
model = new URLModelLoader().loadModel(reference);
- fromZargo = false;
finishLoading();
}
@@ -178,9 +172,10 @@
*
* @param url the URL
* @param critics the Critics defined by this profile
+ * @param dependencies
* @throws ProfileException
*/
- public UserDefinedProfile(String entryName, URL url, Set<CrUML> critics)
+ public UserDefinedProfile(String entryName, URL url, Set<CrUML> critics, Set<Profile> dependencies)
throws ProfileException {
LOG.info("load " + url);
@@ -189,12 +184,14 @@
ProfileReference reference = null;
reference = new UserProfileReference(url.getPath(), url);
model = new URLModelLoader().loadModel(reference);
- fromZargo = false;
} else {
model = new ArrayList(0);
}
this.critics = critics;
+ for (Profile profile : dependencies) {
+ addProfileDependency(profile);
+ }
finishLoading();
}
@@ -230,7 +227,7 @@
if (profile != null) {
LOG.debug("AddingDependency " + profile);
this.
- addProfileDependency(lookForRegisteredProfile(profile));
+ addProfileDependency(ProfileFacade.getManager().lookForRegisteredProfile(profile));
}
} while (st.hasMoreTokens());
@@ -263,61 +260,75 @@
}
// load critiques
- Collection allCritiques = getAllCritiques();
+ Vector<CrUML> allCritiques = getAllCritiquesInModel();
+
+ for (CrUML critique : allCritiques) {
+ this.critics.add(critique);
+ }
+ }
+
+ private CrUML generateCriticFromComment(Object critique) {
+ String ocl = ""+Model.getFacade().getBody(critique);
+ String headline = null;
- for (Object critique : allCritiques) {
- CrUML c = generateCriticFromModel(critique);
- if (c!=null) {
- this.critics.add(c);
+ Collection tags = Model.getFacade().getTaggedValuesCollection(critique);
+
+ for (Object tag : tags) {
+ if (Model.getFacade().getTag(tag).toLowerCase()
+ .equals("headline")) {
+ headline = Model.getFacade().getValueOfTag(tag);
}
}
- }
+
+ LOG.debug("OCL-Critic: "+ocl);
- private CrUML generateCriticFromModel(Object critique) {
-// String ocl = Model.getDataTypesHelper().getBody(critique);
-
- return null;
+ if (headline == null) {
+ return new CrOCL(ocl);
+ } else {
+ return new CrOCL(ocl, headline);
+ }
}
@SuppressWarnings("unchecked")
- private Collection getAllCritiques() {
- Collection ret = new Vector();
+ private Vector<CrUML> getAllCritiquesInModel() {
+ Vector<CrUML> ret = new Vector();
+
+ Collection comments = getAllCommentsInModel(model);
- for (Object obj : model) {
- Collection comments = Model.getModelManagementHelper()
- .getAllModelElementsOfKindWithModel(obj,
- Model.getMetaTypes().getComment());
-
- for (Object comment : comments) {
- if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
- "Critic")) {
- ret.add(generateCriticFromModel(comment));
+ for (Object comment : comments) {
+ if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
+ "Critic")) {
+ CrUML cr = generateCriticFromComment(comment);
+ if (cr!= null) {
+ ret.add(cr);
}
}
-
}
return ret;
}
- private Profile lookForRegisteredProfile(String value) {
- ProfileManager manager = ProfileFacade.getManager();
- List<Profile> registeredProfiles = manager.getRegisteredProfiles();
-
- for (Profile profile : registeredProfiles) {
- if (profile.getDisplayName().equalsIgnoreCase(value)) {
- return profile;
+ @SuppressWarnings("unchecked")
+ private Collection getAllCommentsInModel(Collection objs) {
+ Collection col = new Vector<Object>();
+ for (Object obj : objs) {
+ if (Model.getFacade().isAComment(obj)) {
+ col.add(obj);
+ } else if (Model.getFacade().isANamespace(obj)) {
+ Collection contents = Model.getModelManagementHelper()
+ .getAllContents(obj);
+ if (contents != null) {
+ col.addAll(contents);
+ }
}
- }
- return null;
+ }
+ return col;
}
/**
- * @return the string that should represent this profile in the GUI. An
- * start (*) is placed on it if it comes from the currently opened
- * zargo file.
+ * @return the string that should represent this profile in the GUI.
*/
public String getDisplayName() {
- return displayName + (fromZargo ? "*" : "");
+ return displayName;
}
/**
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java 2008-06-20 01:18:55-0700
@@ -332,4 +332,18 @@
return p;
}
+ /**
+ * @see org.argouml.profile.ProfileManager#lookForRegisteredProfile(java.lang.String)
+ */
+ public Profile lookForRegisteredProfile(String value) {
+ List<Profile> registeredProfiles = getRegisteredProfiles();
+
+ for (Profile profile : registeredProfiles) {
+ if (profile.getDisplayName().equalsIgnoreCase(value)) {
+ return profile;
+ }
+ }
+ return null;
+ }
+
}
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java?view=auto&rev=15013
==============================================================================
--- (empty file)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java 2008-06-20 01:18:55-0700
@@ -0,0 +1,56 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal.ocl;
+
+import java.util.Vector;
+
+import tudresden.ocl.parser.analysis.DepthFirstAdapter;
+import tudresden.ocl.parser.node.AClassifierContext;
+
+/**
+ * Check the triggers related to this OCL
+ *
+ * @author maas
+ */
+public class ComputeTriggers extends DepthFirstAdapter {
+
+ private Vector<String> triggs = new Vector<String>();
+
+ /**
+ * @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAClassifierContext(tudresden.ocl.parser.node.AClassifierContext)
+ */
+ public void caseAClassifierContext(AClassifierContext node) {
+ String str = ""+node.getPathTypeName();
+ triggs.add(str.trim().toLowerCase());
+ }
+
+ /**
+ * @return the triggers
+ */
+ public Vector<String> getTriggers() {
+ return triggs;
+ }
+
+}
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java?view=auto&rev=15013
==============================================================================
--- (empty file)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java 2008-06-20 01:18:55-0700
@@ -0,0 +1,90 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal.ocl;
+
+import java.lang.reflect.Method;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Facade;
+import org.argouml.model.Model;
+
+import tudresden.ocl.parser.analysis.DepthFirstAdapter;
+import tudresden.ocl.parser.node.AClassifierContext;
+
+/**
+ * Checks the context clause of the OCL expression to verify if it
+ * is applicable to the given model element.
+ *
+ * @author maurelio1234
+ */
+public class ContextApplicable extends DepthFirstAdapter {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger.getLogger(ContextApplicable.class);
+
+ private boolean applicable = true;
+
+ private Object modelElement;
+
+ /**
+ * Constructos
+ *
+ * @param modelElement the element
+ */
+ public ContextApplicable(Object modelElement) {
+ this.modelElement = modelElement;
+ }
+
+ /**
+ * @return Returns the applicable.
+ */
+ public boolean isApplicable() {
+ return applicable;
+ }
+
+ /**
+ * @param node
+ * @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAClassifierContext(tudresden.ocl.parser.node.AClassifierContext)
+ */
+ public void caseAClassifierContext(AClassifierContext node) {
+ String metaclass = ("" + node.getPathTypeName()).trim();
+
+ try {
+ Method m = Facade.class.getDeclaredMethod("isA" + metaclass,
+ new Class[] { Object.class });
+ if (m != null) {
+ applicable &= (Boolean) m.invoke(Model.getFacade(),
+ new Object[] { modelElement });
+ }
+ } catch (Exception e) {
+ LOG.error("Exception", e);
+ }
+
+ }
+
+
+}
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java?view=auto&rev=15013
==============================================================================
--- (empty file)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java 2008-06-20 01:18:55-0700
@@ -0,0 +1,104 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal.ocl;
+
+import java.util.Vector;
+
+import org.argouml.cognitive.Designer;
+import org.argouml.cognitive.ToDoItem;
+import org.argouml.uml.cognitive.UMLDecision;
+import org.argouml.uml.cognitive.critics.CrUML;
+
+/**
+ * Represents an critics defined as an OCL expression in
+ * a profile
+ *
+ * @author maurelio1234
+ */
+/**
+ *
+ * @author maas
+ */
+public class CrOCL extends CrUML {
+
+ /**
+ * Logger.
+ */
+ //private static final Logger LOG = Logger.getLogger(CrOCL.class);
+
+ /**
+ * the OCL Interpreter
+ */
+ private OclInterpreter interpreter = null;
+
+ /**
+ * Creates a new OCL critic
+ *
+ * @param ocl ocl expression
+ */
+ public CrOCL(String ocl) {
+ interpreter = new OclInterpreter(ocl);
+
+ addSupportedDecision(UMLDecision.PLANNED_EXTENSIONS);
+ setPriority(ToDoItem.HIGH_PRIORITY);
+
+ Vector<String> triggers = interpreter.getTriggers();
+
+ for (String string : triggers) {
+ addTrigger(string);
+ }
+
+ super.setHeadline("OCL Expression");
+ super.setDescription(ocl);
+ }
+
+ /**
+ * Creates a new OCL critic
+ *
+ * @param ocl ocl expression
+ * @param headline headline
+ */
+ public CrOCL(String ocl, String headline) {
+ this(ocl);
+ super.setHeadline(headline);
+ }
+
+ /**
+ * @see org.argouml.uml.cognitive.critics.CrUML#predicate2(java.lang.Object,
+ * org.argouml.cognitive.Designer)
+ */
+ public boolean predicate2(Object dm, Designer dsgr) {
+ if (!interpreter.applicable(dm)) {
+ return NO_PROBLEM;
+ } else {
+ if (interpreter.check(dm)) {
+ return NO_PROBLEM;
+ } else {
+ return PROBLEM_FOUND;
+ }
+ }
+ }
+
+}
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java?view=auto&rev=15013
==============================================================================
--- (empty file)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java 2008-06-20 01:18:55-0700
@@ -0,0 +1,63 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal.ocl;
+
+import java.util.HashMap;
+
+import tudresden.ocl.parser.analysis.DepthFirstAdapter;
+import tudresden.ocl.parser.node.Start;
+
+/**
+ * Evaluates the OCL invariant
+ *
+ * @author maurelio1234
+ */
+public class EvaluateInvariant extends DepthFirstAdapter {
+
+ private boolean ok = true;
+ private HashMap<String, Object> vt = new HashMap<String,Object>();
+ private Object currentValue = null;
+
+ /**
+ * Constructor
+ *
+ * @param modelElement self
+ */
+ public EvaluateInvariant(Object modelElement) {
+ vt.put("self", modelElement);
+ }
+
+ /**
+ * @return is the invariant ok?
+ */
+ public boolean isOK() {
+ return ok;
+ }
+
+ public void outStart(Start node) {
+
+ }
+
+}
Added: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java?view=auto&rev=15013
==============================================================================
--- (empty file)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java 2008-06-20 01:18:55-0700
@@ -0,0 +1,108 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile.internal.ocl;
+
+import java.io.PushbackReader;
+import java.io.StringReader;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+
+import sun.org.mozilla.javascript.internal.EvaluatorException;
+import tudresden.ocl.parser.OclParser;
+import tudresden.ocl.parser.lexer.Lexer;
+import tudresden.ocl.parser.node.Start;
+
+/**
+ * Encapsulates actual interpretation of the OCL expressions for
+ * OCL critics provided by a Profile
+ *
+ * @author maurelio1234
+ */
+public class OclInterpreter {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger.getLogger(CrOCL.class);
+
+ /**
+ * Parser OCL tree
+ */
+ private Start tree = null;
+
+ /**
+ * Creates a new OCL interpreter for a given OCL expression
+ *
+ * @param ocl expression
+ */
+ public OclInterpreter(String ocl) {
+ Lexer lexer = new Lexer(new PushbackReader(new StringReader(ocl), 2));
+
+ OclParser parser = new OclParser(lexer);
+
+ try {
+ tree = parser.parse();
+ } catch (Exception e) {
+ LOG.error("Exception", e);
+ }
+ }
+
+ /**
+ * Checks whether this OCL expression is applicable to a given
+ * model element
+ *
+ * @param modelElement the ModelElement
+ * @return if is applicable
+ */
+ public boolean applicable(Object modelElement) {
+ ContextApplicable ca = new ContextApplicable(modelElement);
+ tree.apply(ca);
+ return ca.isApplicable();
+ }
+
+ /**
+ * Checks if this expression (invariant) is satisfied for
+ * the given model element
+ *
+ * @param modelElement the ModelElement
+ * @return if is satisfied
+ */
+ public boolean check(Object modelElement) {
+ EvaluateInvariant ei = new EvaluateInvariant(modelElement);
+ tree.apply(ei);
+ return ei.isOK();
+ }
+
+ /**
+ * @return the triggers for this OCL
+ */
+ public Vector<String> getTriggers() {
+ ComputeTriggers ct = new ComputeTriggers();
+ tree.apply(ct);
+ return ct.getTriggers();
+ }
+
+}
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi 2008-06-20 01:18:55-0700
@@ -1,5 +1,5 @@
<?xml version = '1.0' encoding = 'UTF-8' ?>
-<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Fri Jun 06 14:30:08 CEST 2008'>
+<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Thu Jun 19 21:01:27 CEST 2008'>
<XMI.header> <XMI.documentation>
<XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
<XMI.exporterVersion>PRE-0.25.6(6) revised on $Date: 2007-05-12 08:08:08 +0200 (sam., 12 mai 2007) $ </XMI.exporterVersion>
@@ -20,9 +20,9 @@
<UML:TagDefinition xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007C8'
name = 'Dependency' visibility = 'public' isSpecification = 'false'>
<UML:TagDefinition.multiplicity>
- <UML:Multiplicity xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007D7'>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000898'>
<UML:Multiplicity.range>
- <UML:MultiplicityRange xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007D6'
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000897'
lower = '0' upper = '-1'/>
</UML:Multiplicity.range>
</UML:Multiplicity>
@@ -44,6 +44,28 @@
isAbstract = 'false'>
<UML:Stereotype.baseClass>Comment</UML:Stereotype.baseClass>
</UML:Stereotype>
+ <UML:TagDefinition xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000899'
+ name = 'Description' isSpecification = 'false'>
+ <UML:TagDefinition.multiplicity>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089A'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089B'
+ lower = '0' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </UML:TagDefinition.multiplicity>
+ </UML:TagDefinition>
+ <UML:TagDefinition xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089C'
+ name = 'Headline' isSpecification = 'false'>
+ <UML:TagDefinition.multiplicity>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089D'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089E'
+ lower = '0' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </UML:TagDefinition.multiplicity>
+ </UML:TagDefinition>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java?view=diff&rev=15013&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java&r1=15012&r2=15013
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java 2008-06-20 01:18:55-0700
@@ -139,11 +139,13 @@
* appears in the to-do tab of the details pane).
*
* MVW: Maybe we can make it part of the constructor CrUML()?
+ *
+ * FIXME: why override if nobody uses?
*/
- @Override
- public final void setHeadline(String s) {
- setupHeadAndDesc();
- }
+ //@Override
+ //public final void setHeadline(String s) {
+ //setupHeadAndDesc();
+ //}
/**
* Set up the locale specific text for the critic headline
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.