Examples of SchemaElement


Examples of org.jibx.schema.elements.SchemaElement

        while (processExtensions() || modified) {
           
            // normalize all the schema definitions
            modified = false;
            for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
                SchemaElement schema = (SchemaElement)iter.next();
                int count = schema.getChildCount();
                boolean instmod = false;
                for (int i = 0; i < count; i++) {
                    SchemaBase child = schema.getChild(i);
                    Object obj = child.getExtension();
                    if (obj instanceof GlobalExtension) {
                        GlobalExtension global = (GlobalExtension)obj;
                        global.normalize();
                        if (global.isRemoved() ||
                            (!global.isIncluded() && global.isPreferInline() && global.getOverrideType() != null)) {
                           
                            // just eliminate this definition from the schema
                            schema.detachChild(i);
                            instmod = true;
                           
                        }
                    }
                }
                if (instmod) {
                    schema.compactChildren();
                    modified = true;
                }
            }
           
        }
       
        // finish by flagging global definitions requiring separate classes
        TreeWalker wlkr = new TreeWalker(null, new SchemaContextTracker());
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            SchemaCustom custom = ((SchemaExtension)schema.getExtension()).getCustom();
            if (custom.isGenerateAll()) {
                int count = schema.getChildCount();
                for (int i = 0; i < count; i++) {
                   
                    // check if this global needs a class
                    SchemaBase comp = schema.getChild(i);
                    boolean include = false;
                    switch (comp.type()) {
/*                        case SchemaBase.ATTRIBUTE_TYPE:
                            include = !custom.isAttributeInlined();
                            break;  */
 
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

    public void pruneDefinitions() {
       
        // start by recursively checking for removable global definitions
        int index = 0;
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            s_logger.debug("Checking for unused definitions in schema " + ++index + ": "
                + schema.getResolver().getName());
            int count = schema.getChildCount();
            for (int i = 0; i < count; i++) {
                SchemaBase child = schema.getChild(i);
                Object exten = child.getExtension();
                if (exten instanceof GlobalExtension) {
                   
                    // check if global definition is unused and not specifically required
                    ((GlobalExtension)exten).checkRemovable();
                   
                }
            }
        }
       
        // next remove all the definitions flagged in the first step
        index = 0;
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            s_logger.debug("Deleting unused definitions in schema " + ++index + ": " + schema.getResolver().getName());
            int count = schema.getChildCount();
            boolean modified = false;
            for (int i = 0; i < count; i++) {
                SchemaBase child = schema.getChild(i);
                Object exten = child.getExtension();
                if (exten instanceof GlobalExtension && ((ComponentExtension)exten).isRemoved()) {
                   
                    // remove the definition from schema
                    schema.detachChild(i);
                    modified = true;
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug(" Removed definition " + ((INamed)child).getQName());
                    }
                   
                }
            }
            if (modified) {
                schema.compactChildren();
            }
        }
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

    private ArrayList buildItemStructures() {
        ArrayList items = new ArrayList();
        ItemVisitor itembuilder = new ItemVisitor();
        int index = 0;
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            m_validationContext.enterSchema(schema);
            s_logger.info("Building item structure for schema " + ++index + ": " + schema.getResolver().getName());
            int count = schema.getChildCount();
            for (int i = 0; i < count; i++) {
                SchemaBase child = schema.getChild(i);
                if (child.getExtension() instanceof GlobalExtension) {
                   
                    // create the definition
                    GlobalExtension global = (GlobalExtension)child.getExtension();
                    DefinitionItem definition = global.getDefinition();
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

            compactGroups(definition);
           
            // build the binding component for this definition
            ClassHolder clas = (ClassHolder)definition.getGenerateClass();
            OpenAttrBase comp = definition.getSchemaComponent();
            SchemaElement schema = comp.getSchema();
            BindingHolder holder = m_bindingDirectory.getRequiredBinding(schema);
            if (definition.isEnumeration()) {
               
                // construct format and add to binding
                FormatElement format = new FormatElement();
                format.setTypeName(clas.getBindingName());
                format.setQName(definition.getQName());
                ((EnumerationClassHolder)clas).setBinding(format);
                m_bindingDirectory.addFormat(format);
               
            } else {
               
                // construct mapping element
                MappingElementBase mapping = new MappingElement();
                mapping.setClassName(clas.getBindingName());
                if (comp.type() == SchemaBase.ELEMENT_TYPE) {
                   
                    // abstract or concrete mapping for element
                    ElementElement element = (ElementElement)comp;
                    setName(element.getEffectiveQName(), mapping, holder);
                    mapping.setAbstract(element.isAbstract());
                    QName group = element.getSubstitutionGroup();
                    if (group != null) {
                        ElementElement base = m_validationContext.findElement(group);
                        DefinitionItem basedef = ((GlobalExtension)base.getExtension()).getDefinition();
                        mapping.setExtendsName(basedef.getGenerateClass().getFullName());
                    }
                   
                } else {
                   
                    // abstract mapping for type definition or group
                    mapping.setAbstract(true);
                    QName qname = definition.getQName();
                    mapping.setTypeQName(qname);
                    String uri = qname.getUri();
                    if (uri != null) {
                        m_bindingDirectory.addTypeNameReference(holder, uri, schema);
                    }
                   
                }
               
                // add the mapping to binding and set on class
                holder.addMapping(mapping);
                ((StructureClassHolder)clas).setBinding(mapping);
                DefinitionItem elementdef = (DefinitionItem)typeinst.get(definition);
                if (elementdef != null) {
                   
                    // create mapping for element name linked to type
                    ElementElement element = (ElementElement)elementdef.getSchemaComponent();
                    SchemaElement elschema = element.getSchema();
                    MappingElementBase elmapping = new MappingElement();
                    elmapping.setClassName(clas.getBindingName());
                    elmapping.setAbstract(element.isAbstract());
                   
                    // handle linking to substitution group head using extends mapping
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

        Map namebindings = new HashMap();
        Map nsbindings = new HashMap();
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
           
            // check binding handling for schema
            SchemaElement schema = (SchemaElement)iter.next();
            SchemaExtension exten = (SchemaExtension)schema.getExtension();
            String uri = schema.getEffectiveNamespace();
            String prefix = exten.getPrefix();
            BindingHolder holder;
            String name = exten.getBindingFileName();
            boolean dflt = schema.isElementQualifiedDefault() || uri == null;
            if (name != null) {
               
                // specific binding name, create the binding or link to existing
                holder = (BindingHolder)namebindings.get(name);
                if (holder == null) {
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

     * @param handler
     */
    private static void listSchemas(SchemaElement[] schemas, ValidationContext vctx, ProblemHandler handler) {
        Set topset = new HashSet();
        for (int i = 0; i < schemas.length; i++) {
            SchemaElement schema = schemas[i];
            topset.add(schema);
            handler.report(" " + "top-level schema " + schema.getResolver().getName());
        }
        for (Iterator iter = vctx.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            if (!topset.contains(schema)) {
                handler.report(" " + "referenced schema " + schema.getResolver().getName());
            }
        }
    }
View Full Code Here

Examples of org.jibx.schema.elements.SchemaElement

        ProblemHandler handler = new ProblemConsoleLister();
        assertTrue("Schema customization failure", generator.customizeSchemas("dflt", handler));
        generator.applyAndNormalize();
        generator.pruneDefinitions();
        verifySchema(resolver.getText(), writeSchema(schemas[0]));
        SchemaElement schema = m_validationContext.getSchemaById(inclname);
        verifySchema(rslttext, writeSchema(schema));
    }
View Full Code Here

Examples of org.netbeans.modules.dbschema.SchemaElement

            boolean ignoreSunDeploymentDescriptors)
            throws IOException, DBException, ModelException,
            Schema2BeansException, SQLException, GeneratorException,
            ConversionException {

        SchemaElement schema = null;
        if (ejbcContext == null)
            isVerifyFlag = true;

        File cmpMappingFile = getSunCmpMappingFile(inputFilesPath);
        boolean mappedBeans = !ignoreSunDeploymentDescriptors
View Full Code Here

Examples of org.netbeans.modules.dbschema.SchemaElement

            OutputStream outstream = null;

            try {
                SchemaElementImpl outSchemaImpl = new SchemaElementImpl(cp);
                SchemaElement schemaElement = new SchemaElement(outSchemaImpl);
                schemaElement.setName(DBIdentifier.create(generatedSchemaName));

                if(dmd.getDatabaseProductName().compareToIgnoreCase("MYSQL") == 0)
                    outSchemaImpl.initTables(cp, new LinkedList(tables), new LinkedList(), true);
                else
                    outSchemaImpl.initTables(cp, new LinkedList(tables), new LinkedList(), false);
                outstream = new FileOutputStream(
                        new File(classout,
                        new StringBuffer(generatedSchemaName)
                            .append(DBSCHEMA_EXTENSION).toString()));

                // XXX Unfortunately, if SchemaElement.save gets an
                // IOException, it prints the stack trace but does not
                // let us handle it :-(
                schemaElement.save(outstream);

            } catch (IOException ex) {
                // Catch FileNotFound, etc.
                throw JDOCodeGeneratorHelper.createGeneratorException(
                        "CMG.CannotSaveDBSchema", bundle, ex); // NOI18N
View Full Code Here

Examples of org.netbeans.modules.dbschema.SchemaElement

     */
    private void loadOrCreateMappingClasses(boolean ignoreSunDeploymentDescriptors)
        throws IOException, GeneratorException {

        try {
            SchemaElement schema = mappingGenerator.generateMapping(
                    ejbcContext, inputFilesPath, generatedXmlsPath, classout,
                    ignoreSunDeploymentDescriptors);
            // If this is from verify, do not create DDL.
            if (ejbcContext != null
                    && mappingGenerator.isJavaToDatabase()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.