[jbossws-commits] JBossWS SVN: r1555 - in branches/dlofthouse/JBWS-1260/src: main/java/org/jboss/ws/tools test/resources/tools/jbws1260/scenario_A test/resources/tools/jbws1260/scenario_B test/resources/tools/jbws1260/scenario_C test/resources/tools/jbws1260/scenario_D test/resources/tools/jbws1260/scenario_E test/resources/tools/jbws1260/scenario_F test/resources/tools/jbws1260/scenario_G test/resources/tools/jbws1260/scenario_H test/resources/tools/jbws1260/scenario_I test/resources/tools/jbws1260/scenario_J test/resources/tools/jbws1260/scenario_K test/resources/tools/jbws1260/scenario_L

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Dec 5 18:27:43 EST 2006


Author: darran.lofthouse at jboss.com
Date: 2006-12-05 18:27:34 -0500 (Tue, 05 Dec 2006)
New Revision: 1555

Modified:
   branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_A/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_B/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_C/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_D/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_E/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_F/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_G/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_H/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_I/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_J/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_K/wstools-config.xml
   branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_L/wstools-config.xml
Log:
JBWS-1260 - Corrected all failures during code generation.

Modified: branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
--- branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java	2006-12-05 23:27:34 UTC (rev 1555)
@@ -224,56 +224,6 @@
       return "wrapped".equals(parameterStyle) && Constants.DOCUMENT_LITERAL.equals(style);
    }
 
-   private void unwrapRequest(StringBuilder buf, XSTypeDefinition xt) throws IOException
-   {
-      if (xt instanceof XSComplexTypeDefinition == false)
-         throw new WSException("Tried to unwrap a non-complex type.");
-
-      XSComplexTypeDefinition wrapper = (XSComplexTypeDefinition)xt;
-      XSParticle particle = wrapper.getParticle();
-      if (particle == null)
-         throw new WSException("Attempt to unwrap a request type with no particles");
-      XSTerm term = particle.getTerm();
-      if (term instanceof XSModelGroup == false)
-         throw new WSException("Expected model group, could not unwrap");
-      unwrapRequestParticles(buf, (XSModelGroup)term);
-
-      // We need a wrapper class generated
-      generateJavaSource(wrapper, WSDLUtils.getSchemaModel(wsdl.getWsdlTypes()), wrapper.getName());
-   }
-
-   private int unwrapRequestParticles(StringBuilder buf, XSModelGroup group) throws IOException
-   {
-      if (group.getCompositor() != XSModelGroup.COMPOSITOR_SEQUENCE)
-         throw new WSException("Only a sequence type can be unwrapped.");
-
-      int elementCount = 0;
-      XSObjectList particles = group.getParticles();
-      for (int i = 0; i < particles.getLength(); i++)
-      {
-         XSParticle particle = (XSParticle)particles.item(i);
-         XSTerm term = particle.getTerm();
-         if (term instanceof XSModelGroup)
-         {
-            elementCount += unwrapRequestParticles(buf, (XSModelGroup)term);
-         }
-         else if (term instanceof XSElementDeclaration)
-         {
-            if (elementCount++ > 0)
-               buf.append(", ");
-            XSElementDeclaration element = (XSElementDeclaration)term;
-            QName xmlName = new QName(element.getNamespace(), element.getName());
-            QName xmlType = new QName(element.getTypeDefinition().getNamespace(), element.getTypeDefinition().getName());
-            JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
-            boolean array = particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1;
-            generateParameter(buf, null, xmlName, xmlType, xsmodel, element.getTypeDefinition(), array, !element.getNillable());
-            buf.append(" ").append(getMethodParam(xmlName));
-         }
-      }
-
-      return elementCount;
-   }
-
    private XSElementDeclaration unwrapType(XSTypeDefinition xt)
    {
       if (xt instanceof XSComplexTypeDefinition == false)
@@ -350,14 +300,7 @@
             JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
             XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(), xmlType.getNamespaceURI());
 
-            if (isWrapped())
-            {
-               unwrapRequest(buf, xt);
-               break;
-            }
-
-            generateParameter(buf, in, xmlName, xmlType, xsmodel, xt, false, true);
-            buf.append(" ").append(getMethodParam(xmlName));
+            appendParameters(buf, in, in.getElement().getLocalPart(), xmlType, xt);
          }
 
          //Check for out holder only
@@ -388,7 +331,7 @@
                   xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xt);
 
                Class cls = this.getJavaType(xmlType, primitive);
-               buf.append(utils.getHolder(cls).getName()).append(" ").append(getMethodParam(xmlName));
+               //buf.append(utils.getHolder(cls).getName()).append(" ").append(getMethodParam(xmlName));
             }
          }
 
@@ -432,9 +375,104 @@
       }
    }
 
-   private void generateParameter(StringBuilder buf, WSDLInterfaceOperationInput in, QName xmlName, QName xmlType, JBossXSModel xsmodel, XSTypeDefinition xt,
-         boolean array, boolean primitive) throws IOException
+   public boolean unwrapGroup(StringBuilder buf, String containingElement, XSModelGroup group) throws IOException
    {
+      if (group.getCompositor() != XSModelGroup.COMPOSITOR_SEQUENCE)
+         return false;
+
+      XSObjectList particles = group.getParticles();
+      for (int i = 0; i < particles.getLength(); i++)
+      {
+         XSParticle particle = (XSParticle)particles.item(i);
+         XSTerm term = particle.getTerm();
+         if (term instanceof XSModelGroup)
+         {
+            if (unwrapGroup(buf, containingElement, (XSModelGroup)term) == false)
+               return false;
+         }
+         else if (term instanceof XSElementDeclaration)
+         {
+            if (i > 0)
+               buf.append(", ");
+
+            XSElementDeclaration element = (XSElementDeclaration)term;
+            QName xmlName = new QName(element.getNamespace(), element.getName());
+            QName xmlType = new QName(element.getTypeDefinition().getNamespace(), element.getTypeDefinition().getName());
+            JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
+            boolean array = particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1;
+            generateParameter(buf, null, containingElement, xmlType, xsmodel, element.getTypeDefinition(), array, !element.getNillable());
+            buf.append(" ").append(getMethodParam(containingElement));
+         }
+      }
+
+      // If we reach here we must have successfully unwrapped the parameters.
+      return true;
+   }
+
+   private boolean unwrapElementParameters(StringBuilder buf, String containingElement, XSTypeDefinition xt) throws IOException
+   {
+      // If at any point parameter unwrapping can not happen return false so we drop back to not unwrapping.
+
+      if (xt instanceof XSComplexTypeDefinition == false)
+         return false;
+
+      XSComplexTypeDefinition wrapper = (XSComplexTypeDefinition)xt;
+      XSParticle particle = wrapper.getParticle();
+
+      if (particle == null)
+         return false;
+
+      XSTerm term = particle.getTerm();
+      if (term instanceof XSModelGroup == false)
+         return false;
+
+      StringBuilder tempBuf = new StringBuilder();
+
+      if (unwrapGroup(tempBuf, containingElement, (XSModelGroup)term) == false)
+         return false;
+
+      buf.append(tempBuf);
+
+      // We need a wrapper class generated
+      generateJavaSource(wrapper, WSDLUtils.getSchemaModel(wsdl.getWsdlTypes()), containingElement);
+
+      return true;
+   }
+
+   private void appendParameters(StringBuilder buf, WSDLInterfaceOperationInput in, String containingElement, QName xmlType, XSTypeDefinition xt) throws IOException
+   {
+      JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
+
+      boolean wrapped = isWrapped();
+
+      if (wrapped)
+      {
+         XSElementDeclaration unwrapped = unwrapType(xt);
+         if (unwrapped != null)
+         {
+            containingElement = containingElement + unwrapped.getName();
+            XSTypeDefinition unwrappedType = unwrapped.getTypeDefinition();
+
+            wrapped = unwrapElementParameters(buf, containingElement, unwrappedType);
+         }
+         else
+         {
+            // Type was not wrapped to set flag to handle as normal.
+            wrapped = false;
+         }
+      }
+
+      if (wrapped == false)
+      {
+         generateParameter(buf, in, containingElement, xmlType, xsmodel, xt, false, true);
+         buf.append(" ").append(getMethodParam(containingElement));
+      }
+
+   }
+
+   private void generateParameter(StringBuilder buf, WSDLInterfaceOperationInput in, String containingElement, QName xmlType, JBossXSModel xsmodel,
+         XSTypeDefinition xt, boolean array, boolean primitive) throws IOException
+   {
       WrappedArray wrappedArray = new WrappedArray(xt);
       String arraySuffix = (array) ? "[]" : "";
       if (wrappedArray.unwrap())
@@ -449,7 +487,7 @@
          xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xt);
 
       Class cl = getJavaType(xmlType, primitive);
-      //Class cl = typeMapping.getJavaType(inqname,true);
+
       if (in != null)
          cl = this.checkNeedHolder(in, cl);
       if (cl != null)
@@ -458,15 +496,22 @@
       }
       else
       {
-         //buf.append(inqname.getLocalPart() + " " + inqname.getLocalPart().toLowerCase());
-         String className = xmlType.getLocalPart();
+         String className;
+         if (xt.getAnonymous())
+         {
+            className = containingElement;
+         }
+         else
+         {
+            className = xmlType.getLocalPart();
+         }
          if (className.charAt(0) == '>')
             className = className.substring(1);
          className = utils.firstLetterUpperCase(className);
          buf.append(seiPkgName + "." + className + arraySuffix);
 
          if (xt instanceof XSComplexTypeDefinition)
-            generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, xmlName.getLocalPart());
+            generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, containingElement);
       }
    }
 
@@ -557,7 +602,6 @@
          xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xt);
 
       Class cls = getJavaType(xmlType, primitive);
-      //Class cls = typeMapping.getJavaType(qname,true);
 
       if (xt instanceof XSComplexTypeDefinition)
          generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, containingElement);
@@ -648,9 +692,9 @@
       return cls;
    }
 
-   private String getMethodParam(QName qn)
+   private String getMethodParam(String containingElement)
    {
-      return ToolsUtils.firstLetterLowerCase(qn.getLocalPart());
+      return ToolsUtils.firstLetterLowerCase(containingElement);
    }
 
    private File getLocationForJavaGeneration()

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_A/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_A/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_A/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_A/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_B/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_B/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_B/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_B/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_C/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_C/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_C/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_C/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_D/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_D/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_D/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_D/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_E/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_E/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_E/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_E/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_F/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_F/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_F/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_F/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_G/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_G/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_G/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_G/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_H/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_H/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_H/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_H/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_I/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_I/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_I/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_I/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_J/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_J/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_J/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_J/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_K/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_K/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_K/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_K/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>

Modified: branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_L/wstools-config.xml
===================================================================
--- branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_L/wstools-config.xml	2006-12-05 15:24:26 UTC (rev 1554)
+++ branches/dlofthouse/JBWS-1260/src/test/resources/tools/jbws1260/scenario_L/wstools-config.xml	2006-12-05 23:27:34 UTC (rev 1555)
@@ -1,5 +1,5 @@
 <configuration>
   <wsdl-java location="resources/tools/jbws1260/scenario_L/Wrapped.wsdl" parameter-style="wrapped">
-    <mapping file="wrapped-mapping.xml"/>
+    <!--mapping file="wrapped-mapping.xml"/-->
   </wsdl-java>
 </configuration>




More information about the jbossws-commits mailing list