Author: objectiser
Date: 2008-07-29 15:26:43 -0400 (Tue, 29 Jul 2008)
New Revision: 204
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/LanguageToConversationModelChangeRule.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
Log:
Further work on generating actions.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/META-INF/MANIFEST.MF 2008-07-29
19:26:43 UTC (rev 204)
@@ -17,6 +17,8 @@
Scribble-Extensions: org.jboss.tools.overlord.jbossesb.parser.JBossESBParser,
org.jboss.tools.overlord.jbossesb.parser.JBossESBNotation,
org.jboss.tools.overlord.jbossesb.validation.ESBLanguageModelValidationRule,
+ org.jboss.tools.overlord.jbossesb.model.change.LanguageToConversationModelChangeRule,
org.jboss.tools.overlord.jbossesb.model.change.ConversationModelChangeRule,
- org.jboss.tools.overlord.jbossesb.model.change.ConversationInteractionModelChangeRule
+ org.jboss.tools.overlord.jbossesb.model.change.ConversationInteractionModelChangeRule,
+ org.jboss.tools.overlord.jbossesb.model.change.IfModelChangeRule
Bundle-ActivationPolicy: lazy
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/actions/GenerateAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -122,12 +122,17 @@
DefaultESBLanguageModel target=
new DefaultESBLanguageModel(targetRef);
- ModelChangeContext context=
- new DefaultModelChangeContext(targetRef);
+ ModelGenerator generator=(ModelGenerator)
+ RegistryFactory.getRegistry().getExtension(
+ ModelGenerator.class, null);
- context.insert(target, target,
- lcm.getConversation(), -1);
-
+ if (generator != null) {
+ generator.generate(targetRef, role, target,
+ lcm);
+ } else {
+ logger.severe("Unable to find model generator");
+ }
+
try {
System.out.println("------------------------------");
System.out.println("ROLE="+role.getName());
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/AbstractESBAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -33,11 +33,11 @@
public static final String SERVICE_DESCRIPTION_NAME =
"serviceDescriptionName";
public static final String IDENTITIES = "identities";
public static final String SESSION = "session";
- private static final String ACTION_ELEMENT = "action";
- private static final String VALUE_ATTR = "value";
- private static final String NAME_ATTR = "name";
- private static final String PROPERTY_ELEMENT = "property";
- private static final String CLASS_PROPERTY = "class";
+ public static final String ACTION_ELEMENT = "action";
+ public static final String VALUE_ATTR = "value";
+ public static final String NAME_ATTR = "name";
+ public static final String PROPERTY_ELEMENT = "property";
+ public static final String CLASS_PROPERTY = "class";
protected static final String BUSINESS_OBJECT_TYPE_PROPERTY = SESSION;
@@ -347,6 +347,42 @@
}
/**
+ * This method returns the element associated with the
+ * requested property. If the property does not exist, then
+ * it will be created.
+ *
+ * @param property The property
+ * @return The element
+ */
+ protected org.w3c.dom.Element getPropertyElement(String property) {
+ org.w3c.dom.Element ret=null;
+
+ if (m_action != null) {
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(property)) {
+ ret = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (ret == null) {
+ ret = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ ret.setAttribute(NAME_ATTR, property);
+
+ m_action.appendChild(ret);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
* This method returns the list of property names defined for
* this action.
*
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/CreateSessionAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -19,6 +19,7 @@
import org.jboss.tools.overlord.jbossesb.model.ConversionContext;
import org.jboss.tools.overlord.jbossesb.model.ESBAction;
+import org.jboss.tools.overlord.jbossesb.model.ESBActionFactory;
import org.jboss.tools.overlord.jbossesb.model.ESBService;
import org.scribble.model.*;
@@ -45,6 +46,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public CreateSessionAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ CreateSessionAction.class));
+ }
+
+ /**
* This method determines whether the ESB action represents
* a CreateSessionAction.
*
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/IfAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -31,10 +31,11 @@
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
- private static final String ELSE = "else";
- private static final String ELSEIF = "elseif";
- private static final String IF = "if";
- private static final String PATHS = "paths";
+ public static final String EXPRESSION = "expression";
+ public static final String ELSE = "else";
+ public static final String ELSEIF = "elseif";
+ public static final String IF = "if";
+ public static final String PATHS = "paths";
/**
* The constructor for the action.
@@ -49,6 +50,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public IfAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ IfAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@@ -260,4 +273,50 @@
}
}
+ /**
+ * This method adds a path to the if action.
+ *
+ * @param type The type of path (IF, ELSEIF or ELSE)
+ * @param category The service category
+ * @param name The service name
+ * @param immediate Whether invocation should be immediate
+ * @param expr The expression, if type is IF or ELSEIF
+ * @param position The position, if type is ELSEIF
+ */
+ public void addPath(String type, String category, String name,
+ boolean immediate, String expr, int position) {
+
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ org.w3c.dom.Element paths=null;
+
+ for (int i=0; paths == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(PATHS)) {
+ paths = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (paths == null) {
+ paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ paths.setAttribute(NAME_ATTR, PATHS);
+
+ getAction().appendChild(paths);
+ }
+
+ org.w3c.dom.Element path=getAction().getOwnerDocument().createElement(type);
+ path.setAttribute(SERVICE_CATEGORY, category);
+ path.setAttribute(SERVICE_NAME, name);
+ path.setAttribute(IMMEDIATE, ""+immediate);
+
+ if (expr != null && (type == IF || type == ELSEIF)) {
+ path.setAttribute(EXPRESSION, expr);
+ }
+
+ paths.appendChild(path);
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/MessageRouterAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -53,6 +53,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public MessageRouterAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ MessageRouterAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ParallelAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -48,6 +48,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public ParallelAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ ParallelAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ReceiveMessageAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -133,4 +133,32 @@
recv.setToRole(new Role(context.getRole()));
}
}
+
+ /**
+ * This method sets the operation property.
+ *
+ * @param operation The operation
+ */
+ public void setOperation(String operation) {
+
+ org.w3c.dom.Element prop=getPropertyElement(OPERATION);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, operation);
+ }
+ }
+
+ /**
+ * This method sets the message type.
+ *
+ * @param type The message type
+ */
+ public void setMessageType(String type) {
+
+ org.w3c.dom.Element prop=getPropertyElement(MESSAGE_TYPE);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, type);
+ }
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/ScheduleStateAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -45,6 +45,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public ScheduleStateAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ ScheduleStateAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SendMessageAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -52,6 +52,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public SendMessageAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ SendMessageAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@@ -223,4 +235,67 @@
}
}
}
+
+ /**
+ * This method sets the operation property.
+ *
+ * @param operation The operation
+ */
+ public void setOperation(String operation) {
+
+ org.w3c.dom.Element prop=getPropertyElement(OPERATION);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, operation);
+ }
+ }
+
+ /**
+ * This method sets the client's EPR label property.
+ *
+ * @param epr The client EPR label
+ */
+ public void setClientEPR(String epr) {
+
+ org.w3c.dom.Element prop=getPropertyElement(CLIENT_EPR);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, epr);
+ }
+ }
+
+ /**
+ * This method sets the message type.
+ *
+ * @param type The message type
+ */
+ public void setMessageType(String type) {
+
+ org.w3c.dom.Element prop=getPropertyElement(MESSAGE_TYPE);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, type);
+ }
+ }
+
+ /**
+ * This method sets the response service descriptor properties.
+ *
+ * @param category The category
+ * @param name The name
+ */
+ public void setResponseDestination(String category, String name) {
+
+ org.w3c.dom.Element prop=getPropertyElement(RESPONSE_SERVICE_CATEGORY);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, category);
+ }
+
+ prop = getPropertyElement(RESPONSE_SERVICE_NAME);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, name);
+ }
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/SwitchAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -28,6 +28,8 @@
*/
public class SwitchAction extends AbstractESBAction {
+ public static final String TYPE_ATTR = "type";
+ public static final String MESSAGE_ELEMENT = "message";
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
private static final String CASE = "case";
@@ -46,6 +48,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public SwitchAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ SwitchAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
@@ -178,4 +192,55 @@
}
}
+ /**
+ * This method adds a path to the switch action.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @param messageTypes The list of message types
+ * @param position The position
+ */
+ public void addCase(String category, String name,
+ java.util.List<String> messageTypes, int position) {
+
+ org.w3c.dom.Element paths=getPropertyElement(PATHS);
+
+ /*
+ org.w3c.dom.NodeList nl=
+ getAction().getElementsByTagName(PROPERTY_ELEMENT);
+
+ for (int i=0; paths == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ String propName=((org.w3c.dom.Element)nl.item(i)).getAttribute(NAME_ATTR);
+
+ if (propName != null && propName.equals(PATHS)) {
+ paths = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+ }
+
+ if (paths == null) {
+ paths = getAction().getOwnerDocument().createElement(PROPERTY_ELEMENT);
+ paths.setAttribute(NAME_ATTR, PATHS);
+
+ getAction().appendChild(paths);
+ }
+ */
+
+ org.w3c.dom.Element path=
+ getAction().getOwnerDocument().createElement(CASE);
+ path.setAttribute(SERVICE_CATEGORY, category);
+ path.setAttribute(SERVICE_NAME, name);
+
+ for (int i=0; i < messageTypes.size(); i++) {
+ org.w3c.dom.Element mt=
+ getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
+
+ mt.setAttribute(TYPE_ATTR, messageTypes.get(i));
+
+ path.appendChild(mt);
+ }
+
+ paths.appendChild(path);
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhenAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -47,6 +47,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public WhenAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ WhenAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/actions/WhileAction.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -48,6 +48,18 @@
}
/**
+ * This constructor initializes the DOM element for
+ * the action.
+ *
+ * @param service The reference to the service in which
+ * the action will be contained
+ */
+ public WhileAction(ESBService service) {
+ super(service, ESBActionFactory.getConversationAction(
+ WhileAction.class));
+ }
+
+ /**
* This method initializes the links with the ESB service descriptors
* identified in each path of the action.
*/
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -32,21 +32,21 @@
/**
* This method determines whether the rule is appropriate
- * for the supplied type of model, parent and
+ * for the supplied type of model, parent (in the context) and
* model object.
*
+ * @param context The context
* @param model The model
- * @param parent The parent model object
* @param mobj The model object causing the change
* @return Whether the rule supports the supplied information
*/
@Override
- protected boolean isChangeSupported(Model model, ModelObject parent,
- ModelObject mobj) {
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
boolean ret=false;
if (mobj instanceof ConversationInteraction &&
- parent instanceof ESBService &&
+ context.getParent() instanceof ESBService &&
model instanceof ESBLanguageModel) {
ret = true;
}
@@ -65,41 +65,136 @@
*
* @param context The context
* @param model The model being changed
- * @param parent The parent model object
* @param mobj The model object details to be inserted
* @param position The position, where relevant
* @return Whether the change has been applied
*/
@Override
public boolean insert(ModelChangeContext context,
- Model model, ModelObject parent,
- ModelObject mobj, int position) {
+ Model model, ModelObject mobj, int position) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=(ESBService)parent;
+ ESBService service=(ESBService)context.getParent();
ConversationInteraction interaction=(ConversationInteraction)mobj;
// Check if send or receive
if ((interaction.getFromRole() != null &&
- interaction.getFromRole().getName().equals(
- context.getRoleName())) ||
+ interaction.getFromRole().equals(
+ context.getRole())) ||
(interaction.getToRole() != null &&
- interaction.getToRole().getName().equals(
- context.getRoleName()) == false)) {
+ interaction.getToRole().equals(
+ context.getRole()) == false)) {
// Send
+ SendMessageAction action=
+ new SendMessageAction(service);
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+
+ String mtype=null;
+
+ if (ref.getNamespace() != null) {
+ mtype = "{"+ref.getNamespace()+"}";
+ } else {
+ mtype = "";
+ }
+
+ if (ref.getLocalpart() != null) {
+ mtype += ref.getLocalpart();
+ }
+
+ action.setMessageType(mtype);
+ }
+
+ service.addAction(action, position);
+
+ if (interaction.getRequestLabel() != null) {
+
+ action.setClientEPR("client");
+
+ // Create new ESB service
+
+ // TODO: Create unique service name
+ DefaultESBService respService=new DefaultESBService(
+ esbModel, service.getCategory(),
+ service.getName()+"_2");
+
+ esbModel.addService(respService);
+
+ action.setResponseDestination(respService.getCategory(),
+ respService.getName());
+
+ context.setParent(respService);
+
+ } else if (interaction.getReplyToLabel() != null) {
+
+ action.setClientEPR("client");
+ }
+
} else {
// TODO: Create a new service to receive the
// message and add a schedule service to link
// to this new service - issue, how do we
// deal with request/response
+ if (service.isCreateSession() == false &&
+ service.isSessionBased()) {
+ // Already has activities, so need to separate
+ // into another service descriptor
+ DefaultESBService recvService=new DefaultESBService(
+ esbModel, service.getCategory(),
+ service.getName()+"_3");
+
+ esbModel.addService(recvService);
+
+ context.setParent(recvService);
+ }
// Receive
ReceiveMessageAction action=
new ReceiveMessageAction(service);
- service.addAction(action, position);
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ if (interaction.getMessageSignature().getTypes().size() == 1) {
+ TypeReference ref=interaction.getMessageSignature().getTypes().get(0);
+
+ // TODO: Search for an implementation associated with
+ // the type reference, so that the type can be
+ // abstract - possibly have the required message type
+ // notation as part of the context, so that if multiple
+ // implementations found, then can select e.g. XML or
+ // Java as message type representation.
+
+ String mtype=null;
+
+ if (ref.getNamespace() != null) {
+ mtype = "{"+ref.getNamespace()+"}";
+ } else {
+ mtype = "";
+ }
+
+ if (ref.getLocalpart() != null) {
+ mtype += ref.getLocalpart();
+ }
+
+ action.setMessageType(mtype);
+ }
+
+ ((ESBService)context.getParent()).addAction(action, position);
}
return(true);
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-07-29
12:27:41 UTC (rev 203)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/ConversationModelChangeRule.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -18,6 +18,7 @@
package org.jboss.tools.overlord.jbossesb.model.change;
import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.scribble.conversation.model.*;
@@ -31,17 +32,17 @@
/**
* This method determines whether the rule is appropriate
- * for the supplied type of model, parent and
+ * for the supplied type of model, parent (in the context) and
* model object.
- *
+ *
+ * @param context The context
* @param model The model
- * @param parent The parent model object
* @param mobj The model object causing the change
* @return Whether the rule supports the supplied information
*/
@Override
- protected boolean isChangeSupported(Model model, ModelObject parent,
- ModelObject mobj) {
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
boolean ret=false;
if (mobj instanceof Conversation &&
@@ -63,15 +64,13 @@
*
* @param context The context
* @param model The model being changed
- * @param parent The parent model object
* @param mobj The model object details to be inserted
* @param position The position, where relevant
* @return Whether the change has been applied
*/
@Override
public boolean insert(ModelChangeContext context,
- Model model, ModelObject parent,
- ModelObject mobj, int position) {
+ Model model, ModelObject mobj, int position) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
Conversation conv=(Conversation)mobj;
@@ -86,11 +85,18 @@
esbModel.addService(service);
+ // Create 'CreateSession' activity
+ CreateSessionAction csa=new CreateSessionAction(service);
+
+ service.addAction(csa, -1);
+
// Process the activities within the conversation
java.util.List<Activity> acts=conv.getBlock().getContents();
+ context.setParent(service);
+
for (int i=0; i < acts.size(); i++) {
- context.insert(model, service, acts.get(i), i);
+ context.insert(model, acts.get(i), i);
}
return(true);
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/IfModelChangeRule.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the If grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class IfModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof If &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=(ESBService)context.getParent();
+ If ifElem=(If)mobj;
+
+ // Check if should be an 'if' or a 'switch' action
+ if (ifElem.getRoles().contains(context.getRole())) {
+
+ // If action, because the role is a decision maker
+ IfAction ifAction=new IfAction(service);
+
+ service.addAction(ifAction, position);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ DefaultESBService subService=new DefaultESBService(
+ esbModel, service.getCategory(),
+ service.getName()+"_"+i);
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), j);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+ subService.getCategory(), subService.getName(),
+ immediate, null, i);
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ DefaultESBService subService=new DefaultESBService(
+ esbModel, service.getCategory(),
+ service.getName()+"_else");
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), j);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath(IfAction.ELSE,
+ subService.getCategory(), subService.getName(),
+ immediate, null, -1);
+ }
+ } else {
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ service.addAction(switchAction, position);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ DefaultESBService subService=new DefaultESBService(
+ esbModel, service.getCategory(),
+ service.getName()+"_"+i);
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), j);
+ }
+
+ java.util.List<String> messageTypes=new java.util.Vector<String>();
+ messageTypes.add("testType");
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), messageTypes, i);
+ }
+ }
+
+ return(true);
+ }
+
+}
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/LanguageToConversationModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/LanguageToConversationModelChangeRule.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.jbossesb/src/java/org/jboss/tools/overlord/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2008-07-29
19:26:43 UTC (rev 204)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.tools.overlord.jbossesb.model.change;
+
+import org.jboss.tools.overlord.jbossesb.model.*;
+import org.jboss.tools.overlord.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ protected boolean isChangeSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationModel &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, int position) {
+ ConversationModel cm=(ConversationModel)mobj;
+
+ if (cm.getConversation() != null) {
+ context.insert(model, cm.getConversation(), -1);
+ }
+
+ return(true);
+ }
+
+}