[savara-commits] 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.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Oct 17 18:36:19 EDT 2009
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;
More information about the savara-commits
mailing list