Search in sources :

Example 6 with CatalogEntry

use of org.opencastproject.mediapackage.XMLCatalogImpl.CatalogEntry in project opencast by opencast.

the class DublinCoreUtil method getPropertiesSorted.

/**
 * Return a sorted list of all catalog entries.
 */
public static List<CatalogEntry> getPropertiesSorted(DublinCoreCatalog dc) {
    final List<EName> properties = new ArrayList<>(dc.getProperties());
    Collections.sort(properties);
    final List<CatalogEntry> entries = new ArrayList<>();
    for (final EName property : properties) {
        Collections.addAll(entries, dc.getValues(property));
    }
    return new ImmutableListWrapper<>(entries);
}
Also used : EName(org.opencastproject.mediapackage.EName) ArrayList(java.util.ArrayList) CatalogEntry(org.opencastproject.mediapackage.XMLCatalogImpl.CatalogEntry) ImmutableListWrapper(com.entwinemedia.fn.data.ImmutableListWrapper)

Example 7 with CatalogEntry

use of org.opencastproject.mediapackage.XMLCatalogImpl.CatalogEntry in project opencast by opencast.

the class DublinCoreCatalogTest method testLoadEmptiedElementsDublinCore.

@Test
public /**
 *  MH-11621 test optional marshal input XML with intentionally emptied fields
 * @throws Exception
 */
void testLoadEmptiedElementsDublinCore() throws Exception {
    boolean includeEmptiedFields = true;
    final DublinCoreCatalog dc = read("/dublincore-non-oc.xml", includeEmptiedFields);
    for (DublinCoreValue value : dc.getValuesFlat()) {
        logger.debug("DublinCorevalue " + value.getValue());
    }
    // additional empty field is part of the count
    assertEquals(10, dc.getValuesFlat().size());
    assertEquals(2, dc.get(DublinCore.PROPERTY_TITLE).size());
    assertEquals(Opt.some(EName.mk("http://lib.org/metadata-enc", "PlainTitle")), dc.get(DublinCore.PROPERTY_TITLE).get(0).getEncodingScheme());
    for (CatalogEntry entry : dc.getEntriesSorted()) {
        logger.debug(entry.getEName().toString() + " " + entry.getValue());
    }
    assertTrue("Property foo:id should be in the list of known properties.", dc.getProperties().contains(PROPERTY_FOO_ID));
    assertEquals(fooId, dc.getFirstVal(PROPERTY_FOO_ID).getValue());
    // verify that catalog only instantiates properties from catalog
    // and that it instantiates properties with passed in empty values.
    // Passing empty values is how existing values are deleted during metadata update
    assertFalse("Non-passed property dc:temporal should *not* be instantiated.", dc.getProperties().contains(DublinCore.PROPERTY_TEMPORAL));
    assertTrue("Property foo:empty should be in the list of known properties.", dc.getProperties().contains(PROPERTY_FOO_EMPTY));
    assertEquals("", dc.getFirstVal(PROPERTY_FOO_EMPTY).getValue());
}
Also used : CatalogEntry(org.opencastproject.mediapackage.XMLCatalogImpl.CatalogEntry) Test(org.junit.Test)

Aggregations

CatalogEntry (org.opencastproject.mediapackage.XMLCatalogImpl.CatalogEntry)7 Test (org.junit.Test)3 EName (org.opencastproject.mediapackage.EName)2 Fn (com.entwinemedia.fn.Fn)1 Stream (com.entwinemedia.fn.Stream)1 ImmutableListWrapper (com.entwinemedia.fn.data.ImmutableListWrapper)1 InputStream (java.io.InputStream)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1