Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-07-25 16:43:06 +0000
committerCamille Letavernier2013-07-25 16:43:06 +0000
commit0f6f86b482afe273b51a006ca054a3ae0d28c28b (patch)
tree7d8f4fd96b81bc1e4f646e76d4b34024cbdf0762 /extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml
parent6263634e2387d4b3c94cf69296ad5d8b76435945 (diff)
downloadorg.eclipse.papyrus-0f6f86b482afe273b51a006ca054a3ae0d28c28b.tar.gz
org.eclipse.papyrus-0f6f86b482afe273b51a006ca054a3ae0d28c28b.tar.xz
org.eclipse.papyrus-0f6f86b482afe273b51a006ca054a3ae0d28c28b.zip
413755: [RobotML] Add RobotML code generators
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413755 Apply Papyrus formatter; remove unused imports
Diffstat (limited to 'extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml')
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java14
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java503
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java149
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java284
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java68
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java482
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java108
7 files changed, 781 insertions, 827 deletions
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java
index 8202b692812..432d9c1c4ea 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java
@@ -27,15 +27,16 @@ public class Activator extends Plugin {
* The shared instance.
*/
private static Activator plugin;
-
+
/**
* The constructor.
*/
public Activator() {
}
- /**{@inheritDoc}
- *
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@@ -43,8 +44,9 @@ public class Activator extends Plugin {
plugin = this;
}
- /**{@inheritDoc}
- *
+ /**
+ * {@inheritDoc}
+ *
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -54,7 +56,7 @@ public class Activator extends Plugin {
/**
* Returns the shared instance.
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java
index 8708303b18c..4d6aac650b5 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java
@@ -13,9 +13,13 @@
*****************************************************************************/
package org.eclipse.papyrus.robotml.generators.common.mmqueries;
-import java.util.List;
import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.papyrus.RobotML.DataFlowDirectionKind;
+import org.eclipse.papyrus.RobotML.DataFlowPort;
+import org.eclipse.papyrus.RobotML.ServiceFlowKind;
+import org.eclipse.papyrus.RobotML.ServicePort;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.ConnectorEnd;
@@ -27,53 +31,53 @@ import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.util.UMLUtil;
-import org.eclipse.papyrus.RobotML.*;
/**
*
* @author scdtnsm
- *
+ *
*/
public class ArchitectureQueries {
-
- /**
+
+ /**
* Checks whether or not a port is a "source port" from the point of view of a given connector.
* A source port can be an output port for a connector stepping out of a component or it can be
* an input port for a connector linking a component model input port to a component input port
- * inside the component model (e.g. from the model boundaries to a component inside the model).
+ * inside the component model (e.g. from the model boundaries to a component inside the model).
*/
static private boolean isSourcePort(ConnectorEnd end, Port p) {
- return ((isAnInputPort(p) &&end.getPartWithPort() == null) || (isAnOutputPort(p) && end.getPartWithPort() != null));
-
+ return ((isAnInputPort(p) && end.getPartWithPort() == null) || (isAnOutputPort(p) && end.getPartWithPort() != null));
+
}
-
+
/**
* Checks whether or not a port is a "destination port" from the point of view of a given connector.
* A destination port can be an input port for a connector stepping out of a component or it can be
* an output port for a connector linking a component model output port to a component output port
- * inside the component model (e.g. from a component inside the model to the model boundaries).
+ * inside the component model (e.g. from a component inside the model to the model boundaries).
*/
static private boolean isDestPort(ConnectorEnd end, Port p) {
return ((isAnOutputPort(p) && end.getPartWithPort() == null) || (isAnInputPort(p) && end.getPartWithPort() != null));
-
+
}
-
- /**
- * Retrieves the source port for a given connector
+
+ /**
+ * Retrieves the source port for a given connector
+ *
* @see isDestPort and isSourcePort
*/
- static private int getSourcePort(org.eclipse.uml2.uml.Connector conn, Port[] dest_port) {
-
- if (conn.getEnds().get(0).getRole() instanceof Port) {
+ static private int getSourcePort(org.eclipse.uml2.uml.Connector conn, Port[] dest_port) {
+
+ if(conn.getEnds().get(0).getRole() instanceof Port) {
Port test_1 = (Port)conn.getEnds().get(0).getRole();
- if (isSourcePort(conn.getEnds().get(0),test_1)) {
+ if(isSourcePort(conn.getEnds().get(0), test_1)) {
dest_port[0] = test_1;
return 0;
}
Port test_2 = (Port)conn.getEnds().get(1).getRole();
- if (isSourcePort(conn.getEnds().get(1),test_2)) {
+ if(isSourcePort(conn.getEnds().get(1), test_2)) {
dest_port[0] = test_2;
return 1;
}
@@ -81,20 +85,21 @@ public class ArchitectureQueries {
dest_port = null;
return -1;
}
-
- /**
- * Retrieves the destination port for a given connector
+
+ /**
+ * Retrieves the destination port for a given connector
+ *
* @see isDestPort and isSourcePort
*/
public static int getDestPort(org.eclipse.uml2.uml.Connector conn, Port[] dest_port) {
- if (conn.getEnds().get(0).getRole() instanceof Port) {
+ if(conn.getEnds().get(0).getRole() instanceof Port) {
Port test_1 = (Port)conn.getEnds().get(0).getRole();
- if (isDestPort(conn.getEnds().get(0),test_1)) {
+ if(isDestPort(conn.getEnds().get(0), test_1)) {
dest_port[0] = test_1;
return 0;
}
Port test_2 = (Port)conn.getEnds().get(1).getRole();
- if (isDestPort(conn.getEnds().get(1),test_2)) {
+ if(isDestPort(conn.getEnds().get(1), test_2)) {
dest_port[0] = test_2;
return 1;
}
@@ -102,46 +107,48 @@ public class ArchitectureQueries {
dest_port = null;
return -1;
}
-
- /**
+
+ /**
* Get the source port name of a connector.
*/
static public String getSourcePortName(org.eclipse.uml2.uml.Connector conn) {
String inputName;
Port[] inputPort = new Port[1];
int index = getSourcePort(conn, inputPort);
- if (index < 0)
+ if(index < 0)
return "Unknown";
-
- inputName = inputPort[0].getName();
+
+ inputName = inputPort[0].getName();
return inputName;
}
-
+
/**
* Retrieve the model name of a component at the source of a connector.
+ *
* @param conn
* @return a string or null if no component has been found at the source of a connector.
*/
static public String getSourceComponentTypeNameForConnector(org.eclipse.uml2.uml.Connector conn) {
Property prop = getSourceComponentForConnector(conn);
- if (prop == null)
+ if(prop == null)
return null;
return prop.getType().getName();
}
-
+
/**
* Retrieve the instance name of a component at the source of a connector.
+ *
* @param conn
* @return a string or null if no component has been found at the source of a connector.
*/
static public String getSourceComponentInstanceNameForConnector(org.eclipse.uml2.uml.Connector conn) {
Property prop = getSourceComponentForConnector(conn);
- if (prop == null)
+ if(prop == null)
return null;
return prop.getName();
}
-
+
/**
* Get the source component instance of a connector
*/
@@ -149,28 +156,28 @@ public class ArchitectureQueries {
Property input;
Port[] inputPort = new Port[1];
int index = getSourcePort(conn, inputPort);
- if ( (index < 0) || (conn.getEnds().get(index).getPartWithPort()==null) )
- return null;
+ if((index < 0) || (conn.getEnds().get(index).getPartWithPort() == null))
+ return null;
else
input = conn.getEnds().get(index).getPartWithPort();
return input;
}
-
- /**
+
+ /**
* Get the destination port name of a connector
*/
static public String getDestPortName(org.eclipse.uml2.uml.Connector conn) {
String outputName;
Port[] outputPort = new Port[1];
int index = getDestPort(conn, outputPort);
- if (index < 0)
+ if(index < 0)
return "Unknown";
-
- outputName = outputPort[0].getName();
+
+ outputName = outputPort[0].getName();
return outputName;
}
-
+
/**
* Get the destination component instance of a connector
*/
@@ -178,8 +185,8 @@ public class ArchitectureQueries {
Property output;
Port[] outputPort = new Port[1];
int index = getDestPort(conn, outputPort);
- if ( (index < 0) || (conn.getEnds().get(index).getPartWithPort()==null) )
- return null;
+ if((index < 0) || (conn.getEnds().get(index).getPartWithPort() == null))
+ return null;
else
output = conn.getEnds().get(index).getPartWithPort();
return output;
@@ -187,36 +194,38 @@ public class ArchitectureQueries {
/**
* Retrieve the model name (or type name) of a component at the destination of a connector.
+ *
* @param conn
* @return a string or null if no component has been found at the destination of a connector.
*/
static public String getDestComponentTypeNameForConnector(org.eclipse.uml2.uml.Connector conn) {
Property prop = getDestComponentForConnector(conn);
- if (prop == null)
+ if(prop == null)
return null;
return prop.getType().getName();
}
-
+
/**
* Retrieve the instance name of a component at the destination of a connector.
+ *
* @param conn
* @return a string or null if no component has been found at the destination of a connector.
*/
static public String getDestComponentInstanceNameForConnector(org.eclipse.uml2.uml.Connector conn) {
Property prop = getDestComponentForConnector(conn);
- if (prop == null)
+ if(prop == null)
return null;
return prop.getName();
}
-
+
/**
* Retrieves all the connectors between subcomponents inside a given component model.
* (does not retrieve connectors between component model boundaries and subcomponents inside the model).
*/
static public List<org.eclipse.uml2.uml.Connector> getInternalConnectors(org.eclipse.uml2.uml.Class c) {
LinkedList<org.eclipse.uml2.uml.Connector> connectors = new LinkedList<org.eclipse.uml2.uml.Connector>();
- for (Connector conn : c.getOwnedConnectors()) {
- if (conn.getEnds().size() >= 2 && (conn.getEnds().get(0).getPartWithPort() != null) && (conn.getEnds().get(1).getPartWithPort() != null)) {
+ for(Connector conn : c.getOwnedConnectors()) {
+ if(conn.getEnds().size() >= 2 && (conn.getEnds().get(0).getPartWithPort() != null) && (conn.getEnds().get(1).getPartWithPort() != null)) {
connectors.add(conn);
}
}
@@ -229,12 +238,12 @@ public class ArchitectureQueries {
*/
static public List<org.eclipse.uml2.uml.Connector> getExternalInputConnectors(org.eclipse.uml2.uml.Class c) {
LinkedList<org.eclipse.uml2.uml.Connector> connectors = new LinkedList<org.eclipse.uml2.uml.Connector>();
- for (Connector conn : c.getOwnedConnectors()) {
- if (conn.getEnds().size() >= 2) {// && (conn.getEnds().get(1).getPartWithPort() != null)) {
- if (conn.getEnds().get(0).getRole() instanceof Port && conn.getEnds().get(1).getRole() instanceof Port) {
+ for(Connector conn : c.getOwnedConnectors()) {
+ if(conn.getEnds().size() >= 2) {// && (conn.getEnds().get(1).getPartWithPort() != null)) {
+ if(conn.getEnds().get(0).getRole() instanceof Port && conn.getEnds().get(1).getRole() instanceof Port) {
Port port_1 = (Port)conn.getEnds().get(0).getRole();
Port port_2 = (Port)conn.getEnds().get(1).getRole();
- if ((isAnInputPort(port_1) && conn.getEnds().get(0).getPartWithPort() == null) || (isAnInputPort(port_2) && conn.getEnds().get(1).getPartWithPort() == null)) {
+ if((isAnInputPort(port_1) && conn.getEnds().get(0).getPartWithPort() == null) || (isAnInputPort(port_2) && conn.getEnds().get(1).getPartWithPort() == null)) {
connectors.add(conn);
}
}
@@ -242,19 +251,19 @@ public class ArchitectureQueries {
}
return connectors;
}
-
+
/**
* Retrieves all the connectors between subcomponents that are inside the component model and the component model outputs.
* (does not retrieve connectors between subcomponents inside the component model, nor connectors from component model inputs to subcomponents).
*/
static public List<org.eclipse.uml2.uml.Connector> getExternalOutputConnectors(org.eclipse.uml2.uml.Class c) {
LinkedList<org.eclipse.uml2.uml.Connector> connectors = new LinkedList<org.eclipse.uml2.uml.Connector>();
- for (Connector conn : c.getOwnedConnectors()) {
- if (conn.getEnds().size() >= 2) {// && (conn.getEnds().get(0).getPartWithPort() != null)) {
- if (conn.getEnds().get(0).getRole() instanceof Port && conn.getEnds().get(1).getRole() instanceof Port) {
+ for(Connector conn : c.getOwnedConnectors()) {
+ if(conn.getEnds().size() >= 2) {// && (conn.getEnds().get(0).getPartWithPort() != null)) {
+ if(conn.getEnds().get(0).getRole() instanceof Port && conn.getEnds().get(1).getRole() instanceof Port) {
Port port_1 = (Port)conn.getEnds().get(0).getRole();
Port port_2 = (Port)conn.getEnds().get(1).getRole();
- if ((isAnOutputPort(port_1) && conn.getEnds().get(0).getPartWithPort() == null) || (isAnOutputPort(port_2) && conn.getEnds().get(1).getPartWithPort() == null)) {
+ if((isAnOutputPort(port_1) && conn.getEnds().get(0).getPartWithPort() == null) || (isAnOutputPort(port_2) && conn.getEnds().get(1).getPartWithPort() == null)) {
connectors.add(conn);
}
}
@@ -262,69 +271,68 @@ public class ArchitectureQueries {
}
return connectors;
}
-
+
/**
* Retrieves the highest level class into which a given model is contained.
* (a model can be contained in a model ... which is contained in a class).
*/
static public org.eclipse.uml2.uml.Class getRootClassForModel(org.eclipse.uml2.uml.Model m) {
- for (Element ne : m.getOwnedElements()) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- return ( org.eclipse.uml2.uml.Class)ne;
- } else if (ne instanceof org.eclipse.uml2.uml.Model) {
- return getRootClassForModel((org.eclipse.uml2.uml.Model)ne);
- }
+ for(Element ne : m.getOwnedElements()) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ return (org.eclipse.uml2.uml.Class)ne;
+ } else if(ne instanceof org.eclipse.uml2.uml.Model) {
+ return getRootClassForModel((org.eclipse.uml2.uml.Model)ne);
+ }
}
return null;
}
+
/**
* On a given class (a RobotML system), retrieve all the contained systems.
- * Recursive.
+ * Recursive.
*/
- static public List<org.eclipse.uml2.uml.Property> getAllSubComponentsInClass(org.eclipse.uml2.uml.Class c)
- {
+ static public List<org.eclipse.uml2.uml.Property> getAllSubComponentsInClass(org.eclipse.uml2.uml.Class c) {
LinkedList<org.eclipse.uml2.uml.Property> sub_components = new LinkedList<org.eclipse.uml2.uml.Property>();
- List <org.eclipse.uml2.uml.Property> level_1 = getLevel1SubComponentsForComponent(c);
+ List<org.eclipse.uml2.uml.Property> level_1 = getLevel1SubComponentsForComponent(c);
sub_components.addAll(level_1);
- for (Property prop : level_1) {
+ for(Property prop : level_1) {
List<Property> next_levels = getAllSubComponentsInClass((org.eclipse.uml2.uml.Class)prop.getType());
sub_components.addAll(next_levels);
}
return sub_components;
}
-
+
/**
* On a given class (a RobotML system), retrieve all the contained systems.
* Not recursive. Retrieves only one level deep.
*/
- static public List<org.eclipse.uml2.uml.Property> getLevel1SubComponentsForComponent(org.eclipse.uml2.uml.Class c)
- {
+ static public List<org.eclipse.uml2.uml.Property> getLevel1SubComponentsForComponent(org.eclipse.uml2.uml.Class c) {
LinkedList<org.eclipse.uml2.uml.Property> sub_components = new LinkedList<org.eclipse.uml2.uml.Property>();
- for (org.eclipse.uml2.uml.Property prop : c.getAllAttributes()) {
+ for(org.eclipse.uml2.uml.Property prop : c.getAllAttributes()) {
Type t = prop.getType();
- if (t instanceof org.eclipse.uml2.uml.Class) {
- if (GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)t, org.eclipse.papyrus.RobotML.System.class)) {
+ if(t instanceof org.eclipse.uml2.uml.Class) {
+ if(GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)t, org.eclipse.papyrus.RobotML.System.class)) {
sub_components.add(prop);
}
}
}
return sub_components;
}
-
+
/**
* On a given class (a RobotML system), retrieve all the contained systems.
* Not recursive. Retrieves only one level deep.
- * @deprecated replaced by getLevel1SubComponentsForComponent(org.eclipse.uml2.uml.Class c) which uses the RobotML API instead of stereotype names.
+ *
+ * @deprecated replaced by getLevel1SubComponentsForComponent(org.eclipse.uml2.uml.Class c) which uses the RobotML API instead of stereotype
+ * names.
*/
- static public List<org.eclipse.uml2.uml.Property> getLevel1SubComponentsForComponentWithStereotype(org.eclipse.uml2.uml.Class c, String stereotype)
- {
+ static public List<org.eclipse.uml2.uml.Property> getLevel1SubComponentsForComponentWithStereotype(org.eclipse.uml2.uml.Class c, String stereotype) {
LinkedList<org.eclipse.uml2.uml.Property> sub_components = new LinkedList<org.eclipse.uml2.uml.Property>();
- for (Property prop : c.getAllAttributes()) {
+ for(Property prop : c.getAllAttributes()) {
Type t = prop.getType();
- if (t instanceof org.eclipse.uml2.uml.Class) {
-// if(GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class) t, stereotype))
- if(GeneralQueries.inheritsFrom((org.eclipse.uml2.uml.Class) t, stereotype))
- {
+ if(t instanceof org.eclipse.uml2.uml.Class) {
+ // if(GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class) t, stereotype))
+ if(GeneralQueries.inheritsFrom((org.eclipse.uml2.uml.Class)t, stereotype)) {
sub_components.add(prop);
}
}
@@ -332,30 +340,30 @@ public class ArchitectureQueries {
return sub_components;
}
-
+
/**
* As its name says, retrieves the output ports for a given element.
*/
static public List<org.eclipse.uml2.uml.Port> getOutputPortsForElement(Element elt) {
- LinkedList<org.eclipse.uml2.uml.Port> found_output_ports = new LinkedList<org.eclipse.uml2.uml.Port>();
- for (Element child : elt.getOwnedElements()) {
- if (child instanceof org.eclipse.uml2.uml.Port) {
- if (isAnOutputPort((org.eclipse.uml2.uml.Port)child)) {
+ LinkedList<org.eclipse.uml2.uml.Port> found_output_ports = new LinkedList<org.eclipse.uml2.uml.Port>();
+ for(Element child : elt.getOwnedElements()) {
+ if(child instanceof org.eclipse.uml2.uml.Port) {
+ if(isAnOutputPort((org.eclipse.uml2.uml.Port)child)) {
found_output_ports.add((org.eclipse.uml2.uml.Port)child);
}
}
}
return found_output_ports;
}
-
+
/**
* As its name says, retrieves the input ports for a given element.
*/
static public List<Port> getInputPortsForElement(Element elt) {
LinkedList<Port> found_input_ports = new LinkedList<org.eclipse.uml2.uml.Port>();
- for (Element child : elt.getOwnedElements()) {
- if (child instanceof NamedElement && child instanceof org.eclipse.uml2.uml.Port) {
- if (isAnInputPort((org.eclipse.uml2.uml.Port)child)) {
+ for(Element child : elt.getOwnedElements()) {
+ if(child instanceof NamedElement && child instanceof org.eclipse.uml2.uml.Port) {
+ if(isAnInputPort((org.eclipse.uml2.uml.Port)child)) {
Port found_port = (org.eclipse.uml2.uml.Port)child;
found_input_ports.add(found_port);
}
@@ -363,177 +371,163 @@ public class ArchitectureQueries {
}
return found_input_ports;
}
-
- static public List<org.eclipse.uml2.uml.Property> getOnPort(org.eclipse.uml2.uml.Parameter param)
- {
+
+ static public List<org.eclipse.uml2.uml.Property> getOnPort(org.eclipse.uml2.uml.Parameter param) {
LinkedList<org.eclipse.uml2.uml.Property> result = new LinkedList<org.eclipse.uml2.uml.Property>();
- for(Stereotype st : param.getAppliedStereotypes())
- {
- if(st.getName().contains("OnPort"))
- {
- for(Property p: st.getAttributes())
- {
+ for(Stereotype st : param.getAppliedStereotypes()) {
+ if(st.getName().contains("OnPort")) {
+ for(Property p : st.getAttributes()) {
result.add((Property)p);
}
}
}
-
+
return result;
}
-
+
/**
* Retrieves all the component models available inside a RobotML model.
*/
- static public List<NamedElement> getComponentModels(Model model)
- {
+ static public List<NamedElement> getComponentModels(Model model) {
LinkedList<NamedElement> found_elts = new LinkedList<NamedElement>();
- for (Element elt : model.allOwnedElements()) {
- if (elt instanceof org.eclipse.uml2.uml.Class) {
- if (GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)elt,org.eclipse.papyrus.RobotML.System.class) &&
- false == GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)elt, org.eclipse.papyrus.RobotML.Platform.class)) {
+ for(Element elt : model.allOwnedElements()) {
+ if(elt instanceof org.eclipse.uml2.uml.Class) {
+ if(GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)elt, org.eclipse.papyrus.RobotML.System.class) && false == GeneralQueries.hasStereotype((org.eclipse.uml2.uml.Class)elt, org.eclipse.papyrus.RobotML.Platform.class)) {
found_elts.add((NamedElement)elt);
}
}
}
return found_elts;
}
-
+
/**
* Is the elt at the root of the model hierarchy ?
+ *
* @param elt
* @return
*/
- static public Boolean isRootModel(Model elt)
- {
- if (elt==null)
+ static public Boolean isRootModel(Model elt) {
+ if(elt == null)
return false;
return (elt.getOwner() == null);
}
-
+
/**
* Does this class contain properties that are classes themselves ?
* (i.e. is this class a container of sub-classes)
+ *
* @param c
* @return
*/
- static public Boolean isMacroComponent(org.eclipse.uml2.uml.Class c)
- {
+ static public Boolean isMacroComponent(org.eclipse.uml2.uml.Class c) {
boolean result = false;
- if (getLevel1SubComponentsForComponent(c).size() > 0) {
+ if(getLevel1SubComponentsForComponent(c).size() > 0) {
result = true;
}
return result;
}
-
- static public Boolean hasNativeImplementation(org.eclipse.uml2.uml.Class c)
- {
+
+ static public Boolean hasNativeImplementation(org.eclipse.uml2.uml.Class c) {
org.eclipse.papyrus.RobotML.System sys = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(c, org.eclipse.papyrus.RobotML.System.class);
- if (sys == null)
+ if(sys == null)
return false;
return sys.isNative();
}
-
- static public String getNativeLibraryPathForComponent(org.eclipse.uml2.uml.Class c)
- {
+
+ static public String getNativeLibraryPathForComponent(org.eclipse.uml2.uml.Class c) {
org.eclipse.papyrus.RobotML.System sys = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(c, org.eclipse.papyrus.RobotML.System.class);
- if (sys == null)
+ if(sys == null)
return null;
return sys.getLibraryPath();
}
-
- static public String getNativeComponentNameForComponent(org.eclipse.uml2.uml.Class c)
- {
+
+ static public String getNativeComponentNameForComponent(org.eclipse.uml2.uml.Class c) {
org.eclipse.papyrus.RobotML.System sys = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(c, org.eclipse.papyrus.RobotML.System.class);
- if (sys == null)
+ if(sys == null)
return null;
return sys.getLibraryComponentName();
}
-
+
static public int getOutputPortBufferSize(Port p) {
org.eclipse.papyrus.RobotML.DataFlowPort dfp = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(p, org.eclipse.papyrus.RobotML.DataFlowPort.class);
- if (dfp == null)
+ if(dfp == null)
return 0;
return dfp.getBufferSize();
}
+
/**
*
*/
static public String getComponentFileName(org.eclipse.uml2.uml.Class c, String end) {
- return c.getName()+end;
+ return c.getName() + end;
}
-
+
/**
- * @TODO: author to add some doc.
+ * @TODO: author to add some doc.
*/
- static public Boolean isPortConnected(Port p1)
- {
- if (p1.getEnds().size()>0) {
+ static public Boolean isPortConnected(Port p1) {
+ if(p1.getEnds().size() > 0) {
Connector conn = (Connector)p1.getEnds().get(0).getOwner();
return isConnectionValid(conn);
- }
- else return false;
+ } else
+ return false;
}
-
+
/**
* @TODO: author to add some doc. Middleware specific?
*/
- static public String getConnectionOtherSide(Port p1)
- {
- if (p1.getEnds().size()>0) {
+ static public String getConnectionOtherSide(Port p1) {
+ if(p1.getEnds().size() > 0) {
Connector conn = (Connector)p1.getEnds().get(0).getOwner();
ConnectorEnd e1 = conn.getEnds().get(0);
ConnectorEnd e2 = conn.getEnds().get(1);
Port p2 = null;
- java.lang.System.out.println("p1="+p1.getName());
+ java.lang.System.out.println("p1=" + p1.getName());
Property c2 = null;
- if (e1.getRole() == p1)
- {
+ if(e1.getRole() == p1) {
p2 = (Port)e2.getRole();
c2 = (Property)e2.getPartWithPort();
- java.lang.System.out.println("1 - p2="+p2.getName()+", c2="+c2.getName());
- }
- else if (e2.getRole() == p1) {
+ java.lang.System.out.println("1 - p2=" + p2.getName() + ", c2=" + c2.getName());
+ } else if(e2.getRole() == p1) {
p2 = (Port)e1.getRole();
c2 = (Property)e1.getPartWithPort();
- java.lang.System.out.println("2 - p2="+p2.getName()+", c2="+c2.getName());
- }
- if (c2.getName().equals(((NamedElement)conn.getOwner()).getName()))
- {
- return "@"+p2.getName();
+ java.lang.System.out.println("2 - p2=" + p2.getName() + ", c2=" + c2.getName());
}
- else {
- return "@"+c2.getName()+"."+p2.getName();
+ if(c2.getName().equals(((NamedElement)conn.getOwner()).getName())) {
+ return "@" + p2.getName();
+ } else {
+ return "@" + c2.getName() + "." + p2.getName();
}
- }
- else {
+ } else {
return "?????";
}
}
-
+
/**
* Is this property a DataFlow Port
+ *
* @param port
* @return is this a DataFlow port ?
*/
static public Boolean isDataFlowPort(Port port) {
DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
- if (dfp == null)
+ if(dfp == null)
return false;
return true;
}
-
+
/**
* For DataFlow ports: is it an Input Port ?
+ *
* @param port
- * @return false if the port is not a DataFlowPort or not an input port.
+ * @return false if the port is not a DataFlowPort or not an input port.
*/
- static public Boolean isAnInputPort(Port port)
- {
+ static public Boolean isAnInputPort(Port port) {
try {
DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
- if (dfp == null)
+ if(dfp == null)
return false;
- if (dfp.getDirection() == DataFlowDirectionKind.IN)
+ if(dfp.getDirection() == DataFlowDirectionKind.IN)
return true;
return false;
} catch (Exception e) {
@@ -541,19 +535,19 @@ public class ArchitectureQueries {
}
return false;
}
-
+
/**
* For DataFlow ports: is it an Output Port ?
+ *
* @param port
- * @return false if the port is not a DataFlowPort or not an output port.
+ * @return false if the port is not a DataFlowPort or not an output port.
*/
- static public Boolean isAnOutputPort(Port port)
- {
+ static public Boolean isAnOutputPort(Port port) {
try {
DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
- if (dfp == null)
+ if(dfp == null)
return false;
- if (dfp.getDirection() == DataFlowDirectionKind.OUT)
+ if(dfp.getDirection() == DataFlowDirectionKind.OUT)
return true;
return false;
} catch (Exception e) {
@@ -561,18 +555,19 @@ public class ArchitectureQueries {
}
return false;
}
-
+
/**
* For RobotML ServicePorts: is the port a "Provided" port?
+ *
* @param port
* @return false if the port is not a ServicePort or not a "Provided" ServicePort.
*/
static public Boolean isAProvidedPort(Port port) {
try {
ServicePort sp = UMLUtil.getStereotypeApplication(port, ServicePort.class);
- if (sp == null)
+ if(sp == null)
return false;
- if (sp.getKind() == ServiceFlowKind.PROVIDED)
+ if(sp.getKind() == ServiceFlowKind.PROVIDED)
return true;
return false;
} catch (Exception e) {
@@ -583,15 +578,16 @@ public class ArchitectureQueries {
/**
* For RobotML ServicePorts: is the port a "Required" port?
+ *
* @param port
* @return false if the port is not a ServicePort or not a "Required" ServicePort.
*/
static public Boolean isARequiredPort(Port port) {
try {
ServicePort sp = UMLUtil.getStereotypeApplication(port, ServicePort.class);
- if (sp == null)
+ if(sp == null)
return false;
- if (sp.getKind() == ServiceFlowKind.REQUIRED)
+ if(sp.getKind() == ServiceFlowKind.REQUIRED)
return true;
return false;
} catch (Exception e) {
@@ -599,9 +595,10 @@ public class ArchitectureQueries {
}
return false;
}
-
+
/**
* Is this property a Service Port
+ *
* @param port
* @return is this a service port ?
*/
@@ -609,27 +606,23 @@ public class ArchitectureQueries {
ServicePort serviceport = UMLUtil.getStereotypeApplication(port, ServicePort.class);
return serviceport != null;
}
-
+
/**
* @TOOD: author to add some doc.
*/
- static public Boolean definesConnections(org.eclipse.uml2.uml.Class cl)
- {
- return cl.getOwnedConnectors().size()>0;
+ static public Boolean definesConnections(org.eclipse.uml2.uml.Class cl) {
+ return cl.getOwnedConnectors().size() > 0;
}
-
+
/**
* @TODO: author to add some doc
*/
- static public Boolean isConnectionValid(Connector connector)
- {
- if (connector.getEnds().size() != 2)
- {
+ static public Boolean isConnectionValid(Connector connector) {
+ if(connector.getEnds().size() != 2) {
return false;
}
- for (ConnectorEnd cend : connector.getEnds())
- {
- if ((cend.getRole()==null)||(cend.getPartWithPort()==null)) {
+ for(ConnectorEnd cend : connector.getEnds()) {
+ if((cend.getRole() == null) || (cend.getPartWithPort() == null)) {
return false;
}
}
@@ -639,63 +632,54 @@ public class ArchitectureQueries {
/**
* @TODO: this seems to be middleware specific. To be moved to corresponding middleware generator project.
*/
- static public String getConnectionDefinition(Connector connector)
- {
+ static public String getConnectionDefinition(Connector connector) {
ConnectorEnd e1 = connector.getEnds().get(0);
ConnectorEnd e2 = connector.getEnds().get(1);
- return
- e1.getPartWithPort().getName()+"."+e1.getRole().getName()+".connectTo("+e2.getPartWithPort().getName()+"."+e2.getRole().getName()+")";
+ return e1.getPartWithPort().getName() + "." + e1.getRole().getName() + ".connectTo(" + e2.getPartWithPort().getName() + "." + e2.getRole().getName() + ")";
}
-
- static public Port getConnectedPort(Port port)
- {
- if (port.getEnds().size() == 0)
+
+ static public Port getConnectedPort(Port port) {
+ if(port.getEnds().size() == 0)
return null;
-
+
Connector conn = (Connector)port.getEnds().get(0).getOwner();
ConnectorEnd e1 = conn.getEnds().get(0);
ConnectorEnd e2 = conn.getEnds().get(1);
return (e1.getRole() == port) ? (Port)e2.getRole() : (Port)e1.getRole();
}
-
+
/**
- * Get external connectors to a port
+ * Get external connectors to a port
+ *
* @param port
* @return a list of connectors which are connected to the port.
*/
- static public List<org.eclipse.uml2.uml.Connector> getConnectionsFromPort(Port port)
- {
+ static public List<org.eclipse.uml2.uml.Connector> getConnectionsFromPort(Port port) {
LinkedList<org.eclipse.uml2.uml.Connector> connectors = new LinkedList<org.eclipse.uml2.uml.Connector>();
-
- for (ConnectorEnd connEnd : port.getEnds())
- {
+
+ for(ConnectorEnd connEnd : port.getEnds()) {
Connector conn = (Connector)connEnd.getOwner();
- if (conn.getEnds().size() >= 2 &&
- conn.getEnds().get(0).getPartWithPort() != null &&
- conn.getEnds().get(1).getPartWithPort() != null)
- {
+ if(conn.getEnds().size() >= 2 && conn.getEnds().get(0).getPartWithPort() != null && conn.getEnds().get(1).getPartWithPort() != null) {
connectors.add(conn);
}
}
-
+
return connectors;
}
/**
* Debug function: prints info about a given dataflow port.
*/
- static public void inspectDataFlowPort(Port port)
- {
+ static public void inspectDataFlowPort(Port port) {
//
Stereotype pst = port.getAppliedStereotypes().get(0);
-
+
// Type du port
- if (port.getType()!= null) {
- java.lang.System.out.println("\t\t* type: "+port.getType().getName());
- }
- else {
- java.lang.System.err.println("\t\t\t* port "+port.getName()+" has no type ! ");
+ if(port.getType() != null) {
+ java.lang.System.out.println("\t\t* type: " + port.getType().getName());
+ } else {
+ java.lang.System.err.println("\t\t\t* port " + port.getName() + " has no type ! ");
}
//
//
@@ -704,77 +688,66 @@ public class ArchitectureQueries {
// - la direction (énuméré IN ou OUT)
// - le protocole de synchronization (énuméré SYNCH ou ASYNCH ou UNDEFINED)
//
- for (Property propSt : pst.getAllAttributes())
- {
- java.lang.System.out.println("\t\t* port stereotype has attribute: "+propSt.getName()+" - "+port.getValue(pst, propSt.getName()));
- }
-
+ for(Property propSt : pst.getAllAttributes()) {
+ java.lang.System.out.println("\t\t* port stereotype has attribute: " + propSt.getName() + " - " + port.getValue(pst, propSt.getName()));
+ }
+
}
-
+
/**
* Debug function. Prints info about a given service port.
*/
- static public void inspectServicePort(Port port)
- {
+ static public void inspectServicePort(Port port) {
//
Stereotype pst = port.getAppliedStereotypes().get(0);
-
+
//
- if (port.getType()!= null) {
- java.lang.System.out.println("\t\t* type: "+port.getType().getName());
- }
- else {
- java.lang.System.err.println("\t\t\t* port "+port.getName()+" has no type ! ");
+ if(port.getType() != null) {
+ java.lang.System.out.println("\t\t* type: " + port.getType().getName());
+ } else {
+ java.lang.System.err.println("\t\t\t* port " + port.getName() + " has no type ! ");
}
// A partir des attributs ci-dessous, on peut récupérer:
// - le type d'interface(énuméré Provided ou Required)
// - le protocole de synchronization (énuméré SYNCH ou ASYNCH ou UNDEFINED)
//
-
- for (Property propSt : pst.getAllAttributes())
- {
- java.lang.System.out.println("\t\t* port stereotype has attribute: "+propSt.getName()+" - "+port.getValue(pst, propSt.getName()));
- }
- }
-
- static public Boolean isAnAncestorOf(Class current_elt, Class other_elt)
- {
+
+ for(Property propSt : pst.getAllAttributes()) {
+ java.lang.System.out.println("\t\t* port stereotype has attribute: " + propSt.getName() + " - " + port.getValue(pst, propSt.getName()));
+ }
+ }
+
+ static public Boolean isAnAncestorOf(Class current_elt, Class other_elt) {
Boolean result = false;
- if(current_elt != null && other_elt != null)
- {
- if(current_elt == other_elt)
- {
+ if(current_elt != null && other_elt != null) {
+ if(current_elt == other_elt) {
result = true;
- }
- else
- {
- for(Class parent : current_elt.getSuperClasses())
- {
+ } else {
+ for(Class parent : current_elt.getSuperClasses()) {
current_elt = parent;
- if(other_elt == current_elt)
- {
+ if(other_elt == current_elt) {
result = true;
break;
}
}
}
}
-
+
return result;
}
-
+
/**
* For DataFlow ports: is it an Output Port ?
+ *
* @param port
- * @return false if the port is not a DataFlowPort or not an input/output port.
+ * @return false if the port is not a DataFlowPort or not an input/output port.
*/
- static public Boolean isAnInputOutputPort(Port port)
- {
+ static public Boolean isAnInputOutputPort(Port port) {
try {
DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
- if (dfp == null)
+ if(dfp == null)
return false;
- if (dfp.getDirection() == DataFlowDirectionKind.INOUT)
+ if(dfp.getDirection() == DataFlowDirectionKind.INOUT)
return true;
return false;
} catch (Exception e) {
@@ -782,5 +755,5 @@ public class ArchitectureQueries {
}
return false;
}
-
+
}
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java
index f26fed95804..4a3ccebd685 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java
@@ -14,175 +14,174 @@
package org.eclipse.papyrus.robotml.generators.common.mmqueries;
-import java.util.List;
import java.util.LinkedList;
+import java.util.List;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.PrimitiveType;
import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Type;
-public class DataTypeQueries{
- public static String newline = System.getProperty("line.separator");
-
+public class DataTypeQueries {
+
+ public static String newline = System.getProperty("line.separator");
+
public List<DataType> getMetamodelComposedDataTypes(Element rootelt) {
LinkedList<DataType> results = new LinkedList<DataType>();
- if (rootelt instanceof Model) {
+ if(rootelt instanceof Model) {
EList<Package> packages = ((Model)rootelt).getImportedPackages();
- for (Package p : packages ) {
+ for(Package p : packages) {
EList<Element> elts = p.getOwnedElements();
- for (Element elt : elts) {
- if (elt instanceof PrimitiveType) {
- } else if (elt instanceof DataType) {
+ for(Element elt : elts) {
+ if(elt instanceof PrimitiveType) {
+ } else if(elt instanceof DataType) {
results.add((DataType)elt);
- } else if (elt instanceof Package) {
+ } else if(elt instanceof Package) {
results.addAll(getMetamodelComposedDataTypes(elt));
}
}
}
- } else if (rootelt instanceof Package) {
+ } else if(rootelt instanceof Package) {
Package p = (Package)rootelt;
EList<Element> elts = p.getOwnedElements();
- for (Element elt : elts) {
- if (elt instanceof PrimitiveType) {
- } else if (elt instanceof DataType) {
+ for(Element elt : elts) {
+ if(elt instanceof PrimitiveType) {
+ } else if(elt instanceof DataType) {
results.add((DataType)elt);
- } else if (elt instanceof Package) {
+ } else if(elt instanceof Package) {
results.addAll(getMetamodelComposedDataTypes(elt));
}
- }
+ }
}
return results;
}
-
+
/**
* Is the provided DataType one of the RobotML metamodel datatypes ?
+ *
* @param dt
* @return
*/
public static boolean isRobotMLDataType(Element root_model, String datatype_name) {
try {
- if (root_model instanceof Model) {
- EList<Package> packages = ((Model)root_model).getImportedPackages();
- for (Package p : packages ) {
- EList<Element> elts = p.getOwnedElements();
- for (Element elt : elts) {
- if (elt instanceof DataType && datatype_name.compareTo(((DataType)elt).getName())==0) {
- return true;
- } else if (elt instanceof Package) {
- if (isRobotMLDataType(elt,datatype_name))
+ if(root_model instanceof Model) {
+ EList<Package> packages = ((Model)root_model).getImportedPackages();
+ for(Package p : packages) {
+ EList<Element> elts = p.getOwnedElements();
+ for(Element elt : elts) {
+ if(elt instanceof DataType && datatype_name.compareTo(((DataType)elt).getName()) == 0) {
return true;
+ } else if(elt instanceof Package) {
+ if(isRobotMLDataType(elt, datatype_name))
+ return true;
+ }
}
}
- }
- } else if (root_model instanceof Package) {
- EList<Element> elts = ((Package)root_model).getOwnedElements();
- for (Element elt : elts) {
- if (elt instanceof DataType && datatype_name.compareTo(((DataType)elt).getName())==0) {
- return true;
- } else if (elt instanceof Package) {
- if (isRobotMLDataType(elt,datatype_name))
+ } else if(root_model instanceof Package) {
+ EList<Element> elts = ((Package)root_model).getOwnedElements();
+ for(Element elt : elts) {
+ if(elt instanceof DataType && datatype_name.compareTo(((DataType)elt).getName()) == 0) {
return true;
+ } else if(elt instanceof Package) {
+ if(isRobotMLDataType(elt, datatype_name))
+ return true;
+ }
}
- }
- }
+ }
} catch (Exception e) {
System.out.println(e.toString());
}
return false;
}
-
+
public String getCppClassForDatatType(DataType dt) {
try {
- String s="";
- if (dt instanceof Enumeration) {
+ String s = "";
+ if(dt instanceof Enumeration) {
Enumeration en = (Enumeration)dt;
s = "enum " + en.getName() + " {" + newline;
EList<EnumerationLiteral> literals = en.getOwnedLiterals();
- for (EnumerationLiteral literal : literals) {
+ for(EnumerationLiteral literal : literals) {
s += "\t" + literal.getName() + "," + newline;
}
- } else if (dt instanceof EnumerationLiteral){
+ } else if(dt instanceof EnumerationLiteral) {
//do nothing.
- } else {
+ } else {
EList<Property> attributes = dt.getOwnedAttributes();
- s = "class " + dt.getName() + " {"+ newline + "\tpublic:" + newline;
- for (Property attribute : attributes) {
+ s = "class " + dt.getName() + " {" + newline + "\tpublic:" + newline;
+ for(Property attribute : attributes) {
String type_name;
- if (attribute.getType() != null)
+ if(attribute.getType() != null)
type_name = attribute.getType().getName();
else
type_name = "Unknown_NULL_IN_MODEL";
- if (attribute.getUpper()<0) {
- s+="\tstd::vector<" + type_name + "> " + attribute.getName() + ";" + newline;
- } else if (attribute.getUpper() <= 1){
- s+="\t" + type_name + " " + attribute.getName() + ";" + newline;
- } else if (attribute.getUpper() == attribute.getLower()) {
- s+="\t" + type_name + " " + attribute.getName() + "[" + attribute.getUpper() + "];" + newline;
+ if(attribute.getUpper() < 0) {
+ s += "\tstd::vector<" + type_name + "> " + attribute.getName() + ";" + newline;
+ } else if(attribute.getUpper() <= 1) {
+ s += "\t" + type_name + " " + attribute.getName() + ";" + newline;
+ } else if(attribute.getUpper() == attribute.getLower()) {
+ s += "\t" + type_name + " " + attribute.getName() + "[" + attribute.getUpper() + "];" + newline;
} else {
- s+="\tstd::vector<" + type_name + "> " + attribute.getName() + ";" + newline;
+ s += "\tstd::vector<" + type_name + "> " + attribute.getName() + ";" + newline;
}
}
}
- s+= "};" + newline;
+ s += "};" + newline;
return s;
} catch (Exception e) {
java.lang.System.out.println(e.getMessage());
}
return null;
}
+
/**
* Get all user-defined datatypes.
+ *
* @return A list of datatypes
*/
- public List<NamedElement> getElementsDataType(Model model)
- {
+ public List<NamedElement> getElementsDataType(Model model) {
LinkedList<NamedElement> found_elts = new LinkedList<NamedElement>();
- for (NamedElement ne : model.getOwnedMembers())
- {
- if (ne instanceof org.eclipse.uml2.uml.DataType) {
+ for(NamedElement ne : model.getOwnedMembers()) {
+ if(ne instanceof org.eclipse.uml2.uml.DataType) {
found_elts.add((NamedElement)ne);
}
- getElementsDataType(ne,found_elts);
+ getElementsDataType(ne, found_elts);
}
return found_elts;
}
-
+
/**
* Recursive sub-function to browse model and get all user-defined datatypes.
*/
- private void getElementsDataType(Element parent_elt, LinkedList<NamedElement> target_list)
- {
- for (Element ne : parent_elt.getOwnedElements())
- {
- if (ne instanceof org.eclipse.uml2.uml.DataType)
- {
+ private void getElementsDataType(Element parent_elt, LinkedList<NamedElement> target_list) {
+ for(Element ne : parent_elt.getOwnedElements()) {
+ if(ne instanceof org.eclipse.uml2.uml.DataType) {
target_list.add((NamedElement)ne);
}
- getElementsDataType(ne,target_list);
+ getElementsDataType(ne, target_list);
}
return;
}
-
+
public DataType getPortDataType(Port port) {
Type t = port.getType();
- if (t!= null && t instanceof DataType) {
+ if(t != null && t instanceof DataType) {
return (DataType)t;
}
return null;
}
-
+
public static boolean isPrimitiveType(Element elt) {
- if (elt instanceof PrimitiveType)
+ if(elt instanceof PrimitiveType)
return true;
return false;
}
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java
index 3cdf55c07c4..35b5c5f3e46 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java
@@ -15,7 +15,6 @@
package org.eclipse.papyrus.robotml.generators.common.mmqueries;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -23,9 +22,6 @@ import java.util.Set;
import org.eclipse.papyrus.RobotML.Allocate;
import org.eclipse.papyrus.RobotML.DeploymentPlan;
-import org.eclipse.papyrus.RobotML.Platform;
-import org.eclipse.papyrus.RobotML.RoboticMiddleware;
-import org.eclipse.papyrus.RobotML.RoboticSimulator;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Dependency;
import org.eclipse.uml2.uml.Element;
@@ -36,64 +32,66 @@ import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.util.UMLUtil;
public class DeploymentQueries {
+
/**
* Return the list of instance specifications in a model
+ *
* @param model
* @return A list of InstanceSpecification of all instance specifications
*/
static public List<InstanceSpecification> getInstanceSpecificationsInModel(Model model) {
LinkedList<InstanceSpecification> found_elts = new LinkedList<InstanceSpecification>();
- for (Element ne : model.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.InstanceSpecification) {
+ for(Element ne : model.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.InstanceSpecification) {
found_elts.add((InstanceSpecification)ne);
//System.out.println("Instance : "+((NamedElement) ne).getName());
- }else if(ne instanceof org.eclipse.uml2.uml.Package){
+ } else if(ne instanceof org.eclipse.uml2.uml.Package) {
found_elts.addAll(getInstanceSpecificationsInPackage((org.eclipse.uml2.uml.Package)ne));
- }
- } else if (ne instanceof Model) {
+ }
+ } else if(ne instanceof Model) {
found_elts.addAll(getInstanceSpecificationsInModel((Model)ne));
}
}
-// if(found_elts.isEmpty()){
-// System.out.println("Instances list empty");
-// }
+ // if(found_elts.isEmpty()){
+ // System.out.println("Instances list empty");
+ // }
return found_elts;
}
-
+
/**
* Return the list of instance specifications in a package
+ *
* @param pack
* @return A list of InstanceSpecification of all instance specifications
*/
static public List<InstanceSpecification> getInstanceSpecificationsInPackage(org.eclipse.uml2.uml.Package pack) {
LinkedList<InstanceSpecification> found_elts = new LinkedList<InstanceSpecification>();
- for (Element ne : pack.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.InstanceSpecification) {
+ for(Element ne : pack.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.InstanceSpecification) {
found_elts.add((InstanceSpecification)ne);
- } else if(ne instanceof org.eclipse.uml2.uml.Package){
+ } else if(ne instanceof org.eclipse.uml2.uml.Package) {
found_elts.addAll(getInstanceSpecificationsInPackage((org.eclipse.uml2.uml.Package)ne));
- }
- } else if (ne instanceof Model) {
+ }
+ } else if(ne instanceof Model) {
found_elts.addAll(getInstanceSpecificationsInModel((Model)ne));
}
}
return found_elts;
}
-
+
/**
* Return the list of instance specifications allocated to given platform
+ *
* @param model
- * @param
+ * @param
* @return A list of InstanceSpecification of all instance specifications
*/
- static public List<InstanceSpecification> getInstanceSpecificationsForPlatform(org.eclipse.uml2.uml.Model model, java.lang.String pfn)
- {
+ static public List<InstanceSpecification> getInstanceSpecificationsForPlatform(org.eclipse.uml2.uml.Model model, java.lang.String pfn) {
List<InstanceSpecification> found_elts = new LinkedList<InstanceSpecification>();
for(InstanceSpecification instanceSpecification : getInstanceSpecificationsInModel(model)) {
- if(isAllocatedTo(instanceSpecification, pfn))
- {
+ if(isAllocatedTo(instanceSpecification, pfn)) {
found_elts.add(instanceSpecification);
}
}
@@ -101,99 +99,100 @@ public class DeploymentQueries {
}
/**
- * Return the list of instance specifications allocated to given platform. Should be equivalent to getInstanceSpecificationsForPlatform, but different implementation.
+ * Return the list of instance specifications allocated to given platform. Should be equivalent to getInstanceSpecificationsForPlatform, but
+ * different implementation.
+ *
* @param model
- * @param targetPlatformName Name of the requested target platform type.
+ * @param targetPlatformName
+ * Name of the requested target platform type.
* @return A list of InstanceSpecification of all instance specifications.
*/
static public List<InstanceSpecification> getInstanceSpecificationsForPlatform2(org.eclipse.uml2.uml.Model model, String targetPlatformName) { //org.eclipse.papyrus.RobotML.Platform targetPlatform) {
//The list to return in the end.
List<InstanceSpecification> found_elts = new LinkedList<InstanceSpecification>();
- for (org.eclipse.uml2.uml.Package dpPck : getDeploymentPlanPackagesInModel(model)) {
- found_elts.addAll(getDeploymentPlanInstanceSpecsForPlatform(dpPck,targetPlatformName));
+ for(org.eclipse.uml2.uml.Package dpPck : getDeploymentPlanPackagesInModel(model)) {
+ found_elts.addAll(getDeploymentPlanInstanceSpecsForPlatform(dpPck, targetPlatformName));
}
return found_elts;
}
-
+
/**
* Return the parent name of an instance
+ *
* @param inst
* @return Parent name of an instance
*/
- static public java.lang.String getParentName(InstanceSpecification inst)
- {
+ static public java.lang.String getParentName(InstanceSpecification inst) {
String name = inst.getName();
-
- Integer idx = name.lastIndexOf('.');
- if(idx!=-1)
- {
+
+ Integer idx = name.lastIndexOf('.');
+ if(idx != -1) {
return name.substring(0, idx);
- }else{
+ } else {
return null;
}
}
-
-
+
+
/**
* Get real instance from InstanceSpecification object
+ *
* @param model
* @param instanceSpecification
- * @return the instance if found, or else null
+ * @return the instance if found, or else null
*/
- static public Property getInstance(Model model, InstanceSpecification instanceSpecification)
- {
- List<org.eclipse.uml2.uml.Property> l = ArchitectureQueries.getAllSubComponentsInClass(ArchitectureQueries.getRootClassForModel(model));
-
- for(Property p : l)
- {
+ static public Property getInstance(Model model, InstanceSpecification instanceSpecification) {
+ List<org.eclipse.uml2.uml.Property> l = ArchitectureQueries.getAllSubComponentsInClass(ArchitectureQueries.getRootClassForModel(model));
+
+ for(Property p : l) {
String[] str = instanceSpecification.getName().split("\\.");
-
- if(str.length > 0 && p.getName().equals(str[str.length-1]))
- {
+
+ if(str.length > 0 && p.getName().equals(str[str.length - 1])) {
return p;
}
}
-
+
return null;
}
-
-
+
+
/**
- * Function to know if the instance must be generated by the platform or not.
+ * Function to know if the instance must be generated by the platform or not.
+ *
* @param instanceSpecification
* @param platformName
- * @return true if the instance is allocated to the platform which name is given in parameter
+ * @return true if the instance is allocated to the platform which name is given in parameter
*/
- static public boolean isAllocatedTo(InstanceSpecification instSpec, String platformName ) {
- if (instSpec == null || platformName == null)
+ static public boolean isAllocatedTo(InstanceSpecification instSpec, String platformName) {
+ if(instSpec == null || platformName == null)
return false;
- for (Dependency dep : instSpec.getClientDependencies()) {
+ for(Dependency dep : instSpec.getClientDependencies()) {
Allocate alloc = UMLUtil.getStereotypeApplication((Element)dep, Allocate.class);
- if (alloc == null)
- continue;
- for (NamedElement nelt : dep.getSuppliers()) {
- if (isPlatformInstanceSpecificationFromPlatform(nelt,platformName)) {
+ if(alloc == null)
+ continue;
+ for(NamedElement nelt : dep.getSuppliers()) {
+ if(isPlatformInstanceSpecificationFromPlatform(nelt, platformName)) {
return true;
}
}
}
-
+
return false;
}
-
+
/**
* Retrieves the deployment plans defined in a given model.
+ *
* @param model
* @return A list of DeploymentPlans defined in the model.
*/
- static public List<DeploymentPlan> getDeploymentPlansInModel(org.eclipse.uml2.uml.Model model)
- {
+ static public List<DeploymentPlan> getDeploymentPlansInModel(org.eclipse.uml2.uml.Model model) {
List<DeploymentPlan> dep_plans = new LinkedList<DeploymentPlan>();
- for (Element elt : model.getOwnedElements()) {
- if (elt instanceof org.eclipse.uml2.uml.Package) {
+ for(Element elt : model.getOwnedElements()) {
+ if(elt instanceof org.eclipse.uml2.uml.Package) {
DeploymentPlan dp = UMLUtil.getStereotypeApplication(elt, DeploymentPlan.class);
- if (dp != null)
+ if(dp != null)
dep_plans.add(dp);
else
dep_plans.addAll(getDeploymentPlansInPackage((org.eclipse.uml2.uml.Package)elt));
@@ -201,18 +200,19 @@ public class DeploymentQueries {
}
return dep_plans;
}
-
+
/**
* Retrieves the deployment plans defined in a given package.
+ *
* @param pck
* @return
*/
static protected List<DeploymentPlan> getDeploymentPlansInPackage(org.eclipse.uml2.uml.Package pck) {
List<DeploymentPlan> dep_plans = new LinkedList<DeploymentPlan>();
- for (Element elt : pck.getOwnedElements()) {
- if (elt instanceof org.eclipse.uml2.uml.Package) {
+ for(Element elt : pck.getOwnedElements()) {
+ if(elt instanceof org.eclipse.uml2.uml.Package) {
DeploymentPlan dp = UMLUtil.getStereotypeApplication(elt, DeploymentPlan.class);
- if (dp != null)
+ if(dp != null)
dep_plans.add(dp);
else
dep_plans.addAll(getDeploymentPlansInPackage((org.eclipse.uml2.uml.Package)elt));
@@ -223,13 +223,14 @@ public class DeploymentQueries {
/**
* Retrieves the Packages in which Deployment plans are defined in the model.
+ *
* @param model
* @return
*/
static public List<org.eclipse.uml2.uml.Package> getDeploymentPlanPackagesInModel(Model model) {
List<DeploymentPlan> dps = getDeploymentPlansInModel(model);
LinkedList<org.eclipse.uml2.uml.Package> pcks = new LinkedList<org.eclipse.uml2.uml.Package>();
- for (DeploymentPlan dp : dps) {
+ for(DeploymentPlan dp : dps) {
pcks.add(dp.getBase_Package());
}
return pcks;
@@ -237,45 +238,45 @@ public class DeploymentQueries {
/**
* Retrieves the InstanceSpecficiations allocated to a given Platform within a given DeploymentPlan.
+ *
* @param deploymentPlan
* @param targetPlatformName
* @return
*/
- static public List<InstanceSpecification> getDeploymentPlanInstanceSpecsForPlatform(org.eclipse.uml2.uml.Package deploymentPlan, String targetPlatformName)
- {
+ static public List<InstanceSpecification> getDeploymentPlanInstanceSpecsForPlatform(org.eclipse.uml2.uml.Package deploymentPlan, String targetPlatformName) {
//The list to return in the end.
List<InstanceSpecification> found_elts = new LinkedList<InstanceSpecification>();
-
+
//Is the first argument really a Deployment plan ? (a Package with a DeploymentPlan StereoType)
DeploymentPlan dp = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(deploymentPlan, org.eclipse.papyrus.RobotML.DeploymentPlan.class);
- if (dp == null)
+ if(dp == null)
return found_elts;
-
+
//Let's get all the Allocate elements in the DeploymentPlan, and check if the supplier (the target platform) corresponds to the second argument.
- for (Element elt : deploymentPlan.getOwnedElements()) {
- if (elt instanceof Dependency) {
+ for(Element elt : deploymentPlan.getOwnedElements()) {
+ if(elt instanceof Dependency) {
//Is it a Dependency with an "Allocate" stereotype ?
- Dependency dep = (Dependency) elt;
- Allocate alloc = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(elt, org.eclipse.papyrus.RobotML.Allocate.class);
- if (alloc == null)
+ Dependency dep = (Dependency)elt;
+ Allocate alloc = org.eclipse.uml2.uml.util.UMLUtil.getStereotypeApplication(elt, org.eclipse.papyrus.RobotML.Allocate.class);
+ if(alloc == null)
continue;
-
+
//Let's store the potential client (the component instance) of the Allocate.
//for future addition to the list to return.
InstanceSpecification client_instance_spec = null;
- for (NamedElement client_elt : dep.getClients()) {
- if (false == (client_elt instanceof InstanceSpecification)) {
+ for(NamedElement client_elt : dep.getClients()) {
+ if(false == (client_elt instanceof InstanceSpecification)) {
continue;
}
client_instance_spec = (InstanceSpecification)client_elt;
break;
}
- if (client_instance_spec == null)
+ if(client_instance_spec == null)
continue;
-
+
//Is it allocated to the platform provided as argument ?
- for (NamedElement nelt : dep.getSuppliers()) {
- if (isPlatformInstanceSpecificationFromPlatform(nelt,targetPlatformName)) {
+ for(NamedElement nelt : dep.getSuppliers()) {
+ if(isPlatformInstanceSpecificationFromPlatform(nelt, targetPlatformName)) {
found_elts.add(client_instance_spec);
}
}
@@ -283,41 +284,39 @@ public class DeploymentQueries {
}
return found_elts;
}
-
+
/**
- * Function to know the content of allocation string.
+ * Function to know the content of allocation string.
+ *
* @param instanceSpecification
- * @return the allocation string
+ * @return the allocation string
*/
- static public String getAllocationName(InstanceSpecification instanceSpecification)
- {
+ static public String getAllocationName(InstanceSpecification instanceSpecification) {
if(instanceSpecification.getClientDependencies().size() == 0)
return new String();
-
+
//il n'y a toujours qu'un element
Dependency d = instanceSpecification.getClientDependencies().get(0);
-
+
return d.getName();
}
-
+
/**
- * Function to know which class must be generated by the platform or not.
+ * Function to know which class must be generated by the platform or not.
+ *
* @param model
* @param platformName
* @return all classes that are instanciated for the platform "pfn"
*/
- static public List<org.eclipse.uml2.uml.Class> getDefinedComponentsForPlatform(Model model, String platformName)
- {
+ static public List<org.eclipse.uml2.uml.Class> getDefinedComponentsForPlatform(Model model, String platformName) {
//System.out.println("getDefinedComponentsForPlatform");
LinkedList<org.eclipse.uml2.uml.Class> found_classes = new LinkedList<org.eclipse.uml2.uml.Class>();
-
+
List<InstanceSpecification> instances = getInstanceSpecificationsForPlatform(model, platformName);
- for(InstanceSpecification instanceSpecification : instances)
- {
+ for(InstanceSpecification instanceSpecification : instances) {
//System.out.println("instance : " + instanceSpecification.getName());
-
- for(org.eclipse.uml2.uml.Classifier classifier : instanceSpecification.getClassifiers())
- {
+
+ for(org.eclipse.uml2.uml.Classifier classifier : instanceSpecification.getClassifiers()) {
found_classes.add(GeneralQueries.findClassInModel(model, classifier.getName()));
//org.eclipse.uml2.uml.Class theClass = GeneralQueries.findClassInModel(model, classifier.getName());
@@ -326,9 +325,11 @@ public class DeploymentQueries {
}
return found_classes;
}
-
+
/**
- * Function to know which class must be generated by the platform or not. Should be equivalent to getDefinedComponentsForPlatform but with a different implementation.
+ * Function to know which class must be generated by the platform or not. Should be equivalent to getDefinedComponentsForPlatform but with a
+ * different implementation.
+ *
* @param model
* @param platformName
* @return all classes that are instanciated for the platform "pfn"
@@ -336,55 +337,56 @@ public class DeploymentQueries {
static public List<org.eclipse.uml2.uml.Class> getDefinedComponentsForPlatform2(Model model, String platformName) //Platform platform)
{
LinkedList<org.eclipse.uml2.uml.Class> found_classes = new LinkedList<org.eclipse.uml2.uml.Class>();
- List<InstanceSpecification> inst_specs = getInstanceSpecificationsForPlatform2(model,platformName);
- for (InstanceSpecification inst_spec : inst_specs) {
- for(org.eclipse.uml2.uml.Classifier classifier : inst_spec.getClassifiers())
- {
+ List<InstanceSpecification> inst_specs = getInstanceSpecificationsForPlatform2(model, platformName);
+ for(InstanceSpecification inst_spec : inst_specs) {
+ for(org.eclipse.uml2.uml.Classifier classifier : inst_spec.getClassifiers()) {
found_classes.add(GeneralQueries.findClassInModel(model, classifier.getName()));
}
}
-
+
//remove duplicates
Set<org.eclipse.uml2.uml.Class> new_set = new HashSet<org.eclipse.uml2.uml.Class>(found_classes);
List<org.eclipse.uml2.uml.Class> found_classes_2 = new LinkedList<org.eclipse.uml2.uml.Class>(new_set);
-
+
return found_classes_2;
}
-
+
/**
* Checks whether or not a Platform instance specification has a given platform type.
+ *
* @param platformInstanceSpecification
* @param expectedPlatformName
* @return
*/
protected static boolean isPlatformInstanceSpecificationFromPlatform(NamedElement platformInstanceSpecification, String expectedPlatformName) //Platform expectedPlatform)
{
- if (platformInstanceSpecification instanceof InstanceSpecification) {
- InstanceSpecification platformInstance = (InstanceSpecification) platformInstanceSpecification;
- for (Classifier classifier : platformInstance.getClassifiers()) {
- if (classifier.getName().toLowerCase().compareTo(expectedPlatformName)==0)
+ if(platformInstanceSpecification instanceof InstanceSpecification) {
+ InstanceSpecification platformInstance = (InstanceSpecification)platformInstanceSpecification;
+ for(Classifier classifier : platformInstance.getClassifiers()) {
+ if(classifier.getName().toLowerCase().compareTo(expectedPlatformName) == 0)
return true;
/*
- RoboticMiddleware mdw = UMLUtil.getStereotypeApplication(classifier, org.eclipse.papyrus.RobotML.RoboticMiddleware.class);
- RoboticSimulator sim = UMLUtil.getStereotypeApplication(classifier, org.eclipse.papyrus.RobotML.RoboticSimulator.class);
- if (mdw != null) {
- //The target platform seems to be a middleware.
- //Middlewares are identified by their "kind".
- if (expectedPlatform instanceof RoboticMiddleware) {
- if (mdw.getKind() == ((RoboticMiddleware)expectedPlatform).getKind()) {
- //YEEEEHAAAA !!!
- return true;
- }
- }
- }
- if (sim != null && expectedPlatform instanceof RoboticSimulator) {
- //The target platform seems to be a simulator.
- //Simulators are just derived classes.
- if (sim.getClass().getName().compareTo(((RoboticSimulator)expectedPlatform).getClass().getName()) == 0) {
- //YEEEEEHAAAAAA !!!
- return true;
- }
- }*/
+ * RoboticMiddleware mdw = UMLUtil.getStereotypeApplication(classifier, org.eclipse.papyrus.RobotML.RoboticMiddleware.class);
+ * RoboticSimulator sim = UMLUtil.getStereotypeApplication(classifier, org.eclipse.papyrus.RobotML.RoboticSimulator.class);
+ * if (mdw != null) {
+ * //The target platform seems to be a middleware.
+ * //Middlewares are identified by their "kind".
+ * if (expectedPlatform instanceof RoboticMiddleware) {
+ * if (mdw.getKind() == ((RoboticMiddleware)expectedPlatform).getKind()) {
+ * //YEEEEHAAAA !!!
+ * return true;
+ * }
+ * }
+ * }
+ * if (sim != null && expectedPlatform instanceof RoboticSimulator) {
+ * //The target platform seems to be a simulator.
+ * //Simulators are just derived classes.
+ * if (sim.getClass().getName().compareTo(((RoboticSimulator)expectedPlatform).getClass().getName()) == 0) {
+ * //YEEEEEHAAAAAA !!!
+ * return true;
+ * }
+ * }
+ */
}
}
return false;
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java
index e28d2d29735..8d7cc19ff10 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java
@@ -17,84 +17,80 @@ package org.eclipse.papyrus.robotml.generators.common.mmqueries;
import java.util.LinkedList;
import java.util.List;
-
import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.util.UMLUtil;
public class FSMQueries {
+
/**
* Find all states in a state machine.
- * @param sm a state machine
+ *
+ * @param sm
+ * a state machine
* @return a list of states
- * @todo a valider par Nicolas
+ * @todo a valider par Nicolas
*/
- public List<org.eclipse.uml2.uml.Vertex> getStates(StateMachine sm)
- {
+ public List<org.eclipse.uml2.uml.Vertex> getStates(StateMachine sm) {
LinkedList<org.eclipse.uml2.uml.Vertex> res = new LinkedList<org.eclipse.uml2.uml.Vertex>();
- for (org.eclipse.uml2.uml.Region region : sm.getRegions())
+ for(org.eclipse.uml2.uml.Region region : sm.getRegions())
for(org.eclipse.uml2.uml.Vertex vertex : region.getSubvertices())
res.add((org.eclipse.uml2.uml.Vertex)vertex);
-
+
return res;
}
-
+
/**
* Find all transitions in a state machine.
- * @param sm a state machine
+ *
+ * @param sm
+ * a state machine
* @return a list of transitions
- * @todo a valider par Nicolas
+ * @todo a valider par Nicolas
*/
- public List<org.eclipse.papyrus.RobotML.Transition> getTransitions(StateMachine sm)
- {
+ public List<org.eclipse.papyrus.RobotML.Transition> getTransitions(StateMachine sm) {
LinkedList<org.eclipse.papyrus.RobotML.Transition> res = new LinkedList<org.eclipse.papyrus.RobotML.Transition>();
- for (org.eclipse.uml2.uml.Region region : sm.getRegions())
- {
- for(org.eclipse.uml2.uml.Transition transition : region.getTransitions())
- {
- org.eclipse.papyrus.RobotML.Transition robotml_transition = UMLUtil.getStereotypeApplication(transition, org.eclipse.papyrus.RobotML.Transition.class);
- if(robotml_transition != null)
- {
+ for(org.eclipse.uml2.uml.Region region : sm.getRegions()) {
+ for(org.eclipse.uml2.uml.Transition transition : region.getTransitions()) {
+ org.eclipse.papyrus.RobotML.Transition robotml_transition = UMLUtil.getStereotypeApplication(transition, org.eclipse.papyrus.RobotML.Transition.class);
+ if(robotml_transition != null) {
res.add(robotml_transition);
}
}
}
return res;
}
-
+
/**
* Find all state machines in a component.
+ *
* @param elt
* @return a list of state machines
* @todo a valider par Nicolas
*/
- public List<StateMachine> getStateMachines(Element elt)
- {
+ public List<StateMachine> getStateMachines(Element elt) {
LinkedList<StateMachine> res = new LinkedList<StateMachine>();
-
- for (Element child : elt.getOwnedElements())
- if (child instanceof StateMachine)
+
+ for(Element child : elt.getOwnedElements())
+ if(child instanceof StateMachine)
res.add((StateMachine)child);
-
+
return res;
}
-
+
/**
* Generate the state operation
+ *
* @param vertex
* @return
*/
- public String generateOperationStateString(org.eclipse.uml2.uml.Vertex vertex)
- {
+ public String generateOperationStateString(org.eclipse.uml2.uml.Vertex vertex) {
String result = "";
- if(vertex instanceof State)
- {
+ if(vertex instanceof State) {
org.eclipse.papyrus.RobotML.State state = UMLUtil.getStereotypeApplication(vertex, org.eclipse.papyrus.RobotML.State.class);
- if(state != null)
- {
- if(state.getOperation() != null)
- {
+ if(state != null) {
+ if(state.getOperation() != null) {
String operation = state.getOperation().getBase_Operation().getName();
result = operation;
}
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java
index fd89a870b90..e0f022982cc 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java
@@ -34,132 +34,146 @@ import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
public class GeneralQueries {
+
/**
* Retrieve all sub-elements (of type Class) for a given element that have the provided stereotype.
* Basically, retrieves all the component models inside a RobotML model.
- * @param parent_elt the root element to inspect
- * @param clazz the stereotype class we are looking for. Usually something like ...RobotML.SensorSystem
- * @param target_list the list in which the found elements will be stored.
+ *
+ * @param parent_elt
+ * the root element to inspect
+ * @param clazz
+ * the stereotype class we are looking for. Usually something like ...RobotML.SensorSystem
+ * @param target_list
+ * the list in which the found elements will be stored.
*/
static protected void getElementsWithStereotype(Element parent_elt, Class clazz, LinkedList<NamedElement> target_list) {
- if (parent_elt instanceof org.eclipse.uml2.uml.Class) {
+ if(parent_elt instanceof org.eclipse.uml2.uml.Class) {
for(EObject stereoApplication : parent_elt.getStereotypeApplications()) {
// check whether the stereotype is an instance of the passed parameter clazz
if(clazz.isInstance(stereoApplication)) {
- target_list.add((NamedElement) parent_elt);
+ target_list.add((NamedElement)parent_elt);
}
}
}
- for (Element ne : parent_elt.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
+ for(Element ne : parent_elt.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
for(EObject stereoApplication : ne.getStereotypeApplications()) {
// check whether the stereotype is an instance of the passed parameter clazz
if(clazz.isInstance(stereoApplication)) {
- target_list.add((NamedElement) ne);
+ target_list.add((NamedElement)ne);
}
}
- getElementsWithStereotype(ne,clazz,target_list);
+ getElementsWithStereotype(ne, clazz, target_list);
}
}
}
return;
}
+
/**
* Recursive retrieve of all elements with a given stereotype in the model.
- * @param model Model to search in.
- * @param stereotype The stereotype name (e.g. "Sensor", "Actuator", "SubSystem"...)
+ *
+ * @param model
+ * Model to search in.
+ * @param stereotype
+ * The stereotype name (e.g. "Sensor", "Actuator", "SubSystem"...)
* @return A list of NamedElements having the specified stereotype.
* @deprecated to be replaced with calls to the RobotML API. Replaced by getElementsWithStereotype (Model model, StereotypeClass sc)
*/
- static public List<NamedElement> getElementsWithStereotype(Model model, String stereotype) {
+ static public List<NamedElement> getElementsWithStereotype(Model model, String stereotype) {
LinkedList<NamedElement> found_elts = new LinkedList<NamedElement>();
- for (Element ne : model.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if (hasStereotype((org.eclipse.uml2.uml.Class)ne, stereotype)) {
+ for(Element ne : model.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(hasStereotype((org.eclipse.uml2.uml.Class)ne, stereotype)) {
found_elts.add((NamedElement)ne);
}
}
- } else if (ne instanceof Model) {
- found_elts.addAll(getElementsWithStereotype((Model)ne,stereotype));
+ } else if(ne instanceof Model) {
+ found_elts.addAll(getElementsWithStereotype((Model)ne, stereotype));
}
- getElementsWithStereotype(ne,stereotype,found_elts);
+ getElementsWithStereotype(ne, stereotype, found_elts);
}
return found_elts;
}
-
+
/**
* Same as getElementsWithStereotype(Model model...) searches in an Element members, not in a Model members.
* This function is private and used by getElementsWithStereotype(Model model...)
+ *
* @param parent_elt
* @param stereotype
* @param target_list
* @deprecated to be replaced with calls to the RobotML API.
*/
static private void getElementsWithStereotype(Element parent_elt, String stereotype, LinkedList<NamedElement> target_list) {
- for (Element ne : parent_elt.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if(hasStereotype((org.eclipse.uml2.uml.Class)ne, stereotype)){
+ for(Element ne : parent_elt.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(hasStereotype((org.eclipse.uml2.uml.Class)ne, stereotype)) {
target_list.add((NamedElement)ne);
- }
+ }
}
- getElementsWithStereotype(ne,stereotype,target_list);
+ getElementsWithStereotype(ne, stereotype, target_list);
}
}
return;
}
-
+
/**
* Recursive retrieve of all element with a given inherited stereotype in the model.
- * @param model Model to search in.
- * @param stereotype The stereotype name (e.g. "Sensor", "Actuator", "SubSystem"...)
+ *
+ * @param model
+ * Model to search in.
+ * @param stereotype
+ * The stereotype name (e.g. "Sensor", "Actuator", "SubSystem"...)
* @return A list of NamedElements having the specified stereotype.
* @deprecated to be replaced with calls to the RobotML API. Replaced by getElementsWithStereotype (Model model, StereotypeClass sc)
*/
- static public List<NamedElement> getElementsWithInheritedStereotype(Model model, String stereotype) {
+ static public List<NamedElement> getElementsWithInheritedStereotype(Model model, String stereotype) {
LinkedList<NamedElement> found_elts = new LinkedList<NamedElement>();
- for (Element ne : model.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if (inheritsFrom((org.eclipse.uml2.uml.Class)ne, stereotype)) {
+ for(Element ne : model.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(inheritsFrom((org.eclipse.uml2.uml.Class)ne, stereotype)) {
found_elts.add((NamedElement)ne);
}
}
- } else if (ne instanceof Model) {
- found_elts.addAll(getElementsWithInheritedStereotype((Model)ne,stereotype));
+ } else if(ne instanceof Model) {
+ found_elts.addAll(getElementsWithInheritedStereotype((Model)ne, stereotype));
}
- getElementsWithInheritedStereotype(ne,stereotype,found_elts);
+ getElementsWithInheritedStereotype(ne, stereotype, found_elts);
}
return found_elts;
}
-
+
/**
* Same as getElementsWithInheritedStereotype(Model model...) searches in an Element members, not in a Model members.
* This function is private and used by getElementsWithStereotype(Model model...)
+ *
* @param parent_elt
* @param stereotype
* @param target_list
* @deprecated to be replaced with calls to the RobotML API.
*/
static private void getElementsWithInheritedStereotype(Element parent_elt, String stereotype, LinkedList<NamedElement> target_list) {
- for (Element ne : parent_elt.getOwnedElements()) {
- if (ne instanceof NamedElement) {
+ for(Element ne : parent_elt.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
//System.out.println(((NamedElement)ne).getName());
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if(inheritsFrom((org.eclipse.uml2.uml.Class)ne, stereotype)){
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(inheritsFrom((org.eclipse.uml2.uml.Class)ne, stereotype)) {
target_list.add((NamedElement)ne);
- }
-// String current_stereotype = this.getStereotype((org.eclipse.uml2.uml.Class)ne);
-// //if (stereotype != "--")
-// // System.out.println("STEREOTYPE: " + stereotype);
-// if (current_stereotype.compareTo(stereotype)==0) {
-// //System.out.println("FOUND A SENSOR: " + ((NamedElement)ne).getName());
-// target_list.add((NamedElement)ne);
-// }
+ }
+ // String current_stereotype = this.getStereotype((org.eclipse.uml2.uml.Class)ne);
+ // //if (stereotype != "--")
+ // // System.out.println("STEREOTYPE: " + stereotype);
+ // if (current_stereotype.compareTo(stereotype)==0) {
+ // //System.out.println("FOUND A SENSOR: " + ((NamedElement)ne).getName());
+ // target_list.add((NamedElement)ne);
+ // }
}
- getElementsWithInheritedStereotype(ne,stereotype,target_list);
+ getElementsWithInheritedStereotype(ne, stereotype, target_list);
}
}
return;
@@ -168,59 +182,51 @@ public class GeneralQueries {
/**
* Get the first stereotype applied to a given class.
* Warning: other stereotypes are ignored. To use with care.
- * @deprecated superseded by the RobotML API.
+ *
+ * @deprecated superseded by the RobotML API.
*/
- static public String getStereotype(org.eclipse.uml2.uml.Class cl)
- {
- if (cl.getAppliedStereotypes().size()==1) {
+ static public String getStereotype(org.eclipse.uml2.uml.Class cl) {
+ if(cl.getAppliedStereotypes().size() == 1) {
return cl.getAppliedStereotypes().get(0).getName();
- }
- else {
+ } else {
return "--";
}
}
-
- static public Boolean inheritsFrom(org.eclipse.uml2.uml.Class cl, String stname)
- {
- for (Stereotype st : cl.getAppliedStereotypes()) {
- if(st.getName().equals(stname))
- {
+
+ static public Boolean inheritsFrom(org.eclipse.uml2.uml.Class cl, String stname) {
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ if(st.getName().equals(stname)) {
return true;
- }else{
- if(inheritsFrom(st, stname)){
+ } else {
+ if(inheritsFrom(st, stname)) {
return true;
}
}
}
return false;
}
-
- static public Boolean inheritsFrom(org.eclipse.uml2.uml.Stereotype st, String stname)
- {
- if(st.getName().equals(stname))
- {
+
+ static public Boolean inheritsFrom(org.eclipse.uml2.uml.Stereotype st, String stname) {
+ if(st.getName().equals(stname)) {
return true;
- }else{
- for(org.eclipse.uml2.uml.Class scl : st.getSuperClasses())
- {
- if(inheritsFrom((org.eclipse.uml2.uml.Stereotype) scl, stname))
+ } else {
+ for(org.eclipse.uml2.uml.Class scl : st.getSuperClasses()) {
+ if(inheritsFrom((org.eclipse.uml2.uml.Stereotype)scl, stname))
return true;
}
}
- return false;
+ return false;
}
-
- static public String getStereotypeInheritedFrom(org.eclipse.uml2.uml.Class cl, String stname)
- {
- for (Stereotype st : cl.getAppliedStereotypes()) {
- if(inheritsFrom(st, stname))
- {
+
+ static public String getStereotypeInheritedFrom(org.eclipse.uml2.uml.Class cl, String stname) {
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ if(inheritsFrom(st, stname)) {
return st.getName();
}
}
return null;
}
-
+
static public Boolean hasStereotype(org.eclipse.uml2.uml.Class cl, Class stereotype) {
for(EObject stereoApplication : cl.getStereotypeApplications()) {
// check whether the stereotype is an instance of the passed parameter clazz
@@ -230,30 +236,32 @@ public class GeneralQueries {
}
return false;
}
+
/**
* Return true if a given class has specified stereotype.
*/
- static public Boolean hasStereotype(org.eclipse.uml2.uml.Class cl, String s)
- {
- for (Stereotype st : cl.getAppliedStereotypes()) {
- if(st.getName().equals(s)){
+ static public Boolean hasStereotype(org.eclipse.uml2.uml.Class cl, String s) {
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ if(st.getName().equals(s)) {
return true;
}
}
return false;
}
-
+
/**
* Is this element a UML class
+ *
* @param element
* @return is this a UML class ?
*/
static public Boolean isClass(Element elt) {
return elt instanceof org.eclipse.uml2.uml.Class;
}
-
+
/**
* Is this element a UML DataType
+ *
* @param element
* @return is this a UML DataType ?
*/
@@ -262,9 +270,10 @@ public class GeneralQueries {
//System.out.println(((NamedElement)elt).getName()+" - isDataType: "+b+" "+elt.getAppliedStereotypes());
return b;
}
-
+
/**
* Is this element a UML interface
+ *
* @param element
* @return is this a UML class ?
*/
@@ -273,77 +282,74 @@ public class GeneralQueries {
//System.out.println(((NamedElement)elt).getName()+" - isInterface: "+b+" "+elt.getAppliedStereotypes());
return b;
}
-
+
/**
* Is this element a UML Property
+ *
* @param element
* @return is this a UML Property ?
*/
static public Boolean isProperty(Element elt) {
return elt instanceof Property;
}
-
+
/**
* Is this property a Port
+ *
* @param property
* @return is this a port ?
*/
static public Boolean isPort(Element prop) {
return prop instanceof Port;
}
-
+
/**
* Is this element an instance specification
+ *
* @param element
* @return is this an instance specification ?
*/
static public Boolean isInstanceSpecification(Element elt) {
return elt instanceof InstanceSpecification;
}
-
+
/**
* @TODO: this seems to be middleware specific. To be moved to corresponding middleware generator project.
*/
- static public String getInstanceMultiplicity(Property p)
- {
+ static public String getInstanceMultiplicity(Property p) {
try {
- if ((p.getLower()==1)&&(p.getUpper()==1))
- {
+ if((p.getLower() == 1) && (p.getUpper() == 1)) {
return "";
- }
- else if ((p.getLower()==p.getUpper()))
- {
- return "["+p.getLower()+"]";
- }
- else return "[]";
- }
- catch (Exception e) {
+ } else if((p.getLower() == p.getUpper())) {
+ return "[" + p.getLower() + "]";
+ } else
+ return "[]";
+ } catch (Exception e) {
java.lang.System.out.println(e);
e.printStackTrace();
return "";
}
}
-
+
/**
- * Return the value of a given attribute using the given stereotype
+ * Return the value of a given attribute using the given stereotype
*/
- static public String getAttributeValue(org.eclipse.uml2.uml.Class cl, String attr, String stname)
- {
- for (Stereotype st : cl.getAppliedStereotypes()) {
- if(st.getName().equals(stname)){
+ static public String getAttributeValue(org.eclipse.uml2.uml.Class cl, String attr, String stname) {
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ if(st.getName().equals(stname)) {
Object o = cl.getValue(st, attr);
- if (o != null) {
- if (o instanceof NamedElement) {
+ if(o != null) {
+ if(o instanceof NamedElement) {
String v = ((NamedElement)o).getName();
return v;
- }else if( o instanceof String){
- return (String) o;
- }else if( o instanceof EList){
- if(((EList<Object>) o).isEmpty()){
+ } else if(o instanceof String) {
+ return (String)o;
+ } else if(o instanceof EList) {
+ if(((EList<Object>)o).isEmpty()) {
return null;
}
- return ((EList<Object>) o).get(0).toString();
- }else{
+ return ((EList<Object>)o).get(0).toString();
+ } else {
return o.toString();
}
}
@@ -351,45 +357,43 @@ public class GeneralQueries {
}
return null;
}
-
+
/**
- * Return the value of a given attribute using the given stereotype
+ * Return the value of a given attribute using the given stereotype
* If attribute is not defined, then return a default value
*/
- static public String getAttributeValue(org.eclipse.uml2.uml.Class cl, String attr, String stname, String defaultValue)
- {
+ static public String getAttributeValue(org.eclipse.uml2.uml.Class cl, String attr, String stname, String defaultValue) {
String result = null;
result = getAttributeValue(cl, attr, stname);
//System.out.println("value : " + result);
- if(result == null || result.length()==0){
+ if(result == null || result.length() == 0) {
return defaultValue;
}
return result;
-
+
}
-
+
/**
- * Return the values of a given attribute using the given stereotype
+ * Return the values of a given attribute using the given stereotype
*/
- static public List<String> getAttributeValues(org.eclipse.uml2.uml.Class cl, String attr, String stname)
- {
+ static public List<String> getAttributeValues(org.eclipse.uml2.uml.Class cl, String attr, String stname) {
LinkedList<String> result = new LinkedList<String>();
- for (Stereotype st : cl.getAppliedStereotypes()) {
- if(st.getName().equals(stname)){
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ if(st.getName().equals(stname)) {
Object o = cl.getValue(st, attr);
- if (o != null) {
- if (o instanceof NamedElement){
+ if(o != null) {
+ if(o instanceof NamedElement) {
result.add(((NamedElement)o).getName());
- }else if( o instanceof String){
- result.add((String) o);
- }else if( o instanceof EList){
-// System.out.println("Values type: " + o.getClass().getName() );
- for(int i=0; i<((EList<Object>) o).size(); i++) {
- result.add(((EList<Object>) o).get(i).toString());
-// System.out.println("element " + i + " : " + ((EList<Object>) o).get(i));
+ } else if(o instanceof String) {
+ result.add((String)o);
+ } else if(o instanceof EList) {
+ // System.out.println("Values type: " + o.getClass().getName() );
+ for(int i = 0; i < ((EList<Object>)o).size(); i++) {
+ result.add(((EList<Object>)o).get(i).toString());
+ // System.out.println("element " + i + " : " + ((EList<Object>) o).get(i));
}
- }else{
+ } else {
result.add(o.toString());
}
}
@@ -397,197 +401,182 @@ public class GeneralQueries {
}
return result;
}
-
+
/**
- * Find a class with a given name in the model.
+ * Find a class with a given name in the model.
*/
- static public org.eclipse.uml2.uml.Class findClassInModel(org.eclipse.uml2.uml.Model model, String name){
- for (Element ne : model.getOwnedElements()) {
- if (ne instanceof NamedElement) {
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if(((org.eclipse.uml2.uml.Class) ne).getName().equals(name))
- return (org.eclipse.uml2.uml.Class) ne;
- }else if(ne instanceof org.eclipse.uml2.uml.Package){
- org.eclipse.uml2.uml.Class result = findClassInPackage((org.eclipse.uml2.uml.Package)ne,name);
+ static public org.eclipse.uml2.uml.Class findClassInModel(org.eclipse.uml2.uml.Model model, String name) {
+ for(Element ne : model.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(((org.eclipse.uml2.uml.Class)ne).getName().equals(name))
+ return (org.eclipse.uml2.uml.Class)ne;
+ } else if(ne instanceof org.eclipse.uml2.uml.Package) {
+ org.eclipse.uml2.uml.Class result = findClassInPackage((org.eclipse.uml2.uml.Package)ne, name);
if(result != null)
return result;
}
- } else if (ne instanceof Model) {
- org.eclipse.uml2.uml.Class result = findClassInModel((Model)ne,name);
+ } else if(ne instanceof Model) {
+ org.eclipse.uml2.uml.Class result = findClassInModel((Model)ne, name);
if(result != null)
- return result;
+ return result;
}
}
return null;
}
-
+
/**
- * Find a class with a given name in a package.
+ * Find a class with a given name in a package.
*/
- static public org.eclipse.uml2.uml.Class findClassInPackage(org.eclipse.uml2.uml.Package pack, String name){
- for (Element ne : pack.getOwnedElements()) {
- if (ne instanceof NamedElement) {
+ static public org.eclipse.uml2.uml.Class findClassInPackage(org.eclipse.uml2.uml.Package pack, String name) {
+ for(Element ne : pack.getOwnedElements()) {
+ if(ne instanceof NamedElement) {
//System.out.println(((NamedElement) ne).getName());
- if (ne instanceof org.eclipse.uml2.uml.Class) {
- if(((org.eclipse.uml2.uml.Class) ne).getName().equals(name))
- return (org.eclipse.uml2.uml.Class) ne;
- }else if(ne instanceof org.eclipse.uml2.uml.Package){
- org.eclipse.uml2.uml.Class result = findClassInPackage((org.eclipse.uml2.uml.Package)ne,name);
+ if(ne instanceof org.eclipse.uml2.uml.Class) {
+ if(((org.eclipse.uml2.uml.Class)ne).getName().equals(name))
+ return (org.eclipse.uml2.uml.Class)ne;
+ } else if(ne instanceof org.eclipse.uml2.uml.Package) {
+ org.eclipse.uml2.uml.Class result = findClassInPackage((org.eclipse.uml2.uml.Package)ne, name);
if(result != null)
- return result;
- }
- } else if (ne instanceof Model) {
- org.eclipse.uml2.uml.Class result = findClassInModel((Model)ne,name);
- if(result != null)
return result;
+ }
+ } else if(ne instanceof Model) {
+ org.eclipse.uml2.uml.Class result = findClassInModel((Model)ne, name);
+ if(result != null)
+ return result;
}
}
return null;
}
-
+
/**
* Debug function. Prints info about a given datatype.
*/
- static public void inspectDataType(DataType datatype)
- {
- java.lang.System.out.println ("\t\t* data type: "+datatype.getName());
+ static public void inspectDataType(DataType datatype) {
+ java.lang.System.out.println("\t\t* data type: " + datatype.getName());
}
-
+
/**
* Debug function.
*/
- static public void inspectClass(org.eclipse.uml2.uml.Class cl)
- {
-
+ static public void inspectClass(org.eclipse.uml2.uml.Class cl) {
+
// super classes of this classes
- java.lang.System.out.println("\t* super classes: "+cl.getSuperClasses());
-
+ java.lang.System.out.println("\t* super classes: " + cl.getSuperClasses());
+
// stereotypes of this class
- for (Stereotype st : cl.getAppliedStereotypes()) {
- java.lang.System.out.println("\t* applied stereotype: "+st.getName());
+ for(Stereotype st : cl.getAppliedStereotypes()) {
+ java.lang.System.out.println("\t* applied stereotype: " + st.getName());
}
-
+
// properties of this class
- for (Property prop : cl.getAllAttributes()) {
-
- java.lang.System.out.println("\t* property: "+prop.getName());
+ for(Property prop : cl.getAllAttributes()) {
+
+ java.lang.System.out.println("\t* property: " + prop.getName());
// This is a Port
- if (isPort(prop)) {
+ if(isPort(prop)) {
inspectPort((Port)prop);
- }
- else {
+ } else {
Type propType = prop.getType();
- if (isDataType(propType)) {
- java.lang.System.out.println("\t\t* property read from stereotype: "+prop.getName());
- }
- else if (isClass(propType)) {
- java.lang.System.out.println ("\t\t* class sub instance : "+propType.getName()+" - "+prop.getUpper()+" - "+prop.getLower());
- }
- else
- {
- java.lang.System.err.println("UNKONWN PROPERTY TYPE !");
+ if(isDataType(propType)) {
+ java.lang.System.out.println("\t\t* property read from stereotype: " + prop.getName());
+ } else if(isClass(propType)) {
+ java.lang.System.out.println("\t\t* class sub instance : " + propType.getName() + " - " + prop.getUpper() + " - " + prop.getLower());
+ } else {
+ java.lang.System.err.println("UNKONWN PROPERTY TYPE !");
}
}
}
- for (Connector connector : cl.getOwnedConnectors())
- {
- java.lang.System.out.println("\t* owned connector: "+connector.getName());
- for (ConnectorEnd cend : connector.getEnds())
- {
- if ((cend.getRole()!=null)&&(cend.getPartWithPort()!=null)) {
- java.lang.System.out.println("\t\t* from property: "+cend.getRole().getName()+" in instance "+cend.getPartWithPort().getName());
- }
- else {
- java.lang.System.err.println ("\t\t* Unconnected Port !");
+ for(Connector connector : cl.getOwnedConnectors()) {
+ java.lang.System.out.println("\t* owned connector: " + connector.getName());
+ for(ConnectorEnd cend : connector.getEnds()) {
+ if((cend.getRole() != null) && (cend.getPartWithPort() != null)) {
+ java.lang.System.out.println("\t\t* from property: " + cend.getRole().getName() + " in instance " + cend.getPartWithPort().getName());
+ } else {
+ java.lang.System.err.println("\t\t* Unconnected Port !");
java.lang.System.out.println();
}
}
}
- for (Operation op : cl.getAllOperations()) {
- java.lang.System.out.println("\t* operation: "+op.getName()+" - datatype: "+op.getDatatype()+" - interface: "+op.getInterface());
+ for(Operation op : cl.getAllOperations()) {
+ java.lang.System.out.println("\t* operation: " + op.getName() + " - datatype: " + op.getDatatype() + " - interface: " + op.getInterface());
}
}
-
-
- /**
+
+
+ /**
* Debug function. Prints info about a given port.
*/
- static public void inspectPort(Port port)
- {
- if (ArchitectureQueries.isDataFlowPort(port))
- {
+ static public void inspectPort(Port port) {
+ if(ArchitectureQueries.isDataFlowPort(port)) {
ArchitectureQueries.inspectDataFlowPort(port);
- }
- else if (ArchitectureQueries.isServicePort(port))
- {
+ } else if(ArchitectureQueries.isServicePort(port)) {
ArchitectureQueries.inspectServicePort(port);
- }
- else {
+ } else {
java.lang.System.err.println("UNKONWN PORT !");
}
}
+
/**
* Fonction de test pour inspecter un mod�le UML2
+ *
* @param model
* @return
*/
static public Boolean inspectModel(Model model) {
try {
// model name
- java.lang.System.out.println("* model name: "+model.getName());
-
+ java.lang.System.out.println("* model name: " + model.getName());
+
//
// Bibliothèque de DataTypes sera importée
//
- for (PackageableElement elt : model.getImportedElements()) {
- java.lang.System.out.println("* model imported packageable element: "+elt);
+ for(PackageableElement elt : model.getImportedElements()) {
+ java.lang.System.out.println("* model imported packageable element: " + elt);
}
//
// Peut-être ?
//
- for (org.eclipse.uml2.uml.Package elt : model.getImportedPackages()) {
- java.lang.System.out.println("* model imported package: "+elt);
+ for(org.eclipse.uml2.uml.Package elt : model.getImportedPackages()) {
+ java.lang.System.out.println("* model imported package: " + elt);
}
//
// Récupérer Package par Package si possible (cf méthodologie Outil RobotML)
//
- for (org.eclipse.uml2.uml.Package elt : model.getNestedPackages()) {
- java.lang.System.out.println("* model nested package: "+elt);
+ for(org.eclipse.uml2.uml.Package elt : model.getNestedPackages()) {
+ java.lang.System.out.println("* model nested package: " + elt);
}
//
// Parcours des éléments contenus dans le modèle
//
- for (NamedElement elt : model.getMembers()) {
- java.lang.System.out.println("* model member: "+elt.getName());
- if (isClass(elt)) {
+ for(NamedElement elt : model.getMembers()) {
+ java.lang.System.out.println("* model member: " + elt.getName());
+ if(isClass(elt)) {
inspectClass((org.eclipse.uml2.uml.Class)elt);
- }
- else if (isDataType(elt)) {
+ } else if(isDataType(elt)) {
inspectDataType((DataType)elt);
+ } else if(isInterface(elt)) {
+ java.lang.System.out.println("\t* interface definition : " + elt.getName());
+
+ } else {
+ java.lang.System.err.println("\t* unknown element: " + elt);
}
- else if (isInterface(elt)) {
- java.lang.System.out.println("\t* interface definition : "+elt.getName());
-
- }
- else {
- java.lang.System.err.println("\t* unknown element: "+elt);
- }
-
+
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
java.lang.System.out.println(e);
e.printStackTrace();
}
return true;
}
-
+
/**
* String manipulation function :
* remove brackets from a string
+ *
* @param str
* @return
*/
@@ -595,4 +584,3 @@ public class GeneralQueries {
return str.replaceAll("[\\[\\]]", "");
}
}
-
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java
index c4d74e5c941..7b052dad1eb 100644
--- a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java
@@ -26,36 +26,34 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
/**
* Entry point of the 'MMQueries' generation module.
- *
+ *
* @generated
*/
public class MMQueries extends AbstractAcceleoGenerator {
+
/**
* The name of the module.
- *
+ *
* @generated
*/
public static final String MODULE_FILE_NAME = "MMQueries";
-
+
/**
* The name of the templates that are to be generated.
- *
+ *
* @generated
*/
public static final String[] TEMPLATE_NAMES = { "MMQueries", };
/**
* Allows the public constructor to be used. Note that a generator created
- * this way cannot be used to launch generations before one of
- * {@link #initialize(EObject, File, List)} or
- * {@link #initialize(URI, File, List)} is called.
+ * this way cannot be used to launch generations before one of {@link #initialize(EObject, File, List)} or {@link #initialize(URI, File, List)} is
+ * called.
* <p>
- * The main reason for this constructor is to allow clients of this
- * generation to call it from another Java file, as it allows for the
- * retrieval of {@link #getProperties()} and
- * {@link #getGenerationListeners()}.
+ * The main reason for this constructor is to allow clients of this generation to call it from another Java file, as it allows for the retrieval
+ * of {@link #getProperties()} and {@link #getGenerationListeners()}.
* </p>
- *
+ *
* @generated
*/
public MMQueries() {
@@ -66,20 +64,19 @@ public class MMQueries extends AbstractAcceleoGenerator {
* This allows clients to instantiates a generator with all required information.
*
* @param modelURI
- * URI where the model on which this generator will be used is located.
+ * URI where the model on which this generator will be used is located.
* @param targetFolder
- * This will be used as the output folder for this generation : it will be the base path
- * against which all file block URLs will be resolved.
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
* @param arguments
- * If the template which will be called requires more than one argument taken from the model,
- * pass them here.
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
* @throws IOException
- * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
- * the model cannot be loaded.
+ * This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
+ * the model cannot be loaded.
* @generated
*/
- public MMQueries(URI modelURI, File targetFolder,
- List<? extends Object> arguments) throws IOException {
+ public MMQueries(URI modelURI, File targetFolder, List<? extends Object> arguments) throws IOException {
initialize(modelURI, targetFolder, arguments);
}
@@ -87,39 +84,38 @@ public class MMQueries extends AbstractAcceleoGenerator {
* This allows clients to instantiates a generator with all required information.
*
* @param model
- * We'll iterate over the content of this element to find Objects matching the first parameter
- * of the template we need to call.
+ * We'll iterate over the content of this element to find Objects matching the first parameter
+ * of the template we need to call.
* @param targetFolder
- * This will be used as the output folder for this generation : it will be the base path
- * against which all file block URLs will be resolved.
+ * This will be used as the output folder for this generation : it will be the base path
+ * against which all file block URLs will be resolved.
* @param arguments
- * If the template which will be called requires more than one argument taken from the model,
- * pass them here.
+ * If the template which will be called requires more than one argument taken from the model,
+ * pass them here.
* @throws IOException
- * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
+ * This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
* @generated
*/
- public MMQueries(EObject model, File targetFolder,
- List<? extends Object> arguments) throws IOException {
+ public MMQueries(EObject model, File targetFolder, List<? extends Object> arguments) throws IOException {
initialize(model, targetFolder, arguments);
}
-
+
/**
* This can be used to launch the generation from a standalone application.
*
* @param args
- * Arguments of the generation.
+ * Arguments of the generation.
* @generated
*/
public static void main(String[] args) {
try {
- if (args.length < 2) {
+ if(args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
List<String> arguments = new ArrayList<String>();
- for (int i = 2; i < args.length; i++) {
+ for(int i = 2; i < args.length; i++) {
arguments.add(args[i]);
}
MMQueries generator = new MMQueries(modelURI, folder, arguments);
@@ -134,9 +130,9 @@ public class MMQueries extends AbstractAcceleoGenerator {
* Launches the generation described by this instance.
*
* @param monitor
- * This will be used to display progress information to the user.
+ * This will be used to display progress information to the user.
* @throws IOException
- * This will be thrown if any of the output files cannot be saved to disk.
+ * This will be thrown if any of the output files cannot be saved to disk.
* @generated
*/
@Override
@@ -147,7 +143,7 @@ public class MMQueries extends AbstractAcceleoGenerator {
*/
super.doGenerate(monitor);
}
-
+
/**
* If this generator needs to listen to text generation events, listeners can be returned from here.
*
@@ -160,20 +156,19 @@ public class MMQueries extends AbstractAcceleoGenerator {
// TODO if you need to listen to generation event, add listeners to the list here
return listeners;
}
-
+
/**
* If you need to change the way files are generated, this is your entry point.
* <p>
- * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates
- * files on the fly. If you only need to preview the results, return a new
- * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of
- * the running Eclipse and can be used standalone.
+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates files on the fly. If you only need to
+ * preview the results, return a new {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of the
+ * running Eclipse and can be used standalone.
* </p>
* <p>
- * If you need the file generation to be aware of the workspace (A typical example is when you wanna
- * override files that are under clear case or any other VCS that could forbid the overriding), then
- * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}.
- * <b>Note</b>, however, that this <b>cannot</b> be used standalone.
+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna override files that are under clear case or
+ * any other VCS that could forbid the overriding), then return a new
+ * {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. <b>Note</b>, however, that this <b>cannot</b> be used
+ * standalone.
* </p>
* <p>
* All three of these default strategies support merging through JMerge.
@@ -185,7 +180,7 @@ public class MMQueries extends AbstractAcceleoGenerator {
public IAcceleoGenerationStrategy getGenerationStrategy() {
return super.getGenerationStrategy();
}
-
+
/**
* This will be called in order to find and load the module that will be launched through this launcher.
* We expect this name not to contain file extension, and the module to be located beside the launcher.
@@ -197,16 +192,15 @@ public class MMQueries extends AbstractAcceleoGenerator {
public String getModuleName() {
return MODULE_FILE_NAME;
}
-
+
/**
* If the module(s) called by this launcher require properties files, return their qualified path from
* here.Take note that the first added properties files will take precedence over subsequent ones if they
* contain conflicting keys.
* <p>
- * Properties need to be in source folders, the path that we expect to get as a result of this call are of
- * the form &lt;package>.&lt;properties file name without extension>. For example, if you have a file
- * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by
- * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of the form &lt;package>.&lt;properties
+ * file name without extension>. For example, if you have a file named "messages.properties" in package "org.eclipse.acceleo.sample", the path
+ * that needs be returned by a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages".
* </p>
*
* @return The list of properties file we need to add to the generation context.
@@ -227,7 +221,7 @@ public class MMQueries extends AbstractAcceleoGenerator {
*/
return propertiesFiles;
}
-
+
/**
* This will be used to get the list of templates that are to be launched by this launcher.
*
@@ -238,12 +232,12 @@ public class MMQueries extends AbstractAcceleoGenerator {
public String[] getTemplateNames() {
return TEMPLATE_NAMES;
}
-
+
/**
* This can be used to update the resource set's package registry with all needed EPackages.
*
* @param resourceSet
- * The resource set which registry has to be updated.
+ * The resource set which registry has to be updated.
* @generated
*/
@Override
@@ -258,7 +252,7 @@ public class MMQueries extends AbstractAcceleoGenerator {
* This can be used to update the resource set's resource factory registry with all needed factories.
*
* @param resourceSet
- * The resource set which registry has to be updated.
+ * The resource set which registry has to be updated.
* @generated
*/
@Override
@@ -267,5 +261,5 @@ public class MMQueries extends AbstractAcceleoGenerator {
// TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
}
-
+
}

Back to the top