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);
}
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());
}
Aggregations