Bug 566309 - [Robotics] Integrate tables for Assertions, Contracts & NFProperties (ITP contribution)

- Commit changes from ITP

Change-Id: I3f2f304e441f455772dcfbd098ce3b44d416d394
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/assertions/languages/org.eclipse.papyrus.robotics.assertions.languages.othello/src/org/eclipse/papyrus/robotics/assertions/languages/othello/OthelloLanguage.java b/plugins/assertions/languages/org.eclipse.papyrus.robotics.assertions.languages.othello/src/org/eclipse/papyrus/robotics/assertions/languages/othello/OthelloLanguage.java
index 1e3a81b..fb3479b 100644
--- a/plugins/assertions/languages/org.eclipse.papyrus.robotics.assertions.languages.othello/src/org/eclipse/papyrus/robotics/assertions/languages/othello/OthelloLanguage.java
+++ b/plugins/assertions/languages/org.eclipse.papyrus.robotics.assertions.languages.othello/src/org/eclipse/papyrus/robotics/assertions/languages/othello/OthelloLanguage.java
@@ -149,15 +149,20 @@
 		StringBuffer refinedby = new StringBuffer();
 
 		// add components
+		List<String> alreadyAdded = new ArrayList<String>();
 		for (ComponentInstance compInstance : system.getInstances()) {
-			oss.append("\n");
 			ComponentDefinition compDef = compInstance.getCompdef();
-			oss.append(ossFromCompDefinition(compDef, false));
-			if (addContracts) {
-				StringBuffer contract = ossFromCompInstanceContract(compInstance);
-				if (contract.length() != 0) {
-					oss.append(contract);
-					refinedby.append(compInstance.getBase_Property().getName() + ".pass, ");
+			String compDefName = compDef.getBase_Class().getName();
+			if (!alreadyAdded.contains(compDefName)) {
+				oss.append("\n");
+				alreadyAdded.add(compDefName);
+				oss.append(ossFromCompDefinition(compDef, false));
+				if (addContracts) {
+					StringBuffer contract = ossFromCompInstanceContract(compInstance);
+					if (contract.length() != 0) {
+						oss.append(contract);
+						refinedby.append(compInstance.getBase_Property().getName() + ".pass, ");
+					}
 				}
 			}
 		}
diff --git a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.languages/src/org/eclipse/papyrus/robotics/assertions/languages/P4RExpressionsHelper.java b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.languages/src/org/eclipse/papyrus/robotics/assertions/languages/P4RExpressionsHelper.java
index 67e61e7..5aa3c39 100644
--- a/plugins/assertions/org.eclipse.papyrus.robotics.assertions.languages/src/org/eclipse/papyrus/robotics/assertions/languages/P4RExpressionsHelper.java
+++ b/plugins/assertions/org.eclipse.papyrus.robotics.assertions.languages/src/org/eclipse/papyrus/robotics/assertions/languages/P4RExpressionsHelper.java
@@ -127,6 +127,7 @@
 		}
 
 		if (system != null) {
+			// properties of component instances
 			List<ComponentInstance> instances = system.getInstances();
 			for (ComponentInstance instance : instances) {
 				String instanceName = instance.getBase_Property().getName();
@@ -148,6 +149,18 @@
 					}
 				}
 			}
+			// system properties
+			Map<String, ValueSpecification> systemProperties = getProperties(system.getBase_Class());
+			for (String key : systemProperties.keySet()) {
+				if (expression.contains(key)) {
+					Object result = AssertionsHelper.evaluateValueSpecification(system,
+							systemProperties.get(key));
+					if (result == null) {
+						result = "null";
+					}
+					expression = expression.replaceAll(key, result.toString());
+				}
+			}
 		}
 		return expression;
 	}