[savara-commits] savara SVN: r284 - branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 29 07:36:54 EDT 2010


Author: objectiser
Date: 2010-06-29 07:36:53 -0400 (Tue, 29 Jun 2010)
New Revision: 284

Modified:
   branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
   branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
   trunk/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
   trunk/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
Log:
SAVARA-109 and SAVARA-110.

Modified: branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
--- branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF	2010-06-22 19:05:26 UTC (rev 283)
+++ branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF	2010-06-29 11:36:53 UTC (rev 284)
@@ -19,7 +19,10 @@
  org.scribble.pi4soa.cdm;resolution:=optional,
  org.scribble.contract.model,
  org.jboss.savara.tools.wsdl,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.project.facet.core
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: www.jboss.org

Modified: branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java	2010-06-22 19:05:26 UTC (rev 283)
+++ branches/1.0.x/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java	2010-06-29 11:36:53 UTC (rev 284)
@@ -44,6 +44,11 @@
 import org.scribble.model.admin.ModelRepository;
 import org.scribble.model.change.ModelGenerator;
 import org.eclipse.core.runtime.*;
+import org.eclipse.jst.common.project.facet.WtpUtils;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
 
 /**
  * This class provides the mechanism for generating JBossESB
@@ -51,6 +56,8 @@
  */
 public class Generator {
 
+	private static final String WSDL_IMPORT = "wsdl:import";
+
 	private static final String BPEL_DEPLOY_DESCRIPTOR_FILENAME = "bpel-deploy.xml";
 
 	private static final String XMLNS_PREFIX = "xmlns:";
@@ -274,11 +281,11 @@
 						new org.jboss.savara.tools.wsdl.generator.WSDLGenerator();
 			Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
 
-			// Generate WSDL folder
-			IPath wsdlFolderPath=proj.getFullPath().append(
+			// Generate BPEL folder
+			IPath bpelFolderPath=proj.getFullPath().append(
 					new Path(getBuildSystem().getBPELFilePath()));
 
-			IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(wsdlFolderPath);
+			IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(bpelFolderPath);
 			
 			GeneratorUtil.createFolder(wsdlFolder);
 			
@@ -316,40 +323,8 @@
 						
 						defns.get(0).addImport(imp);					
 					} else {
-						
-						// Generate imports for specified message schema
-						for (Namespace ns : contract.getNamespaces()) {
-							
-							if (ns.getSchemaLocation() != null &&
-									ns.getSchemaLocation().trim().length() > 0) {
-								
-								java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
-								
-								while (st.hasMoreTokens()) {
-									IFile file=cdmResource.getParent().getFile(new Path(st.nextToken()));
-									
-									javax.wsdl.Import imp=defns.get(0).createImport();
-									
-									imp.setDefinition(defn);
-									imp.setNamespaceURI(ns.getURI());
-									imp.setLocationURI(file.getName());
-									
-									defns.get(0).addImport(imp);					
-									
-									IPath artifactPath=wsdlFolderPath.append(file.getName());
-						
-									IFile artifactFile=cdmResource.getProject().getWorkspace().getRoot().getFile(artifactPath);
-	
-									if (artifactFile.exists() == false) {
-										artifactFile.create(null, true,
-												new org.eclipse.core.runtime.NullProgressMonitor());
-									}
-									
-									artifactFile.setContents(file.getContents(), true, false,
-												new org.eclipse.core.runtime.NullProgressMonitor());
-								}
-							}
-						}
+						importSchemas(cdmResource, contract, bpelFolderPath,
+									defn, defns.get(0));
 					}
 					
 					java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
@@ -360,7 +335,7 @@
 					
 					baos.close();
 					
-					IPath wsdlPath=wsdlFolderPath.append(filename);
+					IPath wsdlPath=bpelFolderPath.append(filename);
 					
 					IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
 					
@@ -378,6 +353,47 @@
 		}
 	}
 	
+	protected void importSchemas(IFile cdmResource, Contract contract,
+					IPath bpelFolderPath, javax.wsdl.Definition defn,
+					javax.wsdl.Definition firstDefn) throws Exception {
+		
+		// Generate imports for specified message schema
+		for (Namespace ns : contract.getNamespaces()) {
+			
+			if (ns.getSchemaLocation() != null &&
+					ns.getSchemaLocation().trim().length() > 0) {
+				
+				java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
+				
+				while (st.hasMoreTokens()) {
+					IFile file=cdmResource.getParent().getFile(new Path(st.nextToken()));
+					
+					javax.wsdl.Import imp=firstDefn.createImport();
+					
+					imp.setDefinition(defn);
+					imp.setNamespaceURI(ns.getURI());
+					imp.setLocationURI(file.getProjectRelativePath().toPortableString());
+					
+					firstDefn.addImport(imp);					
+					
+					IPath artifactPath=bpelFolderPath.append(file.getProjectRelativePath());
+		
+					IFile artifactFile=cdmResource.getProject().getWorkspace().getRoot().getFile(artifactPath);
+
+					if (artifactFile.exists() == false) {
+						GeneratorUtil.createFolder(artifactFile.getParent());
+
+						artifactFile.create(null, true,
+								new org.eclipse.core.runtime.NullProgressMonitor());
+					}
+					
+					artifactFile.setContents(file.getContents(), true, false,
+								new org.eclipse.core.runtime.NullProgressMonitor());
+				}
+			}
+		}
+	}
+	
 	protected void generatePartnerLinkTypes(Role role, IProject proj, ConversationModel localcm,
 			org.jboss.savara.tools.bpel.model.component.Process bpelProcess) throws Exception {	
 		
@@ -391,6 +407,17 @@
 		
 		defn.setAttribute(TARGET_NAMESPACE_LABEL, bpelProcess.getTargetNamespace());
 		
+		// Add import to associated wsdl
+		String wsdlName=getWSDLFileName(role, localcm.getModelName().getName(), "");
+
+		org.w3c.dom.Element imp=doc.createElement(WSDL_IMPORT);
+		
+		imp.setAttribute("namespace", bpelProcess.getTargetNamespace());
+		imp.setAttribute("location", wsdlName);
+		
+		defn.appendChild(imp);					
+
+		// Create partner link types
 		java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
 		
 		for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
@@ -636,7 +663,19 @@
 		
 		// Open the project
 		project.open(new org.eclipse.core.runtime.NullProgressMonitor());
+		
+		// Add wtp natures
+		WtpUtils.addNatures(project);
+		
+		// Add required project facets	
+		IProjectFacet bpelFacet =
+					ProjectFacetsManager.getProjectFacet("jbt.bpel.facet.core");
+		IProjectFacetVersion ipfv = bpelFacet.getVersion("2.0");
+		IFacetedProject ifp = ProjectFacetsManager.create(project, true, null);
+		ifp.installProjectFacet(ipfv, null,
+					new org.eclipse.core.runtime.NullProgressMonitor());
 
+		// Update the project description
 		IProjectDescription description = project.getDescription();
 		
 		// Setup project reference to CDM project

Modified: trunk/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF	2010-06-22 19:05:26 UTC (rev 283)
+++ trunk/tools/eclipse/org.jboss.savara.tools.bpel/META-INF/MANIFEST.MF	2010-06-29 11:36:53 UTC (rev 284)
@@ -19,7 +19,10 @@
  org.scribble.pi4soa.cdm;resolution:=optional,
  org.scribble.contract.model,
  org.jboss.savara.tools.wsdl,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.eclipse.jst.common.frameworks,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.project.facet.core
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: www.jboss.org

Modified: trunk/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java
===================================================================
--- trunk/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java	2010-06-22 19:05:26 UTC (rev 283)
+++ trunk/tools/eclipse/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/generator/Generator.java	2010-06-29 11:36:53 UTC (rev 284)
@@ -44,6 +44,11 @@
 import org.scribble.model.admin.ModelRepository;
 import org.scribble.model.change.ModelGenerator;
 import org.eclipse.core.runtime.*;
+import org.eclipse.jst.common.project.facet.WtpUtils;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
 
 /**
  * This class provides the mechanism for generating JBossESB
@@ -51,6 +56,8 @@
  */
 public class Generator {
 
+	private static final String WSDL_IMPORT = "wsdl:import";
+
 	private static final String BPEL_DEPLOY_DESCRIPTOR_FILENAME = "bpel-deploy.xml";
 
 	private static final String XMLNS_PREFIX = "xmlns:";
@@ -274,11 +281,11 @@
 						new org.jboss.savara.tools.wsdl.generator.WSDLGenerator();
 			Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
 
-			// Generate WSDL folder
-			IPath wsdlFolderPath=proj.getFullPath().append(
+			// Generate BPEL folder
+			IPath bpelFolderPath=proj.getFullPath().append(
 					new Path(getBuildSystem().getBPELFilePath()));
 
-			IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(wsdlFolderPath);
+			IFolder wsdlFolder=proj.getProject().getWorkspace().getRoot().getFolder(bpelFolderPath);
 			
 			GeneratorUtil.createFolder(wsdlFolder);
 			
@@ -316,40 +323,8 @@
 						
 						defns.get(0).addImport(imp);					
 					} else {
-						
-						// Generate imports for specified message schema
-						for (Namespace ns : contract.getNamespaces()) {
-							
-							if (ns.getSchemaLocation() != null &&
-									ns.getSchemaLocation().trim().length() > 0) {
-								
-								java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
-								
-								while (st.hasMoreTokens()) {
-									IFile file=cdmResource.getParent().getFile(new Path(st.nextToken()));
-									
-									javax.wsdl.Import imp=defns.get(0).createImport();
-									
-									imp.setDefinition(defn);
-									imp.setNamespaceURI(ns.getURI());
-									imp.setLocationURI(file.getName());
-									
-									defns.get(0).addImport(imp);					
-									
-									IPath artifactPath=wsdlFolderPath.append(file.getName());
-						
-									IFile artifactFile=cdmResource.getProject().getWorkspace().getRoot().getFile(artifactPath);
-	
-									if (artifactFile.exists() == false) {
-										artifactFile.create(null, true,
-												new org.eclipse.core.runtime.NullProgressMonitor());
-									}
-									
-									artifactFile.setContents(file.getContents(), true, false,
-												new org.eclipse.core.runtime.NullProgressMonitor());
-								}
-							}
-						}
+						importSchemas(cdmResource, contract, bpelFolderPath,
+									defn, defns.get(0));
 					}
 					
 					java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream();
@@ -360,7 +335,7 @@
 					
 					baos.close();
 					
-					IPath wsdlPath=wsdlFolderPath.append(filename);
+					IPath wsdlPath=bpelFolderPath.append(filename);
 					
 					IFile wsdlFile=proj.getProject().getWorkspace().getRoot().getFile(wsdlPath);
 					
@@ -378,6 +353,47 @@
 		}
 	}
 	
+	protected void importSchemas(IFile cdmResource, Contract contract,
+					IPath bpelFolderPath, javax.wsdl.Definition defn,
+					javax.wsdl.Definition firstDefn) throws Exception {
+		
+		// Generate imports for specified message schema
+		for (Namespace ns : contract.getNamespaces()) {
+			
+			if (ns.getSchemaLocation() != null &&
+					ns.getSchemaLocation().trim().length() > 0) {
+				
+				java.util.StringTokenizer st=new java.util.StringTokenizer(ns.getSchemaLocation());
+				
+				while (st.hasMoreTokens()) {
+					IFile file=cdmResource.getParent().getFile(new Path(st.nextToken()));
+					
+					javax.wsdl.Import imp=firstDefn.createImport();
+					
+					imp.setDefinition(defn);
+					imp.setNamespaceURI(ns.getURI());
+					imp.setLocationURI(file.getProjectRelativePath().toPortableString());
+					
+					firstDefn.addImport(imp);					
+					
+					IPath artifactPath=bpelFolderPath.append(file.getProjectRelativePath());
+		
+					IFile artifactFile=cdmResource.getProject().getWorkspace().getRoot().getFile(artifactPath);
+
+					if (artifactFile.exists() == false) {
+						GeneratorUtil.createFolder(artifactFile.getParent());
+
+						artifactFile.create(null, true,
+								new org.eclipse.core.runtime.NullProgressMonitor());
+					}
+					
+					artifactFile.setContents(file.getContents(), true, false,
+								new org.eclipse.core.runtime.NullProgressMonitor());
+				}
+			}
+		}
+	}
+	
 	protected void generatePartnerLinkTypes(Role role, IProject proj, ConversationModel localcm,
 			org.jboss.savara.tools.bpel.model.component.Process bpelProcess) throws Exception {	
 		
@@ -391,6 +407,17 @@
 		
 		defn.setAttribute(TARGET_NAMESPACE_LABEL, bpelProcess.getTargetNamespace());
 		
+		// Add import to associated wsdl
+		String wsdlName=getWSDLFileName(role, localcm.getModelName().getName(), "");
+
+		org.w3c.dom.Element imp=doc.createElement(WSDL_IMPORT);
+		
+		imp.setAttribute("namespace", bpelProcess.getTargetNamespace());
+		imp.setAttribute("location", wsdlName);
+		
+		defn.appendChild(imp);					
+
+		// Create partner link types
 		java.util.Map<String, String> nsMap=new java.util.HashMap<String, String>();
 		
 		for (PartnerLink pl : bpelProcess.getPartnerLinks()) {
@@ -636,7 +663,19 @@
 		
 		// Open the project
 		project.open(new org.eclipse.core.runtime.NullProgressMonitor());
+		
+		// Add wtp natures
+		WtpUtils.addNatures(project);
+		
+		// Add required project facets	
+		IProjectFacet bpelFacet =
+					ProjectFacetsManager.getProjectFacet("jbt.bpel.facet.core");
+		IProjectFacetVersion ipfv = bpelFacet.getVersion("2.0");
+		IFacetedProject ifp = ProjectFacetsManager.create(project, true, null);
+		ifp.installProjectFacet(ipfv, null,
+					new org.eclipse.core.runtime.NullProgressMonitor());
 
+		// Update the project description
 		IProjectDescription description = project.getDescription();
 		
 		// Setup project reference to CDM project



More information about the savara-commits mailing list