Package org.apache.padaf.xmpbox.schema

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


  }

  @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


  }

  @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

  }

  @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

    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";
    desc2.addValueType(valType, nsType, prefType, "must be replaced", null);
    desc2.addValueType(valType, nsType, prefType, descType, null);
    Assert.assertEquals(1, desc2.getValueTypes().size());
    PDFAValueTypeDescription value = desc2.getValueTypes().get(0);
    Assert.assertEquals(valType, value.getTypeNameValue());
    Assert.assertEquals(nsType, value.getNamespaceURIValue());
    Assert.assertEquals(prefType, value.getPrefixValue());
    Assert.assertEquals(descType, value.getDescriptionValue());
View Full Code Here

  private void parseSchemaDescription(PDFAExtensionSchema schema,
      XMPMetadata metadata) throws XMLStreamException,
      XmpParsingException, XmpUnknownValueTypeException,
      BadFieldValueException {
    expectCurrentLocalName("li");
    SchemaDescription desc = schema.createSchemaDescription();
    if ("Resource".equals(reader.get().getAttributeValue("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "parseType"))) {
      fillSchemaDescription(desc, metadata);
    } else {
      int type = reader.get().nextTag();
      if (type == XMLStreamReader.START_ELEMENT && reader.get().getLocalName().equals("Description")) {
View Full Code Here

    // PDFA Extension
    // Check numbers of schema descriptions
    Assert.assertTrue(metadata.getPDFExtensionSchema()
        .getDescriptionSchema().size() == 1);
    SchemaDescription desc = metadata.getPDFExtensionSchema()
        .getDescriptionSchema().get(0);

    // Check description content
    Assert.assertEquals("ACME E-Mail Schema", desc.getSchema());
    Assert.assertEquals("http://www.acme.com/ns/email/1/", desc
        .getNameSpaceURI());
    Assert.assertEquals("acmeemail", desc.getPrefix());

    // Check property definition
    List<PDFAPropertyDescription> properties = desc.getProperties();
    Assert.assertTrue(properties.size() == 2);

    // Check properties content
    PDFAPropertyDescription tmpProp = properties.get(0);
    Assert.assertEquals("Delivery-Date", tmpProp.getNameValue());
    Assert.assertEquals("Date", tmpProp.getValueTypeValue());
    Assert.assertEquals("internal", tmpProp.getCategoryValue());
    Assert.assertEquals("date of email delivery", tmpProp
        .getDescriptionValue());

    tmpProp = properties.get(1);
    Assert.assertEquals("From", tmpProp.getNameValue());
    Assert.assertEquals("mailaddress", tmpProp.getValueTypeValue());
    Assert.assertEquals("internal", tmpProp.getCategoryValue());
    Assert.assertEquals("sender email address", tmpProp
        .getDescriptionValue());

    // Check valuetype
    // Check numbers of valuetype defined
    Assert.assertTrue(desc.getValueTypes().size() == 1);
    PDFAValueTypeDescription tmpValType = desc.getValueTypes().get(0);
    Assert.assertEquals("mailaddress", tmpValType.getTypeNameValue());
    Assert.assertEquals("http://www.acme.com/ns/email/1/mailaddress/",
        tmpValType.getNamespaceURIValue());
    Assert.assertEquals("mailaddress value", tmpValType
        .getDescriptionValue());
View Full Code Here

    // PDFA Extension
    // Check numbers of schema descriptions
    Assert.assertTrue(metadata.getPDFExtensionSchema()
        .getDescriptionSchema().size() == 1);
    SchemaDescription desc = metadata.getPDFExtensionSchema()
        .getDescriptionSchema().get(0);

    // Check description content
    Assert.assertEquals("ACME E-Mail Schema", desc.getSchema());
    Assert.assertEquals("http://www.acme.com/ns/email/1/", desc
        .getNameSpaceURI());
    Assert.assertEquals("acmeemail", desc.getPrefix());

    // Check property definition
    List<PDFAPropertyDescription> properties = desc.getProperties();
    Assert.assertTrue(properties.size() == 2);

    // Check properties content
    PDFAPropertyDescription tmpProp = properties.get(0);
    Assert.assertEquals("Delivery-Date", tmpProp.getNameValue());
    Assert.assertEquals("Date", tmpProp.getValueTypeValue());
    Assert.assertEquals("internal", tmpProp.getCategoryValue());
    Assert.assertEquals("date of email delivery", tmpProp
        .getDescriptionValue());

    tmpProp = properties.get(1);
    Assert.assertEquals("From", tmpProp.getNameValue());
    Assert.assertEquals("mailaddress", tmpProp.getValueTypeValue());
    Assert.assertEquals("internal", tmpProp.getCategoryValue());
    Assert.assertEquals("sender email address", tmpProp
        .getDescriptionValue());

    // Check valuetype
    // Check numbers of valuetype defined
    Assert.assertTrue(desc.getValueTypes().size() == 1);
    PDFAValueTypeDescription tmpValType = desc.getValueTypes().get(0);
    Assert.assertEquals("mailaddress", tmpValType.getTypeNameValue());
    Assert.assertEquals("http://www.acme.com/ns/email/1/mailaddress/",
        tmpValType.getNamespaceURIValue());
    Assert.assertEquals("mailaddress value", tmpValType
        .getDescriptionValue());
View Full Code Here

        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());
        addValueTypesToSchem(metadata, desc, valTypesManag
            .getValueTypesDescriptionList());
      }
      for (Field field : fields) {
        if (field
            .isAnnotationPresent(PropertyExtensionDefinition.class)
            && field.isAnnotationPresent(PropertyType.class)) {
          try {
            propName = (String) field.get(propName);
          } catch (Exception e) {
            throw propertyDescriptionError(
                classSchem.getName(),
                field.getName(),
                "Couldn't read content, please check accessibility and declaration of field associated",
                e);
          }
          propExtDefAnnot = field
              .getAnnotation(PropertyExtensionDefinition.class);
          propTypeAnnot = field.getAnnotation(PropertyType.class);
          try {
            if (xmlPropDesc != null) {
              Iterator<PropertyDescription> it = xmlPropDesc
                  .iterator();
              PropertyDescription tmp;
              propDesc = null;
              while (it.hasNext() && (propDesc == null)) {
                tmp = it.next();
                if (tmp.getPropertyName().equals(propName)) {
                  propDesc = tmp.getDescription();
                }
              }

            } else {
              propDesc = propExtDefAnnot.propertyDescription();
            }
            if ((propDesc == null) || propDesc.equals("")) {
              propDesc = "Not documented description";
            }
            desc.addProperty(propName,
                propTypeAnnot.propertyType(), propExtDefAnnot
                    .propertyCategory(), propDesc);
          } catch (BadFieldValueException e) {
            throw propertyDescriptionError(classSchem.getName(),
                propName, "Wrong value for property Category",
View Full Code Here

      // 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());
      Assert.assertEquals("Birth-Certificate Schema", schemaDescription
          .getSchema());

      Assert.assertEquals(6, schemaDescription.getProperties().size());
      Assert.assertEquals(1, schemaDescription.getValueTypes().size());
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

TOP

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

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.