Author: objectiser
Date: 2008-09-26 10:15:53 -0400 (Fri, 26 Sep 2008)
New Revision: 346
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
Log:
Fix insertion of receive interaction in the middle of two other receives.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-25
18:39:40 UTC (rev 345)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.jbossesb/src/java/org/jboss/tools/overlord/cdl/jbossesb/model/change/ConversationInteractionModelChangeRule.java 2008-09-26
14:15:53 UTC (rev 346)
@@ -263,13 +263,36 @@
ESBLanguageModel esbModel, ConversationInteraction interaction,
ModelObject ref) {
ESBService service=getESBService(context, ref);
+ ESBService endService=service;
- // TODO: Create a new service to receive the
- // message and add a schedule service to link
- // to this new service - issue, how do we
- // deal with request/response
- if (service.isCreateSession() == false &&
- service.isSessionBased()) {
+ int pos=-1;
+ int endPos=-1;
+ boolean f_subsequentInitiator=false;
+
+ // 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) {
+ pos = service.getActions().indexOf((ESBAction)
+ ref.getSource().getObject());
+
+ // 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 ((ref == null && service.isSessionBased()) || pos > 0) {
+
// Already has activities, so need to separate
// into another service descriptor
ESBService recvService=esbModel.createService(
@@ -286,40 +309,72 @@
schedule.setDestination(recvService.getCategory(),
recvService.getName(), false);
-// service.addAction(schedule, -1);
- int pos=-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) {
- pos = service.getActions().indexOf((ESBAction)
- ref.getSource().getObject());
- }
-
service.addAction(schedule, pos);
context.setParent(recvService);
+
+ endService = recvService;
+ endPos = 0;
}
ReceiveMessageAction action=
- new ReceiveMessageAction((ESBService)context.getParent());
-
+ new ReceiveMessageAction(endService);
+
if (interaction.getMessageSignature().getOperation() != null) {
action.setOperation(interaction.getMessageSignature().getOperation());
}
setMessageType(action, interaction);
+
+ endService.addAction(action, endPos);
- // TODO: Decide how to determine position, in situations
- // where new service no created
- ((ESBService)context.getParent()).addAction(action, -1);
-
if (((ESBService)context.getParent()).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) {
+ 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 a response, then add to the gateway
if (interaction.getReplyToLabel() == null) {
ESBService gwService=esbModel.getGatewayService();
Show replies by date