Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-07-25 12:37:46 -0400
committerCamille Letavernier2013-07-25 12:37:46 -0400
commit0d085addb034a1aa3fdbc20140bb271e56d58910 (patch)
tree0abf9dfa02a90f290682b97235f1b5afbc98ac67 /extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common
parent0cf8e396f1c70664a78562f7a07bffd7479bacd0 (diff)
downloadorg.eclipse.papyrus-0d085addb034a1aa3fdbc20140bb271e56d58910.tar.gz
org.eclipse.papyrus-0d085addb034a1aa3fdbc20140bb271e56d58910.tar.xz
org.eclipse.papyrus-0d085addb034a1aa3fdbc20140bb271e56d58910.zip
413755: [RobotML] Add RobotML code generators
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413755 Initial import
Diffstat (limited to 'extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common')
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java64
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java786
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.mtl144
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java189
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.mtl18
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java392
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.mtl59
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java105
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.mtl33
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java598
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.mtl86
-rw-r--r--extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java271
12 files changed, 2745 insertions, 0 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
new file mode 100644
index 00000000000..8202b692812
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/Activator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.robotml.generators.common;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle.
+ */
+public class Activator extends Plugin {
+
+ /**
+ * The plug-in ID.
+ */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.robotml.generators.common";
+
+ /**
+ * The shared instance.
+ */
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**{@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
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
new file mode 100644
index 00000000000..8708303b18c
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.java
@@ -0,0 +1,786 @@
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas DU LAC (INTEMPORA) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.robotml.generators.common.mmqueries;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Connector;
+import org.eclipse.uml2.uml.ConnectorEnd;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Port;
+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).
+ */
+ static private boolean isSourcePort(ConnectorEnd end, Port p) {
+ 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).
+ */
+ 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
+ * @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) {
+ Port test_1 = (Port)conn.getEnds().get(0).getRole();
+ 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)) {
+ dest_port[0] = test_2;
+ return 1;
+ }
+ }
+ dest_port = null;
+ return -1;
+ }
+
+ /**
+ * 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) {
+ Port test_1 = (Port)conn.getEnds().get(0).getRole();
+ 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)) {
+ dest_port[0] = test_2;
+ return 1;
+ }
+ }
+ 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)
+ return "Unknown";
+
+ 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)
+ 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)
+ return null;
+ return prop.getName();
+ }
+
+ /**
+ * Get the source component instance of a connector
+ */
+ static public org.eclipse.uml2.uml.Property getSourceComponentForConnector(org.eclipse.uml2.uml.Connector conn) {
+ Property input;
+ Port[] inputPort = new Port[1];
+ int index = getSourcePort(conn, inputPort);
+ 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)
+ return "Unknown";
+
+ outputName = outputPort[0].getName();
+
+ return outputName;
+ }
+
+ /**
+ * Get the destination component instance of a connector
+ */
+ static public org.eclipse.uml2.uml.Property getDestComponentForConnector(org.eclipse.uml2.uml.Connector conn) {
+ Property output;
+ Port[] outputPort = new Port[1];
+ int index = getDestPort(conn, outputPort);
+ if ( (index < 0) || (conn.getEnds().get(index).getPartWithPort()==null) )
+ return null;
+ else
+ output = conn.getEnds().get(index).getPartWithPort();
+ return output;
+ }
+
+ /**
+ * 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)
+ 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)
+ 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)) {
+ connectors.add(conn);
+ }
+ }
+ return connectors;
+ }
+
+ /**
+ * Retrieves all the connectors between the input component model boundaries and subcomponents that are inside the model.
+ * (does not retrieve connectors between subcomponents inside the component model, nor connectors from subcomponents to component model outputs).
+ */
+ 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) {
+ 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)) {
+ connectors.add(conn);
+ }
+ }
+ }
+ }
+ 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) {
+ 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)) {
+ connectors.add(conn);
+ }
+ }
+ }
+ }
+ 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);
+ }
+ }
+ return null;
+ }
+ /**
+ * On a given class (a RobotML system), retrieve all the contained systems.
+ * Recursive.
+ */
+ 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);
+ sub_components.addAll(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)
+ {
+ LinkedList<org.eclipse.uml2.uml.Property> sub_components = new LinkedList<org.eclipse.uml2.uml.Property>();
+ 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)) {
+ 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.
+ */
+ 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()) {
+ 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))
+ {
+ sub_components.add(prop);
+ }
+ }
+ }
+ 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)) {
+ 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)) {
+ Port found_port = (org.eclipse.uml2.uml.Port)child;
+ found_input_ports.add(found_port);
+ }
+ }
+ }
+ return found_input_ports;
+ }
+
+ 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())
+ {
+ result.add((Property)p);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Retrieves all the component models available inside a RobotML 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)) {
+ 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)
+ 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)
+ {
+ boolean result = false;
+ if (getLevel1SubComponentsForComponent(c).size() > 0) {
+ result = true;
+ }
+ return result;
+ }
+
+ 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)
+ return false;
+ return sys.isNative();
+ }
+
+ 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)
+ return null;
+ return sys.getLibraryPath();
+ }
+
+ 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)
+ 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)
+ return 0;
+ return dfp.getBufferSize();
+ }
+ /**
+ *
+ */
+ static public String getComponentFileName(org.eclipse.uml2.uml.Class c, String end) {
+ return c.getName()+end;
+ }
+
+ /**
+ * @TODO: author to add some doc.
+ */
+ 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;
+ }
+
+ /**
+ * @TODO: author to add some doc. Middleware specific?
+ */
+ 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());
+ Property c2 = null;
+ 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) {
+ 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();
+ }
+ else {
+ return "@"+c2.getName()+"."+p2.getName();
+ }
+ }
+ 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)
+ 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.
+ */
+ static public Boolean isAnInputPort(Port port)
+ {
+ try {
+ DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
+ if (dfp == null)
+ return false;
+ if (dfp.getDirection() == DataFlowDirectionKind.IN)
+ return true;
+ return false;
+ } catch (Exception e) {
+ java.lang.System.out.println("EXCEPTION caught:" + e.toString());
+ }
+ 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.
+ */
+ static public Boolean isAnOutputPort(Port port)
+ {
+ try {
+ DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
+ if (dfp == null)
+ return false;
+ if (dfp.getDirection() == DataFlowDirectionKind.OUT)
+ return true;
+ return false;
+ } catch (Exception e) {
+ java.lang.System.out.println("EXCEPTION caught:" + e.toString());
+ }
+ 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)
+ return false;
+ if (sp.getKind() == ServiceFlowKind.PROVIDED)
+ return true;
+ return false;
+ } catch (Exception e) {
+ java.lang.System.out.println("EXCEPTION caught:" + e.toString());
+ }
+ return false;
+ }
+
+ /**
+ * 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)
+ return false;
+ if (sp.getKind() == ServiceFlowKind.REQUIRED)
+ return true;
+ return false;
+ } catch (Exception e) {
+ java.lang.System.out.println("EXCEPTION caught:" + e.toString());
+ }
+ return false;
+ }
+
+ /**
+ * Is this property a Service Port
+ * @param port
+ * @return is this a service port ?
+ */
+ static public Boolean isServicePort(Port port) {
+ 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;
+ }
+
+ /**
+ * @TODO: author to add some doc
+ */
+ 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)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @TODO: this seems to be middleware specific. To be moved to corresponding middleware generator project.
+ */
+ 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()+")";
+ }
+
+ 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
+ * @param port
+ * @return a list of connectors which are connected to the 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())
+ {
+ Connector conn = (Connector)connEnd.getOwner();
+
+ 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)
+ {
+ //
+ 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 ! ");
+ }
+ //
+ //
+ // A partir des attributs ci-dessous, on peut récupérer:
+ // - la taille du buffer
+ // - 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()));
+ }
+
+ }
+
+ /**
+ * Debug function. Prints info about a given service 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 ! ");
+ }
+ // 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)
+ {
+ Boolean result = false;
+ if(current_elt != null && other_elt != null)
+ {
+ if(current_elt == other_elt)
+ {
+ result = true;
+ }
+ else
+ {
+ for(Class parent : current_elt.getSuperClasses())
+ {
+ current_elt = parent;
+ 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.
+ */
+ static public Boolean isAnInputOutputPort(Port port)
+ {
+ try {
+ DataFlowPort dfp = UMLUtil.getStereotypeApplication(port, DataFlowPort.class);
+ if (dfp == null)
+ return false;
+ if (dfp.getDirection() == DataFlowDirectionKind.INOUT)
+ return true;
+ return false;
+ } catch (Exception e) {
+ java.lang.System.out.println("EXCEPTION caught:" + e.toString());
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.mtl b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.mtl
new file mode 100644
index 00000000000..cff837a1dff
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/ArchitectureQueries.mtl
@@ -0,0 +1,144 @@
+[comment encoding = UTF-8 /]
+[comment]
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas DU LAC (INTEMPORA) - Initial API and implementation
+ *
+ *****************************************************************************/
+[/comment]
+[module ArchitectureQueries('http://www.eclipse.org/uml2/3.0.0/UML', 'http://Papyrus/RobotML/1')]
+
+
+[query public getSourcePortName(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getSourcePortName(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getSourceComponentForConnector(conn : Connector) : Property =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getSourceComponentForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getSourceComponentTypeNameForConnector(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getSourceComponentTypeNameForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getSourceComponentInstanceNameForConnector(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getSourceComponentInstanceNameForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getDestPortName(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getDestPortName(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getDestComponentForConnector(conn : Connector) : Property =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getDestComponentForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getDestComponentTypeNameForConnector(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getDestComponentTypeNameForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getDestComponentInstanceNameForConnector(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getDestComponentInstanceNameForConnector(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getInternalConnectors(c : Class) : Sequence(Connector) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getInternalConnectors(org.eclipse.uml2.uml.Class)', Sequence{c})
+/]
+[query public getExternalInputConnectors(c : Class) : Sequence(Connector) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getExternalInputConnectors(org.eclipse.uml2.uml.Class)', Sequence{c})
+/]
+[query public getExternalOutputConnectors(c : Class) : Sequence(Connector) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getExternalOutputConnectors(org.eclipse.uml2.uml.Class)', Sequence{c})
+/]
+[query public getAllSubComponentsInClass(class : Class) : Sequence(Property) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getAllSubComponentsInClass(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public getLevel1SubComponentsForComponent(class : Class) : Sequence(Property) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getLevel1SubComponentsForComponent(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public getLevel1SubComponentsForComponentWithStereotype(class : Class, stereotype : String) : Sequence(Property) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getLevel1SubComponentsForComponentWithStereotype(org.eclipse.uml2.uml.Class, java.lang.String)', Sequence{class, stereotype})
+/]
+[query public getOutputPortsForElement(elt : Element) : Sequence(Port) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getOutputPortsForElement(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public getInputPortsForElement(elt : Element) : Sequence(Port) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getInputPortsForElement(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public getOnPort(param : Parameter) : Sequence(Property) =
+ invoke('org.eclipse.proteus.generators.acceleo.mmqueries.ArchitectureQueries', 'getOnPort(org.eclipse.uml2.uml.Parameter)', Sequence{param})
+/]
+[query public getComponentModels(model : Model) : Sequence(NamedElement) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getComponentModels(org.eclipse.uml2.uml.Model)', Sequence{model})
+/]
+[query public isMacroComponent(class : Class) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isMacroComponent(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public hasNativeImplementation(class : Class) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'hasNativeImplementation(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public getNativeLibraryPathForComponent(class : Class) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getNativeLibraryPathForComponent(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public getNativeComponentNameForComponent(class : Class) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getNativeComponentNameForComponent(org.eclipse.uml2.uml.Class)', Sequence{class})
+/]
+[query public getComponentFileName(classifier : Classifier, end : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getComponentFileName(org.eclipse.uml2.uml.Classifier,java.lang.String)', Sequence{classifier,end})
+/]
+[query public getOutputPortBufferSize(p : Port) : Integer =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getOutputPortBufferSize(org.eclipse.uml2.uml.Port)', Sequence{p})
+/]
+[query public isDataFlowPort(elt : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isDataFlowPort(org.eclipse.uml2.uml.Port)', Sequence{elt})
+/]
+[query public isServicePort(elt : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isServicePort(org.eclipse.uml2.uml.Port)', Sequence{elt})
+/]
+[query public definesConnections(cl : Class) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'definesConnections(org.eclipse.uml2.uml.Class)', Sequence{cl})
+/]
+[query public isConnectionValid(conn : Connector) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isConnectionValid(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getConnectionDefinition(conn : Connector) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getConnectionDefinition(org.eclipse.uml2.uml.Connector)', Sequence{conn})
+/]
+[query public getConnectedPort(port : Port) : Port =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getConnectedPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public getConnectionsFromPort(port : Port) : Sequence(Connector) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getConnectionsFromPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isAnInputPort(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isAnInputPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isAnOutputPort(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isAnOutputPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isAProvidedPort(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isAProvidedPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isARequiredPort(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isARequiredPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public getConnectionOtherSide(port : Port) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'getConnectionOtherSide(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isPortConnected(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isPortConnected(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
+[query public isRootModel(elt : Model) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isRootModel(org.eclipse.uml2.uml.Model)', Sequence{elt})
+/]
+[query public getRootClassForModel(model : Model) : Class =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries','getRootClassForModel(org.eclipse.uml2.uml.Model)', Sequence{model})
+/]
+
+[query public isAnAncestorOf(current_class : Class, other_class : Class) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isAnAncestorOf(org.eclipse.uml2.uml.Class, org.eclipse.uml2.uml.Class)', Sequence{current_class, other_class})
+/]
+
+[query public isAnInputOutputPort(port : Port) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.ArchitectureQueries', 'isAnInputOutputPort(org.eclipse.uml2.uml.Port)', Sequence{port})
+/]
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
new file mode 100644
index 00000000000..f26fed95804
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.java
@@ -0,0 +1,189 @@
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas DU LAC (INTEMPORA) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.robotml.generators.common.mmqueries;
+
+import java.util.List;
+import java.util.LinkedList;
+
+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.Model;
+import org.eclipse.uml2.uml.NamedElement;
+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 List<DataType> getMetamodelComposedDataTypes(Element rootelt) {
+ LinkedList<DataType> results = new LinkedList<DataType>();
+ if (rootelt instanceof Model) {
+ EList<Package> packages = ((Model)rootelt).getImportedPackages();
+ for (Package p : packages ) {
+ EList<Element> elts = p.getOwnedElements();
+ for (Element elt : elts) {
+ if (elt instanceof PrimitiveType) {
+ } else if (elt instanceof DataType) {
+ results.add((DataType)elt);
+ } else if (elt instanceof Package) {
+ results.addAll(getMetamodelComposedDataTypes(elt));
+ }
+ }
+ }
+ } 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) {
+ results.add((DataType)elt);
+ } 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))
+ 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))
+ return true;
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.out.println(e.toString());
+ }
+ return false;
+ }
+
+ public String getCppClassForDatatType(DataType dt) {
+ try {
+ String s="";
+ if (dt instanceof Enumeration) {
+ Enumeration en = (Enumeration)dt;
+ s = "enum " + en.getName() + " {" + newline;
+ EList<EnumerationLiteral> literals = en.getOwnedLiterals();
+ for (EnumerationLiteral literal : literals) {
+ s += "\t" + literal.getName() + "," + newline;
+ }
+ } else if (dt instanceof EnumerationLiteral){
+ //do nothing.
+ } else {
+ EList<Property> attributes = dt.getOwnedAttributes();
+ s = "class " + dt.getName() + " {"+ newline + "\tpublic:" + newline;
+ for (Property attribute : attributes) {
+ String type_name;
+ 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;
+ } else {
+ s+="\tstd::vector<" + type_name + "> " + attribute.getName() + ";" + 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)
+ {
+ LinkedList<NamedElement> found_elts = new LinkedList<NamedElement>();
+ for (NamedElement ne : model.getOwnedMembers())
+ {
+ if (ne instanceof org.eclipse.uml2.uml.DataType) {
+ found_elts.add((NamedElement)ne);
+ }
+ 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)
+ {
+ target_list.add((NamedElement)ne);
+ }
+ getElementsDataType(ne,target_list);
+ }
+ return;
+ }
+
+ public DataType getPortDataType(Port port) {
+ Type t = port.getType();
+ if (t!= null && t instanceof DataType) {
+ return (DataType)t;
+ }
+ return null;
+ }
+
+ public static boolean isPrimitiveType(Element elt) {
+ 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/DataTypeQueries.mtl b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.mtl
new file mode 100644
index 00000000000..771e72b4757
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DataTypeQueries.mtl
@@ -0,0 +1,18 @@
+[comment encoding = UTF-8 /]
+[module DataTypeQueries('http://www.eclipse.org/uml2/3.0.0/UML', 'http://Papyrus/RobotML/1')]
+
+[query public getMetamodelComposedDataTypes(rootelt : Element) : Sequence(DataType) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DataTypeQueries', 'getMetamodelComposedDataTypes(org.eclipse.uml2.uml.Element)', Sequence{rootelt})
+/]
+[query public isRobotMLDataType(root_model : Element, datatype_name : String) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DataTypeQueries', 'isRobotMLDataType(org.eclipse.uml2.uml.Element, java.lang.String)', Sequence{root_model,datatype_name})
+/]
+[query public getCppClassForDatatType(dt : DataType) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DataTypeQueries', 'getCppClassForDatatType(org.eclipse.uml2.uml.DataType)', Sequence{dt})
+/]
+[query public getElementsDataType(elt : Model) : Sequence(NamedElement) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DataTypeQueries', 'getElementsDataType(org.eclipse.uml2.uml.Model)', Sequence{elt})
+/]
+[query public isPrimitiveType(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DataTypeQueries', 'isPrimitiveType(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
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
new file mode 100644
index 00000000000..3cdf55c07c4
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.java
@@ -0,0 +1,392 @@
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project Consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastien BONNET (EFFIDENCE) - Initial API and implementation
+ * Nicolas DU LAC (INTEMPORA) - Additional methods and a few updates.
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.robotml.generators.common.mmqueries;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+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;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+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) {
+ found_elts.add((InstanceSpecification)ne);
+ //System.out.println("Instance : "+((NamedElement) ne).getName());
+ }else if(ne instanceof org.eclipse.uml2.uml.Package){
+ found_elts.addAll(getInstanceSpecificationsInPackage((org.eclipse.uml2.uml.Package)ne));
+ }
+ } else if (ne instanceof Model) {
+ found_elts.addAll(getInstanceSpecificationsInModel((Model)ne));
+ }
+ }
+// 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) {
+ found_elts.add((InstanceSpecification)ne);
+ } else if(ne instanceof org.eclipse.uml2.uml.Package){
+ found_elts.addAll(getInstanceSpecificationsInPackage((org.eclipse.uml2.uml.Package)ne));
+ }
+ } 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
+ * @return A list of InstanceSpecification of all instance specifications
+ */
+ 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))
+ {
+ found_elts.add(instanceSpecification);
+ }
+ }
+ return found_elts;
+ }
+
+ /**
+ * 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.
+ * @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));
+ }
+ 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)
+ {
+ String name = inst.getName();
+
+ Integer idx = name.lastIndexOf('.');
+ if(idx!=-1)
+ {
+ return name.substring(0, idx);
+ }else{
+ return null;
+ }
+ }
+
+
+ /**
+ * Get real instance from InstanceSpecification object
+ * @param model
+ * @param instanceSpecification
+ * @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)
+ {
+ String[] str = instanceSpecification.getName().split("\\.");
+
+ 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.
+ * @param instanceSpecification
+ * @param platformName
+ * @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)
+ return false;
+ 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)) {
+ 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)
+ {
+ List<DeploymentPlan> dep_plans = new LinkedList<DeploymentPlan>();
+ for (Element elt : model.getOwnedElements()) {
+ if (elt instanceof org.eclipse.uml2.uml.Package) {
+ DeploymentPlan dp = UMLUtil.getStereotypeApplication(elt, DeploymentPlan.class);
+ if (dp != null)
+ dep_plans.add(dp);
+ else
+ dep_plans.addAll(getDeploymentPlansInPackage((org.eclipse.uml2.uml.Package)elt));
+ }
+ }
+ 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) {
+ DeploymentPlan dp = UMLUtil.getStereotypeApplication(elt, DeploymentPlan.class);
+ if (dp != null)
+ dep_plans.add(dp);
+ else
+ dep_plans.addAll(getDeploymentPlansInPackage((org.eclipse.uml2.uml.Package)elt));
+ }
+ }
+ return dep_plans;
+ }
+
+ /**
+ * 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) {
+ pcks.add(dp.getBase_Package());
+ }
+ return pcks;
+ }
+
+ /**
+ * 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)
+ {
+ //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)
+ 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) {
+ //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)
+ 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)) {
+ continue;
+ }
+ client_instance_spec = (InstanceSpecification)client_elt;
+ break;
+ }
+ if (client_instance_spec == null)
+ continue;
+
+ //Is it allocated to the platform provided as argument ?
+ for (NamedElement nelt : dep.getSuppliers()) {
+ if (isPlatformInstanceSpecificationFromPlatform(nelt,targetPlatformName)) {
+ found_elts.add(client_instance_spec);
+ }
+ }
+ }
+ }
+ return found_elts;
+ }
+
+ /**
+ * Function to know the content of allocation string.
+ * @param instanceSpecification
+ * @return the allocation string
+ */
+ 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.
+ * @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)
+ {
+ //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)
+ {
+ //System.out.println("instance : " + instanceSpecification.getName());
+
+ 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());
+ //System.out.println("\tclass : " + theClass.getName());
+ }
+ }
+ 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.
+ * @param model
+ * @param platformName
+ * @return all classes that are instanciated for the platform "pfn"
+ */
+ 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())
+ {
+ 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)
+ 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/DeploymentQueries.mtl b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.mtl
new file mode 100644
index 00000000000..f7b04a10e57
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/DeploymentQueries.mtl
@@ -0,0 +1,59 @@
+[comment encoding = UTF-8 /]
+[comment]
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastien BONNET (EFFIDENCE) - Initial API and implementation
+ * Nicolas DU LAC (INTEMPORA) - Additional methods.
+ *
+ *****************************************************************************/
+[/comment]
+[module DeploymentQueries('http://www.eclipse.org/uml2/4.0.0/UML', 'http://Papyrus/RobotML/1')]
+
+[comment]
+These functions are implemented in file DeploymentQueries.java.
+[/comment]
+[query public getInstanceSpecifications(elt : Model) : Sequence(InstanceSpecification) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getInstanceSpecificationsInModel(org.eclipse.uml2.uml.Model)', Sequence{elt})
+/]
+[query public getInstanceSpecificationsForPlatform(elt : Model, pfn: String) : Sequence(InstanceSpecification) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getInstanceSpecificationsForPlatform(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{elt, pfn})
+/]
+[query public getInstanceSpecificationsForPlatform2(model : Model, pfmName : String) : Sequence(InstanceSpecification)
+ = invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getInstanceSpecificationsForPlatform2(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, pfmName})
+/]
+[query public getParentName(inst : InstanceSpecification) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getParentName(org.eclipse.uml2.uml.InstanceSpecification)', Sequence{inst})
+/]
+[query public getInstance(elt : Model, inst : InstanceSpecification) : Property =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getInstance(org.eclipse.uml2.uml.Model,org.eclipse.uml2.uml.InstanceSpecification)', Sequence{elt, inst})
+/]
+[query public isAllocatedTo(inst : InstanceSpecification, pfn: String) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'isAllocatedTo(org.eclipse.uml2.uml.InstanceSpecification,java.lang.String)', Sequence{inst, pfn})
+/]
+[query public getAllocationName(inst : InstanceSpecification) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getAllocationName(org.eclipse.uml2.uml.InstanceSpecification)', Sequence{inst})
+/]
+[query public getDefinedComponentsForPlatform(elt : Model, pfn: String) : Sequence(Class) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getDefinedComponentsForPlatform(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{elt, pfn})
+/]
+[query public getDefinedComponentsForPlatform2(model : Model, pfmName : String) : Sequence(Class)
+ = invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getDefinedComponentsForPlatform2(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model, pfmName})
+/]
+[query public getDeploymentPlansInModel(model : Model) : Sequence(DeploymentPlan)
+ = invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getDeploymentPlansInModel(org.eclipse.uml2.uml.Model)', Sequence{model})
+/]
+[query public getDeploymentPlanPackagesInModel(model : Model) : Sequence(Package)
+ = invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getDeploymentPlanPackagesInModel(org.eclipse.uml2.uml.Model)', Sequence{model})
+/]
+[query public getDeploymentPlanInstanceSpecsForPlatform(deploymentPlan : Package, pfmName : String) : Sequence(InstanceSpecification)
+ = invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.DeploymentQueries', 'getDeploymentPlanInstanceSpecsForPlatform(org.eclipse.uml2.uml.Package, java.lang.String)', Sequence{deploymentPlan, pfmName})
+/]
+
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
new file mode 100644
index 00000000000..e28d2d29735
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastien BONNET (EFFIDENCE) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+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.util.UMLUtil;
+
+public class FSMQueries {
+ /**
+ * Find all states in a state machine.
+ * @param sm a state machine
+ * @return a list of states
+ * @todo a valider par Nicolas
+ */
+ 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.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
+ * @return a list of transitions
+ * @todo a valider par Nicolas
+ */
+ 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)
+ {
+ 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)
+ {
+ LinkedList<StateMachine> res = new LinkedList<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)
+ {
+ String result = "";
+ 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)
+ {
+ String operation = state.getOperation().getBase_Operation().getName();
+ result = operation;
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.mtl b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.mtl
new file mode 100644
index 00000000000..fdfa5b45d9b
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/FSMQueries.mtl
@@ -0,0 +1,33 @@
+[comment encoding = UTF-8 /]
+[comment]
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sebastien BONNET (EFFIDENCE) - Initial API and implementation
+ *
+ *****************************************************************************/
+[/comment]
+
+[module FSMQueries('http://Papyrus/RobotML/1', 'http://www.eclipse.org/uml2/3.0.0/UML', 'http://Papyrus/RobotML/1')]
+
+
+[query public getStateMachines(elt : Element) : Sequence(StateMachine) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.FSMQueries', 'getStateMachines(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public getStates(sm : StateMachine) : Sequence(Vertex) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.FSMQueries', 'getStates(org.eclipse.uml2.uml.StateMachine)', Sequence{sm})
+/]
+[query public getTransitions(sm : StateMachine) : Sequence(Transition) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.FSMQueries', 'getTransitions(org.eclipse.uml2.uml.StateMachine)', Sequence{sm})
+/]
+[query public generateOperationStateString(vertex : Vertex) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.FSMQueries', 'generateOperationStateString(org.eclipse.uml2.uml.Vertex)', Sequence{vertex})
+/]
+
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
new file mode 100644
index 00000000000..fd89a870b90
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.java
@@ -0,0 +1,598 @@
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas DU LAC (INTEMPORA) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.robotml.generators.common.mmqueries;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.uml2.uml.Connector;
+import org.eclipse.uml2.uml.ConnectorEnd;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+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.
+ */
+ static protected void getElementsWithStereotype(Element parent_elt, Class clazz, LinkedList<NamedElement> target_list) {
+ 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);
+ }
+ }
+ }
+ 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);
+ }
+ }
+ 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"...)
+ * @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) {
+ 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)) {
+ found_elts.add((NamedElement)ne);
+ }
+ }
+ } else if (ne instanceof Model) {
+ found_elts.addAll(getElementsWithStereotype((Model)ne,stereotype));
+ }
+ 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)){
+ target_list.add((NamedElement)ne);
+ }
+ }
+ 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"...)
+ * @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) {
+ 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)) {
+ found_elts.add((NamedElement)ne);
+ }
+ }
+ } else if (ne instanceof Model) {
+ found_elts.addAll(getElementsWithInheritedStereotype((Model)ne,stereotype));
+ }
+ 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) {
+ //System.out.println(((NamedElement)ne).getName());
+ 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);
+// }
+ }
+ getElementsWithInheritedStereotype(ne,stereotype,target_list);
+ }
+ }
+ return;
+ }
+
+ /**
+ * Get the first stereotype applied to a given class.
+ * Warning: other stereotypes are ignored. To use with care.
+ * @deprecated superseded by the RobotML API.
+ */
+ static public String getStereotype(org.eclipse.uml2.uml.Class cl)
+ {
+ if (cl.getAppliedStereotypes().size()==1) {
+ return cl.getAppliedStereotypes().get(0).getName();
+ }
+ else {
+ return "--";
+ }
+ }
+
+ 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)){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ 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))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ 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
+ if(stereotype.isInstance(stereoApplication)) {
+ return true;
+ }
+ }
+ 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)){
+ 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 ?
+ */
+ static public Boolean isDataType(Element elt) {
+ boolean b = (elt instanceof org.eclipse.uml2.uml.DataType);
+ //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 ?
+ */
+ static public Boolean isInterface(Element elt) {
+ boolean b = (elt instanceof org.eclipse.uml2.uml.Interface);
+ //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)
+ {
+ try {
+ if ((p.getLower()==1)&&(p.getUpper()==1))
+ {
+ return "";
+ }
+ 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
+ */
+ 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) {
+ 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()){
+ return null;
+ }
+ return ((EList<Object>) o).get(0).toString();
+ }else{
+ return o.toString();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 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)
+ {
+ String result = null;
+ result = getAttributeValue(cl, attr, stname);
+ //System.out.println("value : " + result);
+
+ if(result == null || result.length()==0){
+ return defaultValue;
+ }
+ return result;
+
+ }
+
+ /**
+ * 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)
+ {
+ LinkedList<String> result = new LinkedList<String>();
+ for (Stereotype st : cl.getAppliedStereotypes()) {
+ if(st.getName().equals(stname)){
+ Object o = cl.getValue(st, attr);
+ 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{
+ result.add(o.toString());
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 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);
+ 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;
+ }
+
+ /**
+ * 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) {
+ //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(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());
+ }
+
+ /**
+ * Debug function.
+ */
+ 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());
+
+ // stereotypes of this class
+ 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());
+
+ // This is a Port
+ if (isPort(prop)) {
+ inspectPort((Port)prop);
+ }
+ 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 !");
+ }
+ }
+ }
+ 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());
+ }
+
+ }
+
+
+ /**
+ * Debug function. Prints info about a given port.
+ */
+ static public void inspectPort(Port port)
+ {
+ if (ArchitectureQueries.isDataFlowPort(port))
+ {
+ ArchitectureQueries.inspectDataFlowPort(port);
+ }
+ else if (ArchitectureQueries.isServicePort(port))
+ {
+ ArchitectureQueries.inspectServicePort(port);
+ }
+ 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());
+
+ //
+ // Bibliothèque de DataTypes sera importée
+ //
+ 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);
+ }
+ //
+ // 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);
+ }
+ //
+ // 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)) {
+ inspectClass((org.eclipse.uml2.uml.Class)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);
+ }
+
+ }
+
+ }
+ catch (Exception e) {
+ java.lang.System.out.println(e);
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ /**
+ * String manipulation function :
+ * remove brackets from a string
+ * @param str
+ * @return
+ */
+ public String removeBrackets(java.lang.String str) {
+ return str.replaceAll("[\\[\\]]", "");
+ }
+}
+
diff --git a/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.mtl b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.mtl
new file mode 100644
index 00000000000..dedc2f409e3
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/GeneralQueries.mtl
@@ -0,0 +1,86 @@
+[comment encoding = UTF-8 /]
+[comment]
+/*****************************************************************************
+ * Copyright (c) 2013 PROTEUS Project consortium.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas DU LAC (INTEMPORA) - Initial API.
+ *
+ *****************************************************************************/
+[/comment]
+
+[module GeneralQueries('http://www.eclipse.org/uml2/3.0.0/UML', 'http://Papyrus/RobotML/1')/]
+
+[comment]
+- Déclaration de fonction java permettant d'interroger le modèle
+- Ces fonctions sont implémentées dans le fichier 'org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries'
+[/comment]
+[query public getElementsWithStereotype(elt : Model, stereotype : String) : Sequence(NamedElement) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getElementsWithStereotype(org.eclipse.uml2.uml.Model,java.lang.String)', Sequence{elt,stereotype})
+/]
+[query public getElementsWithStereotype(class : Class, stereotype : String) : Sequence(NamedElement) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getElementsWithStereotype(org.eclipse.uml2.uml.Model,java.lang.String)', Sequence{class,stereotype})
+/]
+[query public getElementsWithInheritedStereotype(elt : Model, stereotype : String) : Sequence(NamedElement) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getElementsWithInheritedStereotype(org.eclipse.uml2.uml.Model,java.lang.String)', Sequence{elt,stereotype})
+/]
+[query public inspectModel(model : Model) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'inspectModel(org.eclipse.uml2.uml.Model)', Sequence{model})
+/]
+[query public inspectClass(elt : Class) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'inspectClass(org.eclipse.uml2.uml.Class)', Sequence{elt})
+/]
+[query public isClass(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'isClass(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public isDataType(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'isDataType(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public isInterface(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'isInterface(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public isProperty(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'isProperty(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public isPort(elt : Element) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'isPort(org.eclipse.uml2.uml.Element)', Sequence{elt})
+/]
+[query public getComponentFileName(class : Class, end : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getComponentFileName(org.eclipse.uml2.uml.Class,java.lang.String)', Sequence{class,end})
+/]
+[query public getStereotype(elt : Class) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getStereotype(org.eclipse.uml2.uml.Class)', Sequence{elt})
+/]
+[query public hasStereotype(elt : Class, s : String) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'hasStereotype(org.eclipse.uml2.uml.Class, java.lang.String)', Sequence{elt,s})
+/]
+[query public inheritsFrom(elt: Class, stereotype : String) : Boolean =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'inheritsFrom(org.eclipse.uml2.uml.Class, java.lang.String)', Sequence{elt,stereotype})
+/]
+[query public getStereotypeInheritedFrom(elt: Class, stereotype : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getStereotypeInheritedFrom(org.eclipse.uml2.uml.Class, java.lang.String)', Sequence{elt,stereotype})
+/]
+[query public getAttributeValue(elt : Class, attr : String, stereotype : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getAttributeValue(org.eclipse.uml2.uml.Class, java.lang.String, java.lang.String)', Sequence{elt,attr,stereotype})
+/]
+[query public getAttributeValue(elt : Class, attr : String, stereotype : String, defaultValue : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getAttributeValue(org.eclipse.uml2.uml.Class, java.lang.String, java.lang.String, java.lang.String)', Sequence{elt,attr,stereotype, defaultValue})
+/]
+[query public getAttributeValues(elt : Class, attr : String, stereotype : String) : Sequence(String) =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getAttributeValues(org.eclipse.uml2.uml.Class, java.lang.String, java.lang.String)', Sequence{elt,attr,stereotype})
+/]
+[query public findClassInModel(model : Model, name : String) : Class =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'findClassInModel(org.eclipse.uml2.uml.Model, java.lang.String)', Sequence{model,name})
+/]
+[query public getInstanceMultiplicity(elt : Property) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'getInstanceMultiplicity(org.eclipse.uml2.uml.Property)', Sequence{elt})
+/]
+[query public removeBrackets(str : String) : String =
+ invoke('org.eclipse.papyrus.robotml.generators.common.mmqueries.GeneralQueries', 'removeBrackets(java.lang.String)', Sequence{str})
+/]
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
new file mode 100644
index 00000000000..c4d74e5c941
--- /dev/null
+++ b/extraplugins/robotml/generators/org.eclipse.papyrus.robotml.generators.common/src/org/eclipse/papyrus/robotml/generators/common/mmqueries/MMQueries.java
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.robotml.generators.common.mmqueries;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
+import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
+import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Monitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+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.
+ * <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()}.
+ * </p>
+ *
+ * @generated
+ */
+ public MMQueries() {
+ // Empty implementation
+ }
+
+ /**
+ * 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.
+ * @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.
+ * @param arguments
+ * 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.
+ * @generated
+ */
+ public MMQueries(URI modelURI, File targetFolder,
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
+
+ /**
+ * 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.
+ * @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.
+ * @param arguments
+ * 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.
+ * @generated
+ */
+ 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.
+ * @generated
+ */
+ public static void main(String[] args) {
+ try {
+ 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++) {
+ arguments.add(args[i]);
+ }
+ MMQueries generator = new MMQueries(modelURI, folder, arguments);
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Launches the generation described by this instance.
+ *
+ * @param monitor
+ * 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.
+ * @generated
+ */
+ @Override
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this.
+ * The default behavior should be sufficient in most cases.
+ */
+ super.doGenerate(monitor);
+ }
+
+ /**
+ * If this generator needs to listen to text generation events, listeners can be returned from here.
+ *
+ * @return List of listeners that are to be notified when text is generated through this launch.
+ * @generated
+ */
+ @Override
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ // 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.
+ * </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.
+ * </p>
+ * <p>
+ * All three of these default strategies support merging through JMerge.
+ * </p>
+ *
+ * @return The generation strategy that is to be used for generations launched through this launcher.
+ * @generated
+ */
+ 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.
+ *
+ * @return The name of the module that is to be launched.
+ * @generated
+ */
+ @Override
+ 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".
+ * </p>
+ *
+ * @return The list of properties file we need to add to the generation context.
+ * @see java.util.ResourceBundle#getBundle(String)
+ * @generated
+ */
+ @Override
+ public List<String> getProperties() {
+ List<String> propertiesFiles = super.getProperties();
+ /*
+ * TODO if your generation module requires access to properties files,
+ * add their qualified path to the list here. Properties files are
+ * expected to be in source folders, and the path here to be the
+ * qualified path as if referring to a Java class. For example, if you
+ * have a file named "messages.properties" in package
+ * "org.eclipse.acceleo.sample", the path that needs be added to this
+ * list is "org.eclipse.acceleo.sample.messages".
+ */
+ return propertiesFiles;
+ }
+
+ /**
+ * This will be used to get the list of templates that are to be launched by this launcher.
+ *
+ * @return The list of templates to call on the module {@link #getModuleName()}.
+ * @generated
+ */
+ @Override
+ 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.
+ * @generated
+ */
+ @Override
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+ resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
+ // TODO If you need additional package registrations, do them here. The following line is an example for UML.
+ // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ }
+
+ /**
+ * 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.
+ * @generated
+ */
+ @Override
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ // 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