Return-Path: Delivered-To: apmail-ws-axis-cvs-archive@www.apache.org Received: (qmail 2663 invoked from network); 24 Jan 2006 13:51:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jan 2006 13:51:53 -0000 Received: (qmail 33175 invoked by uid 500); 24 Jan 2006 13:51:52 -0000 Delivered-To: apmail-ws-axis-cvs-archive@ws.apache.org Received: (qmail 32957 invoked by uid 500); 24 Jan 2006 13:51:51 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 32946 invoked by uid 500); 24 Jan 2006 13:51:51 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 32943 invoked by uid 99); 24 Jan 2006 13:51:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2006 05:51:51 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 24 Jan 2006 05:51:50 -0800 Received: (qmail 2503 invoked by uid 65534); 24 Jan 2006 13:51:29 -0000 Message-ID: <20060124135129.2500.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r371914 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema: BeanWriterMetaInfoHolder.java SchemaCompiler.java i18n/resource.properties template/ADBBeanTemplate.xsl writer/JavaBeanWriter.java Date: Tue, 24 Jan 2006 13:51:28 -0000 To: axis2-cvs@ws.apache.org From: ajith@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ajith Date: Tue Jan 24 05:51:17 2006 New Revision: 371914 URL: http://svn.apache.org/viewcvs?rev=371914&view=rev Log: Fixed the ComplexContent handling 1. Added the necesary methods to the SchemaCompiler.java 2. Added a resource to internationalize some messages 3. Updated the ADBBeanTemplate.xsl to include only the non inherited properties 4. Updated the access modifier to be protected rather than private 5. Did some minor improvements to the logic of the BeanWriterMetaInfoHolder.java Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/i18n/resource.properties webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=371914&r1=371913&r2=371914&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Tue Jan 24 05:51:17 2006 @@ -6,6 +6,8 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.List; +import java.util.ArrayList; /* * Copyright 2004,2005 The Apache Software Foundation. * @@ -31,16 +33,31 @@ public class BeanWriterMetaInfoHolder { - private boolean ordered = false; - private boolean anonymous = false; - private boolean extension = false; + protected boolean ordered = false; + protected boolean anonymous = false; + protected boolean extension = false; private String extensionClassName = ""; - private Map elementToSchemaQNameMap = new HashMap(); - private Map elementToJavaClassMap = new HashMap(); - private Map specialTypeFlagMap = new HashMap(); - private Map qNameMaxOccursCountMap = new HashMap(); - private Map qNameMinOccursCountMap = new HashMap(); - private Map qNameOrderMap = new HashMap(); + protected Map elementToSchemaQNameMap = new HashMap(); + protected Map elementToJavaClassMap = new HashMap(); + protected Map specialTypeFlagMap = new HashMap(); + protected Map qNameMaxOccursCountMap = new HashMap(); + protected Map qNameMinOccursCountMap = new HashMap(); + protected Map qNameOrderMap = new HashMap(); + + + + //the parent metainfo holder, useful in handling extensions and + //restrictions + protected BeanWriterMetaInfoHolder parent = null; + + + /** + * Gets the parent + * @return + */ + public BeanWriterMetaInfoHolder getParent() { + return parent; + } /** * Gets the anonymous status. @@ -89,6 +106,8 @@ return extension; } + + /** * Sets the extension status. * @@ -320,4 +339,14 @@ return qNameOrderMap.size(); } + + /** + * Creates link to th + * @param metaInfo + */ + public void setAsParent(BeanWriterMetaInfoHolder metaInfo){ + parent = metaInfo; + + + } } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=371914&r1=371913&r2=371914&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java Tue Jan 24 05:51:17 2006 @@ -1,7 +1,6 @@ package org.apache.axis2.schema; import org.apache.axis2.om.OMElement; -import org.apache.axis2.schema.i18n.SchemaCompilerMessages; import org.apache.axis2.schema.util.SchemaPropertyLoader; import org.apache.axis2.schema.writer.BeanWriter; import org.apache.ws.commons.schema.XmlSchema; @@ -494,7 +493,7 @@ //process the base type if it has not been processed yet if (!isAlreadyProcessed(extension.getBaseTypeName())){ - //pick the relevant basetype from the schema and process it + //pick the relevant basetype from the schema and process it XmlSchemaType type= parentSchema.getTypeByName(extension.getBaseTypeName()); if (type instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; @@ -515,7 +514,7 @@ // children (sometimes even preserving the order) to the metainfo holder of this type // the reason is that for extensions, the prefered way is to have the sequences of the base class //* before * the sequence of the child element. - + copyMetaInfoHierarchy(metaInfHolder,extension.getBaseTypeName(),parentSchema); //process the particle of this node @@ -526,17 +525,76 @@ // The basetype has been processed already metaInfHolder.setExtension(true); metaInfHolder.setExtensionClassName(findClassName(extension.getBaseTypeName(),false)); - //Note - this is no array! so the array boolean is false + //Note - this is no array! so the array boolean is false }else if (content instanceof XmlSchemaComplexContentRestriction){ //todo handle complex restriction here } } + /** + * Recursive method to populate the metainfo holders with info from the base types + * @param metaInfHolder + * @param baseTypeName + * @param parentSchema + */ + private void copyMetaInfoHierarchy(BeanWriterMetaInfoHolder metaInfHolder, + QName baseTypeName, + XmlSchema parentSchema) + throws SchemaCompilationException { + XmlSchemaType type = parentSchema.getTypeByName(baseTypeName); + BeanWriterMetaInfoHolder baseMetaInfoHolder = (BeanWriterMetaInfoHolder) + processedTypeMetaInfoMap.get(baseTypeName); + + if (baseMetaInfoHolder!= null){ + + // see whether this type is also extended from some other type first + // if so proceed to set their parents as well. + if (type instanceof XmlSchemaComplexType){ + XmlSchemaComplexType complexType = (XmlSchemaComplexType)type; + if (complexType.getContentModel()!= null){ + XmlSchemaContentModel content = complexType.getContentModel(); + if (content instanceof XmlSchemaComplexContent){ + XmlSchemaComplexContent complexContent = + (XmlSchemaComplexContent)content; + if (complexContent.getContent() instanceof XmlSchemaComplexContentExtension){ + XmlSchemaComplexContentExtension extension = + (XmlSchemaComplexContentExtension)complexContent.getContent(); + //recursively call the copyMetaInfoHierarchy method + copyMetaInfoHierarchy(baseMetaInfoHolder, + extension.getBaseTypeName(), + parentSchema); + + }else if (complexContent.getContent() instanceof XmlSchemaComplexContentRestriction){ + + XmlSchemaComplexContentRestriction restriction = + (XmlSchemaComplexContentRestriction)complexContent.getContent(); + //recursively call the copyMetaInfoHierarchy method + copyMetaInfoHierarchy(baseMetaInfoHolder, + restriction.getBaseTypeName(), + parentSchema); + + }else{ + throw new SchemaCompilationException(); //todo put the right message + } + + }else if (content instanceof XmlSchemaSimpleContent){ + //todo + }else{ + throw new SchemaCompilationException(); + } + } + + //Do the actual parent setting + metaInfHolder.setAsParent(baseMetaInfoHolder); + } + } + } + private void processSimpleContent(XmlSchemaSimpleContent simpleContent,BeanWriterMetaInfoHolder metaInfHolder){ XmlSchemaContent content = simpleContent.getContent(); if (content instanceof XmlSchemaSimpleContentExtension){ - //todo - handle simple type extension here + //todo - handle simple type extension here }else if (content instanceof XmlSchemaSimpleContentRestriction){ //todo - Handle simple type restriction here } Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/i18n/resource.properties URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/i18n/resource.properties?rev=371914&r1=371913&r2=371914&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/i18n/resource.properties (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/i18n/resource.properties Tue Jan 24 05:51:17 2006 @@ -28,4 +28,5 @@ schema.rootnotfolderexception=Root location needs to be a directory! schema.notimplementedxception=Not implemented yet schema.templateLoadException=Error loading the template -schema.templateNotFoundException=template for this writer is not found \ No newline at end of file +schema.templateNotFoundException=template for this writer is not found +schema.typeMissing=Type missing! \ No newline at end of file Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=371914&r1=371913&r2=371914&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Tue Jan 24 05:51:17 2006 @@ -67,18 +67,22 @@ + + local localTracker + + /** * field for * This was an Attribute! * This was an Array! */ - private ; + protected ; @@ -86,7 +90,7 @@ for this attribute. It will be used to determine whether to include this field in the serialized XML */ - private boolean = false ; + protected boolean = false ; /** @@ -121,6 +125,7 @@ this.=param; } + /** Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=371914&r1=371913&r2=371914&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original) +++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Tue Jan 24 05:51:17 2006 @@ -4,6 +4,7 @@ import org.apache.axis2.schema.CompilerOptions; import org.apache.axis2.schema.SchemaCompilationException; import org.apache.axis2.schema.SchemaCompiler; +import org.apache.axis2.schema.typemap.JavaTypeMap; import org.apache.axis2.schema.i18n.SchemaCompilerMessages; import org.apache.axis2.schema.util.SchemaPropertyLoader; import org.apache.axis2.util.JavaUtils; @@ -73,6 +74,8 @@ private Map modelMap = new HashMap(); private static final String DEFAULT_PACKAGE = "adb"; + private Map baseTypeMap = new JavaTypeMap().getTypeMap(); + /** * Default constructor */ @@ -343,6 +346,47 @@ if (metainf.isExtension()) { XSLTUtils.addAttribute(model, "extension", metainf.getExtensionClassName(), rootElt); } + + //populate all the information + populateInfo(metainf, model, rootElt, propertyNames, typeMap,false); + + + return rootElt; + } + + /** + * + * @param metainf + * @param model + * @param rootElt + * @param propertyNames + * @param typeMap + * @throws SchemaCompilationException + */ + private void populateInfo(BeanWriterMetaInfoHolder metainf, + Document model, + Element rootElt, + ArrayList propertyNames, + Map typeMap,boolean isInherited)throws SchemaCompilationException{ + if (metainf.getParent()!=null){ + populateInfo(metainf.getParent(),model,rootElt,propertyNames,typeMap,true); + } + addPropertyEntries(metainf, model, rootElt, propertyNames, typeMap,isInherited); + + } + + /** + * + * @param metainf + * @param model + * @param rootElt + * @param propertyNames + * @param typeMap + * @throws SchemaCompilationException + */ + private void addPropertyEntries(BeanWriterMetaInfoHolder metainf, Document model, Element rootElt, ArrayList propertyNames, + Map typeMap, + boolean isInherited) throws SchemaCompilationException { // go in the loop and add the part elements QName[] qNames; if (metainf.isOrdered()) { @@ -363,13 +407,9 @@ String javaClassNameForElement = metainf.getClassNameForQName(name); - String shortTypeName = ""; - if (metainf.getSchemaQNameForQName(name) != null) { - shortTypeName = metainf.getSchemaQNameForQName(name).getLocalPart(); - } if (javaClassNameForElement == null) { - throw new SchemaCompilationException("Type missing!"); + throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.typeMissing")); } XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property); @@ -380,15 +420,30 @@ } if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) { - XSLTUtils.addAttribute(model, "ours", "yes", property); //todo introduce a better name for this + XSLTUtils.addAttribute(model, "ours", "yes", property); } if (metainf.getAttributeStatusForQName(name)) { XSLTUtils.addAttribute(model, "attribute", "yes", property); } + String shortTypeName = ""; + if (metainf.getSchemaQNameForQName(name) != null) { + //see whether the QName is a basetype + if (baseTypeMap.containsKey(metainf.getSchemaQNameForQName(name))){ + shortTypeName= metainf.getSchemaQNameForQName(name).getLocalPart(); + }else{ + shortTypeName = getShortTypeName(javaClassNameForElement); + } + }else{ + shortTypeName = getShortTypeName(javaClassNameForElement); + } XSLTUtils.addAttribute(model, "shorttypename", shortTypeName, property); + if (isInherited){ + XSLTUtils.addAttribute(model, "inherited", "yes", property); + } + if (metainf.getAnyStatusForQName(name)) { XSLTUtils.addAttribute(model, "any", "yes", property); } @@ -401,7 +456,7 @@ long minOccurs = metainf.getMinOccurs(name); XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property); - + if (metainf.getArrayStatusForQName(name)) { XSLTUtils.addAttribute(model, "array", "yes", property); @@ -419,11 +474,6 @@ } } } - - ///////////////////////////////////// - //System.out.println("rootElt = " + rootElt); - ///////////////////////////////////// - return rootElt; } /** @@ -566,5 +616,15 @@ mapURItoPrefix.put(uri, prefix); } return prefix; + } + + private String getShortTypeName(String typeClassName){ + if (typeClassName.endsWith("[]")){ + typeClassName = typeClassName.substring(0,typeClassName.lastIndexOf("[")); + } + String s = typeClassName.substring(typeClassName.lastIndexOf(".")+1, typeClassName.length()); + + return s; + } }