Package org.apache.padaf.xmpbox.schema

Examples of org.apache.padaf.xmpbox.schema.PDFAExtensionSchema


    namespaces.put(PDFAExtensionSchema.PDFASCHEMA,
        PDFAExtensionSchema.PDFASCHEMAURI);
    namespaces.put(PDFAExtensionSchema.PDFATYPE,
        PDFAExtensionSchema.PDFATYPEURI);

    PDFAExtensionSchema schem = metadata
        .createAndAddPDFAExtensionSchemaWithNS(namespaces);
    Iterator<Attribute> att = schem.getAllAttributes().iterator();

    // PDFAExtension is removed during the building of
    // PDFAExtensionSchemaWithNS
    namespaces.put(PDFAExtensionSchema.PDFAEXTENSION,
        PDFAExtensionSchema.PDFAEXTENSIONURI);
View Full Code Here


  }

  @Test(expected = XmpSchemaException.class)
  public void testNoPdfExtension() throws Exception {
    Map<String, String> namespaces = new HashMap<String, String>();
    new PDFAExtensionSchema(metadata, namespaces);
  }
View Full Code Here

    new PDFAExtensionSchema(metadata, namespaces);
  }

  @Test
  public void testSameSchemaTwice() throws Exception {
    PDFAExtensionSchema schema = new PDFAExtensionSchema(metadata);
    SchemaDescription sd1 = schema.createSchemaDescription();
    sd1.setPrefixValue("pref1");
    sd1.setNameSpaceURIValue("http://uri1");
    sd1.setSchemaValue("pref 1");
    Assert.assertNull(schema.addSchemaDescription(sd1));

    SchemaDescription sd2 = schema.createSchemaDescription();
    sd2.setPrefixValue("pref1");
    sd2.setNameSpaceURIValue("http://uri1");
    sd2.setSchemaValue("pref 1");
    Assert.assertNotNull(schema.addSchemaDescription(sd2));

    List<SchemaDescription> lsd = schema.getDescriptionSchema();
    Assert.assertEquals(1, lsd.size());
    SchemaDescription sd = lsd.get(0);
    Assert.assertEquals("pref1", sd.getPrefix());
    Assert.assertEquals("http://uri1", sd.getNameSpaceURI());
    Assert.assertEquals("pref 1", sd.getSchema());
View Full Code Here

    Assert.assertEquals("pref 1", sd.getSchema());
  }

  @Test
  public void testSameNSSchemaDifferentPrefix() throws Exception {
    PDFAExtensionSchema schema = new PDFAExtensionSchema(metadata);
    SchemaDescription sd1 = schema.createSchemaDescription();
    sd1.setPrefixValue("pref1");
    sd1.setNameSpaceURIValue("http://uri1");
    sd1.setSchemaValue("pref 1");
    Assert.assertNull(schema.addSchemaDescription(sd1));

    SchemaDescription sd2 = schema.createSchemaDescription();
    sd2.setPrefixValue("pref2");
    sd2.setNameSpaceURIValue("http://uri1");
    sd2.setSchemaValue("pref 2");
    Assert.assertNull(schema.addSchemaDescription(sd2));

    List<SchemaDescription> lsd = schema.getDescriptionSchema();
    Assert.assertEquals(2, lsd.size());
    SchemaDescription sd = lsd.get(0);
    Assert.assertEquals("pref1", sd.getPrefix());
    Assert.assertEquals("http://uri1", sd.getNameSpaceURI());
    Assert.assertEquals("pref 1", sd.getSchema());
View Full Code Here

    Assert.assertEquals("pref 1", sd.getSchema());
  }

  @Test
  public void testDifferentSchemaDifferentPrefix() throws Exception {
    PDFAExtensionSchema schema = new PDFAExtensionSchema(metadata);
    SchemaDescription sd1 = schema.createSchemaDescription();
    sd1.setPrefixValue("pref1");
    sd1.setNameSpaceURIValue("http://uri1");
    sd1.setSchemaValue("pref 1");
    Assert.assertNull(schema.addSchemaDescription(sd1));

    SchemaDescription sd2 = schema.createSchemaDescription();
    sd2.setPrefixValue("pref2");
    sd2.setNameSpaceURIValue("http://uri2");
    sd2.setSchemaValue("pref 2");
    Assert.assertNull(schema.addSchemaDescription(sd2));

    List<SchemaDescription> lsd = schema.getDescriptionSchema();
    Assert.assertEquals(2, lsd.size());
    SchemaDescription sd = lsd.get(0);
    Assert.assertEquals("pref1", sd.getPrefix());
    Assert.assertEquals("http://uri1", sd.getNameSpaceURI());
    Assert.assertEquals("pref 1", sd.getSchema());
View Full Code Here

  }

  @Test
  public void testPDFExt() throws Exception {

    PDFAExtensionSchema schem = metadata
        .createAndAddPDFAExtensionSchemaWithDefaultNS();

    Assert.assertEquals("pdfaExtension", schem.getPrefix());
    Assert.assertEquals("http://www.aiim.org/pdfa/ns/extension/", schem
        .getNamespaceValue());

    String schemDesc = "Schema Acte de naissance";
    String schemURI = "http://test.apache.com/xap/adn/";
    String schemPrefix = "adn";

    SchemaDescription desc = schem.createSchemaDescription();
    desc.setSchemaValue(schemDesc);
    desc.setNameSpaceURIValue(schemURI);
    desc.setPrefixValue(schemPrefix);
    schem.addSchemaDescription(desc);

    Assert.assertEquals(schemDesc, desc.getSchema());
    Assert.assertEquals(schemURI, desc.getNameSpaceURI());
    Assert.assertEquals(schemPrefix, desc.getPrefix());

    String descExpected = "nom de la personne concernée";
    desc.addProperty("nom", "Text", "external",
        "nom de la personne concernee");
    desc.addProperty("nom", "Text", "external", descExpected);
    Assert.assertEquals(1, desc.getProperties().size());
    Assert.assertEquals(descExpected, desc.getProperties().get(0)
        .getDescriptionValue());
    desc.addProperty("prénom", "Text", "external",
        "prénom de la personne concernée");

    List<PDFAPropertyDescription> list = desc.getProperties();
    Assert.assertEquals("nom", list.get(0).getNameValue());
    Assert.assertEquals("prénom", list.get(1).getNameValue());

    // Check retrieve descriptions
    Assert.assertEquals(desc, schem.getIteratorOfDescriptions().next());
    Assert.assertEquals(desc, schem.getDescriptionSchema().get(0));

    // check retrieve this schema in metadata
    Assert.assertEquals(schem, metadata.getPDFExtensionSchema());

    // Check if no problem when create 2 description and display result
    SchemaDescription desc2 = schem.createSchemaDescription();
    desc2.setSchemaValue("2eme schema de test");
    desc2.setNameSpaceURIValue("http://test.apache.com/xap/test/");
    desc2.setPrefixValue("tst");
    desc2.addProperty("TestText", "OwnType", "external",
        "just a text property");
    schem.addSchemaDescription(desc2);
    // Check value type
    String valType = "OwnType";
    String nsType = "http://test.apache.com/xap/test/";
    String prefType = "tst";
    String descType = "Test Own type";
View Full Code Here

            .containsValue(PDFAExtensionSchema.PDFAEXTENSIONURI)
            && namespaces
            .containsValue(PDFAExtensionSchema.PDFAPROPERTYURI)
            && namespaces
            .containsValue(PDFAExtensionSchema.PDFASCHEMAURI)) {
          PDFAExtensionSchema schema = metadata
              .createAndAddPDFAExtensionSchemaWithNS(namespaces);
          treatDescriptionAttributes(metadata, schema);
          parseExtensionSchema(schema, metadata);

        } else {
          throw new XmpUnexpectedNamespaceURIException(
              "Unexpected namespaceURI in PDFA Extension Schema encountered");
        }
      } else {
        throw new XmpUnexpectedNamespacePrefixException(
            "Unexpected namespace Prefix in PDFA Extension Schema");
      }

    } else {
      int c = 0;
      String namespaceUri = reader.get().getNamespaceURI(c);
      String namespacePrefix = reader.get().getNamespacePrefix(c);
      c++;
      XMPSchema schema = nsMap.getAssociatedSchemaObject(metadata, namespaceUri, namespacePrefix);
      while (c<reader.get().getNamespaceCount() && schema==null) {
        // try next
        namespaceUri = reader.get().getNamespaceURI(c);
        namespacePrefix = reader.get().getNamespacePrefix(c);
        schema = nsMap.getAssociatedSchemaObject(metadata, namespaceUri, namespacePrefix);
        c++;
      }

      if (schema != null) {
        namespaces.remove(namespacePrefix);
      } else {
        schema = metadata.createAndAddDefaultSchema(namespacePrefix,namespaceUri);
      }

      for (int i = 1; i < cptNS; i++) {
        schema.setAttribute(new Attribute(XMPSchema.NS_NAMESPACE,
            "xmlns", reader.get().getNamespacePrefix(i), reader.get().getNamespaceURI(i)));
      }
      treatDescriptionAttributes(metadata, schema);
      while (reader.get().nextTag() == XMLStreamReader.START_ELEMENT) {
        parseProperty(schema, metadata);
View Full Code Here

   *             or in Schema Class
   */
  public static void includePDFAExtensionDefinition(XMPMetadata metadata,
      XMPSchema schema)
      throws BuildPDFAExtensionSchemaDescriptionException {
    PDFAExtensionSchema ext = metadata.getPDFExtensionSchema();
    Class<? extends XMPSchema> classSchem = schema.getClass();
    if (ext == null) {
      ext = metadata.createAndAddPDFAExtensionSchemaWithDefaultNS();
    }
    Field[] fields;
    fields = classSchem.getFields();
    SchemaExtensionDefinition schemDefAnnot;
    PropertyExtensionDefinition propExtDefAnnot;
    PropertyType propTypeAnnot;
    String propName = null;
    String propDesc;
    List<PropertyDescription> xmlPropDesc = null;
    if (classSchem.isAnnotationPresent(SchemaExtensionDefinition.class)) {
      schemDefAnnot = classSchem
          .getAnnotation(SchemaExtensionDefinition.class);
      // Try to find and load XML Properties Descriptions file path
      if (!schemDefAnnot.property_descriptions().equals("")) {
        XMLPropertiesDescriptionManager propManag = new XMLPropertiesDescriptionManager();
        propManag.loadListFromXML(classSchem, schemDefAnnot
            .property_descriptions());
        xmlPropDesc = propManag.getPropertiesDescriptionList();
      }
      SchemaDescription desc = ext.createSchemaDescription();
      desc.setSchemaValue(schemDefAnnot.schema());
      desc.setNameSpaceURIValue(schema.getNamespaceValue());
      desc.setPrefixValue(schema.getPrefix());
      ext.addSchemaDescription(desc);
      // Try to find and load XML ValueType Description file path
      if (!schemDefAnnot.valueType_description().equals("")) {
        XMLValueTypeDescriptionManager valTypesManag = new XMLValueTypeDescriptionManager();
        valTypesManag.loadListFromXML(classSchem, schemDefAnnot
            .valueType_description());
View Full Code Here

      BuildPDFExtensionSchemaHelper.includePDFAExtensionDefinition(
          metadata, schema);

      // Values checking is made which what is expected with Schema
      // definition and xml files
      PDFAExtensionSchema ext = metadata.getPDFExtensionSchema();
      Assert.assertEquals(1, ext.getDescriptionSchema().size());
      SchemaDescription schemaDescription = ext.getDescriptionSchema()
          .get(0);
      Assert.assertEquals(schema.getNamespaceValue(), schemaDescription
          .getNameSpaceURI());
      Assert.assertEquals(schema.getPrefix(), schemaDescription
          .getPrefix());
View Full Code Here

     * is created with all default namespaces used in PDFAExtensionSchema
     *
     * @return PDFAExtension schema added in order to work on it
     */
    public PDFAExtensionSchema createAndAddPDFAExtensionSchemaWithDefaultNS() {
        PDFAExtensionSchema pdfAExt = new PDFAExtensionSchema(this);
        pdfAExt.setAboutAsSimple("");
        addSchema(pdfAExt);
        return pdfAExt;
    }
View Full Code Here

TOP

Related Classes of org.apache.padaf.xmpbox.schema.PDFAExtensionSchema

Copyright © 2018 www.massapicom. 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.