summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdhouib2013-07-23 07:24:28 (EDT)
committerCamille Letavernier2013-07-23 07:24:28 (EDT)
commitb75d3398cb72af86c4f52db28901cd234cf3dca2 (patch)
treec46ea557707c8d8fbc4e4916a9cbfb1b2895eaa3
parent5fa4ca4f6201b13a9eb1133e4c2082fd68c01802 (diff)
downloadorg.eclipse.papyrus-b75d3398cb72af86c4f52db28901cd234cf3dca2.zip
org.eclipse.papyrus-b75d3398cb72af86c4f52db28901cd234cf3dca2.tar.gz
org.eclipse.papyrus-b75d3398cb72af86c4f52db28901cd234cf3dca2.tar.bz2
[PATCH] adding a test to verify if robotml profile is applied
This contribution complies with http://www.eclipse.org/legal/CoO.php
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.classpath2
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.settings/org.eclipse.jdt.core.prefs5
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/META-INF/MANIFEST.MF5
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/ConstraintsUtil.java28
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/DetectRecursivity.java21
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/OnlyOneConnectionBetweenTwoPorts.java3
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortIsCorrectlyTyped.java3
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortsAreCorrectlyConnected.java11
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PropertyNameVsItsTypeName.java4
-rw-r--r--extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/VerifyAlphanumericNamedElement.java2
10 files changed, 67 insertions, 17 deletions
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.classpath b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.classpath
index 64c5e31..5e4c1fe 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.classpath
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.settings/org.eclipse.jdt.core.prefs b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.settings/org.eclipse.jdt.core.prefs
index 1b3cd71..416f4fb 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.settings/org.eclipse.jdt.core.prefs
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,11 @@
-#Wed Jun 08 15:29:18 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/META-INF/MANIFEST.MF b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/META-INF/MANIFEST.MF
index 4092127..d9c1b89 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/META-INF/MANIFEST.MF
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/META-INF/MANIFEST.MF
@@ -2,7 +2,10 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.uml.diagram.common;bundle-version="0.10.1",
org.eclipse.papyrus.robotml;bundle-version="0.10.1",
- org.eclipse.uml2.uml
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.uml.tools,
+ org.eclipse.emf.ecore,
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.1"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.10.1.qualifier
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/ConstraintsUtil.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/ConstraintsUtil.java
new file mode 100644
index 0000000..0aa9015
--- /dev/null
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/ConstraintsUtil.java
@@ -0,0 +1,28 @@
+package org.eclipse.papyrus.robotml.validation.constraints;
+
+import org.eclipse.papyrus.RobotML.RobotMLPackage;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+public class ConstraintsUtil {
+ public static Boolean verifyRobotMLApplied(Element elt){
+ Boolean isRobotmlModel = false;
+ Model model = elt.getModel();
+ if ((model != null)&& (model instanceof Package)){
+
+ Profile robotml = UMLUtil.getProfile(RobotMLPackage.eINSTANCE, model);
+
+ if(((Package)model).isProfileApplied(robotml)) {
+ isRobotmlModel = true;
+ }
+
+
+
+ }
+ return isRobotmlModel;
+ }
+
+}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/DetectRecursivity.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/DetectRecursivity.java
index 44dd8b7..79593ba 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/DetectRecursivity.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/DetectRecursivity.java
@@ -12,9 +12,17 @@
package org.eclipse.papyrus.robotml.validation.constraints;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.IValidationContext;
+import org.eclipse.papyrus.RobotML.RobotMLPackage;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.util.UMLUtil;
// TODO: Auto-generated Javadoc
/**
@@ -27,17 +35,24 @@ public class DetectRecursivity extends AbstractModelConstraint {
*
* @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
*/
- @Override
+
public IStatus validate(IValidationContext ctx) {
+
Property subsystem = (Property)ctx.getTarget();
+
+ if (ConstraintsUtil.verifyRobotMLApplied(subsystem)){
//System.err.println("\n\n Type: "+subsystem.getType() +"\n Owner: "+ subsystem.getOwner());
if(subsystem.getType() == null) {
return ctx.createFailureStatus("Property (subsystem or attribute) must have a Type " + subsystem.getQualifiedName());
} else if(subsystem.getType().equals(subsystem.getOwner())) {
return ctx.createFailureStatus("Problem of recursivity the subsystem " + subsystem.getQualifiedName() + " is typed by the same system that contains it)");
}
- // TODO Auto-generated method stub
+ }
+
return ctx.createSuccessStatus();
}
-
+
+
+
+
}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/OnlyOneConnectionBetweenTwoPorts.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/OnlyOneConnectionBetweenTwoPorts.java
index 5f1b67d..3f500c1 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/OnlyOneConnectionBetweenTwoPorts.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/OnlyOneConnectionBetweenTwoPorts.java
@@ -29,6 +29,7 @@ public class OnlyOneConnectionBetweenTwoPorts extends AbstractModelConstraint {
public IStatus validate(IValidationContext ctx) {
Connector elt = (Connector)ctx.getTarget();
+ if (ConstraintsUtil.verifyRobotMLApplied(elt)){
List<ConnectorEnd> cends = new ArrayList<ConnectorEnd>();
cends = elt.getEnds();
if(cends != null) {//if1
@@ -61,7 +62,7 @@ public class OnlyOneConnectionBetweenTwoPorts extends AbstractModelConstraint {
}
}
}
-
+ }
return ctx.createSuccessStatus();
}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortIsCorrectlyTyped.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortIsCorrectlyTyped.java
index fea0b18..13e1a0c 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortIsCorrectlyTyped.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortIsCorrectlyTyped.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.IValidationContext;
import org.eclipse.papyrus.RobotML.DataFlowPort;
import org.eclipse.papyrus.RobotML.ServicePort;
-
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Interface;
import org.eclipse.uml2.uml.Port;
@@ -29,6 +28,7 @@ public class PortIsCorrectlyTyped extends AbstractModelConstraint {
@Override
public IStatus validate(IValidationContext ctx) {
Port elt = (Port)ctx.getTarget();
+ if (ConstraintsUtil.verifyRobotMLApplied(elt)){
//1. verify if the port is typed
if(elt.getType() == null) {
return ctx.createFailureStatus("Port should have a type (" + elt.getQualifiedName() + ")");
@@ -48,6 +48,7 @@ public class PortIsCorrectlyTyped extends AbstractModelConstraint {
}
}
}
+ }
return ctx.createSuccessStatus();
}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortsAreCorrectlyConnected.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortsAreCorrectlyConnected.java
index d83be5d..06f22d7 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortsAreCorrectlyConnected.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PortsAreCorrectlyConnected.java
@@ -45,6 +45,7 @@ public class PortsAreCorrectlyConnected extends AbstractModelConstraint {
@Override
public IStatus validate(IValidationContext ctx) {
Connector elt = (Connector)ctx.getTarget();
+ if (ConstraintsUtil.verifyRobotMLApplied(elt)){
List<ConnectorEnd> cends = new ArrayList<ConnectorEnd>();
cends = elt.getEnds();
// 1. verify that only ports of the same kind are connected
@@ -58,7 +59,7 @@ public class PortsAreCorrectlyConnected extends AbstractModelConstraint {
ConnectableElement connectorEndRole0 = cends.get(0).getRole();
ConnectableElement connectorEndRole1 = cends.get(1).getRole();
- // System.out.println(connectorEndRole0.getEnds());
+
if((connectorEndRole0 instanceof Port) && (connectorEndRole1 instanceof Port)) {// if4
// verify that the connection is between two ports of
// two subsystems of the same containing system
@@ -86,11 +87,7 @@ public class PortsAreCorrectlyConnected extends AbstractModelConstraint {
if((elt.getOwner() == connectorEndRole0.getOwner()) || (elt.getOwner() == connectorEndRole1.getOwner())) {
areSubsystems = false;
}
- // System.err.println("\n\n\nConnector Owner: "
- // + elt.getOwner()+ "\nPort0 owner: "+
- // connectorEndRole0.getOwner()+
- // "\nPort1 owner: "+
- // connectorEndRole1.getOwner()+" "+areSubsystems+"\n\n");
+
// verify if connections are set between in and
// out DataFlowPorts or provided and required
// ServicePorts
@@ -128,7 +125,7 @@ public class PortsAreCorrectlyConnected extends AbstractModelConstraint {
}// end if2
}// end if1
// 2. verify that there is only one connection between ports
-
+ }
return ctx.createSuccessStatus();
}
}
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PropertyNameVsItsTypeName.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PropertyNameVsItsTypeName.java
index 5902f2a..dc137dc 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PropertyNameVsItsTypeName.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/PropertyNameVsItsTypeName.java
@@ -26,7 +26,7 @@ public class PropertyNameVsItsTypeName extends AbstractModelConstraint {
public IStatus validate(IValidationContext ctx) {
Property subsystem = (Property)ctx.getTarget();
//System.err.println("\n\n Type: "+subsystem.getType() +"\n Owner: "+ subsystem.getOwner());
-
+ if (ConstraintsUtil.verifyRobotMLApplied(subsystem)){
//1. verify that a property has a type
if(subsystem.getType() == null) {
return ctx.createFailureStatus("Property (subsystem or attribute) should have a Type" + subsystem.getQualifiedName());
@@ -49,7 +49,7 @@ public class PropertyNameVsItsTypeName extends AbstractModelConstraint {
return ctx.createFailureStatus("Property (subsystem or attribute) should have a name diffrent from its Type name " + subsystem.getQualifiedName());
}
-
+ }
diff --git a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/VerifyAlphanumericNamedElement.java b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/VerifyAlphanumericNamedElement.java
index f614318..26b2804 100644
--- a/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/VerifyAlphanumericNamedElement.java
+++ b/extraplugins/robotml/org.eclipse.papyrus.robotml.validation/src/org/eclipse/papyrus/robotml/validation/constraints/VerifyAlphanumericNamedElement.java
@@ -39,10 +39,12 @@ public class VerifyAlphanumericNamedElement extends AbstractModelConstraint {
public IStatus validate(IValidationContext ctx) {
// TODO Auto-generated method stub
NamedElement element = (NamedElement)ctx.getTarget();
+ if (ConstraintsUtil.verifyRobotMLApplied(element)){
//4. verify that a property has an alphanumeric name that can also contain underscore
if(((element instanceof Classifier) || (element instanceof Property) || (element instanceof DataType)) && !checkAlphaNumeric(element.getName())) {
return ctx.createFailureStatus("Element should have an alphanumeric name beginning by a letter" + element.getQualifiedName());
}
+ }
return ctx.createSuccessStatus();
}