axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maryam Moazeni (JIRA)" <j...@apache.org>
Subject [jira] Updated: (AXIS2-906) Adding Complex Content Restriction Support to ADB
Date Mon, 31 Jul 2006 13:58:14 GMT
     [ http://issues.apache.org/jira/browse/AXIS2-906?page=all ]

Maryam Moazeni updated AXIS2-906:
---------------------------------

    Attachment: ModifiedSrc.zip

Attached the modified source codes.

> 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: ModifiedSrc.zip, patchfile, patchfile.txt, TestCases.zip
>
>
> 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


Mime
View raw message