Overlord SVN: r472 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model: actions/stateless and 1 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-29 15:55:30 -0500 (Thu, 29 Jan 2009)
New Revision: 472
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
Log:
Ensure stateless description is built by locating the main 'switch' action that acts as the root action for the session type.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBService.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -445,8 +445,8 @@
public boolean isGateway() {
boolean ret=false;
- for (int i=0; ret == false && i < m_actions.size(); i++) {
- ret = m_actions.get(i).isGateway();
+ if (m_actions.size() == 1) {
+ ret = m_actions.get(0).isGateway();
}
return(ret);
@@ -479,9 +479,9 @@
public boolean isStateless() {
boolean ret=false;
- for (int i=0; i < m_actions.size(); i++) {
- if (m_actions.get(i).isGateway()) {
- ret = m_actions.get(i).isGateway();
+ for (int i=0; ret == false && i < m_actions.size(); i++) {
+ if (m_actions.get(i).isStateless()) {
+ ret = true;
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
/**
* The abstract model component for the 'ReceiveMessageAction'
@@ -26,7 +25,7 @@
*
* @author gary
*/
-public abstract class AbstractInteractionMessageAction extends AbstractESBAction {
+public abstract class AbstractInteractionMessageAction extends AbstractStatelessESBAction {
private static final long serialVersionUID = 3272234577154434603L;
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractStatelessESBAction.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -0,0 +1,66 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.actions.stateless;
+
+import java.util.logging.Logger;
+
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.AbstractESBAction;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ProblemDefinitions;
+
+/**
+ * This is the generic ESB action class.
+ *
+ * @author gary
+ */
+public abstract class AbstractStatelessESBAction extends AbstractESBAction {
+
+ private static final long serialVersionUID = -4436864250793029006L;
+
+ /**
+ * The constructor for initializing the action based on
+ * an existing DOM element.
+ */
+ protected AbstractStatelessESBAction(ESBService service,
+ org.w3c.dom.Element action) {
+ super(service, action);
+ }
+
+ /**
+ * The contructor for initializing a new action.
+ */
+ protected AbstractStatelessESBAction(ESBService service,
+ String actionClass) {
+ super(service, actionClass);
+ }
+
+ /**
+ * This method determines whether the gateway service is
+ * related to a stateless session.
+ *
+ * @return Whether the gateway service is stateless
+ */
+ @Override
+ public boolean isStateless() {
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model");
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
import org.scribble.model.*;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
@@ -29,7 +28,7 @@
*
* @author gary
*/
-public class IfAction extends AbstractESBAction {
+public class IfAction extends AbstractStatelessESBAction {
private static final long serialVersionUID = 9005791673502330699L;
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -1,366 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.actions.stateless;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.conversation.model.ConditionalBlock;
-import org.scribble.conversation.model.If;
-import org.scribble.model.*;
-import org.scribble.model.admin.ModelIssue;
-import org.scribble.model.admin.ModelListener;
-
-/**
- * The model component for the 'MessageRouterAction'. Although
- * not an integral part of the behaviour of a service, it provides
- * a behavioural gateway to ensure that messages sent to a
- * specific endpoint reference are routed to the appropriate
- * ESB service descriptor. Therefore the routing configuration
- * needs to be synchronized with the definition of the service
- * descriptors representing the various behavioural states associated
- * with a service.
- *
- * @author gary
- */
-public class MessageRouterAction extends AbstractESBAction {
-
- private static final long serialVersionUID = 2920316907680509410L;
-
- public static final String INITIATE = "initiate";
- public static final String SERVICE_NAME = "service-name";
- public static final String SERVICE_CATEGORY = "service-category";
- public static final String ROUTE = "route";
- public static final String PATHS = "paths";
- public static final String MESSAGE_ELEMENT="message";
- public static final String TYPE_ATTR="type";
- public static final String CONVERSATION_TYPE = "conversationType";
-
- /**
- * The constructor for the action.
- *
- * @param service The reference to the service in which
- * the action is contained
- * @param action The XML configuration details for the action
- */
- public MessageRouterAction(ESBService service,
- org.w3c.dom.Element action) {
- super(service, action);
- }
-
- /**
- * 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 determines whether the action is a gateway
- * for inbound requests.
- *
- * @return Whether the action is a gateway
- */
- @Override
- public boolean isGateway() {
- return(true);
- }
-
- /**
- * This method determines whether the ESB action represents
- * a new session type.
- *
- * @return Whether the action represents a new session type
- */
- @Override
- public boolean isSessionType() {
- return(true);
- }
-
- /**
- * This method adds a route to the message router action.
- *
- * @param category The service category
- * @param name The service name
- * @param initiate Whether the route initiates the service
- * @param messageTypes The list of message types
- */
- public void addRoute(String category, String name, boolean initiate,
- java.util.List<MessageSignature> messageTypes) {
-
- org.w3c.dom.Element paths=getPropertyElement(PATHS);
-
- org.w3c.dom.Element path=
- getAction().getOwnerDocument().createElement(ROUTE);
- path.setAttribute(SERVICE_CATEGORY, category);
- path.setAttribute(SERVICE_NAME, name);
-
- if (initiate) {
- path.setAttribute(INITIATE, Boolean.toString(initiate));
- }
-
- for (int i=0; i < messageTypes.size(); i++) {
- org.w3c.dom.Element mt=
- getAction().getOwnerDocument().createElement(MESSAGE_ELEMENT);
-
- if (messageTypes.get(i).getTypes().size() == 1) {
- TypeReference ref=messageTypes.get(i).getTypes().get(0);
-
- mt.setAttribute(TYPE_ATTR, InteractionUtil.getTypeString(ref));
-
- path.appendChild(mt);
- } else {
- logger.warning("Can only handle single type message signatures");
- }
- }
-
- paths.appendChild(path);
- }
-
- /**
- * This method returns the number of routes associated with
- * the message router.
- *
- * @return The number of routes
- */
- public int getNumberOfRoutes() {
- int ret=0;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- ret = nl.getLength();
-
- return(ret);
- }
-
- /**
- * This method returns the DOM element associated with the
- * specified route.
- *
- * @param index The index of the required route
- * @return The route element, or null if not found
- */
- public org.w3c.dom.Element getRouteElement(int index) {
- org.w3c.dom.Element ret=null;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- if (index >= 0 && index < nl.getLength() &&
- nl.item(index) instanceof org.w3c.dom.Element) {
- ret = (org.w3c.dom.Element)nl.item(index);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the DOM element associated with the
- * specified service category and name.
- *
- * @param category The service category
- * @param name The service name
- * @return The route element, or null if not found
- */
- public org.w3c.dom.Element getRouteElement(String category,
- String name) {
- org.w3c.dom.Element ret=null;
-
- org.w3c.dom.NodeList nl=getAction().getElementsByTagName(ROUTE);
-
- for (int i=0; ret == null && i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- ret = (org.w3c.dom.Element)nl.item(i);
-
- if (ret.getAttribute(SERVICE_CATEGORY).equals(category) == false ||
- ret.getAttribute(SERVICE_NAME).equals(name) == false) {
- ret = null;
- }
- }
- }
-
- return(ret);
- }
-
-
- /**
- * This method sets the conversation type property.
- *
- * @param name The conversation type
- */
- public void setConversationType(String type) {
-
- org.w3c.dom.Element prop=getPropertyElement(CONVERSATION_TYPE);
-
- if (prop != null) {
- prop.setAttribute(VALUE_ATTR, type);
- }
- }
-
- /**
- * This method returns the mandatory property names.
- *
- * @return The mandatory property names
- */
- @Override
- protected java.util.List<String> getMandatoryProperties() {
- java.util.List<String> ret=super.getMandatoryProperties();
- ret.add(CONVERSATION_TYPE);
- ret.add(PATHS);
- return(ret);
- }
-
- /**
- * This method validates the ESB action and reports warnings or
- * errors to the supplied model listener.
- *
- * @param l The model listener
- */
- @Override
- public void validate(ModelListener l) {
- super.validate(l);
-
- // Check that message router has no other session based
- // ESB actions in the same service descriptor
- if (getService().isSessionBased()) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_CANNOT_SESSION_BASED_ACTIONS_WITH_ROUTER",
- new String[]{})));
- }
-
- // Check that 'initate' services have a 'CreateSessionAction' and
- // represent the root behaviour
- for (int i=0; i < m_initiateServices.size(); i++) {
- ESBService service=m_initiateServices.get(i);
-
- if (service.isRoot() == false) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_CANNOT_INITIATE_NON_ROOT",
- new String[]{service.getCategory(),
- service.getName()})));
- }
- }
-
- // Check that non-'initate' services don't have a 'CreateSessionAction' and
- // represent the root behaviour
- for (int i=0; i < m_services.size(); i++) {
- ESBService service=m_services.get(i);
-
- if (service.isRoot()) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_MUST_INITIATE_ROOT",
- new String[]{service.getCategory(),
- service.getName()})));
- }
- }
-
- org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
- boolean f_serviceDetailsMissing=false;
- int routeCount=0;
-
- for (int i=0; nl != null && i < nl.getLength(); i++) {
-
- org.w3c.dom.Node n=nl.item(i);
-
- if (n instanceof org.w3c.dom.Element) {
- if (n.getNodeName().equals(ROUTE)) {
- routeCount++;
-
- if (((org.w3c.dom.Element)n).hasAttribute(SERVICE_CATEGORY) == false ||
- ((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
- f_serviceDetailsMissing = true;
- }
- }
- }
- }
-
- // Report any errors
- if (nl != null && routeCount < 1) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_ROUTER_ONE_OR_MORE_PATHS",
- new String[]{})));
- }
-
- if (f_serviceDetailsMissing) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_PATH_SERVICE_DETAILS_MISSING",
- new String[]{})));
- }
- }
-
- /**
- * This method converts the ESB action into an equivalent
- * behavioural description for conformance checking.
- *
- * @param activities The list of activities that will contain
- * the converted action(s)
- * @param context The conversion context
- */
- @Override
- public void convert(java.util.List<Activity> activities,
- ConversionContext context) {
- org.w3c.dom.NodeList nl=getPropertyChildNodes(PATHS);
-
- If choice=new If();
- activities.add(choice);
-
- for (int i=0; i < nl.getLength(); i++) {
-
- org.w3c.dom.Node n=nl.item(i);
-
- if (n instanceof org.w3c.dom.Element) {
- if (n.getNodeName().equals(ROUTE)) {
- String category=((org.w3c.dom.Element)n).getAttribute(SERVICE_CATEGORY);
- String name=((org.w3c.dom.Element)n).getAttribute(SERVICE_NAME);
-
- // TODO: Convert the conditional expression if defined
-
- ConditionalBlock cond=new ConditionalBlock();
- choice.getConditionalBlocks().add(cond);
-
- ESBService service=getService().getModel().getService(category, name);
-
- if (service != null) {
- service.convert(cond.getContents(), context);
- }
- }
- }
- }
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless");
-
- private java.util.List<ESBService> m_initiateServices=new java.util.Vector<ESBService>();
- private java.util.List<ESBService> m_services=new java.util.Vector<ESBService>();
-}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties 2009-01-29 20:55:30 UTC (rev 472)
@@ -18,6 +18,6 @@
_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
_NOT_SPECIFIED_SERVICE_DETAILS=Send does not provide service category and name
-_NOT_SPECIFIED_SERVICE_OR_CLIENT_EPR=Send does not contain request service category/name or response client EPR
+_NOT_SPECIFIED_SERVICE_OR_CLIENT_ROLE=Send does not contain request service category/name or response client role
_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -18,7 +18,6 @@
package org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.admin.ModelIssue;
@@ -30,7 +29,7 @@
*
* @author gary
*/
-public class SwitchAction extends AbstractESBAction {
+public class SwitchAction extends AbstractStatelessESBAction {
private static final long serialVersionUID = 3765702614644769281L;
@@ -99,6 +98,28 @@
}
/**
+ * This method determines whether the action is a gateway
+ * for inbound requests.
+ *
+ * @return Whether the action is a gateway
+ */
+ @Override
+ public boolean isGateway() {
+ return(isStateless());
+ }
+
+ /**
+ * This method determines whether the ESB action represents
+ * a new session type.
+ *
+ * @return Whether the action represents a new session type
+ */
+ @Override
+ public boolean isSessionType() {
+ return(isStateless());
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
@@ -267,4 +288,68 @@
paths.appendChild(path);
}
+
+ /**
+ * This method returns the number of cases associated with
+ * the switch.
+ *
+ * @return The number of cases
+ */
+ public int getNumberOfCases() {
+ int ret=0;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ ret = nl.getLength();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the DOM element associated with the
+ * specified case.
+ *
+ * @param index The index of the required route
+ * @return The case element, or null if not found
+ */
+ public org.w3c.dom.Element getCaseElement(int index) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ if (index >= 0 && index < nl.getLength() &&
+ nl.item(index) instanceof org.w3c.dom.Element) {
+ ret = (org.w3c.dom.Element)nl.item(index);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the DOM element associated with the
+ * specified service category and name.
+ *
+ * @param category The service category
+ * @param name The service name
+ * @return The case element, or null if not found
+ */
+ public org.w3c.dom.Element getCaseElement(String category,
+ String name) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getAction().getElementsByTagName(CASE);
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ ret = (org.w3c.dom.Element)nl.item(i);
+
+ if (ret.getAttribute(SERVICE_CATEGORY).equals(category) == false ||
+ ret.getAttribute(SERVICE_NAME).equals(name) == false) {
+ ret = null;
+ }
+ }
+ }
+
+ return(ret);
+ }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -20,7 +20,6 @@
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
@@ -498,26 +497,26 @@
if (gwService != null) {
ESBAction gwAction=gwService.getGatewayAction();
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
+ if (gwAction instanceof SwitchAction) {
+ SwitchAction mra=(SwitchAction)
gwAction;
org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
+ mra.getCaseElement(service.getCategory(),
service.getName());
if (route != null) {
org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+ route.getElementsByTagName(SwitchAction.MESSAGE_ELEMENT);
for (int i=0; i < nl.getLength(); i++) {
if (nl.item(i) instanceof org.w3c.dom.Element) {
org.w3c.dom.Element mesg=
(org.w3c.dom.Element)nl.item(i);
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ if (mesg.getAttribute(SwitchAction.TYPE_ATTR).
equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ mesg.setAttribute(SwitchAction.TYPE_ATTR,
ma.getMessageType());
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java 2009-01-27 22:55:48 UTC (rev 471)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java 2009-01-29 20:55:30 UTC (rev 472)
@@ -332,8 +332,8 @@
service.addAction(switchAction, pos);
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
+ //java.util.Set<MessageSignature> messageTypes=
+ // new java.util.HashSet<MessageSignature>();
for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
@@ -456,6 +456,7 @@
// Only record message router 'routes' if the switch
// receives request interactions, and it is the first
// session based action in the service
+ /*
if (messageTypes.size() > 0 &&
service.getFirstSessionBasedAction() == switchAction) {
ESBService gwService=
@@ -464,16 +465,17 @@
if (gwService != null) {
ESBAction gwAction=gwService.getGatewayAction();
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
+ if (gwAction instanceof SwitchAction) {
+ SwitchAction mra=(SwitchAction)
gwAction;
- mra.addRoute(service.getCategory(),
+ mra.addCase(service.getCategory(),
service.getName(),
- false, messageTypes);
+ messageTypes, 0);
}
}
}
+ */
/*
if (service.getFirstSessionBasedAction() == switchAction &&
15 years, 3 months
Overlord SVN: r471 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src: java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless and 2 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-27 17:55:48 -0500 (Tue, 27 Jan 2009)
New Revision: 471
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractInteractionMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/SendMessageActionTest.java
Log:
Fixing service category/name properties on the stateless send actions.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractInteractionMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractInteractionMessageAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractInteractionMessageAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -27,6 +27,8 @@
*/
public abstract class AbstractInteractionMessageAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -55542892082426466L;
+
public static final String IDENTITIES = "identities";
public static final String MESSAGE_TYPE = "messageType";
public static final String OPERATION = "operation";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/AbstractInteractionMessageAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -28,9 +28,11 @@
*/
public abstract class AbstractInteractionMessageAction extends AbstractESBAction {
+ private static final long serialVersionUID = 3272234577154434603L;
+
public static final String MESSAGE_TYPE = "messageType";
public static final String OPERATION = "operation";
- public static final String CLIENT_EPR = "clientEPR";
+ public static final String CLIENT_ROLE = "clientRole";
/**
* The constructor for the action.
@@ -73,7 +75,7 @@
protected java.util.List<String> getOptionalProperties() {
java.util.List<String> ret=super.getOptionalProperties();
ret.add(OPERATION);
- ret.add(CLIENT_EPR);
+ ret.add(CLIENT_ROLE);
return(ret);
}
@@ -133,7 +135,7 @@
*/
public void setClientEPR(String epr) {
- org.w3c.dom.Element prop=getPropertyElement(CLIENT_EPR);
+ org.w3c.dom.Element prop=getPropertyElement(CLIENT_ROLE);
if (prop != null) {
prop.setAttribute(VALUE_ATTR, epr);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/IfAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -31,9 +31,10 @@
*/
public class IfAction extends AbstractESBAction {
+ private static final long serialVersionUID = 9005791673502330699L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
- public static final String IMMEDIATE = "immediate";
public static final String EXPRESSION = "expression"; // ???
public static final String ELSE = "else";
public static final String ELSEIF = "elseif";
@@ -90,12 +91,9 @@
// Lookup service associated with category and name
ESBService service=getService().getModel().getService(category, name);
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
-
// Initialize link, even if service is null - this will be
// reported as a validation error later
- getLinks().add(new ESBLink(category, name, service,
- (immediate != null && immediate.equalsIgnoreCase("true"))));
+ getLinks().add(new ESBLink(category, name, service, true));
}
}
}
@@ -128,7 +126,6 @@
boolean f_else=false;
boolean f_orderWrong=false;
boolean f_serviceDetailsMissing=false;
- boolean f_immediateInvalid=false;
for (int i=0; nl != null && i < nl.getLength(); i++) {
@@ -147,13 +144,6 @@
f_serviceDetailsMissing = true;
}
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
-
- if (((org.w3c.dom.Element)n).hasAttribute(IMMEDIATE) &&
- immediate.equalsIgnoreCase("true") == false &&
- immediate.equalsIgnoreCase("false") == false) {
- f_immediateInvalid = true;
- }
} else if (n.getNodeName().equals(ELSEIF)) {
if (f_if == false || f_else) {
@@ -165,13 +155,6 @@
f_serviceDetailsMissing = true;
}
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
-
- if (((org.w3c.dom.Element)n).hasAttribute(IMMEDIATE) &&
- immediate.equalsIgnoreCase("true") == false &&
- immediate.equalsIgnoreCase("false") == false) {
- f_immediateInvalid = true;
- }
} else if (n.getNodeName().equals(ELSE)) {
if (f_if == false || f_else) {
@@ -184,14 +167,6 @@
((org.w3c.dom.Element)n).hasAttribute(SERVICE_NAME) == false) {
f_serviceDetailsMissing = true;
}
-
- String immediate=((org.w3c.dom.Element)n).getAttribute(IMMEDIATE);
-
- if (((org.w3c.dom.Element)n).hasAttribute(IMMEDIATE) &&
- immediate.equalsIgnoreCase("true") == false &&
- immediate.equalsIgnoreCase("false") == false) {
- f_immediateInvalid = true;
- }
}
}
}
@@ -200,7 +175,7 @@
if (nl != null && (f_if == false || f_orderWrong)) {
l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
"_IF_ORDER_WRONG",
new String[]{})));
}
@@ -208,18 +183,10 @@
if (f_serviceDetailsMissing) {
l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
"_PATH_SERVICE_DETAILS_MISSING",
new String[]{})));
}
-
- if (f_immediateInvalid) {
- l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
- java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_BOOLEAN",
- new String[]{IMMEDIATE})));
- }
}
/**
@@ -314,7 +281,6 @@
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);
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/Messages.properties 2009-01-27 22:55:48 UTC (rev 471)
@@ -0,0 +1,23 @@
+# /*
+# * 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.
+# */
+
+_IF_ORDER_WRONG=IfAction must have an 'if' path, followed by zero or more 'elseif' paths and ending with an optional 'else' path
+_NOT_SPECIFIED_SERVICE_DETAILS=Send does not provide service category and name
+_NOT_SPECIFIED_SERVICE_OR_CLIENT_EPR=Send does not contain request service category/name or response client EPR
+_PATH_SERVICE_DETAILS_MISSING=One or more paths are missing the service cateogry and/or name
+_SWITCH_ONE_OR_MORE_PATHS=Switch action must specify atleast one case
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/ReceiveMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/ReceiveMessageAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/ReceiveMessageAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -28,6 +28,8 @@
*/
public class ReceiveMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = -4957103938232460319L;
+
/**
* The constructor for the action.
*
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SendMessageAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -30,10 +30,10 @@
*/
public class SendMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = 2714230118722655345L;
+
public static final String SERVICE_NAME = "serviceName";
public static final String SERVICE_CATEGORY = "serviceCategory";
- public static final String SERVICE_NAME_EXPRESSION = "serviceNameExpression";
- public static final String SERVICE_CATEGORY_EXPRESSION = "serviceCategoryExpression";
/**
* The constructor for the action.
@@ -67,13 +67,10 @@
@Override
protected java.util.List<String> getOptionalProperties() {
java.util.List<String> ret=super.getOptionalProperties();
+
ret.add(SERVICE_NAME);
ret.add(SERVICE_CATEGORY);
- // TODO: Not sure about whether expressions can be
- // used as no state?
- ret.add(SERVICE_NAME_EXPRESSION);
- ret.add(SERVICE_CATEGORY_EXPRESSION);
return(ret);
}
@@ -94,12 +91,17 @@
getPropertyValue(SERVICE_NAME) != null) {
// Sending a request
- } else if (getPropertyValue(SERVICE_CATEGORY_EXPRESSION) != null &&
- getPropertyValue(SERVICE_NAME_EXPRESSION) != null) {
- // Sending a request to service derived from expression
- // on the pojo state
-
- } else if (getPropertyValue(CLIENT_EPR) != null) {
+ // Check if values have been provided
+ if (getPropertyValue(SERVICE_CATEGORY).trim().length() == 0 ||
+ getPropertyValue(SERVICE_NAME).trim().length() == 0) {
+ l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
+ "_NOT_SPECIFIED_SERVICE_DETAILS",
+ new String[]{})));
+ }
+
+ } else if (getPropertyValue(CLIENT_ROLE) != null) {
// Sending a response
// TODO: Validate that the client EPR has been sent on
@@ -107,8 +109,8 @@
} else {
l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
- "_NOT_SPECIFIED_REQ_RESP_EPR",
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
+ "_NOT_SPECIFIED_SERVICE_OR_CLIENT_ROLE",
new String[]{})));
}
}
@@ -187,27 +189,4 @@
prop.setAttribute(VALUE_ATTR, name);
}
}
-
- /**
- * This method sets the destination expressions for the
- * service descriptor properties.
- *
- * @param categoryExpr The category expression
- * @param nameExpr The name expression
- */
- public void setDestinationExpression(String categoryExpr,
- String nameExpr) {
-
- org.w3c.dom.Element prop=getPropertyElement(SERVICE_CATEGORY_EXPRESSION);
-
- if (prop != null) {
- prop.setAttribute(VALUE_ATTR, categoryExpr);
- }
-
- prop = getPropertyElement(SERVICE_NAME_EXPRESSION);
-
- if (prop != null) {
- prop.setAttribute(VALUE_ATTR, nameExpr);
- }
- }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -32,6 +32,8 @@
*/
public class SwitchAction extends AbstractESBAction {
+ private static final long serialVersionUID = 3765702614644769281L;
+
public static final String TYPE_ATTR = "type";
public static final String MESSAGE_ELEMENT = "message";
private static final String SERVICE_NAME = "service-name";
@@ -109,6 +111,18 @@
}
/**
+ * This method returns the optional property names.
+ *
+ * @return The optional property names
+ */
+ @Override
+ protected java.util.List<String> getOptionalProperties() {
+ java.util.List<String> ret=super.getOptionalProperties();
+ ret.add(CONVERSATION_TYPE);
+ return(ret);
+ }
+
+ /**
* This method validates the ESB action and reports warnings or
* errors to the supplied model listener.
*
@@ -142,7 +156,7 @@
if (nl != null && pathCount < 1) {
l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
"_SWITCH_ONE_OR_MORE_PATHS",
new String[]{})));
}
@@ -150,7 +164,7 @@
if (f_serviceDetailsMissing) {
l.error(new ModelIssue(this, org.scribble.util.MessageUtil.format(
java.util.PropertyResourceBundle.getBundle(
- "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.Messages"),
+ "org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.Messages"),
"_PATH_SERVICE_DETAILS_MISSING",
new String[]{})));
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -146,6 +146,17 @@
((Conversation)interaction.getEnclosingDefinition())));
}
+ if (interaction.getReplyToLabel() != null) {
+
+ if (interaction.getToRole() != null) {
+ action.setClientEPR(interaction.getToRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ } else {
+ action.setDestination("", "");
+ }
+
/* IS REQUIRED??
if (interaction.getRequestLabel() != null) {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/SendMessageActionTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/SendMessageActionTest.java 2009-01-25 21:17:53 UTC (rev 470)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/SendMessageActionTest.java 2009-01-27 22:55:48 UTC (rev 471)
@@ -66,7 +66,7 @@
java.util.Map<String,String> props=new java.util.Hashtable<String,String>();
props.put("messageType", "");
- props.put("clientEPR", "");
+ props.put("clientRole", "");
org.w3c.dom.Element elem=ESBActionTestUtil.getAction(null, props, null);
15 years, 3 months
Overlord SVN: r470 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model: change/stateless and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-25 16:17:53 -0500 (Sun, 25 Jan 2009)
New Revision: 470
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
Log:
Change to make 'switch action' the root action, rather than message router action, so it simply reflects the stateless structure. Only difference is that the top level 'switch action' will have the conversation type associated with it.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/SwitchAction.java 2009-01-25 21:17:53 UTC (rev 470)
@@ -38,6 +38,7 @@
private static final String SERVICE_CATEGORY = "service-category";
private static final String CASE = "case";
private static final String PATHS = "paths";
+ public static final String CONVERSATION_TYPE = "conversationType";
/**
* The constructor for the action.
@@ -197,6 +198,20 @@
}
/**
+ * This method sets the conversation type property.
+ *
+ * @param name The conversation type
+ */
+ public void setConversationType(String type) {
+
+ org.w3c.dom.Element prop=getPropertyElement(CONVERSATION_TYPE);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, type);
+ }
+ }
+
+ /**
* This method adds a path to the switch action.
*
* @param category The service category
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java 2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java 2009-01-25 21:17:53 UTC (rev 470)
@@ -107,6 +107,9 @@
DefaultESBService gateway=new DefaultESBService(esbModel,
category, name);
+ esbModel.addService(gateway);
+
+ /*
MessageRouterAction mra=new MessageRouterAction(gateway);
// Construct service description name
@@ -147,6 +150,7 @@
if (ctype != null) {
mra.setConversationType(ctype);
}
+ */
// Process the activities within the conversation
java.util.List<Activity> acts=conv.getBlock().getContents();
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java 2009-01-24 23:36:19 UTC (rev 469)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java 2009-01-25 21:17:53 UTC (rev 470)
@@ -35,6 +35,8 @@
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
public class IfModelChangeRule extends AbstractStatelessESBModelChangeRule {
+ private static final String NAME_SUFFIX = "_main";
+
/**
* This method determines whether the rule is appropriate
* for the supplied type of model, parent (in the context) and inserted
@@ -95,26 +97,30 @@
int pos=getPosition(service, ref);
+ /*
ESBService joinService=
esbModel.createService(service.getCategory(),
esbModel.getUniqueServiceName(service.getCategory(),
service.getName()));
esbModel.addService(joinService);
+ */
// Check if should be an 'if' or a 'switch' action
+
if (ifElem.getRoles().contains(context.getRole())) {
- insertIf(context, model, service, ifElem, joinService, pos);
+ insertIf(context, model, service, ifElem, pos);
} else {
- insertSwitch(context, model, service, ifElem, joinService, pos);
+ insertSwitch(context, model, service, ifElem, pos);
}
- context.setParent(joinService);
+ //context.setParent(joinService);
// If reference provided, then move subsequent activities
// to the 'join service'
+ /*
if (pos != -1) {
for (int i=pos+1; i < service.getActions().size();) {
ESBAction act=service.getActions().get(i);
@@ -123,13 +129,14 @@
joinService.addAction(act, -1);
}
}
+ */
return(true);
}
protected void insertIf(ModelChangeContext context,
Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
+ If ifElem, int pos) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
// If action, because the role is a decision maker
@@ -221,10 +228,10 @@
}
*/
}
-
+
protected void insertSwitch(ModelChangeContext context,
Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
+ If ifElem, int pos) {
ESBLanguageModel esbModel=(ESBLanguageModel)model;
// Check if 'when' needs to be placed in new service
@@ -264,6 +271,56 @@
// Switch action, as role is a decision observer
SwitchAction switchAction=new SwitchAction(service);
+ if (ifElem.getParent() != null &&
+ ifElem.getParent().getParent() instanceof Conversation &&
+ ((Conversation)ifElem.getParent().getParent()).isStateless()) {
+ Conversation conv=(Conversation)ifElem.getParent().getParent();
+
+ String namespace=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ String category=ConversationUtil.getServiceCategory(conv);
+
+ String name=ConversationUtil.getServiceName(conv);
+
+ String sdname="";
+
+ // Construct service description name
+ if (namespace != null) {
+ sdname = "{"+namespace+"}";
+ }
+
+ sdname += conv.getModelName().getName()+"-"+
+ conv.getModelName().getLocatedRole().getName();
+
+ switchAction.setServiceDescriptionName(sdname);
+
+ name += NAME_SUFFIX;
+
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getModelName().getName()+"@"+
+ conv.getModelName().getLocatedRole().getName();
+ }
+
+ if (ctype != null) {
+ switchAction.setConversationType(ctype);
+ }
+ }
+
// Get lookahead analyser
LookaheadAnalyser la=(LookaheadAnalyser)
RegistryFactory.getRegistry().getExtension(
15 years, 3 months
Overlord SVN: r469 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb: src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-24 18:36:19 -0500 (Sat, 24 Jan 2009)
New Revision: 469
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/LanguageToConversationModelChangeRule.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
Log:
Add some initial model change rules for the stateless model.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-24 23:02:09 UTC (rev 468)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-24 23:36:19 UTC (rev 469)
@@ -24,6 +24,10 @@
org.jboss.tools.overlord.cdl.runtime.jbossesb.editor.JBossESBConfigEditorManager,
org.jboss.tools.overlord.cdl.runtime.jbossesb.validation.ESBLanguageModelValidationRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.export.ESBLanguageModelStreamExportRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.LanguageToConversationModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.ConversationModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.ConversationInteractionModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless.IfModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.LanguageToConversationModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationModelChangeRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule,
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationInteractionModelChangeRule.java 2009-01-24 23:36:19 UTC (rev 469)
@@ -0,0 +1,559 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+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 Conversation Interaction.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationInteractionModelChangeRule extends AbstractStatelessESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj,
+ ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction interaction=(ConversationInteraction)mobj;
+
+ // Check if send or receive
+ if (InteractionUtil.isSend(interaction)) {
+
+ // Send
+ insertSend(context, esbModel, interaction, ref);
+
+ } else {
+ // Receive
+ insertReceive(context, esbModel, interaction, ref);
+ }
+
+ return(true);
+ }
+
+ protected void insertSend(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+
+ SendMessageAction action=
+ new SendMessageAction(service);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ boolean f_subsequentInitiator=false;
+ boolean f_moveActions=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ // Move actions if a subsequent initiator has been found
+ f_moveActions = f_subsequentInitiator;
+
+ service.addAction(action, pos);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ /* IS REQUIRED??
+ if (interaction.getRequestLabel() != null) {
+
+ // Create new ESB service
+ ESBService respService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(respService);
+
+ action.setResponseDestination(respService.getCategory(),
+ respService.getName());
+
+ context.setParent(respService);
+
+ // Clear the sub-sequent initiator flag, as
+ // subsequent actions will be moved to new service
+ // anyway
+ f_subsequentInitiator = false;
+
+ } else if (interaction.getReplyToLabel() != null) {
+
+ if (interaction.getToRole() != null) {
+ action.setClientEPR(interaction.getToRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ service.addAction(schedule, pos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+ }
+
+ // Check if existing actions need to be moved
+ if (f_moveActions) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBService extraService=(ESBService)context.getParent();
+
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ extraService.addAction(act, -1);
+ }
+ }
+
+ // If not reply, then include the target service
+ // details
+ if (interaction.getReplyToLabel() == null &&
+ interaction.getToRole() != null &&
+ interaction.getToRole().getName() != null &&
+ interaction.getToRole().getName().length() > 0) {
+ String roleName=Character.toLowerCase(
+ interaction.getToRole().getName().charAt(0))+
+ interaction.getToRole().getName().substring(1);
+
+ action.setDestinationExpression(
+ InteractionUtil.getRoleServiceCategoryProperty(roleName),
+ InteractionUtil.getRoleServiceNameProperty(roleName));
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ */
+ }
+
+ protected void insertReceive(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+ ESBService endService=service;
+
+ int endPos=-1;
+ boolean f_subsequentInitiator=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ endPos = pos;
+
+ // Check if receive needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+
+ /* IS THIS REQUIRED??
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService recvService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(recvService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(recvService.getCategory(),
+ recvService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(recvService);
+
+ endService = recvService;
+ endPos = 0;
+ }
+ */
+
+ ReceiveMessageAction action=
+ new ReceiveMessageAction(endService);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ endService.addAction(action, endPos);
+
+ if (endService.getFirstSessionBasedAction() == action &&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ /* IS STILL REQUIRED?
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(endService.getCategory(),
+ endService.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(endService);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ endService.addAction(schedule, endPos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+
+ endService = extraService;
+ endPos = -1;
+ }
+
+ // Check if existing actions need to be moved
+ if (pos != -1 && service != endService) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ endService.addAction(act, -1);
+ }
+ }
+
+ // If not a response, then add to the gateway
+ if (interaction.getReplyToLabel() == null) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ java.util.List<MessageSignature> mtypes=
+ new java.util.Vector<MessageSignature>();
+ mtypes.add(interaction.getMessageSignature());
+
+ mra.addRoute(endService.getCategory(),
+ endService.getName(),
+ service.isRoot(), mtypes);
+ }
+ }
+
+ // Set client EPR
+ if (interaction.getFromRole() != null) {
+ action.setClientEPR(interaction.getFromRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ */
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof ConversationInteraction &&
+ toObj instanceof ConversationInteraction &&
+ super.isUpdateSupported(context, model, fromObj, toObj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+ ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+ ESBService service=(ESBService)context.getParent();
+
+ // Get action from 'toInteraction'
+ if (toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ 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=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/IfModelChangeRule.java 2009-01-24 23:36:19 UTC (rev 469)
@@ -0,0 +1,431 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the If grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class IfModelChangeRule extends AbstractStatelessESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof If &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ If ifElem=(If)mobj;
+
+ int pos=getPosition(service, ref);
+
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Check if should be an 'if' or a 'switch' action
+ if (ifElem.getRoles().contains(context.getRole())) {
+
+ insertIf(context, model, service, ifElem, joinService, pos);
+ } else {
+ insertSwitch(context, model, service, ifElem, joinService, pos);
+ }
+
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertIf(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // If action, because the role is a decision maker
+ IfAction ifAction=new IfAction(service);
+
+ service.addAction(ifAction, pos);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+ subService.getCategory(), subService.getName(),
+ immediate, null, i);
+
+ /* REQUIRED?
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ */
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath(IfAction.ELSE,
+ subService.getCategory(), subService.getName(),
+ immediate, null, -1);
+
+ /* REQUIRED?
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ */
+ }
+
+ /*
+ if (service.getFirstSessionBasedAction() == ifAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ */
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+
+ /* IS THIS REQUIRED???
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
+
+ service = switchService;
+ pos = -1;
+ }
+ */
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ /* REQUIRED?
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ */
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(ifElem.getElseBlock());
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, -1);
+
+ /*
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ */
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ /*
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ */
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateless");
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/LanguageToConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/LanguageToConversationModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/LanguageToConversationModelChangeRule.java 2009-01-24 23:36:19 UTC (rev 469)
@@ -0,0 +1,98 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+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 inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationModel &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless()) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ConversationModel cm=(ConversationModel)mobj;
+
+ if (cm.getConversation() != null) {
+ context.insert(model, cm.getConversation(), null);
+ }
+
+ return(true);
+ }
+
+}
15 years, 3 months
Overlord SVN: r468 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb: src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator and 6 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-24 18:02:09 -0500 (Sat, 24 Jan 2009)
New Revision: 468
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractStatefulESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/AbstractStatelessESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModelTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/TestESBLanguageModel.java
Log:
Set 'stateless' status on the ESBLanguageModel and use in the model change rules - to distinguish between the change rules for stateful and stateless models.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-24 23:02:09 UTC (rev 468)
@@ -14,6 +14,7 @@
org.scribble.conversation.model,
org.scribble.lang.model,
org.scribble.core,
+ org.scribble.conformance,
org.eclipse.jface.text,
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui.ide,
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -28,6 +28,7 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.generator.BuildSystem;
import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.scribble.conformance.model.transform.StatelessTransformer;
import org.scribble.conversation.model.ConversationModel;
import org.scribble.extensions.RegistryFactory;
import org.scribble.model.*;
@@ -148,13 +149,29 @@
// Check if stateless version of model is required
if (stateless) {
+ StatelessTransformer transformer=
+ (StatelessTransformer)
+ RegistryFactory.getRegistry().getExtension(
+ StatelessTransformer.class,null);
+
+ if (transformer != null) {
+ Conversation statelessConversation=(Conversation)
+ transformer.transform(lcm.getConversation(),
+ new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION));
+
+ if (statelessConversation != null) {
+ lcm.setConversation(statelessConversation);
+ } else {
+ logger.severe("Failed to transform to stateless conversation");
+ }
+ }
}
ModelReference targetRef=
new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
DefaultESBLanguageModel target=
- new DefaultESBLanguageModel(targetRef);
+ new DefaultESBLanguageModel(targetRef, stateless);
ModelGenerator generator=(ModelGenerator)
RegistryFactory.getRegistry().getExtension(
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModel.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModel.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -76,9 +76,11 @@
* This constructor initializes a new ESB configuration.
*
* @param source The model reference for the JBossESB configuration
+ * @param stateless Whether the model is stateless
*/
- public DefaultESBLanguageModel(ModelReference source) {
+ public DefaultESBLanguageModel(ModelReference source, boolean stateless) {
m_source = source;
+ m_stateless = stateless;
initializeNewConfig();
}
@@ -179,6 +181,12 @@
while (serviter.hasNext()) {
ESBService service=serviter.next();
+ // If any service is stateless, then mark the model
+ // as stateless
+ if (service.isStateless()) {
+ m_stateless = true;
+ }
+
if (service.isRoot()) {
/*
@@ -607,6 +615,15 @@
}
/**
+ * This method returns whether the model is stateless.
+ *
+ * @return Whether the model is stateless
+ */
+ public boolean isStateless() {
+ return(m_stateless);
+ }
+
+ /**
* This method returns a custom classloader that uses the project's
* classpath to locate classes referenced by the ESB config file.
*
@@ -634,6 +651,7 @@
private String m_contents=null;
private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
private ClassLoader m_classLoader=null;
+ private boolean m_stateless=false;
public class InnerModelListener implements ModelListener {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBLanguageModel.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBLanguageModel.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -128,4 +128,11 @@
*/
public String getJMSDefinition(String jmsBusId);
+ /**
+ * This method returns whether the model is stateless.
+ *
+ * @return Whether the model is stateless
+ */
+ public boolean isStateless();
+
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateless/MessageRouterAction.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -42,6 +42,8 @@
*/
public class MessageRouterAction extends AbstractESBAction {
+ private static final long serialVersionUID = 2920316907680509410L;
+
public static final String INITIATE = "initiate";
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
@@ -201,7 +203,22 @@
return(ret);
}
+
/**
+ * This method sets the conversation type property.
+ *
+ * @param name The conversation type
+ */
+ public void setConversationType(String type) {
+
+ org.w3c.dom.Element prop=getPropertyElement(CONVERSATION_TYPE);
+
+ if (prop != null) {
+ prop.setAttribute(VALUE_ATTR, type);
+ }
+ }
+
+ /**
* This method returns the mandatory property names.
*
* @return The mandatory property names
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -1,173 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change.stateful;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.scribble.conversation.model.ConversationInteraction;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-
-/**
- * This is the abstract ESB model change rule.
- */
-public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if ((context.getParent() instanceof ESBService ||
- (ref != null && ref.getSource().getObject()
- instanceof AbstractStatefulESBAction &&
- ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null)) &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method returns the ESB service associated with the
- * optional model object reference or the context.
- *
- * @param context The context
- * @param ref The optional model object
- * @return The ESB service, or null if not found
- */
- protected ESBService getESBService(ModelChangeContext context,
- ModelObject ref) {
- ESBService ret=(ESBService)context.getParent();
-
- if (ref != null && ref.getSource().getObject() instanceof AbstractStatefulESBAction) {
- ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
- }
-
- return(ret);
- }
-
- /**
- * This method determines the position of the supplied
- * model object within the supplied service.
- *
- * @param service The service
- * @param ref The optional model object
- * @return The position, or -1 if not found
- */
- protected int getPosition(ESBService service, ModelObject ref) {
- int ret=-1;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- ret = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether an 'initiator' action,
- * inserted at the defined position in the specified
- * service, should actually be placed in a new scheduled
- * service.
- *
- * @param service The current service
- * @param pos The insertion position in that service
- * @return Whether a new service needs to be scheduled to
- * accommodate the initiator action
- */
- protected boolean shouldScheduleNewService(ESBService service,
- int pos) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < pos; i++) {
- ESBAction action=service.getActions().get(i);
-
- if (action.isSessionBased() && !action.isSessionType()) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
- (context.getParent() instanceof ESBService ||
- ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null) &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method removes the supplied model object from the
- * supplied model. The model object representation must
- * contain the necessary model specific to remove the
- * object from the underlying model representation.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object to be deleted
- * @return Whether the change has been applied
- */
- @Override
- public boolean delete(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
- ESBService service=getESBService(context, mobj);
- ESBAction action=(ESBAction)mobj.getSource().getObject();
-
- if (action != null && service != null) {
- ret = service.getActions().remove(action);
- }
-
- return(ret);
- }
-}
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractStatefulESBModelChangeRule.java (from rev 467, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractStatefulESBModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractStatefulESBModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -0,0 +1,199 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractStatefulESBModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if ((context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractStatefulESBAction &&
+ ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null)) &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the ESB service associated with the
+ * optional model object reference or the context.
+ *
+ * @param context The context
+ * @param ref The optional model object
+ * @return The ESB service, or null if not found
+ */
+ protected ESBService getESBService(ModelChangeContext context,
+ ModelObject ref) {
+ ESBService ret=(ESBService)context.getParent();
+
+ if (ref != null && ref.getSource().getObject() instanceof AbstractStatefulESBAction) {
+ ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the position of the supplied
+ * model object within the supplied service.
+ *
+ * @param service The service
+ * @param ref The optional model object
+ * @return The position, or -1 if not found
+ */
+ protected int getPosition(ESBService service, ModelObject ref) {
+ int ret=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ ret = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether an 'initiator' action,
+ * inserted at the defined position in the specified
+ * service, should actually be placed in a new scheduled
+ * service.
+ *
+ * @param service The current service
+ * @param pos The insertion position in that service
+ * @return Whether a new service needs to be scheduled to
+ * accommodate the initiator action
+ */
+ protected boolean shouldScheduleNewService(ESBService service,
+ int pos) {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < pos; i++) {
+ ESBAction action=service.getActions().get(i);
+
+ if (action.isSessionBased() && !action.isSessionType()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
+ (context.getParent() instanceof ESBService ||
+ ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null) &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ if (action != null && service != null) {
+ ret = service.getActions().remove(action);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -31,7 +31,7 @@
* This is the model change rule for the Conversation Interaction.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
+public class ConversationInteractionModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
@@ -420,8 +420,7 @@
if (fromObj instanceof ConversationInteraction &&
toObj instanceof ConversationInteraction &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
+ super.isUpdateSupported(context, model, fromObj, toObj)) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -50,7 +50,8 @@
boolean ret=false;
if (mobj instanceof Conversation &&
- model instanceof ESBLanguageModel) {
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -33,7 +33,7 @@
* This is the model change rule for the If grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class IfModelChangeRule extends AbstractESBModelChangeRule {
+public class IfModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -48,7 +48,8 @@
boolean ret=false;
if (mobj instanceof ConversationModel &&
- model instanceof ESBLanguageModel) {
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -49,7 +49,8 @@
if (fromObj instanceof MessageSignature &&
toObj instanceof MessageSignature &&
- model instanceof ESBLanguageModel) {
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -32,7 +32,7 @@
* This is the model change rule for the Parallel grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
+public class ParallelModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -32,7 +32,7 @@
* This is the model change rule for the Run composition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class RunModelChangeRule extends AbstractESBModelChangeRule {
+public class RunModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -31,7 +31,7 @@
* This is the model change rule for the Spawn composition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
+public class SpawnModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -49,7 +49,8 @@
if (fromObj instanceof TypeReference &&
toObj instanceof TypeReference &&
- model instanceof ESBLanguageModel) {
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless() == false) {
ret = true;
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -32,7 +32,7 @@
* This is the model change rule for the When grouping construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhenModelChangeRule extends AbstractESBModelChangeRule {
+public class WhenModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -32,7 +32,7 @@
* This is the model change rule for the While repetition construct.
*/
@RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhileModelChangeRule extends AbstractESBModelChangeRule {
+public class WhileModelChangeRule extends AbstractStatefulESBModelChangeRule {
/**
* This method determines whether the rule is appropriate
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/AbstractStatelessESBModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/AbstractStatelessESBModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/AbstractStatelessESBModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -0,0 +1,173 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract stateless ESB model change rule.
+ */
+public abstract class AbstractStatelessESBModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if ((context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractESBAction &&
+ ((AbstractESBAction)ref.getSource().getObject()).getService() != null)) &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless()) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the ESB service associated with the
+ * optional model object reference or the context.
+ *
+ * @param context The context
+ * @param ref The optional model object
+ * @return The ESB service, or null if not found
+ */
+ protected ESBService getESBService(ModelChangeContext context,
+ ModelObject ref) {
+ ESBService ret=(ESBService)context.getParent();
+
+ if (ref != null && ref.getSource().getObject() instanceof AbstractESBAction) {
+ ret = ((AbstractESBAction)ref.getSource().getObject()).getService();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the position of the supplied
+ * model object within the supplied service.
+ *
+ * @param service The service
+ * @param ref The optional model object
+ * @return The position, or -1 if not found
+ */
+ protected int getPosition(ESBService service, ModelObject ref) {
+ int ret=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ ret = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj.getSource().getObject() instanceof AbstractESBAction &&
+ (context.getParent() instanceof ESBService ||
+ ((AbstractESBAction)mobj.getSource().getObject()).getService() != null) &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless()) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ if (action != null && service != null) {
+ ret = service.getActions().remove(action);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless()) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateless/ConversationModelChangeRule.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -0,0 +1,181 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateless;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateless.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+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 Conversation.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationModelChangeRule extends AbstractModelChangeRule {
+
+ private static final String NAME_SUFFIX = "_main";
+
+ /**
+ * 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
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Conversation &&
+ model instanceof ESBLanguageModel &&
+ ((ESBLanguageModel)model).isStateless()) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ Conversation conv=(Conversation)mobj;
+
+ String namespace=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ String category=ConversationUtil.getServiceCategory(conv);
+
+ String name=ConversationUtil.getServiceName(conv);
+
+ String sdname="";
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+
+ // Register gateway service
+ DefaultESBService gateway=new DefaultESBService(esbModel,
+ category, name);
+
+ MessageRouterAction mra=new MessageRouterAction(gateway);
+
+ // Construct service description name
+ if (namespace != null) {
+ sdname = "{"+namespace+"}";
+ }
+
+ sdname += conv.getModelName().getName()+"-"+
+ conv.getModelName().getLocatedRole().getName();
+
+ mra.setServiceDescriptionName(sdname);
+
+ gateway.addAction(mra, -1);
+
+ esbModel.addService(gateway);
+
+ name += NAME_SUFFIX;
+
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getModelName().getName()+"@"+
+ conv.getModelName().getLocatedRole().getName();
+ }
+
+ if (ctype != null) {
+ mra.setConversationType(ctype);
+ }
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=conv.getBlock().getContents();
+
+ context.setParent(gateway);
+
+ for (int i=0; i < acts.size(); i++) {
+ context.insert(model, acts.get(i), null);
+ }
+ }
+
+ /*
+ // Create new ESB service
+ ESBService service=esbModel.createService(category, name);
+
+ esbModel.addService(service);
+
+ // Create 'CreateSession' activity
+ // 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, acts.get(i), null);
+ }
+ */
+
+ return(true);
+ }
+
+}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModelTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModelTest.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/DefaultESBLanguageModelTest.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -29,7 +29,7 @@
ModelReference ref=new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
- DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref);
+ DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref, false);
org.w3c.dom.Element config=model.getESBConfiguration();
@@ -113,7 +113,7 @@
ModelReference ref=new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
- DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref);
+ DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref, false);
org.w3c.dom.Element config=model.getESBConfiguration();
@@ -175,7 +175,7 @@
ModelReference ref=new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
- DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref);
+ DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref, false);
org.w3c.dom.Element config=model.getESBConfiguration();
@@ -221,7 +221,7 @@
ModelReference ref=new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
- DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref);
+ DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref, false);
TestESBService service=new TestESBService();
service.setCategory(category);
@@ -241,7 +241,7 @@
ModelReference ref=new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
- DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref);
+ DefaultESBLanguageModel model=new DefaultESBLanguageModel(ref, false);
TestESBService service1=new TestESBService();
service1.setCategory(category);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/TestESBLanguageModel.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/TestESBLanguageModel.java 2009-01-22 20:41:48 UTC (rev 467)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/TestESBLanguageModel.java 2009-01-24 23:02:09 UTC (rev 468)
@@ -113,6 +113,11 @@
return null;
}
+ public boolean isStateless() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
private java.util.Map<String,ESBService> m_services=new java.util.Hashtable<String,ESBService>();
private ESBService m_gatewayService=null;
private org.w3c.dom.Element m_esbConfig=null;
15 years, 3 months
Overlord SVN: r467 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb: src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs and 8 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-22 15:41:48 -0500 (Thu, 22 Jan 2009)
New Revision: 467
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java
Log:
Added 'stateless' checkbox to generator dialog and pass through. Moved current change rules to be stateful specific.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/META-INF/MANIFEST.MF 2009-01-22 20:41:48 UTC (rev 467)
@@ -23,15 +23,15 @@
org.jboss.tools.overlord.cdl.runtime.jbossesb.editor.JBossESBConfigEditorManager,
org.jboss.tools.overlord.cdl.runtime.jbossesb.validation.ESBLanguageModelValidationRule,
org.jboss.tools.overlord.cdl.runtime.jbossesb.export.ESBLanguageModelStreamExportRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.LanguageToConversationModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationInteractionModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.MessageSignatureModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.TypeReferenceModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.IfModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ParallelModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.SpawnModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhenModelChangeRule,
- org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhileModelChangeRule
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.LanguageToConversationModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.MessageSignatureModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.TypeReferenceModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.IfModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ParallelModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.SpawnModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhenModelChangeRule,
+ org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhileModelChangeRule
Bundle-ActivationPolicy: lazy
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/dialogs/GenerateDialog.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -112,12 +112,12 @@
gd=new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 1;
- gd.widthHint = 500;
+ gd.widthHint = 650;
gd.grabExcessHorizontalSpace = true;
group.setLayoutData(gd);
layout = new GridLayout();
- layout.numColumns = 4;
+ layout.numColumns = 6;
group.setLayout(layout);
// Labels
@@ -126,15 +126,23 @@
gd = new GridData();
gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.widthHint = 200;
label.setLayoutData(gd);
label = new Label(group, SWT.NONE);
+ label.setText("Stateless");
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 60;
+ label.setLayoutData(gd);
+
+ label = new Label(group, SWT.NONE);
label.setText("Project Name");
gd = new GridData();
- gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.horizontalSpan = 3;
+ gd.widthHint = 300;
label.setLayoutData(gd);
if (m_conversationModel != null) {
@@ -147,7 +155,7 @@
gd = new GridData();
gd.horizontalSpan = 2;
- gd.widthHint = 150;
+ gd.widthHint = 200;
button.setLayoutData(gd);
m_roleButtons.add(button);
@@ -162,6 +170,26 @@
}
});
+ Button statelessButton=new Button(group, SWT.CHECK);
+ statelessButton.setSelection(true);
+
+ gd = new GridData();
+ gd.horizontalSpan = 1;
+ gd.widthHint = 60;
+ statelessButton.setLayoutData(gd);
+
+ m_statelessButtons.add(statelessButton);
+
+ statelessButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ checkStatus();
+ }
+ });
+
Text projectName=new Text(group, SWT.NONE);
String prjName=m_roles.get(i).getName();
@@ -173,7 +201,7 @@
projectName.setText(prjName);
gd = new GridData();
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
gd.widthHint = 300;
projectName.setLayoutData(gd);
@@ -336,6 +364,7 @@
if (m_roleButtons.get(i).getSelection()) {
generator.generateRole(m_roles.get(i),
+ m_statelessButtons.get(i).getSelection(),
m_projectNames.get(i).getText());
}
}
@@ -374,6 +403,7 @@
private ConversationModel m_conversationModel=null;
private java.util.List<Role> m_roles=null;
private java.util.List<Button> m_roleButtons=new java.util.Vector<Button>();
+ private java.util.List<Button> m_statelessButtons=new java.util.Vector<Button>();
private java.util.List<Text> m_projectNames=new java.util.Vector<Text>();
private Combo m_build=null;
private java.util.List<BuildSystem> m_buildSystems=new java.util.Vector<BuildSystem>();
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -120,10 +120,11 @@
* supplied role.
*
* @param role The role
+ * @param stateless Whether the generated role should be stateless
* @param projectName The project name
* @throws Exception Failed to generate role
*/
- public void generateRole(Role role, String projectName)
+ public void generateRole(Role role, boolean stateless, String projectName)
throws Exception {
if (logger.isLoggable(Level.FINEST)) {
@@ -145,6 +146,10 @@
((ConversationModel)localModel).getConversation() != null) {
ConversationModel lcm=(ConversationModel)localModel;
+ // Check if stateless version of model is required
+ if (stateless) {
+ }
+
ModelReference targetRef=
new ModelReference(ESBLanguageModel.JBOSSESB_NOTATION);
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/ESBActionFactory.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -107,7 +107,7 @@
// Check that it is a conversation based ESB action
if (actionType.startsWith(MODEL_ACTION_PACKAGE)) {
- actionType = actionType.substring(CONVERSATION_ACTION_PACKAGE.length());
+ actionType = actionType.substring(MODEL_ACTION_PACKAGE.length());
String stateValue=null;
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/AbstractESBAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -34,6 +34,8 @@
public abstract class AbstractESBAction extends ModelObject
implements ESBAction {
+ private static final long serialVersionUID = -5660683702154455942L;
+
public static final String ACTION_ELEMENT = "action";
public static final String VALUE_ATTR = "value";
public static final String NAME_ATTR = "name";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/AbstractStatefulESBAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -32,6 +32,8 @@
*/
public abstract class AbstractStatefulESBAction extends AbstractESBAction {
+ private static final long serialVersionUID = -2818664861342681505L;
+
public static final String IDENTITIES = "identities";
public static final String ACTION_ELEMENT = "action";
public static final String VALUE_ATTR = "value";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/IfAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class IfAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 9064103072852303673L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/MessageRouterAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -41,6 +41,8 @@
*/
public class MessageRouterAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -7335984128887046476L;
+
public static final String IDENTITIES_ELEMENT = "identities";
public static final String INITIATE = "initiate";
public static final String SERVICE_NAME = "service-name";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ParallelAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class ParallelAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 6269914598525068328L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/PerformAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -31,6 +31,8 @@
*/
public class PerformAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 6342595605838714160L;
+
private static final String BIND_ELEMENT = "bind";
private static final String TO_VARIABLE_ATTR = "to-variable";
public static final String SERVICE_NAME = "serviceName";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ReceiveMessageAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -28,6 +28,8 @@
*/
public class ReceiveMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = 2272649736091582501L;
+
/**
* The constructor for the action.
*
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/RetrieveSessionAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class RetrieveSessionAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -1468908746103555375L;
+
public static final String IDENTITIES = "identities";
/**
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/ScheduleStateAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class ScheduleStateAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -8137315455582602258L;
+
public static final String IMMEDIATE = "immediate";
public static final String SERVICE_NAME = "serviceName";
public static final String SERVICE_CATEGORY = "serviceCategory";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SendMessageAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class SendMessageAction extends AbstractInteractionMessageAction {
+ private static final long serialVersionUID = 6415982439018207905L;
+
public static final String RESPONSE_SERVICE_NAME = "responseServiceName";
public static final String RESPONSE_SERVICE_CATEGORY = "responseServiceCategory";
public static final String SERVICE_NAME = "serviceName";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetMessageAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -28,6 +28,8 @@
*/
public class SetMessageAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -927023877167087363L;
+
public static final String STATE_EXPRESSION = "stateExpression";
public static final String HEADER_PROPERTY = "headerProperty";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SetStateAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -32,6 +32,8 @@
*/
public class SetStateAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 1433577447941826202L;
+
public static final String STATE_EXPRESSION = "stateExpression";
public static final String MESSAGE_EXPRESSION = "messageExpression";
public static final String VARIABLE = "variable";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/SwitchAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -31,6 +31,8 @@
*/
public class SwitchAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -114174911606651401L;
+
public static final String TYPE_ATTR = "type";
public static final String MESSAGE_ELEMENT = "message";
private static final String SERVICE_NAME = "service-name";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/UnsupportedAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -29,6 +29,8 @@
*/
public class UnsupportedAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 61328489127442228L;
+
/**
* The constructor for the action.
*
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhenAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class WhenAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = 3009772810014450672L;
+
private static final String SERVICE_NAME = "service-name";
private static final String SERVICE_CATEGORY = "service-category";
private static final String WHEN = "when";
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/actions/stateful/WhileAction.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -30,6 +30,8 @@
*/
public class WhileAction extends AbstractStatefulESBAction {
+ private static final long serialVersionUID = -4863147208782217805L;
+
public static final String SERVICE_NAME = "service-name";
public static final String SERVICE_CATEGORY = "service-category";
public static final String IMMEDIATE = "immediate";
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,173 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.scribble.conversation.model.ConversationInteraction;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-
-/**
- * This is the abstract ESB model change rule.
- */
-public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if ((context.getParent() instanceof ESBService ||
- (ref != null && ref.getSource().getObject()
- instanceof AbstractStatefulESBAction &&
- ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null)) &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method returns the ESB service associated with the
- * optional model object reference or the context.
- *
- * @param context The context
- * @param ref The optional model object
- * @return The ESB service, or null if not found
- */
- protected ESBService getESBService(ModelChangeContext context,
- ModelObject ref) {
- ESBService ret=(ESBService)context.getParent();
-
- if (ref != null && ref.getSource().getObject() instanceof AbstractStatefulESBAction) {
- ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
- }
-
- return(ret);
- }
-
- /**
- * This method determines the position of the supplied
- * model object within the supplied service.
- *
- * @param service The service
- * @param ref The optional model object
- * @return The position, or -1 if not found
- */
- protected int getPosition(ESBService service, ModelObject ref) {
- int ret=-1;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
- ret = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether an 'initiator' action,
- * inserted at the defined position in the specified
- * service, should actually be placed in a new scheduled
- * service.
- *
- * @param service The current service
- * @param pos The insertion position in that service
- * @return Whether a new service needs to be scheduled to
- * accommodate the initiator action
- */
- protected boolean shouldScheduleNewService(ESBService service,
- int pos) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < pos; i++) {
- ESBAction action=service.getActions().get(i);
-
- if (action.isSessionBased() && !action.isSessionType()) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
- (context.getParent() instanceof ESBService ||
- ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null) &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method removes the supplied model object from the
- * supplied model. The model object representation must
- * contain the necessary model specific to remove the
- * object from the underlying model representation.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object to be deleted
- * @return Whether the change has been applied
- */
- @Override
- public boolean delete(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
- ESBService service=getESBService(context, mobj);
- ESBAction action=(ESBAction)mobj.getSource().getObject();
-
- if (action != null && service != null) {
- ret = service.getActions().remove(action);
- }
-
- return(ret);
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,553 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-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 Conversation Interaction.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj,
- ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof ConversationInteraction &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ConversationInteraction interaction=(ConversationInteraction)mobj;
-
- // Check if send or receive
- if (InteractionUtil.isSend(interaction)) {
-
- // Send
- insertSend(context, esbModel, interaction, ref);
-
- } else {
- // Receive
- insertReceive(context, esbModel, interaction, ref);
- }
-
- return(true);
- }
-
- protected void insertSend(ModelChangeContext context,
- ESBLanguageModel esbModel, ConversationInteraction interaction,
- ModelObject ref) {
- ESBService service=getESBService(context, ref);
-
- SendMessageAction action=
- new SendMessageAction(service);
-
- if (interaction.getMessageSignature().getOperation() != null) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-
- setMessageType(action, interaction);
-
- boolean f_subsequentInitiator=false;
- boolean f_moveActions=false;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- int pos=getPosition(service, ref);
-
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
- }
-
- // Move actions if a subsequent initiator has been found
- f_moveActions = f_subsequentInitiator;
-
- service.addAction(action, pos);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
- interaction.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)interaction.getEnclosingDefinition())));
- }
-
- if (interaction.getRequestLabel() != null) {
-
- // Create new ESB service
- ESBService respService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(respService);
-
- action.setResponseDestination(respService.getCategory(),
- respService.getName());
-
- context.setParent(respService);
-
- // Clear the sub-sequent initiator flag, as
- // subsequent actions will be moved to new service
- // anyway
- f_subsequentInitiator = false;
-
- } else if (interaction.getReplyToLabel() != null) {
-
- if (interaction.getToRole() != null) {
- action.setClientEPR(interaction.getToRole().getName());
- } else {
- action.setClientEPR("client");
- }
- }
-
- // Check if subsequent initiator found, requiring
- // a new service
- if (f_subsequentInitiator) {
-
- ESBService extraService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(extraService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(extraService.getCategory(),
- extraService.getName(), false);
-
- service.addAction(schedule, pos+1);
-
- // Move pointer on, as now additional 'schedule' action
- pos++;
-
- context.setParent(extraService);
- }
-
- // Check if existing actions need to be moved
- if (f_moveActions) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBService extraService=(ESBService)context.getParent();
-
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- extraService.addAction(act, -1);
- }
- }
-
- // If not reply, then include the target service
- // details
- if (interaction.getReplyToLabel() == null &&
- interaction.getToRole() != null &&
- interaction.getToRole().getName() != null &&
- interaction.getToRole().getName().length() > 0) {
- String roleName=Character.toLowerCase(
- interaction.getToRole().getName().charAt(0))+
- interaction.getToRole().getName().substring(1);
-
- action.setDestinationExpression(
- InteractionUtil.getRoleServiceCategoryProperty(roleName),
- InteractionUtil.getRoleServiceNameProperty(roleName));
- }
-
- if (interaction.getEnclosingDefinition() instanceof Conversation &&
- interaction.getEnclosingDefinition().getModel()
- instanceof ConversationModel) {
-
- java.util.List<Identity> ids=((Conversation)
- interaction.getEnclosingDefinition()).getIdentities();
-
- java.util.List<IdentityLocator> locators=
- ((ConversationModel)interaction.getEnclosingDefinition().
- getModel()).getIdentityLocators();
-
- IdentityUtil.defineIdentities(action.getPropertyElement(
- SendMessageAction.IDENTITIES),
- interaction.getMessageSignature(), ids, locators);
- }
- }
-
- protected void insertReceive(ModelChangeContext context,
- ESBLanguageModel esbModel, ConversationInteraction interaction,
- ModelObject ref) {
- ESBService service=getESBService(context, ref);
- ESBService endService=service;
-
- int endPos=-1;
- boolean f_subsequentInitiator=false;
-
- // Check if reference model object provided, and if so,
- // if it has a position within the service
- int pos=getPosition(service, ref);
-
- // Check if subsequent action(s) are initiators
- if (pos != -1) {
- for (int i=pos; f_subsequentInitiator == false &&
- i < service.getActions().size(); i++) {
- f_subsequentInitiator =
- service.getActions().get(i).isInitiator();
- }
- }
-
- endPos = pos;
-
- // Check if receive needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService recvService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(recvService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(recvService.getCategory(),
- recvService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(recvService);
-
- endService = recvService;
- endPos = 0;
- }
-
- ReceiveMessageAction action=
- new ReceiveMessageAction(endService);
-
- if (interaction.getMessageSignature().getOperation() != null) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-
- setMessageType(action, interaction);
-
- endService.addAction(action, endPos);
-
- if (endService.getFirstSessionBasedAction() == action &&
- interaction.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)interaction.getEnclosingDefinition())));
- }
-
- // Check if subsequent initiator found, requiring
- // a new service
- if (f_subsequentInitiator) {
-
- ESBService extraService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(endService.getCategory(),
- endService.getName()));
-
- esbModel.addService(extraService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(endService);
-
- schedule.setDestination(extraService.getCategory(),
- extraService.getName(), false);
-
- endService.addAction(schedule, endPos+1);
-
- // Move pointer on, as now additional 'schedule' action
- pos++;
-
- context.setParent(extraService);
-
- endService = extraService;
- endPos = -1;
- }
-
- // Check if existing actions need to be moved
- if (pos != -1 && service != endService) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- endService.addAction(act, -1);
- }
- }
-
- // If not a response, then add to the gateway
- if (interaction.getReplyToLabel() == null) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- java.util.List<MessageSignature> mtypes=
- new java.util.Vector<MessageSignature>();
- mtypes.add(interaction.getMessageSignature());
-
- mra.addRoute(endService.getCategory(),
- endService.getName(),
- service.isRoot(), mtypes);
- }
- }
-
- // Set client EPR
- if (interaction.getFromRole() != null) {
- action.setClientEPR(interaction.getFromRole().getName());
- } else {
- action.setClientEPR("client");
- }
- }
-
- if (interaction.getEnclosingDefinition() instanceof Conversation &&
- interaction.getEnclosingDefinition().getModel()
- instanceof ConversationModel) {
-
- java.util.List<Identity> ids=((Conversation)
- interaction.getEnclosingDefinition()).getIdentities();
-
- java.util.List<IdentityLocator> locators=
- ((ConversationModel)interaction.getEnclosingDefinition().
- getModel()).getIdentityLocators();
-
- IdentityUtil.defineIdentities(action.getPropertyElement(
- SendMessageAction.IDENTITIES),
- interaction.getMessageSignature(), ids, locators);
- }
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof ConversationInteraction &&
- toObj instanceof ConversationInteraction &&
- context.getParent() instanceof ESBService &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
- ConversationInteraction toInteraction=(ConversationInteraction)toObj;
- ESBService service=(ESBService)context.getParent();
-
- // Get action from 'toInteraction'
- if (toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- 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=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof ConversationInteraction &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,181 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-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 Conversation.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ConversationModelChangeRule extends AbstractModelChangeRule {
-
- private static final String NAME_SUFFIX = "_main";
-
- /**
- * 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
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Conversation &&
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- Conversation conv=(Conversation)mobj;
-
- String namespace=((Model)conv.getModel()).
- getNamespace().getName();
-
- String category=ConversationUtil.getServiceCategory(conv);
-
- String name=ConversationUtil.getServiceName(conv);
-
- String sdname="";
-
- // Check if root conversation
- if (conv.getParent() instanceof Model) {
-
- // Register gateway service
- DefaultESBService gateway=new DefaultESBService(esbModel,
- category, name);
-
- MessageRouterAction mra=new MessageRouterAction(gateway);
-
- // Construct service description name
- if (namespace != null) {
- sdname = "{"+namespace+"}";
- }
-
- sdname += conv.getModelName().getName()+"-"+
- conv.getModelName().getLocatedRole().getName();
-
- mra.setServiceDescriptionName(sdname);
-
- gateway.addAction(mra, -1);
-
- esbModel.addService(gateway);
-
- name += NAME_SUFFIX;
- }
-
- // Create new ESB service
- ESBService service=esbModel.createService(category, name);
-
- esbModel.addService(service);
-
- // Create 'CreateSession' activity
- CreateSessionAction csa=new CreateSessionAction(service);
-
- // Check if root conversation
- if (conv.getParent() instanceof Model) {
- csa.setRoot(true);
-
- String ctype=null;
-
- // Check if conversation has a 'conforms to' reference
- if (conv.getConformsTo().size() > 0) {
- // Set conversation type based on first 'conforms to'
- // reference
- ConformanceReference cref=conv.getConformsTo().get(0);
-
- ctype = cref.getNamespace()+"."+
- cref.getLocalpart()+"@"+
- cref.getLocatedRole();
- } else {
- // Set conversation type based on conversation
- // namespace and name
- ctype = namespace+"."+
- conv.getModelName().getName()+"@"+
- conv.getModelName().getLocatedRole().getName();
- }
-
- if (ctype != null) {
- csa.setConversationType(ctype);
- }
- }
-
- csa.setServiceDescriptionName(sdname);
- csa.setBusinessObjectType(ConversationUtil.getBusinessObjectType(conv));
-
- 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, acts.get(i), null);
- }
-
- return(true);
- }
-
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,416 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the If grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class IfModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof If &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- If ifElem=(If)mobj;
-
- int pos=getPosition(service, ref);
-
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Check if should be an 'if' or a 'switch' action
- if (ifElem.getRoles().contains(context.getRole())) {
-
- insertIf(context, model, service, ifElem, joinService, pos);
- } else {
- insertSwitch(context, model, service, ifElem, joinService, pos);
- }
-
-
- context.setParent(joinService);
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- protected void insertIf(ModelChangeContext context,
- Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // If action, because the role is a decision maker
- IfAction ifAction=new IfAction(service);
-
- service.addAction(ifAction, pos);
-
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- boolean immediate=false;
-
- ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
- subService.getCategory(), subService.getName(),
- immediate, null, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- boolean immediate=false;
-
- ifAction.addPath(IfAction.ELSE,
- subService.getCategory(), subService.getName(),
- immediate, null, -1);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- if (service.getFirstSessionBasedAction() == ifAction &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- protected void insertSwitch(ModelChangeContext context,
- Model model, ESBService service,
- If ifElem, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // Check if 'when' needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService switchService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(switchService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(switchService.getCategory(),
- switchService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(switchService);
-
- service = switchService;
- pos = -1;
- }
-
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- service.addAction(switchAction, pos);
-
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- if (ifElem.getElseBlock() != null) {
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
- context.insert(model,
- ifElem.getElseBlock().getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(ifElem.getElseBlock());
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, -1);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- ifElem.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)ifElem.getEnclosingDefinition())));
- }
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,97 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-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 inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ConversationModel cm=(ConversationModel)mobj;
-
- if (cm.getConversation() != null) {
- context.insert(model, cm.getConversation(), null);
- }
-
- return(true);
- }
-
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,180 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-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 MessageSignature.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class MessageSignatureModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof MessageSignature &&
- toObj instanceof MessageSignature &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- MessageSignature fromMS=(MessageSignature)fromObj;
- MessageSignature toMS=(MessageSignature)toObj;
- ConversationInteraction toInteraction=null;
- ConversationInteraction fromInteraction=null;
-
- if (toMS != null &&
- toMS.getParent() instanceof ConversationInteraction) {
- toInteraction = (ConversationInteraction)toMS.getParent();
- }
-
- if (fromMS != null &&
- fromMS.getParent() instanceof ConversationInteraction) {
- fromInteraction = (ConversationInteraction)fromMS.getParent();
- }
-
- // Get action from 'toInteraction'
- if (toInteraction != null &&
- toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- // Update operation
- setOperation(ma, fromInteraction);
-
- ESBService service = ma.getService();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- 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=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-
- protected void setOperation(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
- action.setOperation(interaction.getMessageSignature().getOperation());
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,192 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Parallel grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Parallel &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- Parallel parallel=(Parallel)mobj;
-
- int pos=getPosition(service, ref);
-
- // Create the join service
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Create and configure the parallel action
- ParallelAction parAction=new ParallelAction(service);
-
- service.addAction(parAction, pos);
-
- for (int i=0; i < parallel.getBlocks().size(); i++) {
- Block b=parallel.getBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < b.getContents().size(); j++) {
- context.insert(model, b.getContents().get(j), null);
- }
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- parallel.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)parallel.getEnclosingDefinition())));
- }
-
- boolean immediate=true;
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to get lookahead analyser");
- } else {
- java.util.Iterator<Interaction> iter=
- la.getInteractions(b, true).iterator();
-
- while (immediate && iter.hasNext()) {
- Interaction interaction=iter.next();
-
- // If interaction is a receive, then immediate
- // invocation will be false
- immediate = InteractionUtil.isSend(interaction);
- }
- }
-
- parAction.addPath(subService.getCategory(),
- subService.getName(), immediate, false, i);
- }
-
- context.setParent(joinService);
-
- parAction.addPath(joinService.getCategory(),
- joinService.getName(), false, true, -1);
-
- // Check if business object type needs to be specified
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == parAction &&
- parallel.getEnclosingDefinition() instanceof Conversation) {
- parAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)parallel.getEnclosingDefinition())));
- }
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,201 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Run composition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class RunModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Run &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- Run run=(Run)mobj;
-
- int pos=getPosition(service, ref);
-
- PerformAction action=new PerformAction(service);
-
- service.addAction(action, pos);
-
- String category=ConversationUtil.getServiceCategory(run.getDefinition());
- String name=ConversationUtil.getServiceName(run.getDefinition());
-
- action.setDestination(category, name);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- run.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)run.getEnclosingDefinition())));
- }
-
- // Create return service
- ESBService returnService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(returnService);
-
- context.setParent(returnService);
-
- action.setReturnDestination(returnService.getCategory(),
- returnService.getName());
-
- // If reference provided, then move subsequent activities
- // to the 'return service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- returnService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof Run &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method removes the supplied model object from the
- * supplied model. The model object representation must
- * contain the necessary model specific to remove the
- * object from the underlying model representation.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object to be deleted
- * @return Whether the change has been applied
- */
- @Override
- public boolean delete(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
- ESBService service=getESBService(context, mobj);
- ESBAction action=(ESBAction)mobj.getSource().getObject();
-
- int pos=getPosition(service, mobj);
-
- if (action instanceof PerformAction && pos != -1) {
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- PerformAction perform=(PerformAction)action;
-
- schedule.setDestination(perform.getPropertyValue(PerformAction.RETURN_SERVICE_CATEGORY),
- perform.getPropertyValue(PerformAction.RETURN_SERVICE_NAME), true);
-
- service.addAction(schedule, pos);
-
- ret = super.delete(context, model, mobj);
- }
-
- return(ret);
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,138 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-//import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the Spawn composition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof Spawn &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBService service=getESBService(context, ref);
- Spawn spawn=(Spawn)mobj;
-
- int pos=getPosition(service, ref);
-
- PerformAction action=new PerformAction(service);
-
- service.addAction(action, pos);
-
- String category=ConversationUtil.getServiceCategory(spawn.getDefinition());
- String name=ConversationUtil.getServiceName(spawn.getDefinition());
-
- action.setDestination(category, name);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- spawn.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)spawn.getEnclosingDefinition())));
- }
-
- return(true);
- }
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and deleted model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object to be removed
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isDeleteSupported(ModelChangeContext context,
- Model model, ModelObject mobj) {
- boolean ret=false;
-
- if (mobj instanceof Spawn &&
- super.isDeleteSupported(context, model, mobj)) {
- ret = true;
- }
-
- return(ret);
- }
-
- //private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,172 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-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 Type Reference.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context)
- * and modified model object.
- *
- * @param context The context
- * @param model The model
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isUpdateSupported(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- if (fromObj instanceof TypeReference &&
- toObj instanceof TypeReference &&
- model instanceof ESBLanguageModel) {
- ret = true;
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param context The context
- * @param model The model being changed
- * @param fromObj The source model object
- * @param toObj The model object to be updated
- * @return Whether the change has been applied
- */
- @Override
- public boolean update(ModelChangeContext context,
- Model model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- TypeReference fromTypeRef=(TypeReference)fromObj;
- TypeReference toTypeRef=(TypeReference)toObj;
- ConversationInteraction toInteraction=null;
- ConversationInteraction fromInteraction=null;
-
- if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature &&
- toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
- toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
- }
-
- if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature &&
- fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
- fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
- }
-
- // Get action from 'toInteraction'
- if (toInteraction != null &&
- toInteraction.getSource().getObject() instanceof
- AbstractInteractionMessageAction) {
- AbstractInteractionMessageAction ma=
- (AbstractInteractionMessageAction)
- toInteraction.getSource().getObject();
-
- ESBService service = ma.getService();
-
- String origMesgType=ma.getMessageType();
-
- // Set message type
- setMessageType(ma, fromInteraction);
-
- // Update message type in router if appropriate
- if (InteractionUtil.isSend(fromInteraction) == false &&
- fromInteraction.getReplyToLabel() == null) {
- updateRouterMessageType(esbModel, service,
- origMesgType, ma);
- }
-
- ret = true;
- }
-
- return(ret);
- }
-
- protected void updateRouterMessageType(ESBLanguageModel esbModel,
- ESBService service, String origMesgType,
- AbstractInteractionMessageAction ma) {
- ESBService gwService=esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- org.w3c.dom.Element route=
- mra.getRouteElement(service.getCategory(),
- service.getName());
-
- if (route != null) {
- org.w3c.dom.NodeList nl=
- route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- for (int i=0; i < nl.getLength(); i++) {
- if (nl.item(i) instanceof org.w3c.dom.Element) {
- org.w3c.dom.Element mesg=
- (org.w3c.dom.Element)nl.item(i);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
- equals(origMesgType)) {
- mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
- ma.getMessageType());
- }
- }
- }
- }
- }
- }
- }
-
- protected void setMessageType(AbstractInteractionMessageAction action,
- ConversationInteraction interaction) {
-
- 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=InteractionUtil.getTypeString(ref);
-
- action.setMessageType(mtype);
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,322 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the When grouping construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhenModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof When &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- When when=(When)mobj;
-
- int pos=getPosition(service, ref);
-
- // Create join service
- ESBService joinService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(joinService);
-
- // Check if context role is decision maker
- if (when.getRoles().contains(context.getRole())) {
-
- insertWhen(context, model, service,
- when, joinService, pos);
- } else {
- insertSwitch(context, model, service,
- when, joinService, pos);
- }
-
- context.setParent(joinService);
-
- // If reference provided, then move subsequent activities
- // to the 'join service'
- if (pos != -1) {
- for (int i=pos+1; i < service.getActions().size();) {
- ESBAction act=service.getActions().get(i);
- service.getActions().remove(i);
-
- joinService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- protected void insertWhen(ModelChangeContext context,
- Model model, ESBService service,
- When when, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- WhenAction action=new WhenAction(service);
-
- service.addAction(action, pos);
-
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock b=when.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < b.getContents().size(); j++) {
- context.insert(model, b.getContents().get(j), null);
- }
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
-
- action.addPath(subService.getCategory(),
- subService.getName(), i);
- }
-
- if (service.getFirstSessionBasedAction() == action &&
- when.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
- }
-
- protected void insertSwitch(ModelChangeContext context,
- Model model, ESBService service,
- When when, ESBService joinService, int pos) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
-
- // Check if 'when' needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- // Already has activities, so need to separate
- // into another service descriptor
- ESBService switchService=esbModel.createService(
- service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(switchService);
-
- // Add schedule action
- ScheduleStateAction schedule=
- new ScheduleStateAction(service);
-
- schedule.setDestination(switchService.getCategory(),
- switchService.getName(), false);
-
- service.addAction(schedule, pos);
-
- context.setParent(switchService);
-
- service = switchService;
- pos = -1;
- }
-
- // Switch action, as role is a decision observer
- SwitchAction switchAction=new SwitchAction(service);
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- service.addAction(switchAction, pos);
-
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- for (int i=0; i < when.getConditionalBlocks().size(); i++) {
- ConditionalBlock cb=when.getConditionalBlocks().get(i);
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- context.setParent(subService);
-
- for (int j=0; j < cb.getContents().size(); j++) {
- context.insert(model, cb.getContents().get(j), null);
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(cb);
- }
-
- switchAction.addCase(subService.getCategory(),
- subService.getName(), interactions, i);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- schedule.setDestination(joinService.getCategory(),
- joinService.getName(), true);
-
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- when.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- //TODO: Only deals with single type for now
- // If a receive and not a response, then
- // add to the gateway
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getReplyToLabel() == null &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
- }
-
- // Only record message router 'routes' if the switch
- // receives request interactions, and it is the first
- // session based action in the service
- if (messageTypes.size() > 0 &&
- service.getFirstSessionBasedAction() == switchAction) {
- ESBService gwService=
- esbModel.getGatewayService();
-
- if (gwService != null) {
- ESBAction gwAction=gwService.getGatewayAction();
-
- if (gwAction instanceof MessageRouterAction) {
- MessageRouterAction mra=(MessageRouterAction)
- gwAction;
-
- mra.addRoute(service.getCategory(),
- service.getName(),
- false, messageTypes);
- }
- }
- }
-
- if (service.getFirstSessionBasedAction() == switchAction &&
- when.getEnclosingDefinition() instanceof Conversation) {
- switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)when.getEnclosingDefinition())));
- }
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,246 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.model.analysis.*;
-import org.scribble.conversation.model.*;
-import org.scribble.extensions.*;
-
-/**
- * This is the model change rule for the While repetition construct.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
-public class WhileModelChangeRule extends AbstractESBModelChangeRule {
-
- /**
- * This method determines whether the rule is appropriate
- * for the supplied type of model, parent (in the context) and inserted
- * model object.
- *
- * @param context The context
- * @param model The model
- * @param mobj The model object being inserted
- * @param ref The optional reference model object
- * @return Whether the rule supports the supplied information
- */
- @Override
- public boolean isInsertSupported(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- if (mobj instanceof While &&
- super.isInsertSupported(context, model, mobj, ref)) {
- 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.<p>
- * <p>
- * If a reference model object is supplied, then the
- * insertion will occur relative to it. If the reference
- * object is a block, then it means that the insertion
- * should occur at the end of the block. Otherwise the
- * new model object should be inserted before the
- * reference object, within the containing block.<p>
- * <p>
- * If the reference object is not supplied, then the
- * new model object should be inserted at the end of
- * the behaviour associated with the parent in the model
- * change context.
- *
- * @param context The context
- * @param model The model being changed
- * @param mobj The model object details to be inserted
- * @param ref The optional reference model object
- * @return Whether the change has been applied
- */
- @Override
- public boolean insert(ModelChangeContext context,
- Model model, ModelObject mobj, ModelObject ref) {
- ESBLanguageModel esbModel=(ESBLanguageModel)model;
- ESBService service=getESBService(context, ref);
- ESBService original=service;
- While whileElem=(While)mobj;
-
- int pos=getPosition(service, ref);
-
- // Check if action needs to be placed in new service
- // descriptor - i.e. if insert at end, but current service
- // already has service based actions, or reference object
- // provided, but is not first position
- if (shouldScheduleNewService(service, (pos == -1 ?
- service.getActions().size() : pos))) {
-
- ESBService whileService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(whileService);
-
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- // 'immediate' flag set depending on whether the role
- // is an initiator of the while. If not, then the
- // immediate flag is false, which means the loop will be
- // evaluated based on the next received message
- schedule.setDestination(whileService.getCategory(),
- whileService.getName(),
- whileElem.getRoles().contains(context.getRole()));
- service.addAction(schedule, pos);
-
- context.setParent(whileService);
-
- service = whileService;
- }
-
- WhileAction action=new WhileAction(service);
-
- service.addAction(action, -1);
-
- // Check if business object type needs to be specified
- if (service.getFirstSessionBasedAction() == action &&
- whileElem.getEnclosingDefinition() instanceof Conversation) {
- action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)whileElem.getEnclosingDefinition())));
- }
-
- ESBService subService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(subService);
-
- // Configure the while loop service
- context.setParent(subService);
-
- for (int j=0; j < whileElem.getBlock().getContents().size(); j++) {
- context.insert(model, whileElem.getBlock().getContents().get(j), null);
- }
-
- // Need to insert a 'ScheduleStateAction' to return back
- // to the 'WhileAction', to re-evaluate the expression
- ScheduleStateAction schedule=
- new ScheduleStateAction((ESBService)context.getParent());
-
- // 'immediate' flag set depending on whether the role
- // is an initiator of the while. If not, then the
- // immediate flag is false, which means the loop will be
- // evaluated based on the next received message
- schedule.setDestination(service.getCategory(),
- service.getName(),
- whileElem.getRoles().contains(context.getRole()));
- ((ESBService)context.getParent()).addAction(schedule, -1);
-
- // Check if business object type needs to be specified
- if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
- whileElem.getEnclosingDefinition() instanceof Conversation) {
- schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
- ((Conversation)whileElem.getEnclosingDefinition())));
- }
-
- // Check whether message types need to be defined in
- // place of an expression
- java.util.List<MessageSignature> messageTypes=
- new java.util.Vector<MessageSignature>();
-
- // Check if context role is NOT the decision maker
- if (whileElem.getRoles().contains(context.getRole()) == false) {
-
- // Get lookahead analyser
- LookaheadAnalyser la=(LookaheadAnalyser)
- RegistryFactory.getRegistry().getExtension(
- LookaheadAnalyser.class, null);
-
- if (la == null) {
- logger.severe("Failed to find lookahead analyser");
- }
-
- java.util.Set<Interaction> interactions=null;
-
- if (la != null) {
- interactions = la.getInteractions(whileElem.getBlock());
- }
-
- if (interactions != null) {
- java.util.Iterator<Interaction> iter=interactions.iterator();
-
- while (iter.hasNext()) {
- Interaction interaction=iter.next();
-
- if (InteractionUtil.isSend(interaction) == false &&
- interaction.getMessageSignature().getTypes().size()==1) {
-
- messageTypes.add(interaction.getMessageSignature());
- }
- }
- }
-
- }
-
- action.addPath(subService.getCategory(),
- subService.getName(), false, messageTypes, -1);
-
- // Create exit service
- ESBService exitService=
- esbModel.createService(service.getCategory(),
- esbModel.getUniqueServiceName(service.getCategory(),
- service.getName()));
-
- esbModel.addService(exitService);
-
- context.setParent(exitService);
-
- action.addPath(exitService.getCategory(),
- exitService.getName(), true,
- new java.util.Vector<MessageSignature>(), -1);
-
- // If reference provided, then move subsequent activities
- // to the 'exit service'
- if (pos != -1) {
- for (int i=pos+1; i < original.getActions().size();) {
- ESBAction act=original.getActions().get(i);
- original.getActions().remove(i);
-
- exitService.addAction(act, -1);
- }
- }
-
- return(true);
- }
-
- private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
-}
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java (from rev 462, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/AbstractESBModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,173 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractESBModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if ((context.getParent() instanceof ESBService ||
+ (ref != null && ref.getSource().getObject()
+ instanceof AbstractStatefulESBAction &&
+ ((AbstractStatefulESBAction)ref.getSource().getObject()).getService() != null)) &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the ESB service associated with the
+ * optional model object reference or the context.
+ *
+ * @param context The context
+ * @param ref The optional model object
+ * @return The ESB service, or null if not found
+ */
+ protected ESBService getESBService(ModelChangeContext context,
+ ModelObject ref) {
+ ESBService ret=(ESBService)context.getParent();
+
+ if (ref != null && ref.getSource().getObject() instanceof AbstractStatefulESBAction) {
+ ret = ((AbstractStatefulESBAction)ref.getSource().getObject()).getService();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the position of the supplied
+ * model object within the supplied service.
+ *
+ * @param service The service
+ * @param ref The optional model object
+ * @return The position, or -1 if not found
+ */
+ protected int getPosition(ESBService service, ModelObject ref) {
+ int ret=-1;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ if (ref != null && ref.getSource().getObject() instanceof ESBAction) {
+ ret = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether an 'initiator' action,
+ * inserted at the defined position in the specified
+ * service, should actually be placed in a new scheduled
+ * service.
+ *
+ * @param service The current service
+ * @param pos The insertion position in that service
+ * @return Whether a new service needs to be scheduled to
+ * accommodate the initiator action
+ */
+ protected boolean shouldScheduleNewService(ESBService service,
+ int pos) {
+ boolean ret=false;
+
+ for (int i=0; ret == false && i < pos; i++) {
+ ESBAction action=service.getActions().get(i);
+
+ if (action.isSessionBased() && !action.isSessionType()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj.getSource().getObject() instanceof AbstractStatefulESBAction &&
+ (context.getParent() instanceof ESBService ||
+ ((AbstractStatefulESBAction)mobj.getSource().getObject()).getService() != null) &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ if (action != null && service != null) {
+ ret = service.getActions().remove(action);
+ }
+
+ return(ret);
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/AbstractESBModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,553 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.IdentityUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+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 Conversation Interaction.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationInteractionModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj,
+ ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction interaction=(ConversationInteraction)mobj;
+
+ // Check if send or receive
+ if (InteractionUtil.isSend(interaction)) {
+
+ // Send
+ insertSend(context, esbModel, interaction, ref);
+
+ } else {
+ // Receive
+ insertReceive(context, esbModel, interaction, ref);
+ }
+
+ return(true);
+ }
+
+ protected void insertSend(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+
+ SendMessageAction action=
+ new SendMessageAction(service);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ boolean f_subsequentInitiator=false;
+ boolean f_moveActions=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ // Move actions if a subsequent initiator has been found
+ f_moveActions = f_subsequentInitiator;
+
+ service.addAction(action, pos);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == action &&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ if (interaction.getRequestLabel() != null) {
+
+ // Create new ESB service
+ ESBService respService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(respService);
+
+ action.setResponseDestination(respService.getCategory(),
+ respService.getName());
+
+ context.setParent(respService);
+
+ // Clear the sub-sequent initiator flag, as
+ // subsequent actions will be moved to new service
+ // anyway
+ f_subsequentInitiator = false;
+
+ } else if (interaction.getReplyToLabel() != null) {
+
+ if (interaction.getToRole() != null) {
+ action.setClientEPR(interaction.getToRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ service.addAction(schedule, pos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+ }
+
+ // Check if existing actions need to be moved
+ if (f_moveActions) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBService extraService=(ESBService)context.getParent();
+
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ extraService.addAction(act, -1);
+ }
+ }
+
+ // If not reply, then include the target service
+ // details
+ if (interaction.getReplyToLabel() == null &&
+ interaction.getToRole() != null &&
+ interaction.getToRole().getName() != null &&
+ interaction.getToRole().getName().length() > 0) {
+ String roleName=Character.toLowerCase(
+ interaction.getToRole().getName().charAt(0))+
+ interaction.getToRole().getName().substring(1);
+
+ action.setDestinationExpression(
+ InteractionUtil.getRoleServiceCategoryProperty(roleName),
+ InteractionUtil.getRoleServiceNameProperty(roleName));
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ }
+
+ protected void insertReceive(ModelChangeContext context,
+ ESBLanguageModel esbModel, ConversationInteraction interaction,
+ ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+ ESBService endService=service;
+
+ int endPos=-1;
+ boolean f_subsequentInitiator=false;
+
+ // Check if reference model object provided, and if so,
+ // if it has a position within the service
+ int pos=getPosition(service, ref);
+
+ // Check if subsequent action(s) are initiators
+ if (pos != -1) {
+ for (int i=pos; f_subsequentInitiator == false &&
+ i < service.getActions().size(); i++) {
+ f_subsequentInitiator =
+ service.getActions().get(i).isInitiator();
+ }
+ }
+
+ endPos = pos;
+
+ // Check if receive needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService recvService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(recvService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(recvService.getCategory(),
+ recvService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(recvService);
+
+ endService = recvService;
+ endPos = 0;
+ }
+
+ ReceiveMessageAction action=
+ new ReceiveMessageAction(endService);
+
+ if (interaction.getMessageSignature().getOperation() != null) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+
+ setMessageType(action, interaction);
+
+ endService.addAction(action, endPos);
+
+ if (endService.getFirstSessionBasedAction() == action &&
+ interaction.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)interaction.getEnclosingDefinition())));
+ }
+
+ // Check if subsequent initiator found, requiring
+ // a new service
+ if (f_subsequentInitiator) {
+
+ ESBService extraService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(endService.getCategory(),
+ endService.getName()));
+
+ esbModel.addService(extraService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(endService);
+
+ schedule.setDestination(extraService.getCategory(),
+ extraService.getName(), false);
+
+ endService.addAction(schedule, endPos+1);
+
+ // Move pointer on, as now additional 'schedule' action
+ pos++;
+
+ context.setParent(extraService);
+
+ endService = extraService;
+ endPos = -1;
+ }
+
+ // Check if existing actions need to be moved
+ if (pos != -1 && service != endService) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ endService.addAction(act, -1);
+ }
+ }
+
+ // If not a response, then add to the gateway
+ if (interaction.getReplyToLabel() == null) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ java.util.List<MessageSignature> mtypes=
+ new java.util.Vector<MessageSignature>();
+ mtypes.add(interaction.getMessageSignature());
+
+ mra.addRoute(endService.getCategory(),
+ endService.getName(),
+ service.isRoot(), mtypes);
+ }
+ }
+
+ // Set client EPR
+ if (interaction.getFromRole() != null) {
+ action.setClientEPR(interaction.getFromRole().getName());
+ } else {
+ action.setClientEPR("client");
+ }
+ }
+
+ if (interaction.getEnclosingDefinition() instanceof Conversation &&
+ interaction.getEnclosingDefinition().getModel()
+ instanceof ConversationModel) {
+
+ java.util.List<Identity> ids=((Conversation)
+ interaction.getEnclosingDefinition()).getIdentities();
+
+ java.util.List<IdentityLocator> locators=
+ ((ConversationModel)interaction.getEnclosingDefinition().
+ getModel()).getIdentityLocators();
+
+ IdentityUtil.defineIdentities(action.getPropertyElement(
+ SendMessageAction.IDENTITIES),
+ interaction.getMessageSignature(), ids, locators);
+ }
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof ConversationInteraction &&
+ toObj instanceof ConversationInteraction &&
+ context.getParent() instanceof ESBService &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+ ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+ ESBService service=(ESBService)context.getParent();
+
+ // Get action from 'toInteraction'
+ if (toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ 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=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,181 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+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 Conversation.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ConversationModelChangeRule extends AbstractModelChangeRule {
+
+ private static final String NAME_SUFFIX = "_main";
+
+ /**
+ * 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
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Conversation &&
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ Conversation conv=(Conversation)mobj;
+
+ String namespace=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ String category=ConversationUtil.getServiceCategory(conv);
+
+ String name=ConversationUtil.getServiceName(conv);
+
+ String sdname="";
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+
+ // Register gateway service
+ DefaultESBService gateway=new DefaultESBService(esbModel,
+ category, name);
+
+ MessageRouterAction mra=new MessageRouterAction(gateway);
+
+ // Construct service description name
+ if (namespace != null) {
+ sdname = "{"+namespace+"}";
+ }
+
+ sdname += conv.getModelName().getName()+"-"+
+ conv.getModelName().getLocatedRole().getName();
+
+ mra.setServiceDescriptionName(sdname);
+
+ gateway.addAction(mra, -1);
+
+ esbModel.addService(gateway);
+
+ name += NAME_SUFFIX;
+ }
+
+ // Create new ESB service
+ ESBService service=esbModel.createService(category, name);
+
+ esbModel.addService(service);
+
+ // Create 'CreateSession' activity
+ CreateSessionAction csa=new CreateSessionAction(service);
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+ csa.setRoot(true);
+
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getModelName().getName()+"@"+
+ conv.getModelName().getLocatedRole().getName();
+ }
+
+ if (ctype != null) {
+ csa.setConversationType(ctype);
+ }
+ }
+
+ csa.setServiceDescriptionName(sdname);
+ csa.setBusinessObjectType(ConversationUtil.getBusinessObjectType(conv));
+
+ 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, acts.get(i), null);
+ }
+
+ return(true);
+ }
+
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,416 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the If grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class IfModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof If &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ If ifElem=(If)mobj;
+
+ int pos=getPosition(service, ref);
+
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Check if should be an 'if' or a 'switch' action
+ if (ifElem.getRoles().contains(context.getRole())) {
+
+ insertIf(context, model, service, ifElem, joinService, pos);
+ } else {
+ insertSwitch(context, model, service, ifElem, joinService, pos);
+ }
+
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertIf(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // If action, because the role is a decision maker
+ IfAction ifAction=new IfAction(service);
+
+ service.addAction(ifAction, pos);
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath((i==0 ? IfAction.IF : IfAction.ELSEIF),
+ subService.getCategory(), subService.getName(),
+ immediate, null, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ boolean immediate=false;
+
+ ifAction.addPath(IfAction.ELSE,
+ subService.getCategory(), subService.getName(),
+ immediate, null, -1);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == ifAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ ifAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ If ifElem, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
+
+ service = switchService;
+ pos = -1;
+ }
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < ifElem.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=ifElem.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ if (ifElem.getElseBlock() != null) {
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < ifElem.getElseBlock().getContents().size(); j++) {
+ context.insert(model,
+ ifElem.getElseBlock().getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(ifElem.getElseBlock());
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, -1);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ ifElem.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)ifElem.getEnclosingDefinition())));
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/LanguageToConversationModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,97 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+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 inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ConversationModel cm=(ConversationModel)mobj;
+
+ if (cm.getConversation() != null) {
+ context.insert(model, cm.getConversation(), null);
+ }
+
+ return(true);
+ }
+
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/LanguageToConversationModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/MessageSignatureModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,180 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+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 MessageSignature.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class MessageSignatureModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof MessageSignature &&
+ toObj instanceof MessageSignature &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ MessageSignature fromMS=(MessageSignature)fromObj;
+ MessageSignature toMS=(MessageSignature)toObj;
+ ConversationInteraction toInteraction=null;
+ ConversationInteraction fromInteraction=null;
+
+ if (toMS != null &&
+ toMS.getParent() instanceof ConversationInteraction) {
+ toInteraction = (ConversationInteraction)toMS.getParent();
+ }
+
+ if (fromMS != null &&
+ fromMS.getParent() instanceof ConversationInteraction) {
+ fromInteraction = (ConversationInteraction)fromMS.getParent();
+ }
+
+ // Get action from 'toInteraction'
+ if (toInteraction != null &&
+ toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ // Update operation
+ setOperation(ma, fromInteraction);
+
+ ESBService service = ma.getService();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ 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=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+
+ protected void setOperation(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+ action.setOperation(interaction.getMessageSignature().getOperation());
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/MessageSignatureModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,192 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Parallel grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class ParallelModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Parallel &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ Parallel parallel=(Parallel)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Create the join service
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Create and configure the parallel action
+ ParallelAction parAction=new ParallelAction(service);
+
+ service.addAction(parAction, pos);
+
+ for (int i=0; i < parallel.getBlocks().size(); i++) {
+ Block b=parallel.getBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), null);
+ }
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ parallel.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)parallel.getEnclosingDefinition())));
+ }
+
+ boolean immediate=true;
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to get lookahead analyser");
+ } else {
+ java.util.Iterator<Interaction> iter=
+ la.getInteractions(b, true).iterator();
+
+ while (immediate && iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ // If interaction is a receive, then immediate
+ // invocation will be false
+ immediate = InteractionUtil.isSend(interaction);
+ }
+ }
+
+ parAction.addPath(subService.getCategory(),
+ subService.getName(), immediate, false, i);
+ }
+
+ context.setParent(joinService);
+
+ parAction.addPath(joinService.getCategory(),
+ joinService.getName(), false, true, -1);
+
+ // Check if business object type needs to be specified
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == parAction &&
+ parallel.getEnclosingDefinition() instanceof Conversation) {
+ parAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)parallel.getEnclosingDefinition())));
+ }
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,201 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Run composition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class RunModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ Run run=(Run)mobj;
+
+ int pos=getPosition(service, ref);
+
+ PerformAction action=new PerformAction(service);
+
+ service.addAction(action, pos);
+
+ String category=ConversationUtil.getServiceCategory(run.getDefinition());
+ String name=ConversationUtil.getServiceName(run.getDefinition());
+
+ action.setDestination(category, name);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ run.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)run.getEnclosingDefinition())));
+ }
+
+ // Create return service
+ ESBService returnService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(returnService);
+
+ context.setParent(returnService);
+
+ action.setReturnDestination(returnService.getCategory(),
+ returnService.getName());
+
+ // If reference provided, then move subsequent activities
+ // to the 'return service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ returnService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+ ESBService service=getESBService(context, mobj);
+ ESBAction action=(ESBAction)mobj.getSource().getObject();
+
+ int pos=getPosition(service, mobj);
+
+ if (action instanceof PerformAction && pos != -1) {
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ PerformAction perform=(PerformAction)action;
+
+ schedule.setDestination(perform.getPropertyValue(PerformAction.RETURN_SERVICE_CATEGORY),
+ perform.getPropertyValue(PerformAction.RETURN_SERVICE_NAME), true);
+
+ service.addAction(schedule, pos);
+
+ ret = super.delete(context, model, mobj);
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,138 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+//import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the Spawn composition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class SpawnModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Spawn &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBService service=getESBService(context, ref);
+ Spawn spawn=(Spawn)mobj;
+
+ int pos=getPosition(service, ref);
+
+ PerformAction action=new PerformAction(service);
+
+ service.addAction(action, pos);
+
+ String category=ConversationUtil.getServiceCategory(spawn.getDefinition());
+ String name=ConversationUtil.getServiceName(spawn.getDefinition());
+
+ action.setDestination(category, name);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ spawn.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)spawn.getEnclosingDefinition())));
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Spawn &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ //private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/TypeReferenceModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,172 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+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 Type Reference.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class TypeReferenceModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof TypeReference &&
+ toObj instanceof TypeReference &&
+ model instanceof ESBLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ TypeReference fromTypeRef=(TypeReference)fromObj;
+ TypeReference toTypeRef=(TypeReference)toObj;
+ ConversationInteraction toInteraction=null;
+ ConversationInteraction fromInteraction=null;
+
+ if (toTypeRef != null && toTypeRef.getParent() instanceof MessageSignature &&
+ toTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ toInteraction = (ConversationInteraction)toTypeRef.getParent().getParent();
+ }
+
+ if (fromTypeRef != null && fromTypeRef.getParent() instanceof MessageSignature &&
+ fromTypeRef.getParent().getParent() instanceof ConversationInteraction) {
+ fromInteraction = (ConversationInteraction)fromTypeRef.getParent().getParent();
+ }
+
+ // Get action from 'toInteraction'
+ if (toInteraction != null &&
+ toInteraction.getSource().getObject() instanceof
+ AbstractInteractionMessageAction) {
+ AbstractInteractionMessageAction ma=
+ (AbstractInteractionMessageAction)
+ toInteraction.getSource().getObject();
+
+ ESBService service = ma.getService();
+
+ String origMesgType=ma.getMessageType();
+
+ // Set message type
+ setMessageType(ma, fromInteraction);
+
+ // Update message type in router if appropriate
+ if (InteractionUtil.isSend(fromInteraction) == false &&
+ fromInteraction.getReplyToLabel() == null) {
+ updateRouterMessageType(esbModel, service,
+ origMesgType, ma);
+ }
+
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected void updateRouterMessageType(ESBLanguageModel esbModel,
+ ESBService service, String origMesgType,
+ AbstractInteractionMessageAction ma) {
+ ESBService gwService=esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ org.w3c.dom.Element route=
+ mra.getRouteElement(service.getCategory(),
+ service.getName());
+
+ if (route != null) {
+ org.w3c.dom.NodeList nl=
+ route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ org.w3c.dom.Element mesg=
+ (org.w3c.dom.Element)nl.item(i);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).
+ equals(origMesgType)) {
+ mesg.setAttribute(MessageRouterAction.TYPE_ATTR,
+ ma.getMessageType());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void setMessageType(AbstractInteractionMessageAction action,
+ ConversationInteraction interaction) {
+
+ 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=InteractionUtil.getTypeString(ref);
+
+ action.setMessageType(mtype);
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/TypeReferenceModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,322 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the When grouping construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhenModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof When &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ When when=(When)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Create join service
+ ESBService joinService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(joinService);
+
+ // Check if context role is decision maker
+ if (when.getRoles().contains(context.getRole())) {
+
+ insertWhen(context, model, service,
+ when, joinService, pos);
+ } else {
+ insertSwitch(context, model, service,
+ when, joinService, pos);
+ }
+
+ context.setParent(joinService);
+
+ // If reference provided, then move subsequent activities
+ // to the 'join service'
+ if (pos != -1) {
+ for (int i=pos+1; i < service.getActions().size();) {
+ ESBAction act=service.getActions().get(i);
+ service.getActions().remove(i);
+
+ joinService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ protected void insertWhen(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ WhenAction action=new WhenAction(service);
+
+ service.addAction(action, pos);
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock b=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < b.getContents().size(); j++) {
+ context.insert(model, b.getContents().get(j), null);
+ }
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), i);
+ }
+
+ if (service.getFirstSessionBasedAction() == action &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ protected void insertSwitch(ModelChangeContext context,
+ Model model, ESBService service,
+ When when, ESBService joinService, int pos) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+
+ // Check if 'when' needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ // Already has activities, so need to separate
+ // into another service descriptor
+ ESBService switchService=esbModel.createService(
+ service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(switchService);
+
+ // Add schedule action
+ ScheduleStateAction schedule=
+ new ScheduleStateAction(service);
+
+ schedule.setDestination(switchService.getCategory(),
+ switchService.getName(), false);
+
+ service.addAction(schedule, pos);
+
+ context.setParent(switchService);
+
+ service = switchService;
+ pos = -1;
+ }
+
+ // Switch action, as role is a decision observer
+ SwitchAction switchAction=new SwitchAction(service);
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ service.addAction(switchAction, pos);
+
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ for (int i=0; i < when.getConditionalBlocks().size(); i++) {
+ ConditionalBlock cb=when.getConditionalBlocks().get(i);
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ context.setParent(subService);
+
+ for (int j=0; j < cb.getContents().size(); j++) {
+ context.insert(model, cb.getContents().get(j), null);
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(cb);
+ }
+
+ switchAction.addCase(subService.getCategory(),
+ subService.getName(), interactions, i);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ schedule.setDestination(joinService.getCategory(),
+ joinService.getName(), true);
+
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ //TODO: Only deals with single type for now
+ // If a receive and not a response, then
+ // add to the gateway
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getReplyToLabel() == null &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+ }
+
+ // Only record message router 'routes' if the switch
+ // receives request interactions, and it is the first
+ // session based action in the service
+ if (messageTypes.size() > 0 &&
+ service.getFirstSessionBasedAction() == switchAction) {
+ ESBService gwService=
+ esbModel.getGatewayService();
+
+ if (gwService != null) {
+ ESBAction gwAction=gwService.getGatewayAction();
+
+ if (gwAction instanceof MessageRouterAction) {
+ MessageRouterAction mra=(MessageRouterAction)
+ gwAction;
+
+ mra.addRoute(service.getCategory(),
+ service.getName(),
+ false, messageTypes);
+ }
+ }
+ }
+
+ if (service.getFirstSessionBasedAction() == switchAction &&
+ when.getEnclosingDefinition() instanceof Conversation) {
+ switchAction.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)when.getEnclosingDefinition())));
+ }
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRule.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,246 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.model.analysis.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.*;
+
+/**
+ * This is the model change rule for the While repetition construct.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=ESBLanguageModel.JBOSSESB_NOTATION)
+public class WhileModelChangeRule extends AbstractESBModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof While &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ 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.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ESBLanguageModel esbModel=(ESBLanguageModel)model;
+ ESBService service=getESBService(context, ref);
+ ESBService original=service;
+ While whileElem=(While)mobj;
+
+ int pos=getPosition(service, ref);
+
+ // Check if action needs to be placed in new service
+ // descriptor - i.e. if insert at end, but current service
+ // already has service based actions, or reference object
+ // provided, but is not first position
+ if (shouldScheduleNewService(service, (pos == -1 ?
+ service.getActions().size() : pos))) {
+
+ ESBService whileService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(whileService);
+
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ // 'immediate' flag set depending on whether the role
+ // is an initiator of the while. If not, then the
+ // immediate flag is false, which means the loop will be
+ // evaluated based on the next received message
+ schedule.setDestination(whileService.getCategory(),
+ whileService.getName(),
+ whileElem.getRoles().contains(context.getRole()));
+ service.addAction(schedule, pos);
+
+ context.setParent(whileService);
+
+ service = whileService;
+ }
+
+ WhileAction action=new WhileAction(service);
+
+ service.addAction(action, -1);
+
+ // Check if business object type needs to be specified
+ if (service.getFirstSessionBasedAction() == action &&
+ whileElem.getEnclosingDefinition() instanceof Conversation) {
+ action.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)whileElem.getEnclosingDefinition())));
+ }
+
+ ESBService subService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(subService);
+
+ // Configure the while loop service
+ context.setParent(subService);
+
+ for (int j=0; j < whileElem.getBlock().getContents().size(); j++) {
+ context.insert(model, whileElem.getBlock().getContents().get(j), null);
+ }
+
+ // Need to insert a 'ScheduleStateAction' to return back
+ // to the 'WhileAction', to re-evaluate the expression
+ ScheduleStateAction schedule=
+ new ScheduleStateAction((ESBService)context.getParent());
+
+ // 'immediate' flag set depending on whether the role
+ // is an initiator of the while. If not, then the
+ // immediate flag is false, which means the loop will be
+ // evaluated based on the next received message
+ schedule.setDestination(service.getCategory(),
+ service.getName(),
+ whileElem.getRoles().contains(context.getRole()));
+ ((ESBService)context.getParent()).addAction(schedule, -1);
+
+ // Check if business object type needs to be specified
+ if (((ESBService)context.getParent()).getFirstSessionBasedAction() == schedule &&
+ whileElem.getEnclosingDefinition() instanceof Conversation) {
+ schedule.setBusinessObjectType(ConversationUtil.getBusinessObjectType(
+ ((Conversation)whileElem.getEnclosingDefinition())));
+ }
+
+ // Check whether message types need to be defined in
+ // place of an expression
+ java.util.List<MessageSignature> messageTypes=
+ new java.util.Vector<MessageSignature>();
+
+ // Check if context role is NOT the decision maker
+ if (whileElem.getRoles().contains(context.getRole()) == false) {
+
+ // Get lookahead analyser
+ LookaheadAnalyser la=(LookaheadAnalyser)
+ RegistryFactory.getRegistry().getExtension(
+ LookaheadAnalyser.class, null);
+
+ if (la == null) {
+ logger.severe("Failed to find lookahead analyser");
+ }
+
+ java.util.Set<Interaction> interactions=null;
+
+ if (la != null) {
+ interactions = la.getInteractions(whileElem.getBlock());
+ }
+
+ if (interactions != null) {
+ java.util.Iterator<Interaction> iter=interactions.iterator();
+
+ while (iter.hasNext()) {
+ Interaction interaction=iter.next();
+
+ if (InteractionUtil.isSend(interaction) == false &&
+ interaction.getMessageSignature().getTypes().size()==1) {
+
+ messageTypes.add(interaction.getMessageSignature());
+ }
+ }
+ }
+
+ }
+
+ action.addPath(subService.getCategory(),
+ subService.getName(), false, messageTypes, -1);
+
+ // Create exit service
+ ESBService exitService=
+ esbModel.createService(service.getCategory(),
+ esbModel.getUniqueServiceName(service.getCategory(),
+ service.getName()));
+
+ esbModel.addService(exitService);
+
+ context.setParent(exitService);
+
+ action.addPath(exitService.getCategory(),
+ exitService.getName(), true,
+ new java.util.Vector<MessageSignature>(), -1);
+
+ // If reference provided, then move subsequent activities
+ // to the 'exit service'
+ if (pos != -1) {
+ for (int i=pos+1; i < original.getActions().size();) {
+ ESBAction act=original.getActions().get(i);
+ original.getActions().remove(i);
+
+ exitService.addAction(act, -1);
+ }
+ }
+
+ return(true);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change");
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRule.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,1847 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ConversationInteractionModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class ConversationInteractionModelChangeRuleTest extends TestCase {
-
- public void testInsertFirstReceiveAction() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
- }
-
- public void testInsertFirstReceiveAfterCreateSessionAction() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add 'create session' action
- TestESBAction act=new TestESBAction();
- act.setCreateSession(true);
- service.addAction(act, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof TestESBAction) == false) {
- fail("Action was not TestESBAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
- }
-
- public void testInsertSecondReceiveAction() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
- fail("Schedule should not be immediate");
- }
-
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 2) {
- fail("Two routes expected: "+mra.getNumberOfRoutes());
- }
- }
-
-
- public void testInsertMiddleReceiveBetweenTwoReceives() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- ReceiveMessageAction recv2=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+recv2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setToRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // receive
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
-
- ESBService newService2=model.getService(ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME));
-
- if (newService2 == null) {
- fail("Failed to find final service");
- }
-
- if (newService2.getActions().size() != 1) {
- fail("Only expecting one action: "+newService2.getActions().size());
- }
-
- ReceiveMessageAction recv4=(ReceiveMessageAction)
- newService2.getActions().get(0);
-
- String mtype4=InteractionUtil.getTypeString(ref2);
-
- if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
- fail("Message type '"+recv4.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype4);
- }
-
-
- ReceiveMessageAction recv3=(ReceiveMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+recv3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertMiddleSendBetweenTwoReceives() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setToRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Expecting 1 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- ReceiveMessageAction recv2=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+recv2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setFromRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // receive
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction: "+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
-
- ESBService newService2=model.getService(ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME));
-
- if (newService2 == null) {
- fail("Failed to find final service");
- }
-
- if (newService2.getActions().size() != 1) {
- fail("Only expecting one action: "+newService2.getActions().size());
- }
-
- if ((newService2.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Expecting ReceiveMessageAction, but got: "+newService2.getActions().get(0));
- }
-
- ReceiveMessageAction recv4=(ReceiveMessageAction)
- newService2.getActions().get(0);
-
- String mtype4=InteractionUtil.getTypeString(ref2);
-
- if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
- fail("Message type '"+recv4.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype4);
- }
-
-
- SendMessageAction send3=(SendMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (send3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+send3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertMiddleReceiveBetweenTwoSends() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setFromRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- ConversationInteraction mobj2=new ConversationInteraction();
- mobj2.setFromRole(role);
- conv.getBlock().getContents().add(mobj2);
-
- MessageSignature msig2=new MessageSignature();
- mobj2.setMessageSignature(msig2);
-
- TypeReference ref2=new TypeReference();
- ref2.setNamespace("ns");
- ref2.setLocalpart("lp2");
-
- msig2.getTypes().add(ref2);
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- if (rule.insert(context, model, mobj2, null) == false) {
- fail("Failed to insert 2");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- SendMessageAction send2=(SendMessageAction)
- service.getActions().get(1);
-
-
- String mtype=InteractionUtil.getTypeString(ref2);
-
- if (send2.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+send2.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- send2.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // Now second service identified, add new receive
- // action to ensure that third service inserted in the
- // middle
- ConversationInteraction mobj3=new ConversationInteraction();
- mobj3.setToRole(role);
- conv.getBlock().getContents().add(mobj3);
-
- MessageSignature msig3=new MessageSignature();
- mobj3.setMessageSignature(msig3);
-
- TypeReference ref3=new TypeReference();
- ref3.setNamespace("ns");
- ref3.setLocalpart("lp3");
-
- msig3.getTypes().add(ref3);
-
- // Insert into position 1, which should be after first
- // send
-
- // TODO: Need to pass representation of last interaction
- if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
- fail("Failed to insert 3");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Now Expecting 2 action: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction: "+newService.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- ReceiveMessageAction recv3=(ReceiveMessageAction)
- newService.getActions().get(0);
-
- String mtype3=InteractionUtil.getTypeString(ref3);
-
- if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
- fail("Message type '"+recv3.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype3);
- }
- }
-
- public void testInsertReceiveRequestAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(toRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(toRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) == false) {
- fail("Client EPR '"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
- "' invalid, expecting: "+fromRoleName);
- }
- }
-
- public void testInsertFirstSendAction() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(role);
- conv.getBlock().getContents().add(mobj);
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
- }
-
- public void testInsertSendRequestAction() {
- String roleName="role1";
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName(roleName);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(role);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- if (newService.getCategory().equals(action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- action.getPropertyValue(
- SendMessageAction.RESPONSE_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
- }
-
- public void testInsertSendNotReplyAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(fromRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(fromRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setRequestLabel("reqLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two service expected: "+model.getServices().size());
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
- equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
- fail("Service category expression '"+
- action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
- "' invalid, expecting: "+
- InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
- }
-
- if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
- equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
- fail("Service name expression '"+
- action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
- "' invalid, expecting: "+
- InteractionUtil.getRoleServiceNameProperty(toRoleName));
- }
- }
-
- public void testInsertSendReplyAction() {
- String fromRoleName="role1";
- String toRoleName="role2";
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role fromRole=new Role();
- fromRole.setName(fromRoleName);
-
- Role toRole=new Role();
- toRole.setName(toRoleName);
-
- context.setRole(fromRole);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(fromRole);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setFromRole(fromRole);
- mobj.setToRole(toRole);
- conv.getBlock().getContents().add(mobj);
-
- mobj.setReplyToLabel("replyLabel");
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- msig.getTypes().add(ref);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
- fail("Action was not SendMessageAction: "+service.getActions().get(0));
- }
-
- SendMessageAction action=(SendMessageAction)service.getActions().get(0);
-
- if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false) {
- fail("Client EPR '"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
- "' invalid, expecting: "+toRoleName);
- }
- }
-
- public void testChangeFirstReceiveAction() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj=new ConversationInteraction();
- mobj.setToRole(role);
- conv.getBlock().getContents().add(mobj);
-
-
- MessageSignature msig=new MessageSignature();
- mobj.setMessageSignature(msig);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp1");
-
- msig.getTypes().add(ref);
-
- // Create ReceiveMessageAction
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
-
- java.util.List<Activity> activities=new java.util.Vector<Activity>();
- action.convert(activities, new DefaultConversionContext(null));
-
- if (activities.size() != 1) {
- fail("Expecting single interaction activity from ReceiveMessageAction: "+activities.size());
- }
-
- if ((activities.get(0) instanceof ConversationInteraction) == false) {
- fail("Not conversation interaction");
- }
-
- ConversationInteraction recvci=(ConversationInteraction)activities.get(0);
-
- String mtype=InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- // Change local part
- ref.setLocalpart("lp2");
-
- if (rule.update(context, model, mobj, recvci) == false) {
- fail("Failed to update");
- }
-
- // Re-check the message type, to make sure has been updated
- mtype = InteractionUtil.getTypeString(ref);
-
- if (action.getPropertyValue("messageType").equals(mtype)==false) {
- fail("Message type '"+action.getPropertyValue("messageType")+
- "' invalid, expecting: "+mtype);
- }
-
- if (mra.getNumberOfRoutes() != 1) {
- fail("One route expected: "+mra.getNumberOfRoutes());
- }
-
- org.w3c.dom.Element route=mra.getRouteElement(0);
-
- org.w3c.dom.NodeList mesgs=route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
-
- if (mesgs.getLength() != 1) {
- fail("Too many route message elements: "+mesgs.getLength());
- }
-
- org.w3c.dom.Element mesg=(org.w3c.dom.Element)mesgs.item(0);
-
- if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).equals(mtype) == false) {
- fail("Route message type has not been updated");
- }
- }
-
- public void testDeleteMiddleReceiveBetweenTwoActions() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setToRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- ((TestESBService)newService).setSessionBased(true);
-
- // Check schedule details
- ScheduleStateAction schedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (newService.getCategory().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)) == false) {
- fail("Schedule service category '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- service.getCategory());
- }
-
- if (newService.getName().equals(schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)) == false) {
- fail("Schedule service name '"+
- schedule.getPropertyValue(
- ScheduleStateAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- service.getName());
- }
-
- // Check actions
- if (newService.getActions().size() != 2) {
- fail("Expecting 2 actions: "+newService.getActions().size());
- }
-
- if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
- fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
- }
-
- if (newService.getActions().get(1) != act2) {
- fail("Action 2 was not 2nd test ESB action: "+newService.getActions().get(1));
- }
-
- ReceiveMessageAction recv=(ReceiveMessageAction)
- newService.getActions().get(0);
-
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- recv.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete receive");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- // TODO: Need to check if new service has been inserted
- // in the middle of the previously inserted interactions
-
- // Check actions
- if (newService.getActions().size() != 1) {
- fail("Now Expecting 1 action: "+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Action 1 was not 2nd test ESB action: "+newService.getActions().get(0));
- }
- }
-
- public void testDeleteMiddleSendBetweenTwoActions() {
- ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- // Add gateway service
- TestESBService gwservice=(TestESBService)
- model.createService("testcategory", "gateway");
- gwservice.setGateway(true);
-
- MessageRouterAction mra=new MessageRouterAction(gwservice);
- gwservice.setGatewayAction(mra);
-
- model.setGatewayService(gwservice);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- ConversationInteraction mobj1=new ConversationInteraction();
- mobj1.setFromRole(role);
- conv.getBlock().getContents().add(mobj1);
-
- MessageSignature msig1=new MessageSignature();
- mobj1.setMessageSignature(msig1);
-
- TypeReference ref1=new TypeReference();
- ref1.setNamespace("ns");
- ref1.setLocalpart("lp1");
-
- msig1.getTypes().add(ref1);
-
- if (rule.insert(context, model, mobj1, null) == false) {
- fail("Failed to insert 1");
- }
-
- // Once first interaction associated with service it
- // will become session based
- service.setSessionBased(true);
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
- fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Action 3 was not 2nd test ESB action: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
-
- SendMessageAction send=(SendMessageAction)
- service.getActions().get(1);
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- send.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete send");
- }
-
- // Re-Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action: "+service.getActions().get(0));
- }
-
- if (service.getActions().get(1) != act2) {
- fail("Action 2 was not 2nd test ESB action: "+service.getActions().get(1));
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,1069 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.IfModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class IfModelChangeRuleTest extends TestCase {
-
- public void testInsertIfAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (ifService == null && iter.hasNext()) {
- ifService = iter.next();
- if (ifService == service) {
- ifService = null;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
- }
-
- public void testInsertIfActionWithSubsequentActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (ifService == null) {
- ifService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertIfActionWithPrecedingActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof IfAction) == false) {
- fail("Action 2 was not IfAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (ifService == null) {
- ifService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertIfElseIfAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService elseIfService1=null;
- ESBService elseIfService2=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || elseIfService1 == null ||
- elseIfService2 == null || join==null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- ifService = serv;
- }
- if (serv.getName().endsWith("__2")) {
- elseIfService1 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- elseIfService2 = serv;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
-
- if (ifService.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+ifService.getActions().size());
- }
-
- if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+ifService.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("elseif") == false) {
- fail("ElseIf expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(elseIfService1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+elseIfService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseIfService1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseIfService1.getName());
- }
-
- if (elseIfService1.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+elseIfService1.getActions().size());
- }
-
- if ((elseIfService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseIfService1.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)elseIfService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("elseif") == false) {
- fail("ElseIf(2) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(elseIfService2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+elseIfService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseIfService2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseIfService2.getName());
- }
-
- if (elseIfService2.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+elseIfService2.getActions().size());
- }
-
- if ((elseIfService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseIfService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)elseIfService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertIfElseAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- If mobj=new If();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- Block b1=new Block();
- mobj.setElseBlock(b1);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof IfAction) == false) {
- fail("Action was not IfAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService ifService=null;
- ESBService elseService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((ifService == null || elseService == null ||
- join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- ifService = serv;
- }
- if (serv.getName().endsWith("__2")) {
- elseService = serv;
- }
- }
-
- IfAction action=(IfAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("if") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+ifService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+ifService.getName());
- }
-
- if (ifService.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+ifService.getActions().size());
- }
-
- if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+ifService.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("else") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(elseService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+elseService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(elseService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+elseService.getName());
- }
-
- if (elseService.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+elseService.getActions().size());
- }
-
- if ((elseService.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+elseService.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)ifService.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- }
-
- public void testInsertSwitchAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (switchService == null && iter.hasNext()) {
- switchService = iter.next();
- if (switchService == service) {
- switchService = null;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Switch expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+switchService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+switchService.getName());
- }
- }
-
- public void testInsertSwitchMultipleCaseAction() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- Block b1=new Block();
- mobj.setElseBlock(b1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("If expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService1.getName());
- }
-
- if (caseService1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
- }
-
- if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService2.getName());
- }
-
- if (caseService2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
- }
-
- if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService3.getName());
- }
-
- if (caseService3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
- }
-
- if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertSwitchActionWithSubsequentActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((switchService == null || join == null) && iter.hasNext()) {
- ESBService s = iter.next();
- if (s != service) {
- if (switchService == null) {
- switchService = s;
- } else if (join == null) {
- join = s;
- }
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertSwitchActionWithPrecedingActions() {
- IfModelChangeRule rule=new IfModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- If mobj=new If();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("First action not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
-
- ESBService addedService=model.getService(
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
-
- if (addedService == null) {
- fail("Failed to find service '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
- }
-
- if (addedService.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,624 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.ParallelModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.analysis.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class ParallelModelChangeRuleTest extends TestCase {
-
- public void testInsertParallelAction() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Parallel mobj=new Parallel();
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- Block cb2=new Block();
- mobj.getBlocks().add(cb2);
-
- Block cb3=new Block();
- mobj.getBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || s3 == null ||
- join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 4) {
- fail("Four path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(1) immediate not set");
- }
-
- if (s1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+s1.getActions().size());
- }
-
- if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(2) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(2) immediate not set");
- }
-
- if (s2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+s2.getActions().size());
- }
-
- if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(3) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s3.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(3) immediate not set");
- }
-
- if (s3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+s3.getActions().size());
- }
-
- if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(3);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelActionWithImmediateFalse() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
-
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- Parallel mobj=new Parallel();
- conv.getBlock().getContents().add(mobj);
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- cb1.getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("path(1) should not be immediate");
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelActionWithImmediateTrue() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setFromRole(role);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- Parallel mobj=new Parallel();
- conv.getBlock().getContents().add(mobj);
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- cb1.getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("path") == false) {
- fail("path(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (elem.getAttribute("immediate").equals("true") == false) {
- fail("path(1) should be immediate");
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
- }
-
- public void testInsertParallelMiddleAction() {
- ParallelModelChangeRule rule=new ParallelModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- Parallel mobj=new Parallel();
-
- Block cb1=new Block();
- mobj.getBlocks().add(cb1);
-
- Block cb2=new Block();
- mobj.getBlocks().add(cb2);
-
- Block cb3=new Block();
- mobj.getBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ParallelAction) == false) {
- fail("Action was not ParallelAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- ParallelAction action=(ParallelAction)service.getActions().get(1);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 4) {
- fail("Four path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(3);
-
- if (elem.getNodeName().equals("join") == false) {
- fail("join expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+join.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(join.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+join.getName());
- }
-
- if (elem.hasAttribute("immediate")) {
- fail("Join should not be immediate");
- }
-
- if (join.getActions().size() != 1) {
- fail("Expecting 1 join action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Action was not test ESB action 2: "+join.getActions().get(0));
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,471 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class RunModelChangeRuleTest extends TestCase {
-
- public void testInsertPerformAction() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(0);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
- }
-
- public void testInsertPerformActionMiddle() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action: "+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- }
- public void testDeletePerformActionMiddle() {
- String runName="subconv";
-
- RunModelChangeRule rule=new RunModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Run mobj=new Run();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- TestESBAction act2=new TestESBAction();
- ((ESBService)context.getParent()).addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- ESBService newService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
- while (newService == null && iter.hasNext()) {
- ESBService s=iter.next();
-
- if (s != service) {
- newService = s;
- }
- }
-
- if (newService == null) {
- fail("Other service not found");
- }
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- if (newService.getCategory().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
- fail("Perform return service category '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- newService.getCategory());
- }
-
- if (newService.getName().equals(action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)) == false) {
- fail("Perform return service name '"+
- action.getPropertyValue(
- PerformAction.RETURN_SERVICE_NAME)+
- "' invalid, expecting: "+
- newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action: "+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- action.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete spawn");
- }
-
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction ssa=(ScheduleStateAction)service.getActions().get(1);
-
- if (ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY).equals(newService.getCategory()) == false) {
- fail("Category not correct '"+ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY)+
- "' expecting: "+newService.getCategory());
- }
-
- if (ssa.getPropertyValue(PerformAction.SERVICE_NAME).equals(newService.getName()) == false) {
- fail("Name not correct '"+ssa.getPropertyValue(PerformAction.SERVICE_NAME)+
- "' expecting: "+newService.getName());
- }
-
- if (newService.getActions().size() != 1) {
- fail("Return service should have 1 action: "+newService.getActions().size());
- }
-
- if (newService.getActions().get(0) != act2) {
- fail("Expecting test ESB action 2: "+newService.getActions().get(0));
- }
-
- if (model.getServices().size() != 2) {
- fail("Two services expected: "+model.getServices().size());
- }
-
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,346 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.RunModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.SpawnModelChangeRule;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class SpawnModelChangeRuleTest extends TestCase {
-
- public void testInsertPerformAction() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 1) {
- fail("One service expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(0);
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- }
-
- public void testInsertPerformActionMiddle() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 3 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
- }
-
- public void testDeletePerformActionMiddle() {
- String runName="subconv";
-
- SpawnModelChangeRule rule=new SpawnModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- ConversationModel cm=new ConversationModel();
-
- Namespace ns=new Namespace();
- cm.setNamespace(ns);
- ns.setName("ns");
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- mname.setLocatedRole(role);
- conv.setModelName(mname);
-
- cm.setConversation(conv);
-
- Conversation subconv=new Conversation();
- ModelName submname=new ModelName();
- submname.setName(runName);
- submname.setLocatedRole(role);
- subconv.setModelName(mname);
-
- Spawn mobj=new Spawn();
- mobj.setInlineDefinition(subconv);
-
- conv.getBlock().getContents().add(mobj);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- // Check actions
- if (service.getActions().size() != 3) {
- fail("Expecting 3 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof PerformAction) == false) {
- fail("Action was not PerformAction: "+service.getActions().get(1));
- }
-
- if (service.getActions().get(2) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(2));
- }
-
- if (model.getServices().size() != 1) {
- fail("One services expected: "+model.getServices().size());
- }
-
- PerformAction action=(PerformAction)service.getActions().get(1);
-
- // Check details
- if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)) == false) {
- fail("Perform service category '"+
- action.getPropertyValue(
- PerformAction.SERVICE_CATEGORY)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceCategory(mobj.getDefinition()));
- }
-
- if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
- PerformAction.SERVICE_NAME)) == false) {
- fail("Perform service name '"+
- action.getPropertyValue(
- PerformAction.SERVICE_NAME)+
- "' invalid, expecting: "+
- ConversationUtil.getServiceName(mobj.getDefinition()));
- }
-
- java.util.List<Activity> acts=new java.util.Vector<Activity>();
-
- DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
- action.convert(acts, convContext);
-
- if (acts.size() != 1) {
- fail("Expecting 1 activity: "+acts.size());
- }
-
- // TODO: Need to pass representation of last interaction
- if (rule.delete(context, model, acts.get(0)) == false) {
- fail("Failed to delete spawn");
- }
-
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Expecting test ESB action 1: "+service.getActions().get(0));
- }
-
- if (service.getActions().get(1) != act2) {
- fail("Expecting test ESB action 2: "+service.getActions().get(1));
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,903 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhenModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class WhenModelChangeRuleTest extends TestCase {
-
- public void testInsertWhenAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhenAction) == false) {
- fail("Action was not WhenAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- WhenAction action=(WhenAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(1) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- if (s1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+s1.getActions().size());
- }
-
- if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(2) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
-
- if (s2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+s2.getActions().size());
- }
-
- if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("when") == false) {
- fail("when(3) expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s3.getName());
- }
-
- if (s3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+s3.getActions().size());
- }
-
- if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+s3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)s3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertWhenActionWithSubsequentActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 actions: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhenAction) == false) {
- fail("Action was not WhenAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
-
- public void testInsertWhenActionWithPrecedingActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role=new Role();
- role.setName("role1");
-
- context.setRole(role);
-
- When mobj=new When();
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 actions: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action 1 was not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof WhenAction) == false) {
- fail("Action 2 was not WhenAction: "+service.getActions().get(1));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- ESBService s3=null;
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null ||
- s3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- s3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action 2");
- }
- }
-
- public void testInsertSwitchAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService switchService=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (switchService == null && iter.hasNext()) {
- switchService = iter.next();
- if (switchService == service) {
- switchService = null;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 1) {
- fail("Only one path child expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Switch expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+switchService.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+switchService.getName());
- }
- }
-
- public void testInsertSwitchMultipleCaseAction() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- SwitchAction action=(SwitchAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 3) {
- fail("Three path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Case expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService1.getName());
- }
-
- if (caseService1.getActions().size() != 1) {
- fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
- }
-
- if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService1.getActions().get(0));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Case expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService2.getName());
- }
-
- if (caseService2.getActions().size() != 1) {
- fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
- }
-
- if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService2.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService2.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
-
- elem=(org.w3c.dom.Element)paths.item(2);
-
- if (elem.getNodeName().equals("case") == false) {
- fail("Else expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+caseService3.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+caseService3.getName());
- }
-
- if (caseService3.getActions().size() != 1) {
- fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
- }
-
- if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
- fail("Action not schedule state: "+caseService3.getActions().get(0));
- }
-
- schedule=(ScheduleStateAction)caseService3.getActions().get(0);
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(join.getCategory()) == false) {
- fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
- }
-
- if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(join.getName()) == false) {
- fail("Schedule name is not join '"+join.getName()+"': "+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
- }
- }
-
- public void testInsertSwitchActionWithSubsequentActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- service.addAction(act1, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 5) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- ESBService caseService1=null;
- ESBService caseService2=null;
- ESBService caseService3=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((caseService1 == null || caseService2 == null ||
- caseService3 == null || join == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- if (serv.getName().endsWith("__1")) {
- caseService1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- caseService2 = serv;
- }
- if (serv.getName().endsWith("__3")) {
- caseService3 = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act1) {
- fail("Join action is not test ESB action");
- }
- }
-
- public void testInsertSwitchActionWithPrecedingActions() {
- WhenModelChangeRule rule=new WhenModelChangeRule();
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(null);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject ref=new ModelObject() {};
- ref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- Role role1=new Role();
- role1.setName("role1");
-
- Role role2=new Role();
- role2.setName("role2");
-
- context.setRole(role1);
-
- When mobj=new When();
-
- mobj.getRoles().add(role2);
-
- ConditionalBlock cb1=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb1);
-
- ConditionalBlock cb2=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb2);
-
- ConditionalBlock cb3=new ConditionalBlock();
- mobj.getConditionalBlocks().add(cb3);
-
- if (rule.insert(context, model, mobj, ref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 2 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("First action not test ESB action");
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
-
- ESBService addedService=model.getService(
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
-
- if (addedService == null) {
- fail("Failed to find service '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
- schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
- }
-
- if (addedService.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
- fail("Action was not SwitchAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 6) {
- fail("Five services expected: "+model.getServices().size());
- }
-
- ESBService join=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while (join == null && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- join = serv;
- }
- }
-
- if (join.getActions().size() != 1) {
- fail("Join service does not have 1 action: "+join.getActions().size());
- }
-
- if (join.getActions().get(0) != act2) {
- fail("Join action is not test ESB action");
- }
- }
-}
Deleted: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java 2009-01-20 22:16:58 UTC (rev 466)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -1,706 +0,0 @@
-/*
- * 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.cdl.runtime.jbossesb.model.change;
-
-import junit.framework.TestCase;
-
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
-import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.WhileModelChangeRule;
-import org.scribble.model.*;
-import org.scribble.model.analysis.TestLookaheadAnalyser;
-import org.scribble.model.change.*;
-import org.scribble.conversation.model.*;
-
-public class WhileModelChangeRuleTest extends TestCase {
-
- public void testInsertWhileActionInitiator() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message types: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileActionRecipient() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getBlock().getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 1) {
- fail("Should have single message type: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileActionRecipientNoRecvLookahead() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setFromRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getBlock().getContents().add(interaction);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 1) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if ((service.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+service.getActions().get(0));
- }
-
- if (model.getServices().size() != 3) {
- fail("Three services expected: "+model.getServices().size());
- }
-
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null) && iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s2 = serv;
- }
- }
-
- WhileAction action=(WhileAction)service.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message type: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileNotFirstSessionAction() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Make session based service
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, null) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction whileSchedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService whileService=null;
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || whileService == null) &&
- iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- whileService = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- }
-
- if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
- equals(whileService.getCategory()) == false) {
- fail("While schedule action category '"+
- whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+
- "' not expected: "+whileService.getCategory());
- }
-
- if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
- equals(whileService.getName()) == false) {
- fail("While schedule action service name '"+
- whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+
- "' not expected: "+whileService.getName());
- }
-
- if (whileService.getActions().size() != 1) {
- fail("Expecting 1 action: "+whileService.getActions().size());
- }
-
- if ((whileService.getActions().get(0) instanceof WhileAction) == false) {
- fail("Action was not WhileAction: "+whileService.getActions().get(0));
- }
-
- WhileAction action=(WhileAction)whileService.getActions().get(0);
-
- org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
-
- if (paths.getLength() != 2) {
- fail("Two path children expected: "+paths.getLength());
- }
-
- org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
-
- if (elem.getNodeName().equals("while") == false) {
- fail("while expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s1.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s1.getName());
- }
-
- // Check no message types
- org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
-
- if (mtypeNL.getLength() != 0) {
- fail("Should have no message types: "+mtypeNL.getLength());
- }
-
- elem=(org.w3c.dom.Element)paths.item(1);
-
- if (elem.getNodeName().equals("exit") == false) {
- fail("exit expected but got: "+elem.getNodeName());
- }
-
- if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
- fail("Service category '"+elem.getAttribute("service-category")+
- "' not expected: "+s2.getCategory());
- }
-
- if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
- fail("Service name '"+elem.getAttribute("service-name")+
- "' not expected: "+s2.getName());
- }
- }
-
- public void testInsertWhileMiddleAction() {
- WhileModelChangeRule rule=new WhileModelChangeRule();
-
- TestESBLanguageModel model=new TestESBLanguageModel();
-
- TestESBService service=(TestESBService)
- model.createService("testcategory", "testname");
-
- model.addService(service);
-
- // Make session based service
- TestESBAction act1=new TestESBAction();
- act1.setInitiator(true);
- act1.setSessionBased(true);
- service.addAction(act1, -1);
-
- TestESBAction act2=new TestESBAction();
- service.addAction(act2, -1);
-
- ModelObject moref=new ModelObject() {};
- moref.getSource().setObject(act2);
-
- TestModelChangeContext context=new TestModelChangeContext();
- context.setParent(service);
-
- java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
-
- TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
- tla.setInteractions(interactions);
-
- Role role=new Role();
- role.setName("role1");
-
- Interaction interaction=new Interaction();
- interaction.setToRole(role);
-
- TypeReference ref=new TypeReference();
- ref.setNamespace("ns");
- ref.setLocalpart("lp");
-
- MessageSignature msig=new MessageSignature();
- interaction.setMessageSignature(msig);
- msig.getTypes().add(ref);
-
- interactions.add(interaction);
-
- org.scribble.extensions.TestSingleExtensionRegistry reg=
- new org.scribble.extensions.TestSingleExtensionRegistry(tla);
- org.scribble.extensions.RegistryFactory.setRegistry(reg);
-
- context.setRole(role);
-
- Conversation conv=new Conversation();
- ModelName mname=new ModelName();
- conv.setModelName(mname);
-
- mname.setLocatedRole(role);
-
- While mobj=new While();
- conv.getBlock().getContents().add(mobj);
-
- mobj.getRoles().add(role);
-
- if (rule.insert(context, model, mobj, moref) == false) {
- fail("Failed to insert");
- }
-
- // Check actions
- if (service.getActions().size() != 2) {
- fail("Expecting 1 action: "+service.getActions().size());
- }
-
- if (service.getActions().get(0) != act1) {
- fail("Action was not test ESB action: "+service.getActions().get(0));
- }
-
- if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
- fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
- }
-
- ScheduleStateAction whileSchedule=(ScheduleStateAction)
- service.getActions().get(1);
-
- if (model.getServices().size() != 4) {
- fail("Four services expected: "+model.getServices().size());
- }
-
- ESBService whileService=null;
- ESBService s1=null;
- ESBService s2=null;
- java.util.Iterator<ESBService> iter=model.getServices().iterator();
-
- while ((s1 == null || s2 == null || whileService == null) &&
- iter.hasNext()) {
- ESBService serv = iter.next();
- if (serv.getName().endsWith("__0")) {
- whileService = serv;
- }
- if (serv.getName().endsWith("__1")) {
- s1 = serv;
- }
- if (serv.getName().endsWith("__2")) {
- s2 = serv;
- }
- }
-
- if (s2.getActions().size() != 1) {
- fail("Expecting 1 action in exit service: "+s2.getActions().size());
- }
-
- if (s2.getActions().get(0) != act2) {
- fail("Action in exit is not test ESB action: "+s2.getActions().get(0));
- }
- }
-}
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ConversationInteractionModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,1847 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ConversationInteractionModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationInteractionModelChangeRuleTest extends TestCase {
+
+ public void testInsertFirstReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertFirstReceiveAfterCreateSessionAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add 'create session' action
+ TestESBAction act=new TestESBAction();
+ act.setCreateSession(true);
+ service.addAction(act, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof TestESBAction) == false) {
+ fail("Action was not TestESBAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(1);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+ public void testInsertSecondReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.IMMEDIATE) != null) {
+ fail("Schedule should not be immediate");
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)newService.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 2) {
+ fail("Two routes expected: "+mra.getNumberOfRoutes());
+ }
+ }
+
+
+ public void testInsertMiddleReceiveBetweenTwoReceives() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv2=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+recv2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setToRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // receive
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+
+ ESBService newService2=model.getService(ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME));
+
+ if (newService2 == null) {
+ fail("Failed to find final service");
+ }
+
+ if (newService2.getActions().size() != 1) {
+ fail("Only expecting one action: "+newService2.getActions().size());
+ }
+
+ ReceiveMessageAction recv4=(ReceiveMessageAction)
+ newService2.getActions().get(0);
+
+ String mtype4=InteractionUtil.getTypeString(ref2);
+
+ if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+ fail("Message type '"+recv4.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype4);
+ }
+
+
+ ReceiveMessageAction recv3=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+recv3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertMiddleSendBetweenTwoReceives() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setToRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv2=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (recv2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+recv2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setFromRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // receive
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)newService.getActions().get(1);
+
+ ESBService newService2=model.getService(ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY),ssa.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME));
+
+ if (newService2 == null) {
+ fail("Failed to find final service");
+ }
+
+ if (newService2.getActions().size() != 1) {
+ fail("Only expecting one action: "+newService2.getActions().size());
+ }
+
+ if ((newService2.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Expecting ReceiveMessageAction, but got: "+newService2.getActions().get(0));
+ }
+
+ ReceiveMessageAction recv4=(ReceiveMessageAction)
+ newService2.getActions().get(0);
+
+ String mtype4=InteractionUtil.getTypeString(ref2);
+
+ if (recv4.getPropertyValue("messageType").equals(mtype4)==false) {
+ fail("Message type '"+recv4.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype4);
+ }
+
+
+ SendMessageAction send3=(SendMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (send3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+send3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertMiddleReceiveBetweenTwoSends() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setFromRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ ConversationInteraction mobj2=new ConversationInteraction();
+ mobj2.setFromRole(role);
+ conv.getBlock().getContents().add(mobj2);
+
+ MessageSignature msig2=new MessageSignature();
+ mobj2.setMessageSignature(msig2);
+
+ TypeReference ref2=new TypeReference();
+ ref2.setNamespace("ns");
+ ref2.setLocalpart("lp2");
+
+ msig2.getTypes().add(ref2);
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ if (rule.insert(context, model, mobj2, null) == false) {
+ fail("Failed to insert 2");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction send2=(SendMessageAction)
+ service.getActions().get(1);
+
+
+ String mtype=InteractionUtil.getTypeString(ref2);
+
+ if (send2.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+send2.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ send2.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // Now second service identified, add new receive
+ // action to ensure that third service inserted in the
+ // middle
+ ConversationInteraction mobj3=new ConversationInteraction();
+ mobj3.setToRole(role);
+ conv.getBlock().getContents().add(mobj3);
+
+ MessageSignature msig3=new MessageSignature();
+ mobj3.setMessageSignature(msig3);
+
+ TypeReference ref3=new TypeReference();
+ ref3.setNamespace("ns");
+ ref3.setLocalpart("lp3");
+
+ msig3.getTypes().add(ref3);
+
+ // Insert into position 1, which should be after first
+ // send
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.insert(context, model, mobj3, acts.get(0)) == false) {
+ fail("Failed to insert 3");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action 1 was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Now Expecting 2 action: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ if ((newService.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+newService.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ ReceiveMessageAction recv3=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+ String mtype3=InteractionUtil.getTypeString(ref3);
+
+ if (recv3.getPropertyValue("messageType").equals(mtype3)==false) {
+ fail("Message type '"+recv3.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype3);
+ }
+ }
+
+ public void testInsertReceiveRequestAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(toRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(toRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR).equals(fromRoleName) == false) {
+ fail("Client EPR '"+action.getPropertyValue(ReceiveMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+fromRoleName);
+ }
+ }
+
+ public void testInsertFirstSendAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+ }
+
+ public void testInsertSendRequestAction() {
+ String roleName="role1";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName(roleName);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ if (newService.getCategory().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ action.getPropertyValue(
+ SendMessageAction.RESPONSE_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+ }
+
+ public void testInsertSendNotReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setRequestLabel("reqLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two service expected: "+model.getServices().size());
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceCategoryProperty(toRoleName)) == false) {
+ fail("Service category expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_CATEGORY_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceCategoryProperty(toRoleName));
+ }
+
+ if (action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION).
+ equals(InteractionUtil.getRoleServiceNameProperty(toRoleName)) == false) {
+ fail("Service name expression '"+
+ action.getPropertyValue(SendMessageAction.SERVICE_NAME_EXPRESSION)+
+ "' invalid, expecting: "+
+ InteractionUtil.getRoleServiceNameProperty(toRoleName));
+ }
+ }
+
+ public void testInsertSendReplyAction() {
+ String fromRoleName="role1";
+ String toRoleName="role2";
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role fromRole=new Role();
+ fromRole.setName(fromRoleName);
+
+ Role toRole=new Role();
+ toRole.setName(toRoleName);
+
+ context.setRole(fromRole);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(fromRole);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setFromRole(fromRole);
+ mobj.setToRole(toRole);
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.setReplyToLabel("replyLabel");
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ msig.getTypes().add(ref);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SendMessageAction) == false) {
+ fail("Action was not SendMessageAction: "+service.getActions().get(0));
+ }
+
+ SendMessageAction action=(SendMessageAction)service.getActions().get(0);
+
+ if (action.getPropertyValue(SendMessageAction.CLIENT_EPR).equals(toRoleName) == false) {
+ fail("Client EPR '"+action.getPropertyValue(SendMessageAction.CLIENT_EPR)+
+ "' invalid, expecting: "+toRoleName);
+ }
+ }
+
+ public void testChangeFirstReceiveAction() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj=new ConversationInteraction();
+ mobj.setToRole(role);
+ conv.getBlock().getContents().add(mobj);
+
+
+ MessageSignature msig=new MessageSignature();
+ mobj.setMessageSignature(msig);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp1");
+
+ msig.getTypes().add(ref);
+
+ // Create ReceiveMessageAction
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action was not ReceiveMessageAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ ReceiveMessageAction action=(ReceiveMessageAction)service.getActions().get(0);
+
+ java.util.List<Activity> activities=new java.util.Vector<Activity>();
+ action.convert(activities, new DefaultConversionContext(null));
+
+ if (activities.size() != 1) {
+ fail("Expecting single interaction activity from ReceiveMessageAction: "+activities.size());
+ }
+
+ if ((activities.get(0) instanceof ConversationInteraction) == false) {
+ fail("Not conversation interaction");
+ }
+
+ ConversationInteraction recvci=(ConversationInteraction)activities.get(0);
+
+ String mtype=InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ // Change local part
+ ref.setLocalpart("lp2");
+
+ if (rule.update(context, model, mobj, recvci) == false) {
+ fail("Failed to update");
+ }
+
+ // Re-check the message type, to make sure has been updated
+ mtype = InteractionUtil.getTypeString(ref);
+
+ if (action.getPropertyValue("messageType").equals(mtype)==false) {
+ fail("Message type '"+action.getPropertyValue("messageType")+
+ "' invalid, expecting: "+mtype);
+ }
+
+ if (mra.getNumberOfRoutes() != 1) {
+ fail("One route expected: "+mra.getNumberOfRoutes());
+ }
+
+ org.w3c.dom.Element route=mra.getRouteElement(0);
+
+ org.w3c.dom.NodeList mesgs=route.getElementsByTagName(MessageRouterAction.MESSAGE_ELEMENT);
+
+ if (mesgs.getLength() != 1) {
+ fail("Too many route message elements: "+mesgs.getLength());
+ }
+
+ org.w3c.dom.Element mesg=(org.w3c.dom.Element)mesgs.item(0);
+
+ if (mesg.getAttribute(MessageRouterAction.TYPE_ATTR).equals(mtype) == false) {
+ fail("Route message type has not been updated");
+ }
+ }
+
+ public void testDeleteMiddleReceiveBetweenTwoActions() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setToRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ ((TestESBService)newService).setSessionBased(true);
+
+ // Check schedule details
+ ScheduleStateAction schedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (newService.getCategory().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)) == false) {
+ fail("Schedule service category '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ service.getCategory());
+ }
+
+ if (newService.getName().equals(schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)) == false) {
+ fail("Schedule service name '"+
+ schedule.getPropertyValue(
+ ScheduleStateAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ service.getName());
+ }
+
+ // Check actions
+ if (newService.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+newService.getActions().size());
+ }
+
+ if ((newService.getActions().get(0) instanceof ReceiveMessageAction) == false) {
+ fail("Action 1 was not ReceiveMessageAction: "+newService.getActions().get(0));
+ }
+
+ if (newService.getActions().get(1) != act2) {
+ fail("Action 2 was not 2nd test ESB action: "+newService.getActions().get(1));
+ }
+
+ ReceiveMessageAction recv=(ReceiveMessageAction)
+ newService.getActions().get(0);
+
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ recv.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete receive");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action 2 was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ // TODO: Need to check if new service has been inserted
+ // in the middle of the previously inserted interactions
+
+ // Check actions
+ if (newService.getActions().size() != 1) {
+ fail("Now Expecting 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Action 1 was not 2nd test ESB action: "+newService.getActions().get(0));
+ }
+ }
+
+ public void testDeleteMiddleSendBetweenTwoActions() {
+ ConversationInteractionModelChangeRule rule=new ConversationInteractionModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ // Add gateway service
+ TestESBService gwservice=(TestESBService)
+ model.createService("testcategory", "gateway");
+ gwservice.setGateway(true);
+
+ MessageRouterAction mra=new MessageRouterAction(gwservice);
+ gwservice.setGatewayAction(mra);
+
+ model.setGatewayService(gwservice);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ ConversationInteraction mobj1=new ConversationInteraction();
+ mobj1.setFromRole(role);
+ conv.getBlock().getContents().add(mobj1);
+
+ MessageSignature msig1=new MessageSignature();
+ mobj1.setMessageSignature(msig1);
+
+ TypeReference ref1=new TypeReference();
+ ref1.setNamespace("ns");
+ ref1.setLocalpart("lp1");
+
+ msig1.getTypes().add(ref1);
+
+ if (rule.insert(context, model, mobj1, null) == false) {
+ fail("Failed to insert 1");
+ }
+
+ // Once first interaction associated with service it
+ // will become session based
+ service.setSessionBased(true);
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof SendMessageAction) == false) {
+ fail("Action 2 was not SendMessageAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Action 3 was not 2nd test ESB action: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+
+ SendMessageAction send=(SendMessageAction)
+ service.getActions().get(1);
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ send.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete send");
+ }
+
+ // Re-Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if (service.getActions().get(1) != act2) {
+ fail("Action 2 was not 2nd test ESB action: "+service.getActions().get(1));
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ConversationInteractionModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/IfModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,1069 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.IfModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class IfModelChangeRuleTest extends TestCase {
+
+ public void testInsertIfAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (ifService == null && iter.hasNext()) {
+ ifService = iter.next();
+ if (ifService == service) {
+ ifService = null;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+ }
+
+ public void testInsertIfActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertIfActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof IfAction) == false) {
+ fail("Action 2 was not IfAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (ifService == null) {
+ ifService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertIfElseIfAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService elseIfService1=null;
+ ESBService elseIfService2=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || elseIfService1 == null ||
+ elseIfService2 == null || join==null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ ifService = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ elseIfService1 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ elseIfService2 = serv;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+
+ if (ifService.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+ }
+
+ if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+ifService.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("elseif") == false) {
+ fail("ElseIf expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(elseIfService1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+elseIfService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseIfService1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseIfService1.getName());
+ }
+
+ if (elseIfService1.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+elseIfService1.getActions().size());
+ }
+
+ if ((elseIfService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseIfService1.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)elseIfService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("elseif") == false) {
+ fail("ElseIf(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(elseIfService2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+elseIfService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseIfService2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseIfService2.getName());
+ }
+
+ if (elseIfService2.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+elseIfService2.getActions().size());
+ }
+
+ if ((elseIfService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseIfService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)elseIfService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertIfElseAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ If mobj=new If();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ Block b1=new Block();
+ mobj.setElseBlock(b1);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof IfAction) == false) {
+ fail("Action was not IfAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService ifService=null;
+ ESBService elseService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((ifService == null || elseService == null ||
+ join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ ifService = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ elseService = serv;
+ }
+ }
+
+ IfAction action=(IfAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("if") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(ifService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+ifService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(ifService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+ifService.getName());
+ }
+
+ if (ifService.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+ifService.getActions().size());
+ }
+
+ if ((ifService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+ifService.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("else") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(elseService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+elseService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(elseService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+elseService.getName());
+ }
+
+ if (elseService.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+elseService.getActions().size());
+ }
+
+ if ((elseService.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+elseService.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)ifService.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ }
+
+ public void testInsertSwitchAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (switchService == null && iter.hasNext()) {
+ switchService = iter.next();
+ if (switchService == service) {
+ switchService = null;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Switch expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+switchService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+switchService.getName());
+ }
+ }
+
+ public void testInsertSwitchMultipleCaseAction() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ Block b1=new Block();
+ mobj.setElseBlock(b1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("If expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService1.getName());
+ }
+
+ if (caseService1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
+ }
+
+ if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService2.getName());
+ }
+
+ if (caseService2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
+ }
+
+ if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService3.getName());
+ }
+
+ if (caseService3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
+ }
+
+ if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((switchService == null || join == null) && iter.hasNext()) {
+ ESBService s = iter.next();
+ if (s != service) {
+ if (switchService == null) {
+ switchService = s;
+ } else if (join == null) {
+ join = s;
+ }
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ IfModelChangeRule rule=new IfModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ If mobj=new If();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/IfModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/ParallelModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,624 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.ParallelModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.analysis.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class ParallelModelChangeRuleTest extends TestCase {
+
+ public void testInsertParallelAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || s3 == null ||
+ join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) immediate not set");
+ }
+
+ if (s1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+s1.getActions().size());
+ }
+
+ if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(2) immediate not set");
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+s2.getActions().size());
+ }
+
+ if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(3) immediate not set");
+ }
+
+ if (s3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+s3.getActions().size());
+ }
+
+ if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateFalse() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("path(1) should not be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelActionWithImmediateTrue() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ Parallel mobj=new Parallel();
+ conv.getBlock().getContents().add(mobj);
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ cb1.getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("path") == false) {
+ fail("path(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (elem.getAttribute("immediate").equals("true") == false) {
+ fail("path(1) should be immediate");
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+ }
+
+ public void testInsertParallelMiddleAction() {
+ ParallelModelChangeRule rule=new ParallelModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ Parallel mobj=new Parallel();
+
+ Block cb1=new Block();
+ mobj.getBlocks().add(cb1);
+
+ Block cb2=new Block();
+ mobj.getBlocks().add(cb2);
+
+ Block cb3=new Block();
+ mobj.getBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ParallelAction) == false) {
+ fail("Action was not ParallelAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ ParallelAction action=(ParallelAction)service.getActions().get(1);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 4) {
+ fail("Four path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(3);
+
+ if (elem.getNodeName().equals("join") == false) {
+ fail("join expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(join.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+join.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(join.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+join.getName());
+ }
+
+ if (elem.hasAttribute("immediate")) {
+ fail("Join should not be immediate");
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Expecting 1 join action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Action was not test ESB action 2: "+join.getActions().get(0));
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/ParallelModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/RunModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,471 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class RunModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+ }
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ }
+ public void testDeletePerformActionMiddle() {
+ String runName="subconv";
+
+ RunModelChangeRule rule=new RunModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Run mobj=new Run();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ TestESBAction act2=new TestESBAction();
+ ((ESBService)context.getParent()).addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ ESBService newService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+ while (newService == null && iter.hasNext()) {
+ ESBService s=iter.next();
+
+ if (s != service) {
+ newService = s;
+ }
+ }
+
+ if (newService == null) {
+ fail("Other service not found");
+ }
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ if (newService.getCategory().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)) == false) {
+ fail("Perform return service category '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ newService.getCategory());
+ }
+
+ if (newService.getName().equals(action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)) == false) {
+ fail("Perform return service name '"+
+ action.getPropertyValue(
+ PerformAction.RETURN_SERVICE_NAME)+
+ "' invalid, expecting: "+
+ newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ action.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete spawn");
+ }
+
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction ssa=(ScheduleStateAction)service.getActions().get(1);
+
+ if (ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY).equals(newService.getCategory()) == false) {
+ fail("Category not correct '"+ssa.getPropertyValue(PerformAction.SERVICE_CATEGORY)+
+ "' expecting: "+newService.getCategory());
+ }
+
+ if (ssa.getPropertyValue(PerformAction.SERVICE_NAME).equals(newService.getName()) == false) {
+ fail("Name not correct '"+ssa.getPropertyValue(PerformAction.SERVICE_NAME)+
+ "' expecting: "+newService.getName());
+ }
+
+ if (newService.getActions().size() != 1) {
+ fail("Return service should have 1 action: "+newService.getActions().size());
+ }
+
+ if (newService.getActions().get(0) != act2) {
+ fail("Expecting test ESB action 2: "+newService.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 2) {
+ fail("Two services expected: "+model.getServices().size());
+ }
+
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/RunModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/SpawnModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,346 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.RunModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.SpawnModelChangeRule;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.ConversationUtil;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class SpawnModelChangeRuleTest extends TestCase {
+
+ public void testInsertPerformAction() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One service expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(0);
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+
+ public void testInsertPerformActionMiddle() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 3 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+ }
+
+ public void testDeletePerformActionMiddle() {
+ String runName="subconv";
+
+ SpawnModelChangeRule rule=new SpawnModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ ConversationModel cm=new ConversationModel();
+
+ Namespace ns=new Namespace();
+ cm.setNamespace(ns);
+ ns.setName("ns");
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ mname.setLocatedRole(role);
+ conv.setModelName(mname);
+
+ cm.setConversation(conv);
+
+ Conversation subconv=new Conversation();
+ ModelName submname=new ModelName();
+ submname.setName(runName);
+ submname.setLocatedRole(role);
+ subconv.setModelName(mname);
+
+ Spawn mobj=new Spawn();
+ mobj.setInlineDefinition(subconv);
+
+ conv.getBlock().getContents().add(mobj);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ // Check actions
+ if (service.getActions().size() != 3) {
+ fail("Expecting 3 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof PerformAction) == false) {
+ fail("Action was not PerformAction: "+service.getActions().get(1));
+ }
+
+ if (service.getActions().get(2) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(2));
+ }
+
+ if (model.getServices().size() != 1) {
+ fail("One services expected: "+model.getServices().size());
+ }
+
+ PerformAction action=(PerformAction)service.getActions().get(1);
+
+ // Check details
+ if (ConversationUtil.getServiceCategory(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)) == false) {
+ fail("Perform service category '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_CATEGORY)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceCategory(mobj.getDefinition()));
+ }
+
+ if (ConversationUtil.getServiceName(mobj.getDefinition()).equals(action.getPropertyValue(
+ PerformAction.SERVICE_NAME)) == false) {
+ fail("Perform service name '"+
+ action.getPropertyValue(
+ PerformAction.SERVICE_NAME)+
+ "' invalid, expecting: "+
+ ConversationUtil.getServiceName(mobj.getDefinition()));
+ }
+
+ java.util.List<Activity> acts=new java.util.Vector<Activity>();
+
+ DefaultConversionContext convContext=new DefaultConversionContext(role.getName());
+ action.convert(acts, convContext);
+
+ if (acts.size() != 1) {
+ fail("Expecting 1 activity: "+acts.size());
+ }
+
+ // TODO: Need to pass representation of last interaction
+ if (rule.delete(context, model, acts.get(0)) == false) {
+ fail("Failed to delete spawn");
+ }
+
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Expecting test ESB action 1: "+service.getActions().get(0));
+ }
+
+ if (service.getActions().get(1) != act2) {
+ fail("Expecting test ESB action 2: "+service.getActions().get(1));
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/SpawnModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhenModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,903 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhenModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhenModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhenAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ WhenAction action=(WhenAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(1) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ if (s1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+s1.getActions().size());
+ }
+
+ if ((s1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)s1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(2) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+s2.getActions().size());
+ }
+
+ if ((s2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("when") == false) {
+ fail("when(3) expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s3.getName());
+ }
+
+ if (s3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+s3.getActions().size());
+ }
+
+ if ((s3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+s3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)s3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertWhenActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 actions: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhenAction) == false) {
+ fail("Action was not WhenAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+
+ public void testInsertWhenActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ context.setRole(role);
+
+ When mobj=new When();
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 actions: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action 1 was not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof WhenAction) == false) {
+ fail("Action 2 was not WhenAction: "+service.getActions().get(1));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ ESBService s3=null;
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null ||
+ s3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ s3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action 2");
+ }
+ }
+
+ public void testInsertSwitchAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService switchService=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (switchService == null && iter.hasNext()) {
+ switchService = iter.next();
+ if (switchService == service) {
+ switchService = null;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 1) {
+ fail("Only one path child expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Switch expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(switchService.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+switchService.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(switchService.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+switchService.getName());
+ }
+ }
+
+ public void testInsertSwitchMultipleCaseAction() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ SwitchAction action=(SwitchAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 3) {
+ fail("Three path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService1.getName());
+ }
+
+ if (caseService1.getActions().size() != 1) {
+ fail("Path(1) does not have 1 action: "+caseService1.getActions().size());
+ }
+
+ if ((caseService1.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService1.getActions().get(0));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)caseService1.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Case expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService2.getName());
+ }
+
+ if (caseService2.getActions().size() != 1) {
+ fail("Path(2) does not have 1 action: "+caseService2.getActions().size());
+ }
+
+ if ((caseService2.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService2.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService2.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(2);
+
+ if (elem.getNodeName().equals("case") == false) {
+ fail("Else expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(caseService3.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+caseService3.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(caseService3.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+caseService3.getName());
+ }
+
+ if (caseService3.getActions().size() != 1) {
+ fail("Path(3) does not have 1 action: "+caseService3.getActions().size());
+ }
+
+ if ((caseService3.getActions().get(0) instanceof ScheduleStateAction) == false) {
+ fail("Action not schedule state: "+caseService3.getActions().get(0));
+ }
+
+ schedule=(ScheduleStateAction)caseService3.getActions().get(0);
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(join.getCategory()) == false) {
+ fail("Schedule cateogry is not join '"+join.getCategory()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY));
+ }
+
+ if (schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(join.getName()) == false) {
+ fail("Schedule name is not join '"+join.getName()+"': "+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+ }
+ }
+
+ public void testInsertSwitchActionWithSubsequentActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ service.addAction(act1, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 5) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ ESBService caseService1=null;
+ ESBService caseService2=null;
+ ESBService caseService3=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((caseService1 == null || caseService2 == null ||
+ caseService3 == null || join == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ caseService1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ caseService2 = serv;
+ }
+ if (serv.getName().endsWith("__3")) {
+ caseService3 = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act1) {
+ fail("Join action is not test ESB action");
+ }
+ }
+
+ public void testInsertSwitchActionWithPrecedingActions() {
+ WhenModelChangeRule rule=new WhenModelChangeRule();
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(null);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject ref=new ModelObject() {};
+ ref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ Role role1=new Role();
+ role1.setName("role1");
+
+ Role role2=new Role();
+ role2.setName("role2");
+
+ context.setRole(role1);
+
+ When mobj=new When();
+
+ mobj.getRoles().add(role2);
+
+ ConditionalBlock cb1=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb1);
+
+ ConditionalBlock cb2=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb2);
+
+ ConditionalBlock cb3=new ConditionalBlock();
+ mobj.getConditionalBlocks().add(cb3);
+
+ if (rule.insert(context, model, mobj, ref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 2 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("First action not test ESB action");
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction schedule=(ScheduleStateAction)service.getActions().get(1);
+
+ ESBService addedService=model.getService(
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY),
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME));
+
+ if (addedService == null) {
+ fail("Failed to find service '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+"' '"+
+ schedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+"'");
+ }
+
+ if (addedService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((addedService.getActions().get(0) instanceof SwitchAction) == false) {
+ fail("Action was not SwitchAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 6) {
+ fail("Five services expected: "+model.getServices().size());
+ }
+
+ ESBService join=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while (join == null && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ join = serv;
+ }
+ }
+
+ if (join.getActions().size() != 1) {
+ fail("Join service does not have 1 action: "+join.getActions().size());
+ }
+
+ if (join.getActions().get(0) != act2) {
+ fail("Join action is not test ESB action");
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhenModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java (from rev 459, cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/WhileModelChangeRuleTest.java)
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java 2009-01-22 20:41:48 UTC (rev 467)
@@ -0,0 +1,706 @@
+/*
+ * 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.cdl.runtime.jbossesb.model.change.stateful;
+
+import junit.framework.TestCase;
+
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.actions.stateful.*;
+import org.jboss.tools.overlord.cdl.runtime.jbossesb.model.change.stateful.WhileModelChangeRule;
+import org.scribble.model.*;
+import org.scribble.model.analysis.TestLookaheadAnalyser;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+
+public class WhileModelChangeRuleTest extends TestCase {
+
+ public void testInsertWhileActionInitiator() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message types: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipient() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 1) {
+ fail("Should have single message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileActionRecipientNoRecvLookahead() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setFromRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getBlock().getContents().add(interaction);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 1) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if ((service.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+service.getActions().get(0));
+ }
+
+ if (model.getServices().size() != 3) {
+ fail("Three services expected: "+model.getServices().size());
+ }
+
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null) && iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s2 = serv;
+ }
+ }
+
+ WhileAction action=(WhileAction)service.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message type: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileNotFirstSessionAction() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Make session based service
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, null) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction whileSchedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService whileService=null;
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || whileService == null) &&
+ iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ whileService = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ }
+
+ if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY).
+ equals(whileService.getCategory()) == false) {
+ fail("While schedule action category '"+
+ whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_CATEGORY)+
+ "' not expected: "+whileService.getCategory());
+ }
+
+ if (whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME).
+ equals(whileService.getName()) == false) {
+ fail("While schedule action service name '"+
+ whileSchedule.getPropertyValue(ScheduleStateAction.SERVICE_NAME)+
+ "' not expected: "+whileService.getName());
+ }
+
+ if (whileService.getActions().size() != 1) {
+ fail("Expecting 1 action: "+whileService.getActions().size());
+ }
+
+ if ((whileService.getActions().get(0) instanceof WhileAction) == false) {
+ fail("Action was not WhileAction: "+whileService.getActions().get(0));
+ }
+
+ WhileAction action=(WhileAction)whileService.getActions().get(0);
+
+ org.w3c.dom.NodeList paths=action.getPropertyChildNodes("paths");
+
+ if (paths.getLength() != 2) {
+ fail("Two path children expected: "+paths.getLength());
+ }
+
+ org.w3c.dom.Element elem=(org.w3c.dom.Element)paths.item(0);
+
+ if (elem.getNodeName().equals("while") == false) {
+ fail("while expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s1.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s1.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s1.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s1.getName());
+ }
+
+ // Check no message types
+ org.w3c.dom.NodeList mtypeNL=elem.getElementsByTagName("message");
+
+ if (mtypeNL.getLength() != 0) {
+ fail("Should have no message types: "+mtypeNL.getLength());
+ }
+
+ elem=(org.w3c.dom.Element)paths.item(1);
+
+ if (elem.getNodeName().equals("exit") == false) {
+ fail("exit expected but got: "+elem.getNodeName());
+ }
+
+ if (elem.getAttribute("service-category").equals(s2.getCategory()) == false) {
+ fail("Service category '"+elem.getAttribute("service-category")+
+ "' not expected: "+s2.getCategory());
+ }
+
+ if (elem.getAttribute("service-name").equals(s2.getName()) == false) {
+ fail("Service name '"+elem.getAttribute("service-name")+
+ "' not expected: "+s2.getName());
+ }
+ }
+
+ public void testInsertWhileMiddleAction() {
+ WhileModelChangeRule rule=new WhileModelChangeRule();
+
+ TestESBLanguageModel model=new TestESBLanguageModel();
+
+ TestESBService service=(TestESBService)
+ model.createService("testcategory", "testname");
+
+ model.addService(service);
+
+ // Make session based service
+ TestESBAction act1=new TestESBAction();
+ act1.setInitiator(true);
+ act1.setSessionBased(true);
+ service.addAction(act1, -1);
+
+ TestESBAction act2=new TestESBAction();
+ service.addAction(act2, -1);
+
+ ModelObject moref=new ModelObject() {};
+ moref.getSource().setObject(act2);
+
+ TestModelChangeContext context=new TestModelChangeContext();
+ context.setParent(service);
+
+ java.util.Set<Interaction> interactions=new java.util.HashSet<Interaction>();
+
+ TestLookaheadAnalyser tla=new TestLookaheadAnalyser();
+ tla.setInteractions(interactions);
+
+ Role role=new Role();
+ role.setName("role1");
+
+ Interaction interaction=new Interaction();
+ interaction.setToRole(role);
+
+ TypeReference ref=new TypeReference();
+ ref.setNamespace("ns");
+ ref.setLocalpart("lp");
+
+ MessageSignature msig=new MessageSignature();
+ interaction.setMessageSignature(msig);
+ msig.getTypes().add(ref);
+
+ interactions.add(interaction);
+
+ org.scribble.extensions.TestSingleExtensionRegistry reg=
+ new org.scribble.extensions.TestSingleExtensionRegistry(tla);
+ org.scribble.extensions.RegistryFactory.setRegistry(reg);
+
+ context.setRole(role);
+
+ Conversation conv=new Conversation();
+ ModelName mname=new ModelName();
+ conv.setModelName(mname);
+
+ mname.setLocatedRole(role);
+
+ While mobj=new While();
+ conv.getBlock().getContents().add(mobj);
+
+ mobj.getRoles().add(role);
+
+ if (rule.insert(context, model, mobj, moref) == false) {
+ fail("Failed to insert");
+ }
+
+ // Check actions
+ if (service.getActions().size() != 2) {
+ fail("Expecting 1 action: "+service.getActions().size());
+ }
+
+ if (service.getActions().get(0) != act1) {
+ fail("Action was not test ESB action: "+service.getActions().get(0));
+ }
+
+ if ((service.getActions().get(1) instanceof ScheduleStateAction) == false) {
+ fail("Action was not ScheduleStateAction: "+service.getActions().get(1));
+ }
+
+ ScheduleStateAction whileSchedule=(ScheduleStateAction)
+ service.getActions().get(1);
+
+ if (model.getServices().size() != 4) {
+ fail("Four services expected: "+model.getServices().size());
+ }
+
+ ESBService whileService=null;
+ ESBService s1=null;
+ ESBService s2=null;
+ java.util.Iterator<ESBService> iter=model.getServices().iterator();
+
+ while ((s1 == null || s2 == null || whileService == null) &&
+ iter.hasNext()) {
+ ESBService serv = iter.next();
+ if (serv.getName().endsWith("__0")) {
+ whileService = serv;
+ }
+ if (serv.getName().endsWith("__1")) {
+ s1 = serv;
+ }
+ if (serv.getName().endsWith("__2")) {
+ s2 = serv;
+ }
+ }
+
+ if (s2.getActions().size() != 1) {
+ fail("Expecting 1 action in exit service: "+s2.getActions().size());
+ }
+
+ if (s2.getActions().get(0) != act2) {
+ fail("Action in exit is not test ESB action: "+s2.getActions().get(0));
+ }
+ }
+}
Property changes on: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/test/org/jboss/tools/overlord/cdl/runtime/jbossesb/model/change/stateful/WhileModelChangeRuleTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
15 years, 3 months
Overlord SVN: r466 - in cdl/trunk/tools/plugins: org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-20 17:16:58 -0500 (Tue, 20 Jan 2009)
New Revision: 466
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
Log:
Remove 'external roles' parameter from projector interface.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-01-15 19:25:01 UTC (rev 465)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-01-20 22:16:58 UTC (rev 466)
@@ -139,7 +139,7 @@
if (projector != null) {
Model localModel=projector.project(m_conversationModel,
- role, null, new DefaultModelListener());
+ role, new DefaultModelListener());
if (localModel instanceof ConversationModel &&
((ConversationModel)localModel).getConversation() != null) {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-15 19:25:01 UTC (rev 465)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-20 22:16:58 UTC (rev 466)
@@ -139,7 +139,7 @@
if (projector != null) {
Model localModel=projector.project(m_conversationModel,
- role, null, new DefaultModelListener());
+ role, new DefaultModelListener());
if (localModel instanceof ConversationModel &&
((ConversationModel)localModel).getConversation() != null) {
15 years, 3 months
Overlord SVN: r465 - cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/parser.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-15 14:25:01 -0500 (Thu, 15 Jan 2009)
New Revision: 465
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/parser/JBossESBParser.java
Log:
Remove unnecessary retrieval of dependency manager.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/parser/JBossESBParser.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/parser/JBossESBParser.java 2009-01-13 21:44:00 UTC (rev 464)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/parser/JBossESBParser.java 2009-01-15 19:25:01 UTC (rev 465)
@@ -53,11 +53,6 @@
ModelListener l) {
DefaultESBLanguageModel ret=null;
- org.scribble.model.admin.DependencyManager dm=
- (org.scribble.model.admin.DependencyManager)
- org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
- org.scribble.model.admin.DependencyManager.class, null);
-
try {
// Transform the text representation to DOM
DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
@@ -74,7 +69,8 @@
// and therefore this was the only way to extract the
// content and also provide the stream to the XML
// document builder.
- java.io.ByteArrayInputStream bais=new java.io.ByteArrayInputStream(b);
+ java.io.ByteArrayInputStream bais=
+ new java.io.ByteArrayInputStream(b);
org.w3c.dom.Document doc=builder.parse(bais);
15 years, 3 months
Overlord SVN: r464 - in cdl/trunk/distribution/eclipse: features and 1 other directories.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-13 16:44:00 -0500 (Tue, 13 Jan 2009)
New Revision: 464
Added:
cdl/trunk/distribution/eclipse/features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200901132140.jar
cdl/trunk/distribution/eclipse/features/org.scribble.conversation.feature_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/features/org.scribble.experimental.feature_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/features/org.scribble.feature_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/features/org.scribble.java.feature_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/features/org.scribble.protocol.feature_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb_1.0.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb_1.0.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conformance_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.comparator_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.export.text_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.model_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.parser_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.projector_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.validation_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.core_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.designer_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.comparator_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.java.parser_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.model_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.osgi_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.comparator_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.export.text_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.model_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.parser_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.projector_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.validation_0.1.0.200901132140.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.type.java.parser_0.1.0.200901132140.jar
Removed:
cdl/trunk/distribution/eclipse/features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200811131234.jar
cdl/trunk/distribution/eclipse/features/org.scribble.conversation.feature_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/features/org.scribble.experimental.feature_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/features/org.scribble.feature_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/features/org.scribble.java.feature_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/features/org.scribble.protocol.feature_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb_1.0.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb_1.0.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conformance_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.comparator_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.export.text_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.model_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.parser_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.projector_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.validation_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.core_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.designer_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.comparator_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.java.parser_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.model_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.osgi_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.comparator_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.export.text_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.model_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.parser_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.projector_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.validation_0.1.0.200811131234.jar
cdl/trunk/distribution/eclipse/plugins/org.scribble.type.java.parser_0.1.0.200811131234.jar
Modified:
cdl/trunk/distribution/eclipse/site.xml
Log:
Updated plugins in Overlord CDL Eclipse distribution, due to change in Projector interface.
Deleted: cdl/trunk/distribution/eclipse/features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/features/org.scribble.conversation.feature_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.scribble.conversation.feature_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.scribble.conversation.feature_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/features/org.scribble.experimental.feature_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.scribble.experimental.feature_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.scribble.experimental.feature_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/features/org.scribble.feature_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.scribble.feature_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.scribble.feature_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/features/org.scribble.java.feature_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.scribble.java.feature_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.scribble.java.feature_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/features/org.scribble.protocol.feature_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/features/org.scribble.protocol.feature_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/features/org.scribble.protocol.feature_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb_1.0.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb_1.0.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb_1.0.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb_1.0.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb_1.0.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.jboss.tools.overlord.cdl.validator.jbossesb_1.0.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conformance_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conformance_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conformance_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.comparator_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.comparator_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.comparator_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.export.text_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.export.text_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.export.text_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.model_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.model_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.model_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.parser_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.parser_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.parser_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.projector_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.projector_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.projector_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.validation_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.validation_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.conversation.validation_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.core_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.core_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.core_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.designer_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.designer_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.designer_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.comparator_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.comparator_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.comparator_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.java.parser_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.java.parser_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.java.parser_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.model_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.model_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.lang.model_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.osgi_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.osgi_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.osgi_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.comparator_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.comparator_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.comparator_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.export.text_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.export.text_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.export.text_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.model_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.model_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.model_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.parser_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.parser_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.parser_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.projector_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.projector_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.projector_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.validation_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.validation_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.protocol.validation_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: cdl/trunk/distribution/eclipse/plugins/org.scribble.type.java.parser_0.1.0.200811131234.jar
===================================================================
(Binary files differ)
Added: cdl/trunk/distribution/eclipse/plugins/org.scribble.type.java.parser_0.1.0.200901132140.jar
===================================================================
(Binary files differ)
Property changes on: cdl/trunk/distribution/eclipse/plugins/org.scribble.type.java.parser_0.1.0.200901132140.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: cdl/trunk/distribution/eclipse/site.xml
===================================================================
--- cdl/trunk/distribution/eclipse/site.xml 2009-01-13 21:36:23 UTC (rev 463)
+++ cdl/trunk/distribution/eclipse/site.xml 2009-01-13 21:44:00 UTC (rev 464)
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
- <feature url="features/org.scribble.conversation.feature_0.1.0.200811131234.jar" id="org.scribble.conversation.feature" version="0.1.0.200811131234">
+ <feature url="features/org.scribble.conversation.feature_0.1.0.200901132140.jar" id="org.scribble.conversation.feature" version="0.1.0.200901132140">
<category name="Common"/>
</feature>
- <feature url="features/org.scribble.experimental.feature_0.1.0.200811131234.jar" id="org.scribble.experimental.feature" version="0.1.0.200811131234">
+ <feature url="features/org.scribble.experimental.feature_0.1.0.200901132140.jar" id="org.scribble.experimental.feature" version="0.1.0.200901132140">
<category name="Common"/>
</feature>
- <feature url="features/org.scribble.feature_0.1.0.200811131234.jar" id="org.scribble.feature" version="0.1.0.200811131234">
+ <feature url="features/org.scribble.feature_0.1.0.200901132140.jar" id="org.scribble.feature" version="0.1.0.200901132140">
<category name="Common"/>
</feature>
- <feature url="features/org.scribble.java.feature_0.1.0.200811131234.jar" id="org.scribble.java.feature" version="0.1.0.200811131234">
+ <feature url="features/org.scribble.java.feature_0.1.0.200901132140.jar" id="org.scribble.java.feature" version="0.1.0.200901132140">
<category name="Common"/>
</feature>
- <feature url="features/org.scribble.protocol.feature_0.1.0.200811131234.jar" id="org.scribble.protocol.feature" version="0.1.0.200811131234">
+ <feature url="features/org.scribble.protocol.feature_0.1.0.200901132140.jar" id="org.scribble.protocol.feature" version="0.1.0.200901132140">
<category name="Common"/>
</feature>
- <feature url="features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200811131234.jar" id="org.jboss.tools.overlord.cdl.jbossesb.feature" version="1.0.0.200811131234">
+ <feature url="features/org.jboss.tools.overlord.cdl.jbossesb.feature_1.0.0.200901132140.jar" id="org.jboss.tools.overlord.cdl.jbossesb.feature" version="1.0.0.200901132140">
<category name="JBossESB"/>
</feature>
<category-def name="JBossESB" label="JBossESB">
15 years, 3 months
Overlord SVN: r463 - in cdl/trunk/tools/plugins: org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator and 1 other directory.
by overlord-commits@lists.jboss.org
Author: objectiser
Date: 2009-01-13 16:36:23 -0500 (Tue, 13 Jan 2009)
New Revision: 463
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
Log:
Updated to use modified Scribble projector interface.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-01-13 20:01:58 UTC (rev 462)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/generator/Generator.java 2009-01-13 21:36:23 UTC (rev 463)
@@ -139,7 +139,7 @@
if (projector != null) {
Model localModel=projector.project(m_conversationModel,
- role, new DefaultModelListener());
+ role, null, new DefaultModelListener());
if (localModel instanceof ConversationModel &&
((ConversationModel)localModel).getConversation() != null) {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-13 20:01:58 UTC (rev 462)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.runtime.jbossesb/src/java/org/jboss/tools/overlord/cdl/runtime/jbossesb/generator/Generator.java 2009-01-13 21:36:23 UTC (rev 463)
@@ -139,7 +139,7 @@
if (projector != null) {
Model localModel=projector.project(m_conversationModel,
- role, new DefaultModelListener());
+ role, null, new DefaultModelListener());
if (localModel instanceof ConversationModel &&
((ConversationModel)localModel).getConversation() != null) {
15 years, 3 months