Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 59868 invoked from network); 20 Jul 2006 05:31:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jul 2006 05:31:28 -0000 Received: (qmail 36031 invoked by uid 500); 20 Jul 2006 05:31:26 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 35984 invoked by uid 500); 20 Jul 2006 05:31:26 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 35971 invoked by uid 99); 20 Jul 2006 05:31:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jul 2006 22:31:26 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jul 2006 22:31:25 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 40279714219 for ; Thu, 20 Jul 2006 05:29:14 +0000 (GMT) Message-ID: <8294476.1153373354245.JavaMail.jira@brutus> Date: Wed, 19 Jul 2006 22:29:14 -0700 (PDT) From: "Maryam Moazeni (JIRA)" To: axis-dev@ws.apache.org Subject: [jira] Updated: (AXIS2-906) Adding Complex Content Restriction Support to ADB In-Reply-To: <10485791.1153293918998.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/AXIS2-906?page=all ] Maryam Moazeni updated AXIS2-906: --------------------------------- Attachment: patchfile svn diff > Adding Complex Content Restriction Support to ADB > ------------------------------------------------- > > Key: AXIS2-906 > URL: http://issues.apache.org/jira/browse/AXIS2-906 > Project: Apache Axis 2.0 (Axis2) > Issue Type: Improvement > Reporter: Maryam Moazeni > Priority: Minor > Attachments: patchfile > > > Regarding the implementation of complex content restriction: > These are the changes of code in the JavaBeanWriter. Changes in SchemaCompiler and BeanWriterMetaInfoHandler are not shown. > 1) Missing Elements > 2) Missing Attributes * > 3) Changes in Type > 3) Changes in Occurance > are supporte sofar. > * Attributes still needs more work. > ------------------------------------------------------------------------------------------------------------------------------------------------------------ > /* JavaBeanWriter.java */ > 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[] qName; > ArrayList missingQNames = new ArrayList(); > ArrayList qNames = new ArrayList(); > > BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent(); > > if (metainf.isOrdered()) { > qName = metainf.getOrderedQNameArray(); > } else { > qName= metainf.getQNameArray(); > } > > for (int i = 0; i < qName.length; i++) { > qNames.add(qName[i]); > } > //adding missing QNames to the end, including elements & attributes. > if (metainf.isRestriction()) { > addMissingQNames(metainf, qNames); > } > QName name; > for (int i = 0; i < qNames.size(); i++) { > name = (QName) qNames.get(i); > > Element property = XSLTUtils.addChildElement(model, "property", rootElt); > > String xmlName = name.getLocalPart(); > XSLTUtils.addAttribute(model, "name", xmlName, property); > XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property); > String javaName = makeUniqueJavaClassName(propertyNames, xmlName); > XSLTUtils.addAttribute(model, "javaname", javaName, property); > String javaClassNameForElement = metainf.getClassNameForQName(name); > if (javaClassNameForElement == null) { > throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.typeMissing")); > } > > if (metainf.isRestriction() && typeChanged(name, metainf)) { > XSLTUtils.addAttribute(model, "typeChanged", "yes", property); > XSLTUtils.addAttribute(model, "rewrite", "yes", property); > } > > XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property); > if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) { > XSLTUtils.addAttribute(model, "primitive", "yes", property); > } > //add an attribute that says the type is default > if (isDefault(javaClassNameForElement)) { > XSLTUtils.addAttribute(model, "default", "yes", property); > } > if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) { > XSLTUtils.addAttribute(model, "ours", "yes", property); > } > if (metainf.getAttributeStatusForQName(name)) { > XSLTUtils.addAttribute(model, "attribute", "yes", property); > } > if (metainf.isNillable(name)) { > XSLTUtils.addAttribute(model, "nillable", "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 (missingQNames.contains(name) && metainf.isRestriction()) { > XSLTUtils.addAttribute(model, "restricted", "yes", property); > } > > if (isInherited){ > XSLTUtils.addAttribute(model, "inherited", "yes", property); > } > if (metainf.getAnyStatusForQName(name)) { > XSLTUtils.addAttribute(model, "any", "yes", property); > } > if (metainf.getBinaryStatusForQName(name)) { > XSLTUtils.addAttribute(model, "binary", "yes", property); > } > //put the min occurs count irrespective of whether it's an array or not > long minOccurs = metainf.getMinOccurs(name); > XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property); > //in the case the original element is an array but the derived one is not. > if ((parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name)) && metainf.isRestriction()) { > XSLTUtils.addAttribute(model, "rewrite", "yes", property); > XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property); > } > else if ((minOccursChanged(name, metainf) || maxOccursChanged(name, metainf)) && metainf.isRestriction()) { > XSLTUtils.addAttribute(model, "restricted", "yes", property); > XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property); > } > > if (metainf.getArrayStatusForQName(name)) { > XSLTUtils.addAttribute(model, "array", "yes", property); > XSLTUtils.addAttribute( > model, > "arrayBaseType", > javaClassNameForElement.substring(0, javaClassNameForElement.indexOf("[")), > property); > long maxOccurs = metainf.getMaxOccurs(name); > if (maxOccurs == Long.MAX_VALUE) { > XSLTUtils.addAttribute(model, "unbound", "yes", property); > } else { > XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "", property); > } > } > > } > > } > > // added method > private void addMissingQNames(BeanWriterMetaInfoHolder metainf, ArrayList qName) { > > QName[] qNames; > QName[] pQNames; > ArrayList missingQNames = new ArrayList(); > > BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent(); > > if (metainf.isOrdered()) { > qNames = metainf.getOrderedQNameArray(); > } else { > qNames = metainf.getQNameArray(); > } > > if (parentMetaInf.isOrdered()) { > pQNames = parentMetaInf.getOrderedQNameArray(); > } else { > pQNames = parentMetaInf.getQNameArray(); > } > > > for (int i=0; i < pQNames.length; i++) { > if (qNameNotFound(pQNames[i], metainf)) { > missingQNames.add(pQNames[i]); > } > if (i < qNames.length) { > //keeping the order of restricted type. > qName.add(qNames[i]); > } > } > //adding missing QNames to the end of list. > if (!missingQNames.isEmpty()) { > for (int i=0; i < missingQNames.size(); i++) { > qName.add(missingQNames.get(i)); > } > } > > } > > // added method > private boolean qNameNotFound(QName qname, BeanWriterMetaInfoHolder metainf) { > > boolean found = false; > QName[] qNames; > > if (metainf.isOrdered()) { > qNames = metainf.getOrderedQNameArray(); > } else { > qNames = metainf.getQNameArray(); > } > > for (int j = 0; j < qNames.length; j++) { > if (qname.getLocalPart().equals(qNames[j].getLocalPart())) { > found = true; > } > } > return !found; > } > > // added method > private boolean typeChanged(QName qname, BeanWriterMetaInfoHolder metainf) { > > boolean typeChanged = false; > QName[] pQNames; > > BeanWriterMetaInfoHolder parentMetainf = metainf.getParent(); > > if (parentMetainf.isOrdered()) { > pQNames = parentMetainf.getOrderedQNameArray(); > } else { > pQNames = parentMetainf.getQNameArray(); > } > > for (int j = 0; j < pQNames.length; j++) { > if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) { > > String javaClassForParentElement = parentMetainf.getClassNameForQName(pQNames[j]); > String javaClassForElement = metainf.getClassNameForQName(qname); > > if (!javaClassForParentElement.equals(javaClassForElement)) { > typeChanged = true; > } > } > } > return typeChanged; > } > > // added method > private boolean minOccursChanged(QName qname, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException { > > boolean minChanged = false; > QName[] pQNames; > > BeanWriterMetaInfoHolder parentMetainf = metainf.getParent(); > > if (parentMetainf.isOrdered()) { > pQNames = parentMetainf.getOrderedQNameArray(); > } else { > pQNames = parentMetainf.getQNameArray(); > } > > for (int j = 0; j < pQNames.length; j++) { > if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) { > > if (metainf.getMinOccurs(qname) > parentMetainf.getMinOccurs(pQNames[j])) { > minChanged = true; > } > else if(metainf.getMinOccurs(qname) < parentMetainf.getMinOccurs(pQNames[j])) { > throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("minOccurs Wrong!")); > } > } > } > return minChanged; > } > > // added method > private boolean maxOccursChanged(QName qname, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException { > > boolean maxChanged = false; > QName[] pQNames; > > BeanWriterMetaInfoHolder parentMetainf = metainf.getParent(); > > if (parentMetainf.isOrdered()) { > pQNames = parentMetainf.getOrderedQNameArray(); > } else { > pQNames = parentMetainf.getQNameArray(); > } > > for (int j = 0; j < pQNames.length; j++) { > if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) { > > if (metainf.getMaxOccurs(qname) > parentMetainf.getMaxOccurs(pQNames[j])) { > maxChanged = true; > } > else if(metainf.getMaxOccurs(qname) < parentMetainf.getMaxOccurs(pQNames[j])) { > throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("maxOccurs Wrong!")); > } > } > } > return maxChanged; > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org For additional commands, e-mail: axis-dev-help@ws.apache.org