Examples of XMPSchemaFactory


Examples of org.apache.xmpbox.schema.XMPSchemaFactory

                        PDFASchemaType st = (PDFASchemaType) af;
                        String namespaceUri = st.getNamespaceURI().trim();
                        String prefix = st.getPrefixValue();
                        ArrayProperty properties = st.getProperty();
                        ArrayProperty valueTypes = st.getValueType();
                        XMPSchemaFactory xsf = tm.getSchemaFactory(namespaceUri);
                        // retrieve namespaces
                        if (xsf == null)
                        {
                            // create namespace with no field
                            tm.addNewNameSpace(namespaceUri, prefix);
                            xsf = tm.getSchemaFactory(namespaceUri);
                        }
                        // populate value type
                        if (valueTypes != null)
                        {
                            for (AbstractField af2 : valueTypes.getAllProperties())
                            {
                                if (af2 instanceof PDFATypeType)
                                {
                                    PDFATypeType type = (PDFATypeType) af2;
                                    String ttype = type.getType();
                                    String tns = type.getNamespaceURI();
                                    String tprefix = type.getPrefixValue();
                                    String tdescription = type.getDescription();
                                    ArrayProperty fields = type.getFields();
                                    if (ttype == null || tns == null || tprefix == null || tdescription == null)
                                    {
                                        // all fields are mandatory
                                        throw new XmpParsingException(ErrorType.RequiredProperty,
                                                "Missing field in type definition");
                                    }
                                    // create the structured type
                                    DefinedStructuredType structuredType = new DefinedStructuredType(meta, tns,
                                            tprefix, null); // TODO
                                                            // maybe
                                                            // a name
                                                            // exists
                                    if (fields != null)
                                    {
                                        List<AbstractField> definedFields = fields.getAllProperties();
                                        for (AbstractField af3 : definedFields)
                                        {
                                            if (af3 instanceof PDFAFieldType)
                                            {
                                                PDFAFieldType field = (PDFAFieldType) af3;
                                                String fName = field.getName();
                                                String fDescription = field.getDescription();
                                                String fValueType = field.getValueType();
                                                if (fName == null || fDescription == null || fValueType == null)
                                                {
                                                    throw new XmpParsingException(ErrorType.RequiredProperty,
                                                            "Missing field in field definition");
                                                }
                                                try
                                                {
                                                    Types fValue = Types.valueOf(fValueType);
                                                    structuredType.addProperty(fName,
                                                            TypeMapping.createPropertyType(fValue, Cardinality.Simple));
                                                }
                                                catch (IllegalArgumentException e)
                                                {
                                                    throw new XmpParsingException(ErrorType.NoValueType,
                                                            "Type not defined : " + fValueType, e);
                                                    // TODO could fValueType be
                                                    // a structured type ?
                                                }
                                            } // else TODO
                                        }
                                    }
                                    // add the structured type to list
                                    PropertiesDescription pm = new PropertiesDescription();
                                    for (Map.Entry<String, PropertyType> entry : structuredType.getDefinedProperties()
                                            .entrySet())
                                    {
                                        pm.addNewProperty(entry.getKey(), entry.getValue());
                                    }
                                    tm.addToDefinedStructuredTypes(ttype, tns, pm);
                                }
                            }
                        }
                        // populate properties
                        if (properties == null)
                        {
                            throw new XmpParsingException(ErrorType.RequiredProperty,
                                    "Missing pdfaSchema:property in type definition");
                        }
                        for (AbstractField af2 : properties.getAllProperties())
                        {
                            if (af2 instanceof PDFAPropertyType)
                            {
                                PDFAPropertyType property = (PDFAPropertyType) af2;
                                String pname = property.getName();
                                String ptype = property.getValueType();
                                String pdescription = property.getDescription();
                                String pCategory = property.getCategory();
                                // check all mandatory fields are OK
                                if (pname == null || ptype == null || pdescription == null || pCategory == null)
                                {
                                    // all fields are mandatory
                                    throw new XmpParsingException(ErrorType.RequiredProperty,
                                            "Missing field in property definition");
                                }
                                // check ptype existance
                                PropertyType pt = transformValueType(tm, ptype);
                                if (pt.type() == null)
                                {
                                    throw new XmpParsingException(ErrorType.NoValueType, "Type not defined : " + ptype);
                                }
                                else if (pt.type().isSimple() || pt.type().isStructured()
                                        || pt.type() == Types.DefinedType)
                                {
                                    xsf.getPropertyDefinition().addNewProperty(pname, pt);
                                }
                                else
                                {
                                    throw new XmpParsingException(ErrorType.NoValueType, "Type not defined : " + ptype);
                                }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    @Test
    public void checkExistence () throws Exception {
        // ensure schema exists
        XMPMetadata xmpmd = new XMPMetadata();
        TypeMapping mapping = new TypeMapping(xmpmd);
        XMPSchemaFactory factory = mapping.getSchemaFactory(namespace);
        assertNotNull("Schema not existing: " + namespace, factory);
        // ensure preferred is as expected
        XMPSchema schema = factory.createXMPSchema(xmpmd,"aa");
        assertEquals(preferred,schema.getPreferedPrefix());
        // ensure field is defined
        boolean found = false;
        Class<?> clz  = schema.getClass();
        for (Field dfield : clz.getDeclaredFields()) {
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    private void addNameSpace(Class<? extends XMPSchema> classSchem)
    {
        StructuredType st = classSchem.getAnnotation(StructuredType.class);
        String ns = st.namespace();
        schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem)));
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    }

    public void addNewNameSpace(String ns, String prefered)
    {
        PropertiesDescription mapping = new PropertiesDescription();
        schemaMap.put(ns, new XMPSchemaFactory(ns, XMPSchema.class, mapping));
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix)
            throws XmpSchemaException
    {
        if (schemaMap.containsKey(namespace))
        {
            XMPSchemaFactory factory = schemaMap.get(namespace);
            return factory.createXMPSchema(metadata, prefix);
        }
        else
        {
            XMPSchemaFactory factory = getSchemaFactory(namespace);
            return factory != null ? factory.createXMPSchema(metadata, prefix) : null;
        }
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

     *            the property Qualified Name
     * @return Property type declared for namespace specified, null if unknown
     */
    public PropertyType getSpecifiedPropertyType(QName name) throws BadFieldValueException
    {
        XMPSchemaFactory factory = getSchemaFactory(name.getNamespaceURI());
        if (factory != null)
        {
            // found in schema
            return factory.getPropertyType(name.getLocalPart());
        }
        else
        {
            // try in structured
            Types st = structuredNamespaces.get(name.getNamespaceURI());
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    private void addNameSpace(Class<? extends XMPSchema> classSchem)
    {
        StructuredType st = classSchem.getAnnotation(StructuredType.class);
        String ns = st.namespace();
        schemaMap.put(ns, new XMPSchemaFactory(ns, classSchem, initializePropMapping(classSchem)));
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    }

    public void addNewNameSpace(String ns, String prefered)
    {
        PropertiesDescription mapping = new PropertiesDescription();
        schemaMap.put(ns, new XMPSchemaFactory(ns, XMPSchema.class, mapping));
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

    public XMPSchema getAssociatedSchemaObject(XMPMetadata metadata, String namespace, String prefix)
            throws XmpSchemaException
    {
        if (schemaMap.containsKey(namespace))
        {
            XMPSchemaFactory factory = schemaMap.get(namespace);
            return factory.createXMPSchema(metadata, prefix);
        }
        else
        {
            XMPSchemaFactory factory = getSchemaFactory(namespace);
            return factory != null ? factory.createXMPSchema(metadata, prefix) : null;
        }
    }
View Full Code Here

Examples of org.apache.xmpbox.schema.XMPSchemaFactory

     *            the property Qualified Name
     * @return Property type declared for namespace specified, null if unknown
     */
    public PropertyType getSpecifiedPropertyType(QName name) throws BadFieldValueException
    {
        XMPSchemaFactory factory = getSchemaFactory(name.getNamespaceURI());
        if (factory != null)
        {
            // found in schema
            return factory.getPropertyType(name.getLocalPart());
        }
        else
        {
            // try in structured
            Types st = structuredNamespaces.get(name.getNamespaceURI());
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.