[overlord-commits] Overlord SVN: r591 - in cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src: plugintest/org/jboss/tools/overlord/cdl/bpel/generator and 2 other directories.
overlord-commits at lists.jboss.org
overlord-commits at lists.jboss.org
Tue Apr 21 17:57:34 EDT 2009
Author: objectiser
Date: 2009-04-21 17:57:34 -0400 (Tue, 21 Apr 2009)
New Revision: 591
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/EventHandler at Store.bpel
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/EventHandler at Store.scv
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel
Log:
Supporting different types of interaction constructs - scope with fault handlers, and pick/onMessage. Need to refactor some big methods and produce unit tests.
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-20 23:13:30 UTC (rev 590)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-04-21 21:57:34 UTC (rev 591)
@@ -151,12 +151,11 @@
portType = role.getName()+"PT";
- if (interaction.getMessageSignature().getAnnotations().keySet().contains("faultName")) {
- ((Reply)act).setFaultName((String)interaction.
- getMessageSignature().getAnnotations().get("faultName"));
+ if (InteractionPatterns.isFaultResponse(interaction)) {
+ ((Reply)act).setFaultName(InteractionPatterns.getFaultName(interaction));
}
}
- } else {
+ } else if (InteractionPatterns.isResponseInFaultHandler(interaction) == false) {
act = new Receive(bpelModel);
if (InteractionUtil.isRequest(interaction)) {
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java 2009-04-20 23:13:30 UTC (rev 590)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java 2009-04-21 21:57:34 UTC (rev 591)
@@ -86,44 +86,133 @@
DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
org.scribble.conversation.model.If elem=
(org.scribble.conversation.model.If)mobj;
+ java.util.List<Block> paths=elem.getPaths();
- If act=new If(bpelModel);
-
- if (context.getParent() instanceof Sequence) {
- ((Sequence)context.getParent()).addActivity(act, -1);
- }
-
- for (int i=0; i < elem.getPaths().size(); i++) {
- Block path=elem.getPaths().get(i);
+ // Check if the 'If' construct is to handle responses
+ // to a preceding request being sent
+ if (InteractionPatterns.isResponseAndFaultHandler(elem)) {
- Sequence seq=new Sequence(bpelModel);
-
- // Process the activities within the conversation
- java.util.List<Activity> acts=path.getContents();
+ if (context.getParent() instanceof Sequence) {
+ // Find fault handler
+ Sequence seq=(Sequence)context.getParent();
+ Scope scope=new Scope(bpelModel,
+ (org.w3c.dom.Element)seq.getDOMElement().getParentNode());
+ FaultHandlers fh=scope.getFaultHandlers();
+
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
+
+ if (path.getContents().size() > 0) {
+ Activity act=path.getContents().get(0);
+ Sequence subseq=null;
- Object parent=context.getParent();
+ if (act instanceof Interaction &&
+ InteractionPatterns.isFaultResponse(
+ (Interaction)act)) {
+ String faultName=InteractionPatterns.getFaultName((Interaction)act);
+
+ Catch c=new Catch(bpelModel);
+ c.setFaultName(faultName);
+
+ fh.addCatch(c);
+
+ subseq = new Sequence(bpelModel);
+ c.setActivity(subseq);
+ } else {
+ subseq = seq;
+ }
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int j=1; j < path.getContents().size(); j++) {
+ context.insert(model, path.getContents().get(j), null);
+ }
+
+ context.setParent(parent);
+ }
+ }
+ } else {
+ // TODO: Error handling
+ }
+ } else if (InteractionPatterns.isSwitch(elem)) {
+ Pick act=new Pick(bpelModel);
- context.setParent(seq);
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+ }
- for (int j=0; j < acts.size(); j++) {
- context.insert(model, acts.get(j), null);
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int j=1; j < acts.size(); j++) {
+ context.insert(model, acts.get(j), null);
+ }
+
+ context.setParent(parent);
+
+ OnMessage onm=new OnMessage(bpelModel);
+ onm.setActivity(seq);
+
+ Interaction recv=(Interaction)acts.get(0);
+
+ MessageSignature ms=recv.getMessageSignature();
+ if (ms.getOperation() != null) {
+ onm.setOperation(ms.getOperation());
+ }
+
+ act.addOnMessage(onm, -1);
}
- context.setParent(parent);
-
- if (i == 0) {
- act.setActivity(seq);
- } else if (i == elem.getPaths().size()-1) {
- Else construct=new Else(bpelModel);
- construct.setActivity(seq);
+ } else {
+ If act=new If(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+ }
+
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
- act.setElsePath(construct);
- } else {
- Elseif construct=new Elseif(bpelModel);
+ Sequence seq=new Sequence(bpelModel);
- construct.setActivity(seq);
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getContents();
+
+ Object parent=context.getParent();
- act.addElseIfPath(construct);
+ context.setParent(seq);
+
+ for (int j=0; j < acts.size(); j++) {
+ context.insert(model, acts.get(j), null);
+ }
+
+ context.setParent(parent);
+
+ if (i == 0) {
+ act.setActivity(seq);
+ } else if (i == elem.getPaths().size()-1) {
+ Else construct=new Else(bpelModel);
+ construct.setActivity(seq);
+
+ act.setElsePath(construct);
+ } else {
+ Elseif construct=new Elseif(bpelModel);
+
+ construct.setActivity(seq);
+
+ act.addElseIfPath(construct);
+ }
}
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java 2009-04-20 23:13:30 UTC (rev 590)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/InteractionPatterns.java 2009-04-21 21:57:34 UTC (rev 591)
@@ -18,7 +18,8 @@
package org.jboss.tools.overlord.cdl.bpel.model.change;
import org.jboss.tools.overlord.cdl.bpel.model.util.InteractionUtil;
-import org.scribble.model.Interaction;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
/**
* This class provides utility functions for detecting
@@ -26,6 +27,8 @@
*/
public class InteractionPatterns {
+ private static final String FAULT_NAME = "faultName";
+
/**
* This method checks whether the supplied interaction
* is a request that requires a scope with associated
@@ -41,7 +44,8 @@
// Check if interaction is an invoke, and followed
// by a choice representing a normal and multiple
// fault responses
- if (InteractionUtil.isRequest(interaction)) {
+ if (InteractionUtil.isRequest(interaction) &&
+ interaction.getRequestLabel() != null) {
if (interaction.getParent() instanceof
org.scribble.model.Block) {
@@ -92,4 +96,144 @@
// place itself and subsequent activities in a fault handler.
// Methods need to return (and set) the relevant sequence
// to use for subsequent activities.
+
+ public static boolean isResponseAndFaultHandler(If choice) {
+ boolean ret=false;
+
+ // Obtain interaction prior to 'If'
+ if (choice.getPaths().size() > 0 &&
+ choice.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isSend((Interaction)act) &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ ((Interaction)act).getRequestLabel() != null) {
+
+ // Check if each path has a response/fault associated
+ // with the preceding request
+ String requestLabel=
+ ((Interaction)act).getRequestLabel();
+
+ java.util.List<Block> paths=choice.getPaths();
+ int matched=0;
+
+ for (int i=0; i < paths.size(); i++) {
+ if (paths.get(i).getContents().size() > 0) {
+ org.scribble.model.Activity sub=
+ paths.get(i).getContents().get(0);
+
+ if (sub instanceof Interaction &&
+ InteractionUtil.isRequest((Interaction)sub) == false &&
+ ((Interaction)sub).getReplyToLabel() != null &&
+ ((Interaction)sub).getReplyToLabel().equals(requestLabel)) {
+ matched++;
+ }
+ }
+ }
+
+ if (matched == paths.size()) {
+ ret = true;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public static boolean isSwitch(If choice) {
+ boolean ret=false;
+
+ if (choice.getPaths().size() > 0) {
+ java.util.List<Block> paths=choice.getPaths();
+ int matched=0;
+
+ for (int i=0; i < paths.size(); i++) {
+ if (paths.get(i).getContents().size() > 0) {
+ org.scribble.model.Activity sub=
+ paths.get(i).getContents().get(0);
+
+ if (sub instanceof Interaction &&
+ InteractionUtil.isSend((Interaction)sub) == false) {
+ matched++;
+ }
+ }
+ }
+
+ if (matched == paths.size()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public static Interaction getRequestForResponseInFaultHandler(Interaction interaction) {
+ Interaction ret=null;
+
+ if (InteractionUtil.isRequest(interaction) == false &&
+ interaction.getReplyToLabel() != null) {
+
+ // Find if contained in 'if' path
+ if (interaction.getParent() instanceof Block &&
+ interaction.getParent().getParent() instanceof If) {
+
+ If choice=(If)interaction.getParent().getParent();
+
+ // Obtain interaction prior to 'If'
+ if (choice.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ ((Interaction)act).getRequestLabel() != null &&
+ interaction.getReplyToLabel().equals(
+ ((Interaction)act).getRequestLabel())) {
+ ret = (Interaction)act;
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public static boolean isResponseInFaultHandler(Interaction interaction) {
+ return(getRequestForResponseInFaultHandler(interaction) != null);
+ }
+
+ public static boolean isFaultResponse(Interaction interaction) {
+ boolean ret=false;
+
+ if (InteractionUtil.isRequest(interaction) == false &&
+ interaction.getMessageSignature().getAnnotations().
+ keySet().contains(FAULT_NAME)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static String getFaultName(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getAnnotations().get(FAULT_NAME));
+ }
}
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-20 23:13:30 UTC (rev 590)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/GeneratorTest.java 2009-04-21 21:57:34 UTC (rev 591)
@@ -36,6 +36,7 @@
TestSuite suite = new TestSuite("Conversation->BPEL Generator Tests");
suite.addTest(new ConversationToBPELTest("ESBBrokerProcess at Broker"));
suite.addTest(new ConversationToBPELTest("PurchaseGoodsProcess at Store"));
+ suite.addTest(new ConversationToBPELTest("EventHandler at Store"));
suite.addTest(new ChoreographyToBPELTest("ReqRespFault", "Buyer"));
suite.addTest(new ChoreographyToBPELTest("ReqRespFault", "Seller"));
return suite;
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/EventHandler at Store.bpel
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/EventHandler at Store.bpel (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/EventHandler at Store.bpel 2009-04-21 21:57:34 UTC (rev 591)
@@ -0,0 +1,22 @@
+<process xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
+ <partnerLinks>
+ <partnerLink myRole="StoreService" name="BuyerToStore" partnerLinkType="BuyerToStoreServiceLT"/>
+ <partnerLink myRole="StoreRequester" name="StoreToCreditAgency" partnerLinkType="StoreToCreditAgencyLT" partnerRole="CreditAgencyRequester"/>
+ </partnerLinks>
+ <sequence>
+ <receive operation="buy" partnerLink="BuyerToStore" portType="StorePT"/>
+ <invoke operation="checkCredit" partnerLink="StoreToCreditAgency" portType="CreditAgencyPT"/>
+ <if>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="StoreToCreditAgency" portType="StoreCreditAgencyCallbackPT"/>
+ <reply operation="buy" partnerLink="BuyerToStore" portType="StorePT"/>
+ </sequence>
+ <else>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="StoreToCreditAgency" portType="StoreCreditAgencyCallbackPT"/>
+ <reply operation="buy" partnerLink="BuyerToStore" portType="StorePT"/>
+ </sequence>
+ </else>
+ </if>
+ </sequence>
+</process>
Modified: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel 2009-04-20 23:13:30 UTC (rev 590)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/results/ReqRespFault at Buyer.bpel 2009-04-21 21:57:34 UTC (rev 591)
@@ -3,16 +3,21 @@
<partnerLink myRole="BuyerRequester" name="BuyerToSeller" partnerLinkType="BuyerToSellerLT" partnerRole="SellerRequester"/>
</partnerLinks>
<sequence>
- <invoke operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
- <if>
+ <scope>
+ <faultHandlers/>
<sequence>
- <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
+ <invoke operation="checkCredit" partnerLink="BuyerToSeller" portType="SellerPT"/>
+ <if>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
+ </sequence>
+ <else>
+ <sequence>
+ <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
+ </sequence>
+ </else>
+ </if>
</sequence>
- <else>
- <sequence>
- <receive operation="checkCredit" partnerLink="BuyerToSeller" portType="BuyerSellerCallbackPT"/>
- </sequence>
- </else>
- </if>
+ </scope>
</sequence>
</process>
Added: cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/EventHandler at Store.scv
===================================================================
--- cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/EventHandler at Store.scv (rev 0)
+++ cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/generator/testmodels/EventHandler at Store.scv 2009-04-21 21:57:34 UTC (rev 591)
@@ -0,0 +1,11 @@
+namespace org.examples;
+
+conversation EventHandler at Store {
+ role CreditAgency;
+
+ if @ CreditAgency {
+ checkCredit(CreditCheckOk) from CreditAgency to Store;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Store;
+ }
+}
\ No newline at end of file
More information about the overlord-commits
mailing list