[savara-commits] savara SVN: r283 - in branches/1.0.x/tools/eclipse: org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jun 22 15:05:27 EDT 2010


Author: objectiser
Date: 2010-06-22 15:05:26 -0400 (Tue, 22 Jun 2010)
New Revision: 283

Modified:
   branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
   branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/WSDLGenerator.java
   branches/1.0.x/tools/eclipse/org.scribble.core/src/java/org/scribble/model/TypeReference.java
   branches/1.0.x/tools/eclipse/org.scribble.pi4soa.cdm/src/java/org/scribble/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
Log:
SAVARA-107 - CDL InfoType type/element field is now mapped onto single part in a WSDL message type defined in the same wsdl file as the portType.

Modified: branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/WSDLGenerator.java
===================================================================
--- branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/WSDLGenerator.java	2010-06-22 19:03:49 UTC (rev 282)
+++ branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl/src/java/org/jboss/savara/tools/wsdl/generator/WSDLGenerator.java	2010-06-22 19:05:26 UTC (rev 283)
@@ -17,6 +17,9 @@
  */
 package org.jboss.savara.tools.wsdl.generator;
 
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.scribble.contract.model.FaultDetails;
@@ -294,8 +297,12 @@
 			
 			ret.setName(mep.getOperation());
 			
-			javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes(), wsdlBinding);
+			QName msgname=new QName(portType.getQName().getNamespaceURI(),
+								mep.getOperation()+"Request");
 			
+			javax.wsdl.Message mesg=getMessage(wsdls, contract, msgname,
+								mep.getTypes(), wsdlBinding);
+			
 			if (mesg != null) {
 				javax.wsdl.Input input=defn.createInput();
 				input.setMessage(mesg);
@@ -306,7 +313,11 @@
 			if (mep instanceof RequestResponseMEP) {
 				RequestResponseMEP rr=(RequestResponseMEP)mep;
 				
-				javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes(), wsdlBinding);
+				msgname=new QName(portType.getQName().getNamespaceURI(),
+								mep.getOperation()+"Response");
+			
+				javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+									rr.getResponseTypes(), wsdlBinding);
 				if (om != null) {
 					javax.wsdl.Output output=defn.createOutput();
 					output.setMessage(om);
@@ -318,7 +329,11 @@
 					for (int i=0; i < rr.getFaultDetails().size(); i++) {
 						FaultDetails fd=rr.getFaultDetails().get(i);
 						
-						javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes(), wsdlBinding);
+						msgname = new QName(portType.getQName().getNamespaceURI(),
+										mep.getOperation()+"Fault"+(i+1));
+					
+						javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+											fd.getTypes(), wsdlBinding);
 						if (fm != null) {
 							javax.wsdl.Fault fault=defn.createFault();
 							fault.setName(fd.getName());
@@ -369,7 +384,11 @@
 			
 			ret.setName(mep.getOperation());
 			
-			javax.wsdl.Message mesg=getMessage(wsdls, contract, mep.getTypes(), wsdlBinding);
+			QName msgname=new QName(binding.getQName().getNamespaceURI(),
+								mep.getOperation()+"Request");
+		
+			javax.wsdl.Message mesg=getMessage(wsdls, contract,msgname,
+								mep.getTypes(), wsdlBinding);
 			
 			if (mesg != null) {
 				javax.wsdl.BindingInput input=defn.createBindingInput();
@@ -386,7 +405,11 @@
 			if (mep instanceof RequestResponseMEP) {
 				RequestResponseMEP rr=(RequestResponseMEP)mep;
 				
-				javax.wsdl.Message om=getMessage(wsdls, contract, rr.getResponseTypes(), wsdlBinding);
+				msgname=new QName(binding.getQName().getNamespaceURI(),
+						mep.getOperation()+"Response");
+	
+				javax.wsdl.Message om=getMessage(wsdls, contract, msgname,
+									rr.getResponseTypes(), wsdlBinding);
 				if (om != null) {
 					javax.wsdl.BindingOutput output=defn.createBindingOutput();
 					
@@ -403,7 +426,11 @@
 					for (int i=0; i < rr.getFaultDetails().size(); i++) {
 						FaultDetails fd=rr.getFaultDetails().get(i);
 						
-						javax.wsdl.Message fm=getMessage(wsdls, contract, fd.getTypes(), wsdlBinding);
+						msgname = new QName(binding.getQName().getNamespaceURI(),
+								mep.getOperation()+"Fault"+(i+1));
+			
+						javax.wsdl.Message fm=getMessage(wsdls, contract, msgname,
+									fd.getTypes(), wsdlBinding);
 						if (fm != null) {
 							javax.wsdl.BindingFault fault=defn.createBindingFault();
 							fault.setName(fd.getName());
@@ -438,35 +465,47 @@
 	 * 
 	 * @param wsdls The list of current WSDL definitions
 	 * @param contract The contract
+	 * @param msgname The message name
 	 * @param types The list of type references
 	 * @return The WSDL message
 	 */
 	public javax.wsdl.Message getMessage(java.util.List<javax.wsdl.Definition> wsdls,
 						org.scribble.contract.model.Contract contract,
-								java.util.List<TypeReference> types,
+						javax.xml.namespace.QName msgname,
+						java.util.List<TypeReference> types,
 								WSDLBinding wsdlBinding) {
 		javax.wsdl.Message ret=null;
 		
-		if (types != null && types.size() > 0) {
-			javax.xml.namespace.QName qname=null;
-			javax.wsdl.Definition defn=null;
+		if (types == null || types.size() == 0) {
+			throw new UnsupportedOperationException("Expecting single type reference");
+		} else if (types.size() > 1) {
+			throw new UnsupportedOperationException("Currently only supports single type reference");			
+		} else {
+			TypeReference ref=types.get(0);
+			javax.xml.namespace.QName qname=
+						new javax.xml.namespace.QName(ref.getNamespace(),ref.getLocalpart());
+			javax.wsdl.Definition defn=
+				getDefinition(wsdls, contract, msgname.getNamespaceURI(), wsdlBinding);
 					
-			if (types.size() == 1) {
-				TypeReference ref=types.get(0);
-				qname = new javax.xml.namespace.QName(ref.getNamespace(),ref.getLocalpart());
-				
-				defn = getDefinition(wsdls, contract, ref.getNamespace(), wsdlBinding);
-			} else {
-				throw new UnsupportedOperationException("Currently only supports single type reference");
-			}
-			
 			if (defn != null && qname != null &&
-					(ret = defn.getMessage(qname)) == null) {
+					(ret = defn.getMessage(msgname)) == null) {
 				ret = defn.createMessage();
 				ret.setUndefined(false);
 				
-				ret.setQName(qname);
+				ret.setQName(msgname);
 				
+				// Create single part for type or element
+				Part part=defn.createPart();
+				part.setName("content");
+				
+				if (TypeReference.TS_XSD_ELEMENT.equals(ref.getProperty(TypeReference.TYPE_SYSTEM))) {
+					part.setElementName(qname);					
+				} else {
+					part.setTypeName(qname);
+				}
+				
+				ret.addPart(part);
+				
 				defn.addMessage(ret);
 			}
 		}

Modified: branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java
===================================================================
--- branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java	2010-06-22 19:03:49 UTC (rev 282)
+++ branches/1.0.x/tools/eclipse/org.jboss.savara.tools.wsdl.tests/src/java/org/jboss/savara/tools/wsdl/tests/WSDLGeneratorTest.java	2010-06-22 19:05:26 UTC (rev 283)
@@ -17,6 +17,9 @@
  */
 package org.jboss.savara.tools.wsdl.tests;
 
+import javax.wsdl.Part;
+import javax.xml.namespace.QName;
+
 import org.jboss.savara.tools.wsdl.generator.WSDLGenerator;
 import org.scribble.contract.model.*;
 import org.scribble.model.TypeReference;
@@ -25,6 +28,8 @@
 
 public class WSDLGeneratorTest extends TestCase {
 
+	private static final String TEST_LOCALPART = "test.localpart";
+	private static final String HTTP_TEST_NAMESPACE = "http://test.namespace";
 	private static final String TEST_TYPE_NS = "testTypeNS";
 	private static final String TEST_TYPE_LP = "testTypeLP";
 	private static final String TEST_NAME_SPACE = "testNameSpace";
@@ -380,8 +385,10 @@
 		
 		java.util.List<javax.wsdl.Definition> defns=new java.util.Vector<javax.wsdl.Definition>();
 		
-		javax.wsdl.Message result=gen.getMessage(defns, new Contract(), refs, null);
+		QName msgname=new QName(HTTP_TEST_NAMESPACE,TEST_LOCALPART);
 		
+		javax.wsdl.Message result=gen.getMessage(defns, new Contract(), msgname, refs, null);
+		
 		if (result == null) {
 			fail("Message is null");
 		}
@@ -394,7 +401,7 @@
 			fail("QName localpart not set");
 		}
 		
-		if (TEST_TYPE_LP.equals(result.getQName().getLocalPart()) == false) {
+		if (TEST_LOCALPART.equals(result.getQName().getLocalPart()) == false) {
 			fail("QName localpart not correct: "+result.getQName().getLocalPart());
 		}
 		
@@ -402,9 +409,31 @@
 			fail("QName namespace not set");
 		}
 		
-		if (TEST_TYPE_NS.equals(result.getQName().getNamespaceURI()) == false) {
+		if (HTTP_TEST_NAMESPACE.equals(result.getQName().getNamespaceURI()) == false) {
 			fail("QName namespace not correct: "+result.getQName().getNamespaceURI());
 		}
+		
+		if (result.getParts().size() != 1) {
+			fail("Should be one part: "+result.getParts().size());
+		}
+		
+		Part part=(Part)result.getParts().values().toArray()[0];
+		
+		if (part.getElementName() != null) {
+			fail("Element name should not be set");
+		}
+		
+		if (part.getTypeName() == null) {
+			fail("Type name not set");
+		}
+		
+		if (TEST_TYPE_NS.equals(part.getTypeName().getNamespaceURI()) == false) {
+			fail("Element namespace incorrect: "+part.getTypeName().getNamespaceURI());
+		}
+		
+		if (TEST_TYPE_LP.equals(part.getTypeName().getLocalPart()) == false) {
+			fail("Element localpart incorrect: "+part.getTypeName().getLocalPart());
+		}
 	}
 	
 	public void testDefnWithPortTypesAndMesgsInDiffNamespaces() {
@@ -467,8 +496,8 @@
 		
 		java.util.List<javax.wsdl.Definition> defns=gen.generateDefinitions(c, null);
 		
-		if (defns.size() != 3) {
-			fail("Four Definitions expected, but got: "+defns.size());
+		if (defns.size() != 2) {
+			fail("Two Definitions expected, but got: "+defns.size());
 		}
 		
 		javax.wsdl.Definition defn1=defns.get(0);
@@ -505,23 +534,6 @@
 			") does not match number expected (1)");
 		}
 		
-		javax.wsdl.Definition defn3=defns.get(2);
-
-		if (defn3.getPortTypes().size() != 0) {
-			fail("3: Number of port types ("+defn3.getPortTypes().size()+
-					") does not match number expected (0)");
-		}
-		
-		if (defn3.getBindings().size() != 0) {
-			fail("3: Number of port type bindings ("+defn3.getBindings().size()+
-					") does not match number expected (0)");
-		}
-		
-		if (defn3.getMessages().size() != 1) {
-			fail("3: Number of message ("+defn3.getMessages().size()+
-			") does not match number expected (1)");
-		}
-		
 		// Check service only associated with the first defn
 		if (defn1.getServices().size() != 1) {
 			fail("First definition should only have 1 service: "+defn1.getServices().size());
@@ -536,9 +548,5 @@
 		if (defn2.getServices().size() != 0) {
 			fail("Second definition should not have any services: "+defn2.getServices().size());
 		}
-		
-		if (defn3.getServices().size() != 0) {
-			fail("Third definition should not have any services: "+defn3.getServices().size());
-		}
 	}
 }

Modified: branches/1.0.x/tools/eclipse/org.scribble.core/src/java/org/scribble/model/TypeReference.java
===================================================================
--- branches/1.0.x/tools/eclipse/org.scribble.core/src/java/org/scribble/model/TypeReference.java	2010-06-22 19:03:49 UTC (rev 282)
+++ branches/1.0.x/tools/eclipse/org.scribble.core/src/java/org/scribble/model/TypeReference.java	2010-06-22 19:05:26 UTC (rev 283)
@@ -26,6 +26,11 @@
 
 	private static final long serialVersionUID = 6492984753933254949L;
 
+	public static final String TYPE_SYSTEM="TypeSystem";
+	
+	public static final String TS_XSD_TYPE="XSDType";
+	public static final String TS_XSD_ELEMENT="XSDElement";
+	
 	/**
 	 * This is the default constructor for the type reference.
 	 */

Modified: branches/1.0.x/tools/eclipse/org.scribble.pi4soa.cdm/src/java/org/scribble/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
===================================================================
--- branches/1.0.x/tools/eclipse/org.scribble.pi4soa.cdm/src/java/org/scribble/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java	2010-06-22 19:03:49 UTC (rev 282)
+++ branches/1.0.x/tools/eclipse/org.scribble.pi4soa.cdm/src/java/org/scribble/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java	2010-06-22 19:05:26 UTC (rev 283)
@@ -721,12 +721,17 @@
 				if (defn.getElementNamespace() != null) {
 					ret.setNamespace(defn.getElementNamespace());
 				}
+				
+				ret.setProperty(TypeReference.TYPE_SYSTEM, TypeReference.TS_XSD_ELEMENT);
+
 			} else if (defn.getType() != null && defn.getType().trim().length() > 0) {
 				ret.setLocalpart(defn.getType());
 				
 				if (defn.getTypeNamespace() != null) {
 					ret.setNamespace(defn.getTypeNamespace());
 				}
+				
+				ret.setProperty(TypeReference.TYPE_SYSTEM, TypeReference.TS_XSD_TYPE);
 			}
 			
 			return(ret);



More information about the savara-commits mailing list