savara SVN: r71 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel: model/change and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-31 15:03:06 -0400 (Sat, 31 Oct 2009)
New Revision: 71
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
Log:
Generate initial partner link types to separate wsdl. Needs more work/testing.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-31 15:49:57 UTC (rev 70)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-31 19:03:06 UTC (rev 71)
@@ -17,15 +17,22 @@
*/
package org.jboss.savara.tools.bpel.generator;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.apache.commons.logging.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.jboss.savara.tools.bpel.generator.BuildSystem;
import org.jboss.savara.tools.bpel.model.*;
+import org.jboss.savara.tools.bpel.model.component.PartnerLink;
import org.jboss.savara.tools.bpel.util.XMLUtils;
import org.jboss.savara.tools.wsdl.soap.SOAPRPCWSDLBinding;
import org.scribble.contract.model.Contract;
+import org.scribble.contract.model.Interface;
import org.scribble.conversation.model.*;
import org.scribble.extensions.RegistryFactory;
import org.scribble.model.*;
@@ -160,8 +167,7 @@
lcm);
generateRoleProject(projectName, role,
- target.getBPELProcess().getDOMElement(),
- lcm, target);
+ target.getBPELProcess(), lcm, target);
} else {
logger.error("Unable to find model generator");
}
@@ -170,12 +176,12 @@
}
protected void generateRoleProject(String projectName, Role role,
- org.w3c.dom.Element bpel, ConversationModel localcm,
+ org.jboss.savara.tools.bpel.model.component.Process bpelProcess, ConversationModel localcm,
BPELLanguageModel model) throws Exception {
final IProject proj=createProject(projectName);
- if (proj != null && bpel != null) {
+ if (proj != null && bpelProcess != null) {
// Store BPEL configuration
IPath bpelPath=proj.getFullPath().append(
@@ -188,7 +194,7 @@
bpelFile.create(null, true,
new org.eclipse.core.runtime.NullProgressMonitor());
- String bpelText=XMLUtils.toText(bpel);
+ String bpelText=XMLUtils.toText(bpelProcess.getDOMElement());
if (bpelText != null) {
bpelFile.setContents(new java.io.ByteArrayInputStream(
@@ -204,6 +210,9 @@
for (int i=0; i < roles.size(); i++) {
generateWSDL(roles.get(i), proj, localcm);
}
+
+ // Generate WSDL with partner link types
+ generatePartnerLinkTypes(role, proj, localcm, bpelProcess);
}
}
@@ -262,7 +271,180 @@
}
}
+ protected void generatePartnerLinkTypes(Role role, IProject proj, ConversationModel localcm,
+ org.jboss.savara.tools.bpel.model.component.Process bpelProcess) throws Exception {
+
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();;
+
+ org.w3c.dom.Element defn=doc.createElementNS("http://schemas.xmlsoap.org/wsdl/", "definition");
+ doc.appendChild(defn);
+
+ defn.setAttribute("xmlns:plnk", "http://docs.oasis-open.org/wsbpel/2.0/plnktype");
+
+ for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
+ org.w3c.dom.Element plt=doc.createElement("plnk:partnerLinkType");
+
+ plt.setAttribute("name", pl.getPartnerLinkType());
+
+ if (pl.getPartnerRole() != null && pl.getPartnerRole().trim().length() > 0) {
+ org.w3c.dom.Element plRole=doc.createElement("plnk:role");
+
+ plt.appendChild(plRole);
+
+ plRole.setAttribute("name", pl.getPartnerRole());
+
+ Role useRole=null;
+
+ for (int i=0; useRole == null &&
+ i < localcm.getConversation().getRoles().size(); i++) {
+ if (pl.getPartnerRole().startsWith(localcm.getConversation().getRoles().get(i).getName())) {
+ useRole = localcm.getConversation().getRoles().get(i);
+ }
+ }
+
+ if (useRole != null &&
+ useRole.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)useRole.getAnnotations().get(Contract.class.getName());
+
+ if (contract.getInterfaces().size() > 0) {
+ Interface intf=contract.getInterfaces().get(0);
+
+ plRole.setAttribute("portType", intf.getName());
+ }
+ }
+ }
+
+ if (pl.getMyRole() != null && pl.getMyRole().trim().length() > 0) {
+ org.w3c.dom.Element plRole=doc.createElement("plnk:role");
+
+ plt.appendChild(plRole);
+
+ plRole.setAttribute("name", pl.getMyRole());
+
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+
+ if (contract.getInterfaces().size() > 0) {
+ Interface intf=contract.getInterfaces().get(0);
+
+ plRole.setAttribute("portType", intf.getName());
+ }
+ }
+ }
+
+ defn.appendChild(plt);
+ }
+
+ IPath wsdlPath=proj.getFullPath().append(
+ new Path(getBuildSystem().getBPELFilePath())).
+ append(role.getName()+"PartnerLinkTypes.wsdl");
+
+ IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
+ GeneratorUtil.createParentFolder(wsdlFile);
+ wsdlFile.create(null, true,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+
+ java.io.ByteArrayOutputStream xmlstr=
+ new java.io.ByteArrayOutputStream();
+
+ DOMSource source=new DOMSource();
+ source.setNode(doc);
+
+ StreamResult result=new StreamResult(xmlstr);
+
+ Transformer trans=
+ TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ String xml=reformat(new String(xmlstr.toByteArray()));
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(xml.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
+ }
+
/**
+ * This method reformats the XML text for presentation.
+ *
+ * @param xmltext The original XML text
+ * @return The reformatted text
+ */
+ private static String reformat(String xmltext) {
+ String ret=xmltext;
+ int pos=0;
+ int prevpos=0;
+ StringBuffer buf=new StringBuffer();
+ int level=0;
+
+ while ((pos=ret.indexOf('<', prevpos)) != -1) {
+
+ if (prevpos < pos &&
+ ret.substring(prevpos, pos).trim().length() > 0 &&
+ ret.charAt(prevpos-1) != '?') {
+
+ if (ret.charAt(prevpos) == '\r' &&
+ ret.charAt(prevpos+1) == '\n') {
+ prevpos += 2;
+ }
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+
+ buf.append(ret.substring(prevpos, pos).trim());
+ buf.append("\r\n");
+ }
+
+ int endpos=ret.indexOf('>', pos);
+
+ if (endpos > 0) {
+ boolean noreturn=false;
+
+ if (pos > 0 && ret.charAt(pos+1) == '/') {
+ level--;
+ }
+
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+ buf.append(ret.substring(pos, endpos+1));
+
+ if (ret.charAt(endpos-1)== '?') {
+ //noreturn = true;
+
+ } else if (ret.charAt(endpos-1) == '/') {
+ // Ignore
+ } else if (pos > 0 && ret.charAt(pos+1) == '/') {
+ // Ignore
+
+ } else if (pos > 0 && ret.charAt(pos+1) == '!') {
+ // Ignore
+
+ } else {
+ level++;
+ }
+
+ if (noreturn == false) {
+ buf.append("\r\n");
+ }
+
+ pos = endpos+1;
+ }
+
+ prevpos = pos;
+ }
+
+ if (prevpos != -1 &&
+ ret.substring(prevpos).trim().length() > 0) {
+ buf.append(ret.substring(prevpos));
+ }
+
+ ret = buf.toString();
+
+ return(ret);
+ }
+
+ /**
* This method returns the WSDL file name for the supplied role and local
* conversation model.
*
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-31 15:49:57 UTC (rev 70)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-31 19:03:06 UTC (rev 71)
@@ -91,6 +91,7 @@
Model model, ModelObject mobj, ModelObject ref) {
DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
Conversation conv=(Conversation)mobj;
+ String roleNamespace=null;
Sequence seq=new Sequence(bpelModel);
@@ -106,6 +107,8 @@
Contract contract=(Contract)conv.getLocatedName().
getRole().getAnnotations().get(Contract.class.getName());
+ roleNamespace = contract.getNamespace();
+
// Set namespace
bpelModel.getBPELProcess().setTargetNamespace(contract.getNamespace());
@@ -151,6 +154,14 @@
addImport(context, bpelModel, conv, roles.get(i));
}
+ // Add import for partner link types
+ Import imp=new Import(bpelModel);
+ imp.setLocation(context.getRole().getName()+"PartnerLinkTypes.wsdl");
+ imp.setNamespace(roleNamespace);
+ imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getBPELProcess().addImport(imp, -1);
+
// Add sequence to model
bpelModel.getBPELProcess().setActivity(seq);
14 years, 6 months
savara SVN: r70 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src: java/org/jboss/savara/tools/bpel/model/component and 2 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-31 11:49:57 -0400 (Sat, 31 Oct 2009)
New Revision: 70
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Pick.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/util/InteractionUtil.java
Log:
Define 'createInstance' attribute on appropriate receive and pick constructs.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-31 12:35:22 UTC (rev 69)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-31 15:49:57 UTC (rev 70)
@@ -238,6 +238,11 @@
if (varName != null) {
((Receive)act).setVariable(varName);
}
+
+ // Check if create instance
+ if (InteractionUtil.isFirstInteraction(interaction)) {
+ ((Receive)act).setCreateInstance(true);
+ }
}
}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-31 12:35:22 UTC (rev 69)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-31 15:49:57 UTC (rev 70)
@@ -265,6 +265,11 @@
createVariable(varName, recv, bpelModel);
}
+ // Check if create instance
+ if (InteractionUtil.isFirstInteraction(recv)) {
+ act.setCreateInstance(true);
+ }
+
// Set details on interaction
onm.setPartnerLink(pl.getName());
onm.setPortType(portType);
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Pick.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Pick.java 2009-10-31 12:35:22 UTC (rev 69)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Pick.java 2009-10-31 15:49:57 UTC (rev 70)
@@ -32,6 +32,7 @@
private static final long serialVersionUID = -2235972351406517577L;
public static final String PICK = "pick";
+ public static final String CREATE_INSTANCE = "createInstance";
/**
* The constructor for the activity.
@@ -72,6 +73,36 @@
}
/**
+ * This method sets the 'create instance'
+ * attribute.
+ *
+ * @param b Whether to create instance
+ */
+ public void setCreateInstance(boolean b) {
+ String create=(b?"yes":"no");
+
+ getDOMElement().setAttribute(CREATE_INSTANCE, create);
+ }
+
+ /**
+ * This method returns whether to create instance.
+ *
+ * @return Whether to create instance
+ */
+ public boolean getCreateInstance() {
+ boolean ret=false;
+ String create=
+ getDOMElement().getAttribute(CREATE_INSTANCE);
+
+ if (create != null &&
+ create.equals("yes")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
* This method adds an 'onMessage' to the grouping construct.
*
* @param on The 'onMessage' to be added
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/util/InteractionUtil.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/util/InteractionUtil.java 2009-10-31 12:35:22 UTC (rev 69)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/util/InteractionUtil.java 2009-10-31 15:49:57 UTC (rev 70)
@@ -20,6 +20,7 @@
import org.jboss.savara.tools.bpel.model.component.BPELActivity;
import org.jboss.savara.tools.bpel.model.component.Invoke;
import org.jboss.savara.tools.bpel.model.component.Sequence;
+import org.scribble.conversation.model.If;
import org.scribble.model.*;
/**
@@ -91,6 +92,60 @@
}
/**
+ * This method determines whether this is the first interaction
+ * associated with the conversation.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is the first in the conversation
+ */
+ public static boolean isFirstInteraction(Interaction interaction) {
+ boolean ret=false;
+
+ if (interaction.getParent() instanceof Block &&
+ interaction.getParent().getParent() != null) {
+ ModelObject parent=(ModelObject)interaction.getParent().getParent();
+
+ // Check that first interaction in block
+ Block block=(Block)interaction.getParent();
+ ret = true;
+
+ for (int i=0; ret && i < block.getContents().size(); i++) {
+ if (block.getContents().get(i) == interaction) {
+ break;
+ } else if (block.getContents().get(i) instanceof Interaction) {
+ ret = false;
+ }
+ }
+
+ // Check if definition
+ if (ret) {
+
+ if (parent instanceof If) {
+ if (parent.getParent() instanceof Block) {
+ parent = parent.getParent().getParent();
+ }
+ }
+
+ if (parent instanceof Definition) {
+
+ // Check if it is the top level definition
+ ret = (parent.getParent() instanceof Model);
+
+ // TODO: How do we know if this conversation is the
+ // top level, or has it been 'run' by the top level
+ // conversation? While the conversation used to
+ // generate the BPEL is produced as one definition,
+ // this should not be a problem.
+ } else {
+ ret = false;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
* This method determines whether the supplied activity
* is either an invoke, or a sequence that has an
* invoke as its first element.
Added: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/util/InteractionUtilTest.java 2009-10-31 15:49:57 UTC (rev 70)
@@ -0,0 +1,92 @@
+/*
+ * 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.savara.tools.bpel.util;
+
+import junit.framework.TestCase;
+
+import org.jboss.savara.tools.bpel.model.util.InteractionUtil;
+import org.scribble.conversation.model.*;
+import org.scribble.model.*;
+
+public class InteractionUtilTest extends TestCase {
+
+ public void testIsFirstInteractionSingleInteraction() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ Interaction i1=new Interaction();
+
+ c.getBlock().getContents().add(i1);
+
+ if (InteractionUtil.isFirstInteraction(i1) == false) {
+ fail("Interaction should be first in conversation");
+ }
+ }
+
+ public void testIsFirstInteractionSecondInteraction() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ Interaction i1=new Interaction();
+ Interaction i2=new Interaction();
+
+ c.getBlock().getContents().add(i1);
+ c.getBlock().getContents().add(i2);
+
+ if (InteractionUtil.isFirstInteraction(i2)) {
+ fail("Interaction should NOT be first in conversation");
+ }
+ }
+
+ public void testIsFirstInteractionIfElse() {
+ ConversationModel cm=new ConversationModel();
+ Conversation c=new Conversation();
+ cm.setConversation(c);
+
+ If choice=new If();
+ c.getBlock().getContents().add(choice);
+
+ Block b=choice.createNewPath();
+
+ Interaction i1=new Interaction();
+
+ b.getContents().add(i1);
+
+ Block b2=choice.createNewPath();
+
+ Interaction i2=new Interaction();
+ Interaction i3=new Interaction();
+
+ b2.getContents().add(i2);
+ b2.getContents().add(i3);
+
+ if (InteractionUtil.isFirstInteraction(i1) == false) {
+ fail("Interaction should be first in conversation");
+ }
+
+ if (InteractionUtil.isFirstInteraction(i2) == false) {
+ fail("Interaction should be first in conversation");
+ }
+
+ if (InteractionUtil.isFirstInteraction(i3)) {
+ fail("Interaction should NOT be first in conversation");
+ }
+ }
+}
14 years, 6 months
savara SVN: r69 - tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-31 08:35:22 -0400 (Sat, 31 Oct 2009)
New Revision: 69
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
Log:
Add namespace prefix to faultName in catch and reply.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-31 10:51:56 UTC (rev 68)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-31 12:35:22 UTC (rev 69)
@@ -96,6 +96,7 @@
Role role=null;
String portType=null;
String varName=InteractionPatterns.getVariableName(interaction);
+ Interface intf=null;
if (interaction.getEnclosingDefinition() != null) {
role = interaction.getEnclosingDefinition().
@@ -115,17 +116,19 @@
// Assume that contract only has one interface for now
if (contract.getInterfaces().size() > 0) {
- Interface intf=contract.getInterfaces().get(0);
-
- portType = intf.getName();
-
- String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
-
- if (prefix != null) {
- portType = prefix+":"+portType;
- }
+ intf = contract.getInterfaces().get(0);
}
}
+
+ if (intf != null) {
+ portType = intf.getName();
+
+ String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
// Check if send or receive
if (InteractionUtil.isSend(interaction)) {
@@ -176,7 +179,18 @@
//portType = role.getName()+"PT";
if (InteractionPatterns.isFaultResponse(interaction)) {
- ((Reply)act).setFaultName(InteractionPatterns.getFaultName(interaction));
+ String faultName=InteractionPatterns.getFaultName(interaction);
+
+ // Find namespace prefix
+ if (intf != null) {
+ String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ faultName = prefix+":"+faultName;
+ }
+ }
+
+ ((Reply)act).setFaultName(faultName);
}
if (varName != null) {
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-31 10:51:56 UTC (rev 68)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-31 12:35:22 UTC (rev 69)
@@ -114,7 +114,6 @@
String faultVarName=InteractionPatterns.getVariableName((Interaction)act);
Catch c=new Catch(bpelModel);
- c.setFaultName(faultName);
c.setFaultVariable(faultVarName);
// Define fault message type
@@ -127,9 +126,11 @@
if (prefix != null) {
mesgType = prefix+":"+mesgType;
+ faultName = prefix+":"+faultName;
}
}
+ c.setFaultName(faultName);
c.setFaultMessageType(mesgType);
// Add catch to fault handler
14 years, 6 months
savara SVN: r68 - tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-31 06:51:56 -0400 (Sat, 31 Oct 2009)
New Revision: 68
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
Log:
Added namespace prefix to port type, plus updated it to use the name used in the WSDL. Also prevent fault variable being generated to variables area, and instead defined in the catch, with the faultMessageType also added.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-30 23:48:26 UTC (rev 67)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-10-31 10:51:56 UTC (rev 68)
@@ -22,6 +22,8 @@
import org.jboss.savara.tools.bpel.model.util.*;
import org.scribble.model.*;
import org.scribble.model.change.*;
+import org.scribble.contract.model.Contract;
+import org.scribble.contract.model.Interface;
import org.scribble.conversation.model.*;
import org.scribble.extensions.RegistryInfo;
@@ -100,6 +102,31 @@
getLocatedName().getRole();
}
+ // Identify port type role
+ Role portTypeRole=role;
+
+ if (InteractionUtil.isRequest(interaction) && interaction.getToRole() != null) {
+ portTypeRole = interaction.getToRole();
+ }
+
+ if (portTypeRole != null &&
+ portTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)portTypeRole.getAnnotations().get(Contract.class.getName());
+
+ // Assume that contract only has one interface for now
+ if (contract.getInterfaces().size() > 0) {
+ Interface intf=contract.getInterfaces().get(0);
+
+ portType = intf.getName();
+
+ String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
+ }
+
// Check if send or receive
if (InteractionUtil.isSend(interaction)) {
@@ -133,7 +160,7 @@
pl.setName(role.getName()+"To"+interaction.getToRole().getName());
pl.setPartnerLinkType(role.getName()+"To"+interaction.getToRole().getName()+"LT");
- portType = interaction.getToRole().getName()+"PT";
+ //portType = interaction.getToRole().getName()+"PT";
if (varName != null) {
((Invoke)act).setInputVariable(varName);
@@ -146,7 +173,7 @@
pl.setName(interaction.getToRole().getName()+"To"+role.getName());
pl.setPartnerLinkType(interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT");
- portType = role.getName()+"PT";
+ //portType = role.getName()+"PT";
if (InteractionPatterns.isFaultResponse(interaction)) {
((Reply)act).setFaultName(InteractionPatterns.getFaultName(interaction));
@@ -183,15 +210,15 @@
pl.setName(interaction.getFromRole().getName()+"To"+role.getName());
pl.setPartnerLinkType(interaction.getFromRole().getName()+"To"+role.getName()+"Service"+"LT");
- portType = role.getName()+"PT";
+ //portType = role.getName()+"PT";
} else {
pl.setMyRole(role.getName()+"Requester");
pl.setPartnerRole(interaction.getFromRole().getName()+"Service");
pl.setName(role.getName()+"To"+interaction.getFromRole().getName());
pl.setPartnerLinkType(role.getName()+"To"+interaction.getFromRole().getName()+"Requester"+"LT");
- portType = role.getName()+
- interaction.getFromRole().getName()+"CallbackPT";
+ //portType = role.getName()+
+ // interaction.getFromRole().getName()+"CallbackPT";
}
if (varName != null) {
@@ -232,6 +259,7 @@
// Set details on interaction
act.setPartnerLink(pl.getName());
+
act.setPortType(portType);
if (interaction.getMessageSignature() != null) {
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-30 23:48:26 UTC (rev 67)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-10-31 10:51:56 UTC (rev 68)
@@ -117,15 +117,22 @@
c.setFaultName(faultName);
c.setFaultVariable(faultVarName);
- // TODO: Maybe variable should not be created - just
- // defined in the scope of the catch? But would then
- // need to define the fault message type/element.
+ // Define fault message type
+ String mesgType=InteractionPatterns.getMessageTypeLocalPart((Interaction)act);
+ String namespace=InteractionPatterns.getMessageTypeNameSpace((Interaction)act);
+
+ // Find namespace prefix
+ if (namespace != null) {
+ String prefix=bpelModel.getBPELProcess().addNamespace(namespace);
+
+ if (prefix != null) {
+ mesgType = prefix+":"+mesgType;
+ }
+ }
- // Create variable
- if (faultVarName != null) {
- createVariable(faultVarName, (Interaction)act, bpelModel);
- }
-
+ c.setFaultMessageType(mesgType);
+
+ // Add catch to fault handler
fh.addCatch(c);
subseq = new Sequence(bpelModel);
14 years, 6 months
savara SVN: r67 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src: java/org/jboss/savara/tools/bpel/model/change and 2 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-30 19:48:26 -0400 (Fri, 30 Oct 2009)
New Revision: 67
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java
Log:
Minor changes and added bpel prefix namespace by default, as Eclipse BPEL editor expects this to be present.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2009-10-27 23:34:03 UTC (rev 66)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2009-10-30 23:48:26 UTC (rev 67)
@@ -17,7 +17,7 @@
*/
package org.jboss.savara.tools.bpel.model;
-import org.apache.commons.logging.*;
+//import org.apache.commons.logging.*;
import org.jboss.savara.tools.bpel.model.component.Process;
import org.scribble.conversation.model.Conversation;
import org.scribble.model.*;
@@ -124,7 +124,7 @@
return(m_bpelProcess);
}
- private static Log logger = LogFactory.getLog(DefaultBPELLanguageModel.class);
+ //private static Log logger = LogFactory.getLog(DefaultBPELLanguageModel.class);
private ModelReference m_source=null;
private Process m_bpelProcess=null;
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-27 23:34:03 UTC (rev 66)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-30 23:48:26 UTC (rev 67)
@@ -33,7 +33,7 @@
@RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
public class ConversationModelChangeRule extends AbstractModelChangeRule {
- private static final String NAME_SUFFIX = "_main";
+ //private static final String NAME_SUFFIX = "_main";
/**
* This method determines whether the rule is appropriate
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-27 23:34:03 UTC (rev 66)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-30 23:48:26 UTC (rev 67)
@@ -41,6 +41,7 @@
public static final String NAME = "name";
public static final String TARGET_NAMESPACE = "targetNamespace";
public static final String CONVERSATION_TYPE = "conversationType";
+ public static final String BPEL_PREFIX = "bpel";
public static final String CONVERSATION_NS="http://www.scribble.org/conversation";
@@ -78,8 +79,8 @@
}
}
- m_messageExchangesElem = findChildElement("messageExchanges");
- m_correlationSetsElem = findChildElement("correlationSets");
+ //m_messageExchangesElem = findChildElement("messageExchanges");
+ //m_correlationSetsElem = findChildElement("correlationSets");
org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
if (ehs != null) {
@@ -101,6 +102,8 @@
*/
public Process(BPELLanguageModel model) {
super(model, PROCESS);
+
+ initNamespace(BPEL_NS, BPEL_PREFIX);
}
/**
@@ -839,9 +842,9 @@
private static Log logger = LogFactory.getLog(Process.class);
private org.w3c.dom.Element m_partnerLinksElem=null;
- private org.w3c.dom.Element m_messageExchangesElem=null;
+ //private org.w3c.dom.Element m_messageExchangesElem=null;
private org.w3c.dom.Element m_variablesElem=null;
- private org.w3c.dom.Element m_correlationSetsElem=null;
+ //private org.w3c.dom.Element m_correlationSetsElem=null;
private java.util.List<Import> m_imports=new java.util.Vector<Import>();
private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java 2009-10-27 23:34:03 UTC (rev 66)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java 2009-10-30 23:48:26 UTC (rev 67)
@@ -41,7 +41,7 @@
public void testProcessFromDOM() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<partnerLinks><partnerLink/></partnerLinks>"+
"<messageExchanges/>"+
"<variables><variable/></variables>"+
@@ -49,7 +49,7 @@
"<faultHandlers/>"+
"<eventHandlers/>"+
"<sequence/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element elem=null;
@@ -98,14 +98,14 @@
public void testAddVariable() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<partnerLinks><partnerLink/></partnerLinks>"+
"<messageExchanges/>"+
"<correlationSets/>"+
"<faultHandlers/>"+
"<eventHandlers/>"+
"<sequence/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element ifelem=null;
@@ -151,14 +151,14 @@
public void testAddPartnerLink() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<messageExchanges/>"+
"<variables><variable/></variables>"+
"<correlationSets/>"+
"<faultHandlers/>"+
"<eventHandlers/>"+
"<sequence/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element elem=null;
@@ -224,14 +224,14 @@
public void testSetEventHandlers() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<partnerLinks><partnerLink/></partnerLinks>"+
"<messageExchanges/>"+
"<variables><variable/></variables>"+
"<correlationSets/>"+
"<faultHandlers/>"+
"<sequence/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element ifelem=null;
@@ -277,14 +277,14 @@
public void testSetFaultHandlers() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<partnerLinks><partnerLink/></partnerLinks>"+
"<messageExchanges/>"+
"<variables><variable/></variables>"+
"<correlationSets/>"+
"<eventHandlers/>"+
"<sequence/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element ifelem=null;
@@ -330,14 +330,14 @@
public void testSetActivity() {
BPELLanguageModel model=new DefaultBPELLanguageModel(null);
- String xml="<scope xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+ String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
"<partnerLinks><partnerLink/></partnerLinks>"+
"<messageExchanges/>"+
"<variables><variable/></variables>"+
"<correlationSets/>"+
"<faultHandlers/>"+
"<eventHandlers/>"+
- "</scope>";
+ "</process>";
org.w3c.dom.Element ifelem=null;
@@ -421,4 +421,20 @@
fail("Prefixes should be same: "+prefix1+" "+prefix2);
}
}
+
+ public void testDefaultNamesapces() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ Process component=new Process(model);
+
+ String ns=component.getNamespace(Process.BPEL_PREFIX);
+
+ if (ns == null) {
+ fail("Namespace not found");
+ }
+
+ if (ns.equals(Process.BPEL_NS) == false) {
+ fail("Namespace is wrong: "+ns+" was expecting "+Process.BPEL_NS);
+ }
+ }
}
14 years, 6 months
savara SVN: r66 - validator/trunk and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-27 19:34:03 -0400 (Tue, 27 Oct 2009)
New Revision: 66
Modified:
runtime/trunk/
validator/trunk/
Log:
Ignore eclipse project file.
Property changes on: runtime/trunk
___________________________________________________________________
Name: svn:ignore
+ .project
Property changes on: validator/trunk
___________________________________________________________________
Name: svn:ignore
+ .project
14 years, 6 months
savara SVN: r65 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model: component and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-19 17:40:21 -0400 (Mon, 19 Oct 2009)
New Revision: 65
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
Log:
Initialise namespace prefixes from contract.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-19 21:26:24 UTC (rev 64)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-19 21:40:21 UTC (rev 65)
@@ -108,6 +108,11 @@
// Set namespace
bpelModel.getBPELProcess().setTargetNamespace(contract.getNamespace());
+
+ // Add other namespaces
+ for (org.scribble.contract.model.Namespace ns : contract.getNamespaces()) {
+ bpelModel.getBPELProcess().initNamespace(ns.getURI(), ns.getPrefix());
+ }
}
String namespace=((Model)conv.getModel()).
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-19 21:26:24 UTC (rev 64)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-19 21:40:21 UTC (rev 65)
@@ -380,6 +380,17 @@
}
/**
+ * This method initialises the prefix associated with the supplied
+ * namespace.
+ *
+ * @param namespace
+ * @param prefix
+ */
+ public void initNamespace(String namespace, String prefix) {
+ getDOMElement().setAttribute("xmlns:"+prefix, namespace);
+ }
+
+ /**
* This method adds a new namespace and returns the
* prefix allocated to it.
*
@@ -402,7 +413,7 @@
return(ret);
}
-
+
/**
* This method adds a variable to the scope.
*
14 years, 6 months
savara SVN: r64 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model: component and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-19 17:26:24 -0400 (Mon, 19 Oct 2009)
New Revision: 64
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
Log:
Set the target namespace.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-19 20:10:54 UTC (rev 63)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-19 21:26:24 UTC (rev 64)
@@ -101,6 +101,15 @@
bpelModel.getBPELProcess().setName(conv.getLocatedName().getName()+"_"+
conv.getLocatedName().getRole().getName());
+ // Get contract
+ if (conv.getLocatedName().getRole().getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)conv.getLocatedName().
+ getRole().getAnnotations().get(Contract.class.getName());
+
+ // Set namespace
+ bpelModel.getBPELProcess().setTargetNamespace(contract.getNamespace());
+ }
+
String namespace=((Model)conv.getModel()).
getNamespace().getName();
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-19 20:10:54 UTC (rev 63)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-19 21:26:24 UTC (rev 64)
@@ -39,6 +39,7 @@
public static final String PROCESS = "process";
public static final String NAME = "name";
+ public static final String TARGET_NAMESPACE = "targetNamespace";
public static final String CONVERSATION_TYPE = "conversationType";
public static final String CONVERSATION_NS="http://www.scribble.org/conversation";
@@ -286,6 +287,25 @@
}
/**
+ * This method sets the target namespace.
+ *
+ * @param tns The target namespace
+ */
+ public void setTargetNamespace(String tns) {
+ getDOMElement().setAttribute(TARGET_NAMESPACE, tns);
+ }
+
+ /**
+ * This method returns the target namespace.
+ *
+ * @return The target namespace
+ */
+ public String getTargetNamespace() {
+ return(getDOMElement().hasAttribute(TARGET_NAMESPACE)?
+ getDOMElement().getAttribute(TARGET_NAMESPACE):null);
+ }
+
+ /**
* This method sets the conversation type.
*
* @param ctype The conversation type
14 years, 6 months
savara SVN: r63 - in tools/eclipse/trunk/plugins: org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component and 3 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-19 16:10:54 -0400 (Mon, 19 Oct 2009)
New Revision: 63
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
Log:
Fix namespace issue and remove 'SOAP' from binding suffix.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-17 22:36:19 UTC (rev 62)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-19 20:10:54 UTC (rev 63)
@@ -224,7 +224,8 @@
javax.wsdl.Definition defn=defns.get(i);
// Check if definition has a port type
- if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0) {
+ if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0
+ || defn.getServices().size() > 0) {
String filename=getWSDLFileName(role, localcm.getModelName().getName(), i);
if (i > 0) {
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-17 22:36:19 UTC (rev 62)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-19 20:10:54 UTC (rev 63)
@@ -324,7 +324,7 @@
if (attr.getNodeValue().equals(namespace) &&
attr.getNodeName().startsWith("xmlns:")) {
- ret = attr.getNodeName().substring(7);
+ ret = attr.getNodeName().substring(6);
}
}
}
@@ -369,14 +369,14 @@
public String addNamespace(String namespace) {
String ret=getPrefix(namespace);
int i=1;
-
+
while (ret == null) {
- String prefix="ns"+i;
+ String prefix="ns"+(i++);
if (getDOMElement().hasAttribute("xmlns:"+prefix) == false) {
ret = prefix;
- getDOMElement().setAttribute(prefix, namespace);
+ getDOMElement().setAttribute("xmlns:"+prefix, namespace);
}
}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java 2009-10-17 22:36:19 UTC (rev 62)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ProcessTest.java 2009-10-19 20:10:54 UTC (rev 63)
@@ -379,4 +379,46 @@
item(6).getLocalName());
}
}
+
+ public void testAddDistinctNamespaces() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ Process component=new Process(model);
+
+ String prefix1=component.addNamespace("namespace1");
+ String prefix2=component.addNamespace("namespace2");
+
+ if (prefix1 == null) {
+ fail("First prefix is null");
+ }
+
+ if (prefix2 == null) {
+ fail("Second prefix is null");
+ }
+
+ if (prefix1.equals(prefix2)) {
+ fail("Prefixes should be different: "+prefix1+" "+prefix2);
+ }
+ }
+
+ public void testAddSameNamespaces() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ Process component=new Process(model);
+
+ String prefix1=component.addNamespace("namespace1");
+ String prefix2=component.addNamespace("namespace1");
+
+ if (prefix1 == null) {
+ fail("First prefix is null");
+ }
+
+ if (prefix2 == null) {
+ fail("Second prefix is null");
+ }
+
+ if (prefix1.equals(prefix2) == false) {
+ fail("Prefixes should be same: "+prefix1+" "+prefix2);
+ }
+ }
}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-17 22:36:19 UTC (rev 62)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-10-19 20:10:54 UTC (rev 63)
@@ -30,7 +30,8 @@
*/
public class WSDLGenerator {
- public static final String SOAP_BINDING_SUFFIX = "SOAPBinding";
+ public static final String BINDING_SUFFIX = "Binding";
+
private static Log logger = LogFactory.getLog(WSDLGenerator.class);
public WSDLGenerator() {
@@ -236,7 +237,7 @@
if (intf.getName() != null) {
ret.setQName(new javax.xml.namespace.QName(intf.getNamespace(),
- intf.getName()+SOAP_BINDING_SUFFIX));
+ intf.getName()+BINDING_SUFFIX));
}
ret.setPortType(portType);
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-17 22:36:19 UTC (rev 62)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java 2009-10-19 20:10:54 UTC (rev 63)
@@ -139,7 +139,7 @@
fail("QName localpart not set");
}
- if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGenerator.SOAP_BINDING_SUFFIX) == false) {
+ if (result.getQName().getLocalPart().equals(TEST_NAME+WSDLGenerator.BINDING_SUFFIX) == false) {
fail("QName localpart not correct: "+result.getQName().getLocalPart());
}
}
14 years, 6 months
savara SVN: r62 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel: model/change and 1 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-10-17 18:36:19 -0400 (Sat, 17 Oct 2009)
New Revision: 62
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Import.java
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
Log:
Added import statements to BPEL definition for relevant WSDL files generated.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-17 20:07:25 UTC (rev 61)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-10-17 22:36:19 UTC (rev 62)
@@ -225,8 +225,7 @@
// Check if definition has a port type
if (defn.getPortTypes().size() > 0 || defn.getMessages().size() > 0) {
- String filename=localcm.getModelName().getName()+"_"+
- role.getName()+i+".wsdl";
+ String filename=getWSDLFileName(role, localcm.getModelName().getName(), i);
if (i > 0) {
javax.wsdl.Import imp=defns.get(0).createImport();
@@ -248,8 +247,7 @@
IPath wsdlPath=proj.getFullPath().append(
new Path(getBuildSystem().getBPELFilePath())).
- append(localcm.getModelName().getName()+"_"+
- role.getName()+i+".wsdl");
+ append(filename);
IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
GeneratorUtil.createParentFolder(wsdlFile);
@@ -262,6 +260,24 @@
}
}
}
+
+ /**
+ * This method returns the WSDL file name for the supplied role and local
+ * conversation model.
+ *
+ * @param role The role
+ * @param localcm The local conversation model
+ * @param fileNum The file name (zero being the main wsdl file)
+ * @return The file name
+ */
+ public static String getWSDLFileName(Role role, String modelName, int fileNum) {
+ String num="";
+ if (fileNum > 0) {
+ num += fileNum;
+ }
+
+ return(modelName+"_"+role.getName()+num+".wsdl");
+ }
protected IProject createProject(String projectName)
throws Exception {
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-17 20:07:25 UTC (rev 61)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-10-17 22:36:19 UTC (rev 62)
@@ -17,10 +17,13 @@
*/
package org.jboss.savara.tools.bpel.model.change;
+import org.jboss.savara.tools.bpel.generator.Generator;
import org.jboss.savara.tools.bpel.model.*;
import org.jboss.savara.tools.bpel.model.component.*;
+import org.jboss.savara.tools.bpel.model.component.Import;
import org.scribble.model.*;
import org.scribble.model.change.*;
+import org.scribble.contract.model.Contract;
import org.scribble.conversation.model.*;
import org.scribble.extensions.RegistryInfo;
@@ -124,6 +127,16 @@
bpelModel.getBPELProcess().setConversationType(ctype);
}
+ // Add import for this role
+ addImport(context, bpelModel, conv, context.getRole());
+
+ // Add import statements for partner roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ addImport(context, bpelModel, conv, roles.get(i));
+ }
+
// Add sequence to model
bpelModel.getBPELProcess().setActivity(seq);
@@ -161,4 +174,41 @@
return(true);
}
+
+ /**
+ * This method adds an import statement for the contract associated with the
+ * supplied role.
+ *
+ * @param context The context
+ * @param bpelModel The model
+ * @param conv The conversation
+ * @param role The role
+ */
+ protected void addImport(ModelChangeContext context, DefaultBPELLanguageModel bpelModel,
+ Conversation conv, Role role) {
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+
+ boolean gen=false;
+
+ for (int i=0; gen == false && i < contract.getInterfaces().size(); i++) {
+ if (contract.getInterfaces().get(i).getMessageExchangePatterns().size() > 0) {
+ gen = true;
+ }
+ }
+
+ if (gen) {
+ String fileName=Generator.getWSDLFileName(role,
+ conv.getLocatedName().getName(), 0);
+
+ Import imp=new Import(bpelModel);
+
+ imp.setLocation(fileName);
+ imp.setNamespace(contract.getNamespace());
+ imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getBPELProcess().addImport(imp, -1);
+ }
+ }
+ }
}
Added: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Import.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Import.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Import.java 2009-10-17 22:36:19 UTC (rev 62)
@@ -0,0 +1,120 @@
+/*
+ * 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.savara.tools.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.tools.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'import' construct.
+ */
+public class Import extends BPELElement {
+
+ private static final long serialVersionUID = -7103589689575940289L;
+
+ private static final String IMPORT_TYPE = "importType";
+ private static final String NAMESPACE = "namespace";
+ private static final String LOCATION = "location";
+
+ public static final String IMPORT="import";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Import(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Import(BPELLanguageModel model) {
+ super(model, IMPORT);
+ }
+
+ /**
+ * This method sets the import type.
+ *
+ * @param importType The import type
+ */
+ public void setImportType(String importType) {
+ getDOMElement().setAttribute(IMPORT_TYPE, importType);
+ }
+
+ /**
+ * This method returns the iport type.
+ *
+ * @return The import type
+ */
+ public String getImportType() {
+ return(getDOMElement().hasAttribute(IMPORT_TYPE)?
+ getDOMElement().getAttribute(IMPORT_TYPE):null);
+ }
+
+ /**
+ * This method sets the namespace.
+ *
+ * @param ns The namespace
+ */
+ public void setNamespace(String ns) {
+ getDOMElement().setAttribute(NAMESPACE, ns);
+ }
+
+ /**
+ * This method returns the namespace.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(getDOMElement().hasAttribute(NAMESPACE)?
+ getDOMElement().getAttribute(NAMESPACE):null);
+ }
+
+ /**
+ * This method sets the location.
+ *
+ * @param location The location
+ */
+ public void setLocation(String location) {
+ getDOMElement().setAttribute(LOCATION, location);
+ }
+
+ /**
+ * This method returns the location.
+ *
+ * @return The location
+ */
+ public String getLocation() {
+ return(getDOMElement().hasAttribute(LOCATION)?
+ getDOMElement().getAttribute(LOCATION):null);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-17 20:07:25 UTC (rev 61)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-10-17 22:36:19 UTC (rev 62)
@@ -103,6 +103,87 @@
}
/**
+ * This method adds an import to the scope.
+ *
+ * @param imp The import to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addImport(Import imp, int pos) {
+
+ if (pos != -1 && pos < m_imports.size()) {
+ m_imports.add(pos, imp);
+ } else {
+ m_imports.add(imp);
+ }
+
+ java.util.List<BPELElement> children=findChildElements(BPELElement.class);
+
+ org.w3c.dom.Node newNode=imp.getDOMElement().cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ if (pos != -1 && pos < children.size()) {
+ getDOMElement().insertBefore(newNode, children.get(pos).getDOMElement());
+ } else {
+ getDOMElement().appendChild(newNode);
+ }
+ }
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removeImport(Import imp) {
+ boolean ret=m_imports.remove(imp);
+
+ if (ret) {
+ getDOMElement().removeChild(imp.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of imports.
+ *
+ * @return The imports
+ */
+ public java.util.List<Import> getImports() {
+ return(m_imports);
+ }
+
+ /**
+ * This method returns the list of partner links.
+ *
+ * @return The partner links
+ */
+ public java.util.List<PartnerLink> getPartnerLinks() {
+ return(m_partnerLinks);
+ }
+
+ /**
+ * This method returns the partner link associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The partner link, or null if not found
+ */
+ public PartnerLink getPartnerLink(String name) {
+ PartnerLink ret=null;
+
+ for (int i=0; ret == null && i < m_partnerLinks.size(); i++) {
+ if (m_partnerLinks.get(i).getName().equals(name)) {
+ ret = m_partnerLinks.get(i);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
* This method adds a partner link to the scope.
*
* @param pl The partner link to be added
@@ -186,34 +267,6 @@
}
/**
- * This method returns the list of partner links.
- *
- * @return The partner links
- */
- public java.util.List<PartnerLink> getPartnerLinks() {
- return(m_partnerLinks);
- }
-
- /**
- * This method returns the partner link associated
- * with the supplied name.
- *
- * @param name The name
- * @return The partner link, or null if not found
- */
- public PartnerLink getPartnerLink(String name) {
- PartnerLink ret=null;
-
- for (int i=0; ret == null && i < m_partnerLinks.size(); i++) {
- if (m_partnerLinks.get(i).getName().equals(name)) {
- ret = m_partnerLinks.get(i);
- }
- }
-
- return(ret);
- }
-
- /**
* This method sets the name.
*
* @param name The name
@@ -758,6 +811,7 @@
private org.w3c.dom.Element m_messageExchangesElem=null;
private org.w3c.dom.Element m_variablesElem=null;
private org.w3c.dom.Element m_correlationSetsElem=null;
+ private java.util.List<Import> m_imports=new java.util.Vector<Import>();
private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
private EventHandlers m_eventHandlers=null;
14 years, 6 months