Author: sagara Date: Tue Jul 17 07:04:32 2012 New Revision: 1362379 URL: http://svn.apache.org/viewvc?rev=1362379&view=rev Log: Merged r1362377 to 1.6 branch.
Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/testsuite/extensions.xsd axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1362379&r1=1362378&r2=1362379&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Tue Jul 17 07:04:32 2012 @@ -1618,13 +1618,16 @@ public class SchemaCompiler { copyMetaInfoHierarchy(metaInfHolder, extBaseType, resolvedSchema); } else if (type instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; - if (complexType.getContentModel() == null) { // do not set as a simple type since we want to // print the element names metaInfHolder.setExtension(true); metaInfHolder.setExtensionClassName(className); copyMetaInfoHierarchy(metaInfHolder, extBaseType, resolvedSchema); - } + XmlSchemaContentModel typeContent =complexType.getContentModel(); + if(typeContent != null && typeContent instanceof XmlSchemaSimpleContent){ + metaInfHolder.setSimple(true); + } + } } Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=1362379&r1=1362378&r2=1362379&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Tue Jul 17 07:04:32 2012 @@ -702,7 +702,9 @@ public class JavaBeanWriter implements B * current and parent BeanWriterMetaInfoHolders.Decide best approach * ? */ - mergeBeanWriterMetaInfoHolderForRestriction(metainf, parent); + if(metainf.isRestriction()){ + mergeBeanWriterMetaInfoHolderForRestriction(metainf, parent); + } populateInfo(parent, model, rootElt, propertyNames, typeMap, groupTypeMap, true); } addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap, groupTypeMap, Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/testsuite/extensions.xsd URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/testsuite/extensions.xsd?rev=1362379&r1=1362378&r2=1362379&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/testsuite/extensions.xsd (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/test-resources/testsuite/extensions.xsd Tue Jul 17 07:04:32 2012 @@ -85,6 +85,51 @@ <xs:element minOccurs="0" name="SORT_DESCENDING" type="xs:int"/> </xs:sequence> </xs:complexType> - + + <xs:element name="SimpleAmmountElement" type="tns:SimpleAmmount" /> + <xs:complexType name="SimpleAmmount"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="currency" type="xs:string" + use="required" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- complexType having simpleContent extension --> + <xs:element name="PaymentAmountElement" type="tns:PaymentAmount" /> + <xs:complexType name="PaymentAmount"> + <xs:simpleContent> + <xs:extension base="tns:Amount" /> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="Amount"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="currency" type="xs:string" + use="required" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- complexType having complexContent extension --> + <xs:element name="fullpersoninfoElement" type="tns:fullpersoninfo" /> + <xs:complexType name="fullpersoninfo"> + <xs:complexContent> + <xs:extension base="tns:personinfo"> + <xs:sequence> + <xs:element name="address" type="xs:string" /> + <xs:element name="city" type="xs:string" /> + <xs:element name="country" type="xs:string" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <xs:complexType name="personinfo"> + <xs:sequence> + <xs:element name="firstname" type="xs:string" /> + <xs:element name="lastname" type="xs:string" /> + </xs:sequence> + </xs:complexType> </schema> \ No newline at end of file Modified: axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java?rev=1362379&r1=1362378&r2=1362379&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java (original) +++ axis/axis2/java/core/branches/1_6/modules/adb-codegen/test/org/apache/axis2/schema/extension/SimpleExtensionTest.java Tue Jul 17 07:04:32 2012 @@ -19,8 +19,15 @@ package org.apache.axis2.schema.extension; +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; import org.apache.axis2.databinding.types.Language; import org.apache.axis2.schema.AbstractTestCase; +import org.apache.axis2.schema.restriction.LimitedString; +import org.apache.axis2.schema.restriction.LimitedStringE; public class SimpleExtensionTest extends AbstractTestCase { @@ -36,6 +43,99 @@ public class SimpleExtensionTest extends testSerializeDeserialize(fullName, false); } + + public void testSimpleAmmountElementGetOMElement() throws Exception { + SimpleAmmountElement ammountElement = new SimpleAmmountElement(); + SimpleAmmount param = new SimpleAmmount(); + param.setCurrency("SLR"); + param.setString("1000"); + ammountElement.setSimpleAmmountElement(param); + OMElement omElement = ammountElement.getOMElement(SimpleAmmountElement.MY_QNAME, + OMAbstractFactory.getSOAP11Factory()); + } + + public void testSimpleAmmountElementParse() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "SimpleAmmountElement")); + element.addAttribute("currency", "SLR", null); + element.setText("1000"); + SimpleAmmountElement ammountElement = SimpleAmmountElement.Factory.parse(element + .getXMLStreamReader()); + assertNotNull(ammountElement); + assertEquals("SLR", ammountElement.getSimpleAmmountElement().getCurrency()); + assertEquals("1000", ammountElement.getSimpleAmmountElement().getString()); + } + public void testPaymentAmountElementGetOMElement() throws Exception { + PaymentAmountElement ammountElement = new PaymentAmountElement(); + PaymentAmount param = new PaymentAmount(); + param.setCurrency("SLR"); + param.setString("2000"); + ammountElement.setPaymentAmountElement(param); + OMElement omElement = ammountElement.getOMElement(PaymentAmountElement.MY_QNAME, + OMAbstractFactory.getSOAP11Factory()); + } + public void testPaymentAmountElementParse() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "PaymentAmountElement")); + element.addAttribute("currency", "SLR", null); + element.setText("2000"); + PaymentAmountElement ammountElement = PaymentAmountElement.Factory.parse(element + .getXMLStreamReader()); + assertNotNull(ammountElement); + assertEquals("SLR", ammountElement.getPaymentAmountElement().getCurrency()); + assertEquals("2000", ammountElement.getPaymentAmountElement().getString()); + } + + public void testFullpersoninfoElementGetOMElement() throws Exception { + FullpersoninfoElement fullpersoninfoElement = new FullpersoninfoElement(); + Fullpersoninfo param = new Fullpersoninfo(); + param.setAddress("123 Main Street"); + param.setCity("Kandy"); + param.setCountry("Sri Lanka"); + param.setFirstname("Sagara"); + param.setLastname("Gunathunga"); + fullpersoninfoElement.setFullpersoninfoElement(param); + OMElement omElement = fullpersoninfoElement.getOMElement(FullpersoninfoElement.MY_QNAME, + OMAbstractFactory.getSOAP11Factory()); + } + + public void testFullpersoninfoElementParse() throws Exception { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement element = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "fullpersoninfoElement")); + OMElement firstname = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "firstname")); + firstname.setText("Sagara"); + OMElement lastname = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "lastname")); + lastname.setText("Gunathunga"); + OMElement address = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "address")); + address.setText("123 Main Street"); + OMElement city = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "city")); + city.setText("Kandy"); + OMElement country = factory.createOMElement(new QName( + "http://apache.org/axis2/schema/extension", "country")); + country.setText("Sri Lanka"); + element.addChild(firstname); + element.addChild(lastname); + element.addChild(address); + element.addChild(city); + element.addChild(country); + FullpersoninfoElement fullpersoninfoElement = FullpersoninfoElement.Factory.parse(element + .getXMLStreamReader()); + assertNotNull(fullpersoninfoElement); + assertEquals("Sagara", fullpersoninfoElement.getFullpersoninfoElement().getFirstname()); + assertEquals("Gunathunga", fullpersoninfoElement.getFullpersoninfoElement().getLastname()); + assertEquals("123 Main Street", fullpersoninfoElement.getFullpersoninfoElement() + .getAddress()); + assertEquals("Kandy", fullpersoninfoElement.getFullpersoninfoElement().getCity()); + assertEquals("Sri Lanka", fullpersoninfoElement.getFullpersoninfoElement().getCountry()); + + } }