savara SVN: r76 - 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-11-08 10:03:11 -0500 (Sun, 08 Nov 2009)
New Revision: 76
Added:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationChangeRule.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ModelChangeUtils.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/change/
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/change/ModelChangeUtilsTest.java
Removed:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
Log:
Store contract to role association in context to deal with composed conversations.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2009-11-07 00:25:46 UTC (rev 75)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF 2009-11-08 15:03:11 UTC (rev 76)
@@ -26,7 +26,7 @@
org.jboss.savara.tools.bpel.parser.BPELModelParserRule,
org.jboss.savara.tools.bpel.model.BPELNotation,
org.jboss.savara.tools.bpel.model.change.LanguageToConversationModelChangeRule,
- org.jboss.savara.tools.bpel.model.change.ConversationModelChangeRule,
+ org.jboss.savara.tools.bpel.model.change.ConversationChangeRule,
org.jboss.savara.tools.bpel.model.change.WhileModelChangeRule,
org.jboss.savara.tools.bpel.model.change.WhenModelChangeRule,
org.jboss.savara.tools.bpel.model.change.IfModelChangeRule,
Copied: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationChangeRule.java (from rev 71, 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/ConversationChangeRule.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationChangeRule.java 2009-11-08 15:03:11 UTC (rev 76)
@@ -0,0 +1,243 @@
+/*
+ * 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.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;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+(a)RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class ConversationChangeRule 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 DefaultBPELLanguageModel) {
+ 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) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ Conversation conv=(Conversation)mobj;
+ String roleNamespace=null;
+
+ Sequence seq=new Sequence(bpelModel);
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+
+ ModelChangeUtils.initializeContracts(context, conv);
+
+ // Set the name of the process
+ bpelModel.getBPELProcess().setName(conv.getLocatedName().getName()+"_"+
+ conv.getLocatedName().getRole().getName());
+
+ // Get contract
+ //Contract contract=ModelChangeUtils.getContract(context, conv.getLocatedName().getRole().getName());
+
+ if (conv.getLocatedName().getRole().getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)conv.getLocatedName().
+ getRole().getAnnotations().get(Contract.class.getName());
+
+ roleNamespace = contract.getNamespace();
+
+ // 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()).
+ getNamespace().getName();
+
+ 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.getLocatedName().getName()+"@"+
+ conv.getLocatedName().getRole().getName();
+ }
+
+ if (ctype != null) {
+ 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 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);
+
+ } else if (context.getParent() instanceof Sequence) {
+
+ // Create a scope
+ Scope scope=new Scope(bpelModel);
+
+ ((Sequence)context.getParent()).addActivity(scope, -1);
+
+ // NOTE: Currently needs to be added after adding scope
+ // to parent sequence, as otherwise the DOM element
+ // associated with the 'seq' sequence becomes
+ // disconnected from the actual document - due to
+ // the fact that added elements are copied (in
+ // turn due to an xml parser exception).
+ scope.setActivity(seq);
+ }
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=conv.getBlock().getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int i=0; i < acts.size(); i++) {
+ if ((acts.get(i) instanceof Definition) == false) {
+ context.insert(model, acts.get(i), null);
+ }
+ }
+
+ // Reset old parent
+ context.setParent(parent);
+
+ 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);
+ }
+ }
+ }
+}
Deleted: 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-11-07 00:25:46 UTC (rev 75)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationModelChangeRule.java 2009-11-08 15:03:11 UTC (rev 76)
@@ -1,239 +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.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;
-
-/**
- * This is the model change rule for the Conversation.
- */
-(a)RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
-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 DefaultBPELLanguageModel) {
- 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) {
- DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
- Conversation conv=(Conversation)mobj;
- String roleNamespace=null;
-
- Sequence seq=new Sequence(bpelModel);
-
- // Check if root conversation
- if (conv.getParent() instanceof Model) {
-
- // Set the name of the process
- 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());
-
- roleNamespace = contract.getNamespace();
-
- // 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()).
- getNamespace().getName();
-
- 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.getLocatedName().getName()+"@"+
- conv.getLocatedName().getRole().getName();
- }
-
- if (ctype != null) {
- 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 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);
-
- } else if (context.getParent() instanceof Sequence) {
-
- // Create a scope
- Scope scope=new Scope(bpelModel);
-
- ((Sequence)context.getParent()).addActivity(scope, -1);
-
- // NOTE: Currently needs to be added after adding scope
- // to parent sequence, as otherwise the DOM element
- // associated with the 'seq' sequence becomes
- // disconnected from the actual document - due to
- // the fact that added elements are copied (in
- // turn due to an xml parser exception).
- scope.setActivity(seq);
- }
-
- // Process the activities within the conversation
- java.util.List<Activity> acts=conv.getBlock().getContents();
-
- Object parent=context.getParent();
-
- context.setParent(seq);
-
- for (int i=0; i < acts.size(); i++) {
- if ((acts.get(i) instanceof Definition) == false) {
- context.insert(model, acts.get(i), null);
- }
- }
-
- // Reset old parent
- context.setParent(parent);
-
- 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/change/ModelChangeUtils.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ModelChangeUtils.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ModelChangeUtils.java 2009-11-08 15:03:11 UTC (rev 76)
@@ -0,0 +1,145 @@
+/*
+ * 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.change;
+
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.contract.model.Contract;
+import org.scribble.conversation.model.*;
+
+/**
+ * Model change utilities.
+ */
+public class ModelChangeUtils {
+
+ /**
+ * This method checks whether the contracts need to be initialized.
+ *
+ * @param context The context
+ * @param conv The conversation
+ */
+ public static void initializeContracts(ModelChangeContext context, Conversation conv) {
+
+ if (context.getProperties().containsKey(Contract.class.getName()) == false) {
+ java.util.Map<String,Contract> contracts=new java.util.HashMap<String, Contract>();
+
+ if (conv.getLocatedName().getRole() != null) {
+ initializeRoleContract(conv.getLocatedName().getRole(), contracts);
+ }
+
+ for (Role r : conv.getRoles()) {
+ initializeRoleContract(r, contracts);
+ }
+
+ context.getProperties().put(Contract.class.getName(), contracts);
+ }
+ }
+
+ /**
+ * This method initializes the contract associated with the supplied role.
+ *
+ * @param role The role
+ * @param contracts The map of roles to contracts
+ */
+ protected static void initializeRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+ if (role != null && role.getAnnotations().containsKey(Contract.class.getName())) {
+ contracts.put(role.getName(),
+ (Contract)role.getAnnotations().get(Contract.class.getName()));
+ }
+ }
+
+ /**
+ * This method returns the contract associated with the supplied role.
+ *
+ * @param contezt The context
+ * @param roleName The role name
+ * @return The contract, or null if not found
+ */
+ @SuppressWarnings("unchecked")
+ public static Contract getContract(ModelChangeContext context, String roleName) {
+ Contract ret=null;
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ ret = contracts.get(roleName);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method updates the role mapping based on the supplied list of
+ * declaration bindings.
+ *
+ * @param context The context
+ * @param bindings The declaration bindings
+ */
+ @SuppressWarnings("unchecked")
+ public static void pushRoleContractMapping(ModelChangeContext context,
+ java.util.List<DeclarationBinding> bindings) {
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ for (DeclarationBinding db : bindings) {
+ if (db.getDeclaration() instanceof Role) {
+ Contract c=contracts.remove(db.getDeclaration().getName());
+
+ if (c != null) {
+ contracts.put(db.getBoundName(), c);
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * This method resets the role mapping based on the supplied list of
+ * declaration bindings.
+ *
+ * @param context The context
+ * @param bindings The declaration bindings
+ */
+ @SuppressWarnings("unchecked")
+ public static void popRoleContractMapping(ModelChangeContext context,
+ java.util.List<DeclarationBinding> bindings) {
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ for (DeclarationBinding db : bindings) {
+ if (db.getDeclaration() instanceof Role) {
+ Contract c=contracts.remove(db.getBoundName());
+
+ if (c != null) {
+ contracts.put(db.getDeclaration().getName(), c);
+ }
+ }
+ }
+
+ }
+ }
+}
Added: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/change/ModelChangeUtilsTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/change/ModelChangeUtilsTest.java (rev 0)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/change/ModelChangeUtilsTest.java 2009-11-08 15:03:11 UTC (rev 76)
@@ -0,0 +1,171 @@
+/*
+ * 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.change;
+
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+import org.scribble.model.change.DefaultModelChangeContext;
+import org.scribble.model.change.ModelChangeContext;
+import org.scribble.contract.model.*;
+
+import junit.framework.TestCase;
+
+public class ModelChangeUtilsTest extends TestCase {
+
+ private static final String MY_ROLE = "MyRole";
+ private static final String MY_OTHER_ROLE = "MyOtherRole";
+
+ public void testInitialiseContracts() {
+ ModelChangeContext context=new DefaultModelChangeContext(null, null);
+
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ Role r=new Role();
+ r.setName(MY_ROLE);
+
+ Contract c=new Contract();
+ r.getAnnotations().put(Contract.class.getName(), c);
+
+ ln.setRole(r);
+ conv.setLocatedName(ln);
+
+ ModelChangeUtils.initializeContracts(context, conv);
+
+ Contract c2=ModelChangeUtils.getContract(context, MY_ROLE);
+
+ if (c2 == null) {
+ fail("Contract not found");
+ }
+
+ if (c2 != c) {
+ fail("Contract not the same as the one stored");
+ }
+ }
+
+ public void testInitialiseContractsTwice() {
+ ModelChangeContext context=new DefaultModelChangeContext(null, null);
+
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ Role r=new Role();
+ r.setName(MY_ROLE);
+
+ Contract c=new Contract();
+ r.getAnnotations().put(Contract.class.getName(), c);
+
+ ln.setRole(r);
+ conv.setLocatedName(ln);
+
+ ModelChangeUtils.initializeContracts(context, conv);
+
+ Contract c2=new Contract();
+ r.getAnnotations().put(Contract.class.getName(), c2);
+
+ Contract c3=ModelChangeUtils.getContract(context, MY_ROLE);
+
+ if (c3 == null) {
+ fail("Contract not found");
+ }
+
+ if (c3 != c) {
+ fail("Contract not the same as the one stored");
+ }
+ }
+
+ public void testPushRoleContractMapping() {
+ ModelChangeContext context=new DefaultModelChangeContext(null, null);
+
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ Role r=new Role();
+ r.setName(MY_ROLE);
+
+ Contract c=new Contract();
+ r.getAnnotations().put(Contract.class.getName(), c);
+
+ ln.setRole(r);
+ conv.setLocatedName(ln);
+
+ ModelChangeUtils.initializeContracts(context, conv);
+
+ java.util.List<DeclarationBinding> bindings=new java.util.Vector<DeclarationBinding>();
+
+ DeclarationBinding db=new DeclarationBinding();
+ db.setDeclaration(r);
+ db.setBoundName(MY_OTHER_ROLE);
+ bindings.add(db);
+
+ ModelChangeUtils.pushRoleContractMapping(context, bindings);
+
+ Contract c2=ModelChangeUtils.getContract(context, MY_ROLE);
+ Contract c3=ModelChangeUtils.getContract(context, MY_OTHER_ROLE);
+
+ if (c2 != null) {
+ fail("Contract for "+MY_ROLE+" should be null");
+ }
+
+ if (c3 == null) {
+ fail("Contract for "+MY_OTHER_ROLE+" should NOT be null");
+ }
+
+ if (c3 != c) {
+ fail("Contract not the same as the one stored");
+ }
+ }
+
+ public void testPopRoleContractMapping() {
+ ModelChangeContext context=new DefaultModelChangeContext(null, null);
+
+ Conversation conv=new Conversation();
+ LocatedName ln=new LocatedName();
+ Role r=new Role();
+ r.setName(MY_ROLE);
+
+ Contract c=new Contract();
+ r.getAnnotations().put(Contract.class.getName(), c);
+
+ ln.setRole(r);
+ conv.setLocatedName(ln);
+
+ ModelChangeUtils.initializeContracts(context, conv);
+
+ java.util.List<DeclarationBinding> bindings=new java.util.Vector<DeclarationBinding>();
+
+ DeclarationBinding db=new DeclarationBinding();
+ db.setDeclaration(r);
+ db.setBoundName(MY_OTHER_ROLE);
+ bindings.add(db);
+
+ ModelChangeUtils.popRoleContractMapping(context, bindings);
+
+ Contract c2=ModelChangeUtils.getContract(context, MY_ROLE);
+ Contract c3=ModelChangeUtils.getContract(context, MY_OTHER_ROLE);
+
+ if (c2 == null) {
+ fail("Contract for "+MY_ROLE+" should NOT be null");
+ }
+
+ if (c3 != null) {
+ fail("Contract for "+MY_OTHER_ROLE+" should be null");
+ }
+
+ if (c2 != c) {
+ fail("Contract not the same as the one stored");
+ }
+ }
+}
16 years, 5 months
savara SVN: r75 - 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-11-06 19:25:46 -0500 (Fri, 06 Nov 2009)
New Revision: 75
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java
Log:
Simplify identification of port type - but does not solve absence of port type in particular example, as this was related to the fact that the generation is being done using a sub-conversation whose roles don't have access to the contracts of their mapped top level roles.
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-11-06 23:20:02 UTC (rev 74)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-11-07 00:25:46 UTC (rev 75)
@@ -104,8 +104,6 @@
}
// Identify port type role
- Role toPortTypeRole=role;
- Role fromPortTypeRole=role;
String prefix=null;
String mainPrefix=null;
@@ -116,28 +114,28 @@
mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
}
+ Role roleType=null;
+
if (InteractionUtil.isRequest(interaction)) {
- toPortTypeRole = interaction.getToRole();
+ roleType = interaction.getToRole();
+ if (roleType == null) {
+ roleType = role;
+ }
} else {
- fromPortTypeRole = interaction.getFromRole();
+ roleType = interaction.getFromRole();
+ if (roleType == null) {
+ roleType = role;
+ }
}
- if (toPortTypeRole != null &&
- toPortTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
- Contract contract=(Contract)toPortTypeRole.getAnnotations().get(Contract.class.getName());
+ if (roleType != null &&
+ roleType.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)roleType.getAnnotations().get(Contract.class.getName());
// Assume that contract only has one interface for now
if (contract.getInterfaces().size() > 0) {
intf = contract.getInterfaces().get(0);
}
- } else if (fromPortTypeRole != null &&
- fromPortTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
- Contract contract=(Contract)fromPortTypeRole.getAnnotations().get(Contract.class.getName());
-
- // Assume that contract only has one interface for now
- if (contract.getInterfaces().size() > 0) {
- intf = contract.getInterfaces().get(0);
- }
}
if (intf != null) {
16 years, 5 months
savara SVN: r74 - 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-11-06 18:20:02 -0500 (Fri, 06 Nov 2009)
New Revision: 74
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java
Log:
Define correct port type.
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-11-05 23:22:06 UTC (rev 73)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-11-06 23:20:02 UTC (rev 74)
@@ -23,6 +23,7 @@
import org.scribble.model.*;
import org.scribble.model.change.*;
import org.scribble.contract.model.Contract;
+import org.scribble.contract.model.Interface;
import org.scribble.extensions.RegistryInfo;
/**
@@ -248,7 +249,21 @@
pl.setPartnerLinkType(plt);
- portType = role.getName()+"PT";
+ 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);
+
+ portType = intf.getName();
+
+ String prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
+ }
} else {
pl.setMyRole(role.getName()+"Requester");
pl.setPartnerRole(recv.getFromRole().getName()+"Service");
@@ -262,8 +277,25 @@
pl.setPartnerLinkType(plt);
- portType = role.getName()+
- recv.getFromRole().getName()+"CallbackPT";
+ //portType = role.getName()+
+ // recv.getFromRole().getName()+"CallbackPT";
+
+ if (recv.getFromRole().getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)recv.getFromRole().getAnnotations().get(Contract.class.getName());
+
+ 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;
+ }
+ }
+ }
+
}
// Create partner link
16 years, 5 months
savara SVN: r73 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src: java/org/jboss/savara/tools/bpel/model/change and 6 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-11-05 18:22:06 -0500 (Thu, 05 Nov 2009)
New Revision: 73
Removed:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/results/EventHandler(a)Store.bpel
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/testmodels/EventHandler(a)Store.scv
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/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/ConversionContext.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/FaultHandlers.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.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/java/org/jboss/savara/tools/bpel/model/component/Scope.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/results/LoanApprovalService(a)Service.scv
Log:
Updated to handle variables declared in catch blocks, generation of bpel deployment descriptor (most details), fix some generation tests - had to remove some based on just scribble to BPEL, as scribble model does not have enough details (i.e. the info from the Contract that is created by the choreography to scribble module).
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-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -48,6 +48,46 @@
*/
public class Generator {
+ private static final String BPEL_DEPLOY_DESCRIPTOR_FILENAME = "bpel-deploy.xml";
+
+ private static final String XMLNS_PREFIX = "xmlns:";
+
+ private static final String SERVICE_LABEL = "service";
+
+ private static final String PROVIDE_LABEL = "provide";
+
+ private static final String PARTNER_LINK_LABEL = "partnerLink";
+
+ private static final String INVOKE_LABEL = "invoke";
+
+ private static final String ACTIVE_LABEL = "active";
+
+ private static final String PROCESS_LABEL = "process";
+
+ private static final String DEPLOY_LABEL = "deploy";
+
+ private static final String APACHE_ODE_NAMESPACE = "http://www.apache.org/ode/schemas/dd/2007/03";
+
+ private static final String PORT_TYPE_LABEL = "portType";
+
+ private static final String TARGET_NAMESPACE_LABEL = "targetNamespace";
+
+ private static final String PLNK_ROLE = "plnk:role";
+
+ private static final String NAME_LABEL = "name";
+
+ private static final String PLNK_PARTNER_LINK_TYPE = "plnk:partnerLinkType";
+
+ private static final String WSDL_DEFINITIONS = "wsdl:definitions";
+
+ private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
+
+ private static final String PLNKTYPE_NS = "http://docs.oasis-open.org/wsbpel/2.0/plnktype";
+
+ private static final String XMLNS_WSDL = "xmlns:wsdl";
+
+ private static final String XMLNS_PLNK = "xmlns:plnk";
+
/**
* This is the constructor for the generator.
*
@@ -210,9 +250,12 @@
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);
+
+ // Generate BPEL deployment descriptor
+ generateBPELDeploy(role, proj, localcm, bpelProcess);
}
}
@@ -276,22 +319,27 @@
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");
+ org.w3c.dom.Element defn=doc.createElement(WSDL_DEFINITIONS);
doc.appendChild(defn);
- defn.setAttribute("xmlns:plnk", "http://docs.oasis-open.org/wsbpel/2.0/plnktype");
+ defn.setAttribute(XMLNS_PLNK, PLNKTYPE_NS);
+ defn.setAttribute(XMLNS_WSDL, WSDL_NS);
+ defn.setAttribute(TARGET_NAMESPACE_LABEL, bpelProcess.getTargetNamespace());
+
+ java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
+
for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
- org.w3c.dom.Element plt=doc.createElement("plnk:partnerLinkType");
+ org.w3c.dom.Element plt=doc.createElement(PLNK_PARTNER_LINK_TYPE);
- plt.setAttribute("name", pl.getPartnerLinkType());
+ plt.setAttribute(NAME_LABEL, XMLUtils.getLocalname(pl.getPartnerLinkType()));
if (pl.getPartnerRole() != null && pl.getPartnerRole().trim().length() > 0) {
- org.w3c.dom.Element plRole=doc.createElement("plnk:role");
+ org.w3c.dom.Element plRole=doc.createElement(PLNK_ROLE);
plt.appendChild(plRole);
- plRole.setAttribute("name", pl.getPartnerRole());
+ plRole.setAttribute(NAME_LABEL, pl.getPartnerRole());
Role useRole=null;
@@ -309,17 +357,26 @@
if (contract.getInterfaces().size() > 0) {
Interface intf=contract.getInterfaces().get(0);
- plRole.setAttribute("portType", intf.getName());
+ String prefix=null;
+ String portType=intf.getName();
+
+ if (intf.getNamespace() != null) {
+ prefix = XMLUtils.getPrefix(intf.getNamespace(), nsMap);
+
+ portType = prefix+":"+portType;
+ }
+
+ plRole.setAttribute(PORT_TYPE_LABEL, portType);
}
}
}
if (pl.getMyRole() != null && pl.getMyRole().trim().length() > 0) {
- org.w3c.dom.Element plRole=doc.createElement("plnk:role");
+ org.w3c.dom.Element plRole=doc.createElement(PLNK_ROLE);
plt.appendChild(plRole);
- plRole.setAttribute("name", pl.getMyRole());
+ plRole.setAttribute(NAME_LABEL, pl.getMyRole());
if (role.getAnnotations().containsKey(Contract.class.getName())) {
Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
@@ -327,7 +384,16 @@
if (contract.getInterfaces().size() > 0) {
Interface intf=contract.getInterfaces().get(0);
- plRole.setAttribute("portType", intf.getName());
+ String prefix=null;
+ String portType=intf.getName();
+
+ if (intf.getNamespace() != null) {
+ prefix = XMLUtils.getPrefix(intf.getNamespace(), nsMap);
+
+ portType = prefix+":"+portType;
+ }
+
+ plRole.setAttribute(PORT_TYPE_LABEL, portType);
}
}
}
@@ -335,6 +401,16 @@
defn.appendChild(plt);
}
+ // Create remaining namespace/prefix mappings
+ java.util.Iterator<String> iter=nsMap.keySet().iterator();
+ while (iter.hasNext()) {
+ String ns=iter.next();
+ String prefix=nsMap.get(ns);
+
+ defn.setAttribute(XMLNS_PREFIX+prefix, ns);
+ }
+
+ // Write partner link types to file
IPath wsdlPath=proj.getFullPath().append(
new Path(getBuildSystem().getBPELFilePath())).
append(role.getName()+"PartnerLinkTypes.wsdl");
@@ -358,92 +434,116 @@
xmlstr.close();
- String xml=reformat(new String(xmlstr.toByteArray()));
+ String xml=XMLUtils.format(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;
+
+ protected void generateBPELDeploy(Role role, IProject proj, ConversationModel localcm,
+ org.jboss.savara.tools.bpel.model.component.Process bpelProcess) throws Exception {
- while ((pos=ret.indexOf('<', prevpos)) != -1) {
+ org.w3c.dom.Document doc=javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();;
+
+ org.w3c.dom.Element defn=doc.createElementNS(APACHE_ODE_NAMESPACE,
+ DEPLOY_LABEL);
+ doc.appendChild(defn);
+
+ java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
+
+ // Create process element
+ org.w3c.dom.Element proc=doc.createElement(PROCESS_LABEL);
+ defn.appendChild(proc);
+
+ String name=bpelProcess.getName();
+
+ if (bpelProcess.getTargetNamespace() != null) {
+ String prefix=XMLUtils.getPrefix(bpelProcess.getTargetNamespace(), nsMap);
- if (prevpos < pos &&
- ret.substring(prevpos, pos).trim().length() > 0 &&
- ret.charAt(prevpos-1) != '?') {
+ name = prefix+":"+name;
+ }
+
+ proc.setAttribute(NAME_LABEL, name);
+
+ org.w3c.dom.Element active=doc.createElement(ACTIVE_LABEL);
+ proc.appendChild(active);
+
+ org.w3c.dom.Text activeText=doc.createTextNode(Boolean.TRUE.toString());
+ active.appendChild(activeText);
+
+ // TODO: Need more info - possibly Contract should have interfaces based on
+ // the relationship between two roles, as this may provide the necessary
+ // information - but this requires the ability to have multiple interfaces
+ // per role, which some other parts of the BPEL generation would currently
+ // not handle.
+
+ // Work through partner links for now
+ for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
+ if (pl.getPartnerRole() != null && pl.getPartnerRole().trim().length() > 0) {
+ org.w3c.dom.Element invoke=doc.createElement(INVOKE_LABEL);
- if (ret.charAt(prevpos) == '\r' &&
- ret.charAt(prevpos+1) == '\n') {
- prevpos += 2;
- }
- for (int i=0; i < level; i++) {
- buf.append(" ");
- }
+ invoke.setAttribute(PARTNER_LINK_LABEL, XMLUtils.getLocalname(pl.getName()));
- buf.append(ret.substring(prevpos, pos).trim());
- buf.append("\r\n");
+ org.w3c.dom.Element service=doc.createElement(SERVICE_LABEL);
+
+ invoke.appendChild(service);
+
+ proc.appendChild(invoke);
}
- int endpos=ret.indexOf('>', pos);
-
- if (endpos > 0) {
- boolean noreturn=false;
+ if (pl.getMyRole() != null && pl.getMyRole().trim().length() > 0) {
+ org.w3c.dom.Element provide=doc.createElement(PROVIDE_LABEL);
- if (pos > 0 && ret.charAt(pos+1) == '/') {
- level--;
- }
+ provide.setAttribute(PARTNER_LINK_LABEL, XMLUtils.getLocalname(pl.getName()));
- for (int i=0; i < level; i++) {
- buf.append(" ");
- }
- buf.append(ret.substring(pos, endpos+1));
+ org.w3c.dom.Element service=doc.createElement(SERVICE_LABEL);
- 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");
- }
+ provide.appendChild(service);
- pos = endpos+1;
+ proc.appendChild(provide);
}
-
- prevpos = pos;
}
- if (prevpos != -1 &&
- ret.substring(prevpos).trim().length() > 0) {
- buf.append(ret.substring(prevpos));
+ // Create remaining namespace/prefix mappings
+ java.util.Iterator<String> iter=nsMap.keySet().iterator();
+ while (iter.hasNext()) {
+ String ns=iter.next();
+ String prefix=nsMap.get(ns);
+
+ defn.setAttribute(XMLNS_PREFIX+prefix, ns);
}
- ret = buf.toString();
+ // Write partner link types to file
+ IPath wsdlPath=proj.getFullPath().append(
+ new Path(getBuildSystem().getBPELFilePath())).
+ append(BPEL_DEPLOY_DESCRIPTOR_FILENAME);
- return(ret);
+ 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=XMLUtils.format(new String(xmlstr.toByteArray()));
+
+ wsdlFile.setContents(new java.io.ByteArrayInputStream(xml.getBytes()), true, false,
+ new org.eclipse.core.runtime.NullProgressMonitor());
}
-
+
/**
* 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/ConversationInteractionModelChangeRule.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/ConversationInteractionModelChangeRule.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -102,28 +102,48 @@
role = interaction.getEnclosingDefinition().
getLocatedName().getRole();
}
-
+
// Identify port type role
- Role portTypeRole=role;
+ Role toPortTypeRole=role;
+ Role fromPortTypeRole=role;
+ String prefix=null;
- if (InteractionUtil.isRequest(interaction) && interaction.getToRole() != null) {
- portTypeRole = interaction.getToRole();
+ String mainPrefix=null;
+
+ if (context.getRole().getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)context.getRole().getAnnotations().get(Contract.class.getName());
+
+ mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
}
- if (portTypeRole != null &&
- portTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
- Contract contract=(Contract)portTypeRole.getAnnotations().get(Contract.class.getName());
+ if (InteractionUtil.isRequest(interaction)) {
+ toPortTypeRole = interaction.getToRole();
+ } else {
+ fromPortTypeRole = interaction.getFromRole();
+ }
+
+ if (toPortTypeRole != null &&
+ toPortTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)toPortTypeRole.getAnnotations().get(Contract.class.getName());
// Assume that contract only has one interface for now
if (contract.getInterfaces().size() > 0) {
intf = contract.getInterfaces().get(0);
}
+ } else if (fromPortTypeRole != null &&
+ fromPortTypeRole.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)fromPortTypeRole.getAnnotations().get(Contract.class.getName());
+
+ // Assume that contract only has one interface for now
+ if (contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().get(0);
+ }
}
if (intf != null) {
portType = intf.getName();
- String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+ prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
if (prefix != null) {
portType = prefix+":"+portType;
@@ -161,7 +181,14 @@
pl.setPartnerRole(interaction.getToRole().getName()+"Requester");
pl.setName(role.getName()+"To"+interaction.getToRole().getName());
- pl.setPartnerLinkType(role.getName()+"To"+interaction.getToRole().getName()+"LT");
+
+ String plt=role.getName()+"To"+interaction.getToRole().getName()+"LT";
+
+ if (prefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
//portType = interaction.getToRole().getName()+"PT";
@@ -174,7 +201,14 @@
pl.setMyRole(role.getName()+"Service");
pl.setName(interaction.getToRole().getName()+"To"+role.getName());
- pl.setPartnerLinkType(interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT");
+
+ String plt=interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (prefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
//portType = role.getName()+"PT";
@@ -182,13 +216,13 @@
String faultName=InteractionPatterns.getFaultName(interaction);
// Find namespace prefix
- if (intf != null) {
- String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+ //if (intf != null) {
+ // String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
if (prefix != null) {
faultName = prefix+":"+faultName;
}
- }
+ //}
((Reply)act).setFaultName(faultName);
}
@@ -222,14 +256,28 @@
pl.setMyRole(role.getName()+"Service");
//pl.setPartnerRole(interaction.getToRole().getName());
pl.setName(interaction.getFromRole().getName()+"To"+role.getName());
- pl.setPartnerLinkType(interaction.getFromRole().getName()+"To"+role.getName()+"Service"+"LT");
+
+ String plt=interaction.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (prefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
//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");
+
+ String plt=role.getName()+"To"+interaction.getFromRole().getName()+"Requester"+"LT";
+
+ if (prefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
//portType = role.getName()+
// interaction.getFromRole().getName()+"CallbackPT";
@@ -300,10 +348,10 @@
// Find namespace prefix
if (namespace != null) {
- String prefix=bpelModel.getBPELProcess().addNamespace(namespace);
+ String pfix=bpelModel.getBPELProcess().addNamespace(namespace);
- if (prefix != null) {
- mesgType = prefix+":"+mesgType;
+ if (pfix != null) {
+ mesgType = pfix+":"+mesgType;
}
}
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-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/change/IfModelChangeRule.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -22,6 +22,7 @@
import org.jboss.savara.tools.bpel.model.util.InteractionUtil;
import org.scribble.model.*;
import org.scribble.model.change.*;
+import org.scribble.contract.model.Contract;
import org.scribble.extensions.RegistryInfo;
/**
@@ -220,6 +221,14 @@
String prevPLName=role.getName()+"To"+recv.getFromRole().getName();
+ String mainPrefix=null;
+
+ if (context.getRole().getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)context.getRole().getAnnotations().get(Contract.class.getName());
+
+ mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
+ }
+
// Check if partner link already exists in
// other direction
PartnerLink prev=
@@ -230,14 +239,28 @@
pl.setMyRole(role.getName()+"Service");
//pl.setPartnerRole(interaction.getToRole().getName());
pl.setName(recv.getFromRole().getName()+"To"+role.getName());
- pl.setPartnerLinkType(recv.getFromRole().getName()+"To"+role.getName()+"Service"+"LT");
+
+ String plt=recv.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
portType = role.getName()+"PT";
} else {
pl.setMyRole(role.getName()+"Requester");
pl.setPartnerRole(recv.getFromRole().getName()+"Service");
pl.setName(role.getName()+"To"+recv.getFromRole().getName());
- pl.setPartnerLinkType(role.getName()+"To"+recv.getFromRole().getName()+"Requester"+"LT");
+
+ String plt=role.getName()+"To"+recv.getFromRole().getName()+"Requester"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
portType = role.getName()+
recv.getFromRole().getName()+"CallbackPT";
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -44,6 +44,13 @@
public void addVariable(Variable var);
/**
+ * This method removes a variable from the context.
+ *
+ * @param var The variable
+ */
+ public void removeVariable(Variable var);
+
+ /**
* This method returns the namespace for the supplied prefix.
*
* @param prefix The prefix
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -65,6 +65,15 @@
}
/**
+ * This method removes a variable from the context.
+ *
+ * @param var The variable
+ */
+ public void removeVariable(Variable var) {
+ m_variables.remove(var.getName());
+ }
+
+ /**
* This method returns the namespace for the supplied prefix.
*
* @param prefix The prefix
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/FaultHandlers.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/FaultHandlers.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/FaultHandlers.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -126,8 +126,6 @@
@Override
public void convert(List<Activity> activities, ConversionContext context) {
- // TODO Auto-generated method stub
-
}
private static Log logger=LogFactory.getLog(FaultHandlers.class);
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -166,6 +166,16 @@
mesgType = catchBlock.getFaultMessageElement();
}
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
mesgType, context);
@@ -179,6 +189,10 @@
fcb.getContents().add(raise);
te.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
}
}
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-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -704,6 +704,16 @@
mesgType = catchBlock.getFaultMessageElement();
}
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
mesgType, context);
@@ -712,6 +722,10 @@
}
choice.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
}
activities.add(choice);
@@ -739,11 +753,25 @@
tref.setLocalpart(getFaultHandlers().getCatchPaths().get(i).getFaultName());
cb.setType(tref);
+ Variable faultVar=null;
+
+ if (getFaultHandlers().getCatchPaths().get(i).getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(getFaultHandlers().getCatchPaths().get(i).getFaultVariable());
+ faultVar.setMessageType(getFaultHandlers().getCatchPaths().get(i).getFaultMessageType());
+ faultVar.setElement(getFaultHandlers().getCatchPaths().get(i).getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
if (getFaultHandlers().getCatchPaths().get(i).getActivity() != null) {
getFaultHandlers().getCatchPaths().get(i).getActivity().
convert(cb.getContents(), context);
}
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+
te.getEscapeBlocks().add(cb);
}
}
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Scope.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Scope.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Scope.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -580,6 +580,16 @@
mesgType = catchBlock.getFaultMessageElement();
}
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
mesgType, context);
@@ -588,6 +598,10 @@
}
choice.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
}
activities.add(choice);
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/util/XMLUtils.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -28,10 +28,12 @@
import org.w3c.dom.Node;
/**
- *
+ * This class defines a set of XML related utility functions.
*/
public final class XMLUtils {
+ private static final String NS_LABEL = "ns";
+
/**
* This class converts a DOM representation node to text.
* @param node
@@ -168,11 +170,41 @@
return(ret);
}
- public static void main(String[] args) throws Exception {
- String raw = "<books><book>The World is Flat</book></books>";
- String pretty = format(raw);
- System.out.println(pretty);
+ /**
+ * This method returns the localname part of the supplied
+ * qualified name.
+ *
+ * @param qname The qualified name
+ * @return The localname part
+ */
+ public static String getLocalname(String qname) {
+ String ret=qname;
+ int pos=0;
+
+ if (qname != null && ((pos=qname.indexOf(':')) != -1)) {
+ ret = qname.substring(pos+1);
+ }
+
+ return(ret);
}
+ /**
+ * This method returns the prefix associated with the supplied namespace.
+ *
+ * @param namespace The namespace
+ * @param nsMap The existing namespace prefix mappings
+ * @return The prefix
+ */
+ public static String getPrefix(String namespace, java.util.Map<String,String> nsMap) {
+ String prefix=null;
+
+ prefix = nsMap.get(namespace);
+
+ if (prefix == null) {
+ prefix = NS_LABEL+(nsMap.size()+1);
+ nsMap.put(namespace, prefix);
+ }
+
+ return(prefix);
+ }
}
-
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2009-11-05 23:22:06 UTC (rev 73)
@@ -23,9 +23,7 @@
import org.jboss.savara.tools.bpel.model.BPELNotation;
import org.jboss.savara.tools.bpel.model.DefaultBPELLanguageModel;
-import org.jboss.savara.tools.bpel.parser.ParserTest;
import org.jboss.savara.tools.bpel.util.XMLUtils;
-import org.scribble.conversation.model.ConversationNotation;
import org.scribble.pi4soa.cdm.model.CDMNotation;
import org.scribble.extensions.RegistryFactory;
import org.scribble.model.Definition;
@@ -38,7 +36,6 @@
public static TestSuite suite() {
TestSuite suite = new TestSuite("Conversation->BPEL Generator Tests");
- suite.addTest(new ConversationToBPELTest("EventHandler@Store"));
suite.addTest(new ChoreographyToBPELTest("ESBBroker", "Broker"));
suite.addTest(new ChoreographyToBPELTest("ESBBroker", "Buyer"));
suite.addTest(new ChoreographyToBPELTest("ESBBroker", "CreditAgency"));
@@ -58,200 +55,6 @@
}
/**
- * The test case for running the conversation to BPEL test.
- */
- protected static class ConversationToBPELTest extends TestCase {
-
- /**
- * This constructor is initialized with the test
- * name.
- *
- * @param name The test name
- */
- public ConversationToBPELTest(String name) {
- super(name);
- m_name = name;
- }
-
- /**
- * This method runs the test.
- *
- * @param result The test result
- */
- public void run(TestResult result) {
- result.startTest(this);
-
- String filename="testmodels/"+m_name+".scv";
-
- java.io.InputStream is=
- GeneratorTest.class.getResourceAsStream(filename);
-
- if (is == null) {
- result.addError(this,
- new Throwable("Unable to locate resource: "+filename));
- } else {
- org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
- org.scribble.model.ModelReference ref=
- new org.scribble.model.ModelReference(ConversationNotation.NOTATION_CODE);
- org.scribble.model.admin.ModelListener l=
- new org.scribble.model.admin.DefaultModelListener();
-
- org.scribble.model.Model model=p.parse(ref, is, l);
-
- if (model == null) {
- result.addError(this, new Throwable("Model is null"));
- } else {
- ModelGenerator generator=(ModelGenerator)
- RegistryFactory.getRegistry().getExtension(
- ModelGenerator.class, null);
-
- java.util.List<Definition> defns=model.getDefinitions();
- Definition defn=null;
-
- if (defns.size() == 1) {
- defn = defns.get(0);
- }
-
- if (generator != null && defn != null) {
- ModelReference targetRef=
- new ModelReference(BPELNotation.NOTATION_CODE);
-
- targetRef.setAlias(defn.getLocatedName().getName());
- targetRef.setLocatedRole(defn.getLocatedName().getRole().getName());
-
- DefaultBPELLanguageModel target=
- new DefaultBPELLanguageModel(targetRef);
-
- generator.generate(targetRef,
- defn.getLocatedName().getRole(),
- target, model);
-
- if (target.getBPELProcess().getDOMElement() != null) {
- try {
- String text=XMLUtils.toText(target.getBPELProcess().getDOMElement());
- checkResults(result, text);
- } catch(Exception e) {
- result.addError(this, e);
- }
- } else {
- result.addError(this,
- new Throwable("No BPEL generated"));
- }
-
- } else {
- result.addError(this,
- new Throwable("Unable to find Model Generator"));
- }
- }
- }
-
- result.endTest(this);
- }
-
- /**
- * This method checks the generated BPEL against a
- * previously stored correct version.
- *
- * @param result The test result
- * @param bpel The BPEL
- */
- protected void checkResults(TestResult result, String bpel) {
- boolean f_valid=false;
-
- String filename="results/"+m_name+".bpel";
-
- java.io.InputStream is=
- GeneratorTest.class.getResourceAsStream(filename);
-
- if (is != null) {
-
- try {
- byte[] b=new byte[is.available()];
-
- is.read(b);
-
- is.close();
-
- String orig=new String(b);
-
- if (orig.equals(bpel) == false) {
- result.addError(this,
- new Throwable("Generated BPEL does not match stored version"));
- } else {
- f_valid = true;
- }
- } catch(Exception e) {
- result.addError(this, e);
- }
- } else {
- result.addError(this,
- new Throwable("Resulting BPEL '"+filename+
- "' not found for comparison"));
- }
-
- if (f_valid == false) {
- String bpelfile="testmodels/"+m_name+".scv";
-
- java.net.URL url=GeneratorTest.class.getResource(bpelfile);
-
- try {
- url = org.eclipse.core.runtime.FileLocator.toFileURL(url);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- if (url != null) {
- // URL will point to copy of test models in the classes folder, so need
- // to obtain reference back to source version
- java.io.File f=null;
-
- if (url.getFile().indexOf("classes") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("classes","src/plugintest"));
- } else if (url.getFile().indexOf("bin") != -1) {
- f = new java.io.File(url.getFile().replaceFirst("bin","src/plugintest"));
- } else {
- result.addError(this, new Exception("Could not locate results folder to record expected result"));
- }
-
- if (f != null && f.exists()) {
- f = f.getParentFile().getParentFile();
-
- java.io.File resultsDir=new java.io.File(f, "results");
-
- if (resultsDir.exists() == false) {
- resultsDir.mkdirs();
- }
-
- java.io.File resultFile=new java.io.File(resultsDir,
- m_name+".expected");
-
- if (resultFile.exists() == false) {
- try {
- java.io.FileOutputStream fos=new java.io.FileOutputStream(resultFile);
-
- fos.write(bpel.getBytes());
-
- fos.flush();
- fos.close();
-
- } catch(Exception e){
- result.addError(this, e);
- }
- } else {
- System.err.println("NOTE: Expected output '"+resultFile+
- "' already exists - not being overwritten");
- }
- } else {
- result.addError(this, new Throwable("Unable to obtain URL for SCV model source '"+
- m_name+"': "+url));
- }
- }
- }
- }
-
- private String m_name=null;
- }
- /**
* The test case for running the choreography to BPEL test.
*/
protected static class ChoreographyToBPELTest extends TestCase {
Deleted: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/results/EventHandler(a)Store.bpel
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/results/EventHandler(a)Store.bpel 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/results/EventHandler(a)Store.bpel 2009-11-05 23:22:06 UTC (rev 73)
@@ -1,22 +0,0 @@
-<process xmlns:ns0="http://www.scribble.org/conversation" ns0:conversationType="EventHandler@Store" name="EventHandler_Store" 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="creditCheck" partnerLink="StoreToCreditAgency" portType="CreditAgencyPT"/>
- <pick>
- <onMessage operation="checkCreditOk" partnerLink="StoreToCreditAgency" portType="StoreCreditAgencyCallbackPT">
- <sequence>
- <reply operation="buy" partnerLink="BuyerToStore" portType="StorePT"/>
- </sequence>
- </onMessage>
- <onMessage operation="checkCreditInvalid" partnerLink="StoreToCreditAgency" portType="StoreCreditAgencyCallbackPT">
- <sequence>
- <reply operation="buy" partnerLink="BuyerToStore" portType="StorePT"/>
- </sequence>
- </onMessage>
- </pick>
- </sequence>
-</process>
Deleted: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/testmodels/EventHandler(a)Store.scv
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/testmodels/EventHandler(a)Store.scv 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/testmodels/EventHandler(a)Store.scv 2009-11-05 23:22:06 UTC (rev 73)
@@ -1,19 +0,0 @@
-namespace org.examples;
-
-conversation EventHandler@Store {
- role Buyer, CreditAgency;
-
- buy(BuyInfo) from Buyer to Store request "buy";
-
- creditCheck(CreditInformation) from Store to CreditAgency;
-
- // No request/replyTo, so will be treated as invocations on a callback interface
-
- if @ CreditAgency {
- checkCreditOk(CreditCheckOk) from CreditAgency to Store;
- buy(Confirmed) from Store to Buyer replyTo "buy";
- } else if {
- checkCreditInvalid(CreditCheckInvalid) from CreditAgency to Store;
- buy(Rejected) from Store to Buyer replyTo "buy";
- }
-}
\ No newline at end of file
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/results/LoanApprovalService(a)Service.scv
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/results/LoanApprovalService(a)Service.scv 2009-11-05 23:13:40 UTC (rev 72)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/results/LoanApprovalService(a)Service.scv 2009-11-05 23:22:06 UTC (rev 73)
@@ -4,16 +4,16 @@
try {
boolean receive-to-assess, receive-to-approval, approval-to-reply, assess-to-setMessage, setMessage-to-reply, assess-to-approval;
parallel {
- request(lns:creditInformationMessage) from customer;
+ request(creditInformationMessage) from customer;
receive-to-assess = xpath[true()];
receive-to-approval = xpath[true()];
} and {
when (xpath[$receive-to-assess]) {
- check(lns:creditInformationMessage) to assessor;
+ check(creditInformationMessage) to assessor;
if {
- check(lns:riskAssessmentMessage) from assessor;
+ check(riskAssessmentMessage) from assessor;
} else if {
- check(lns:errorMessage) from assessor;
+ check(errorMessage) from assessor;
raise lns:loanProcessFault;
}
assess-to-setMessage = xpath[true()];
@@ -21,21 +21,21 @@
}
} and {
when (xpath[$receive-to-approval and $assess-to-approval]) {
- approve(lns:creditInformationMessage) to approver;
+ approve(creditInformationMessage) to approver;
if {
- approve(lns:approvalMessage) from approver;
+ approve(approvalMessage) from approver;
} else if {
- approve(lns:errorMessage) from approver;
+ approve(errorMessage) from approver;
raise lns:loanProcessFault;
}
approval-to-reply = xpath[true()];
}
} and {
when (xpath[$setMessage-to-reply and $approval-to-reply]) {
- request(lns:approvalMessage) to customer;
+ request(approvalMessage) to customer;
}
}
} catch lns:loanProcessFault {
- request() to customer;
+ request(errorMessage) to customer;
}
}
\ No newline at end of file
16 years, 5 months
savara SVN: r72 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl: soap and 1 other directory.
by do-not-reply@jboss.org
Author: objectiser
Date: 2009-11-05 18:13:40 -0500 (Thu, 05 Nov 2009)
New Revision: 72
Modified:
tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java
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/soap/SOAPRPCWSDLBinding.java
Log:
Create a default soap address entry in the wsdl service if using soap binding.
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java 2009-10-31 19:03:06 UTC (rev 71)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLBinding.java 2009-11-05 23:13:40 UTC (rev 72)
@@ -78,4 +78,12 @@
*/
public void updateFault(javax.wsdl.Definition defn, javax.wsdl.BindingFault fault);
+ /**
+ * This method adds WSDL binding information to the fault.
+ *
+ * @param defn The definition
+ * @param port The port
+ */
+ public void updatePort(javax.wsdl.Definition defn, javax.wsdl.Port port);
+
}
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-31 19:03:06 UTC (rev 71)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/WSDLGenerator.java 2009-11-05 23:13:40 UTC (rev 72)
@@ -52,6 +52,11 @@
// Create definition for contract's target namespace
javax.wsdl.Definition main=getDefinition(ret, contract, contract.getNamespace(), wsdlBinding);
+ // If no definition, then return
+ if (main == null) {
+ return(ret);
+ }
+
// Create service
javax.wsdl.Service service=main.createService();
service.setQName(new javax.xml.namespace.QName(contract.getNamespace(),
@@ -76,6 +81,10 @@
port.setBinding(binding);
service.addPort(port);
+
+ if (wsdlBinding != null) {
+ wsdlBinding.updatePort(main, port);
+ }
}
} catch(Exception e) {
Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java 2009-10-31 19:03:06 UTC (rev 71)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/soap/SOAPRPCWSDLBinding.java 2009-11-05 23:13:40 UTC (rev 72)
@@ -144,4 +144,23 @@
}
}
+ /**
+ * This method adds WSDL binding information to the fault.
+ *
+ * @param defn The definition
+ * @param port The port
+ */
+ public void updatePort(javax.wsdl.Definition defn, javax.wsdl.Port port) {
+ try {
+ javax.wsdl.extensions.soap.SOAPAddress soap=(javax.wsdl.extensions.soap.SOAPAddress)
+ defn.getExtensionRegistry().createExtension(javax.wsdl.Port.class,
+ new javax.xml.namespace.QName("http://schemas.xmlsoap.org/wsdl/soap/", "address"));
+ soap.setLocationURI("http://localhost:8080/"+defn.getQName().getLocalPart()+"Service");
+
+ port.addExtensibilityElement(soap);
+ } catch(Exception e) {
+ logger.error("Failed to add SOAP address to port", e);
+ }
+ }
+
}
16 years, 5 months