private void addPropertyEntries()

in modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java [730:907]


    private void addPropertyEntries(BeanWriterMetaInfoHolder metainf,
                                    Document model, Element rootElt,
                                    ArrayList<String> propertyNames,
                                    Map<QName,String> typeMap,
                                    Map<QName,String> groupTypeMap,
                                    boolean isInherited) throws SchemaCompilationException {
        // go in the loop and add the part elements
        QName[] qName;
        String javaClassNameForElement;
        ArrayList<QName> missingQNames = new ArrayList<QName>();
        ArrayList<QName> qNames = new ArrayList<QName>();

        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.
        // for the simple types we have already add the parent elements
        // it is almost consider as an extension
        if (metainf.isRestriction() && !metainf.isSimple()) {
            addMissingQNames(metainf, qNames, missingQNames);
        }
        
    	List<BeanWriterMetaInfoHolder> parents=new ArrayList<BeanWriterMetaInfoHolder>();
    	BeanWriterMetaInfoHolder immediateParent=metainf.getParent();
    	while(immediateParent != null){
    		parents.add(immediateParent);
    		immediateParent=immediateParent.getParent();
    	}
        
        for (QName name : qNames) {
            Element property = XSLTUtils.addChildElement(model, "property", rootElt);

            String xmlName = name.getLocalPart();
            
			String xmlNameNew=identifyUniqueNameForQName(parents,xmlName, metainf, name,name);
			while(!xmlName.equalsIgnoreCase(xmlNameNew)){
				xmlName=xmlNameNew;
				xmlNameNew=identifyUniqueNameForQName(parents,xmlNameNew, metainf, name,new QName(xmlNameNew));
			}
            
            XSLTUtils.addAttribute(model, "name", xmlName, property);
            XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property);
            

            String javaName;
            if (metainf.isJavaNameMappingAvailable(xmlName)) {
                javaName = metainf.getJavaName(xmlName);
            } else {
                javaName = makeUniqueJavaClassName(propertyNames, xmlName);
                // in a restriction if this element already there and array status have changed
                // then we have to generate a new  name for this
                if (parentMetaInf != null && metainf.isRestriction() && !missingQNames.contains(name) &&
                        (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {
                    javaName = makeUniqueJavaClassName(propertyNames, xmlName);
                }
                metainf.addXmlNameJavaNameMapping(xmlName,javaName);
            }

            XSLTUtils.addAttribute(model, "javaname", javaName, property);

            if (parentMetaInf != null && metainf.isRestriction() && missingQNames.contains(name)) {
                javaClassNameForElement = parentMetaInf.getClassNameForQName(name);
            } else {
                javaClassNameForElement = metainf.getClassNameForQName(name);
            }


            if (javaClassNameForElement == null) {
                javaClassNameForElement = getDefaultClassName();
                log.warn(SchemaCompilerMessages
                        .getMessage("schema.typeMissing", name.toString()));
            }

            if (metainf.isRestriction() && typeChanged(name, missingQNames, metainf)) {
                XSLTUtils.addAttribute(model, "typeChanged", "yes", property);
                //XSLTUtils.addAttribute(model, "restricted", "yes", property);
            }

            long minOccurs = metainf.getMinOccurs(name);
            if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)
                    && isUseWrapperClasses && ((minOccurs == 0) || metainf.isNillable(name))) {
                 // if this is an primitive class and user wants to use the
                 // wrapper type we change the type to wrapper type.
                 javaClassNameForElement = PrimitiveTypeWrapper.getWrapper(javaClassNameForElement);
            }

            XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);


            if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {

                XSLTUtils.addAttribute(model, "primitive", "yes", property);
            }

             // add the default value
            if (metainf.isDefaultValueAvailable(name)){
                QName schemaQName = metainf.getSchemaQNameForQName(name);
                if (baseTypeMap.containsKey(schemaQName)){
                    XSLTUtils.addAttribute(model, "defaultValue",
                            metainf.getDefaultValueForQName(name), property);
                }
            }
            
            
            //in the case the original element is an array but the derived one is not.
            if (parentMetaInf != null && metainf.isRestriction() && !missingQNames.contains(name) &&
                    (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {

                XSLTUtils.addAttribute(model, "rewrite", "yes", property);
                XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
            } else if (metainf.isRestriction() && !missingQNames.contains(name) &&
                    (minOccursChanged(name, missingQNames, metainf) || maxOccursChanged(name, missingQNames, metainf)))
            {

                XSLTUtils.addAttribute(model, "restricted", "yes", property);
                XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
            }

            // set the is particle class
            if (metainf.getParticleTypeStatusForQName(name)){
                XSLTUtils.addAttribute(model, "particleClassType", "yes", property);
            }

            // if we have an particle class in a extension class then we have
            // to consider the whole class has a particle type.

            if (metainf.isHasParticleType()) {
                XSLTUtils.addAttribute(model, "hasParticleType", "yes", rootElt);
            }

            // what happed if this contain attributes
            // TODO: check the meaning of this removed property

            if (metainf.isRestriction() && missingQNames.contains(name) && !metainf.isSimple()) {
                //XSLTUtils.addAttribute(model, "restricted", "yes", property);
                XSLTUtils.addAttribute(model, "removed", "yes", property);
            }

            if (isInherited) {
                XSLTUtils.addAttribute(model, "inherited", "yes", property);
            }

            if (metainf.getInnerChoiceStatusForQName(name)){
                XSLTUtils.addAttribute(model, "innerchoice", "yes", property);
            }
            
            if ((parentMetaInf != null) && metainf.isRestriction() && missingQNames.contains(name)) {
                // this element details should be there with the parent meta Inf
                addAttributesToProperty(
                        parentMetaInf,
                        name,
                        model,
                        property,
                        typeMap,
                        groupTypeMap,
                        javaClassNameForElement);

            } else {
                addAttributesToProperty(
                        metainf,
                        name,
                        model,
                        property,
                        typeMap,
                        groupTypeMap,
                        javaClassNameForElement);
            }
        }  // end of foo
    }