use of org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataCollection in project opencast by opencast.
the class ConfigurableEventDCCatalogUIAdapter method getFields.
@Override
public MetadataCollection getFields(MediaPackage mediapackage) {
DublinCoreMetadataCollection dublinCoreMetadata = new DublinCoreMetadataCollection();
Set<String> emptyFields = new TreeSet<>(dublinCoreProperties.keySet());
if (mediapackage != null) {
for (Catalog catalog : mediapackage.getCatalogs(getFlavor())) {
getFieldValuesFromCatalog(dublinCoreMetadata, emptyFields, catalog);
}
}
populateEmptyFields(dublinCoreMetadata, emptyFields);
return dublinCoreMetadata;
}
use of org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataCollection in project opencast by opencast.
the class ConfigurableSeriesDCCatalogUIAdapter method getFields.
@Override
public Opt<MetadataCollection> getFields(String seriesId) {
final Opt<DublinCoreCatalog> optDCCatalog = loadDublinCoreCatalog(RequireUtil.requireNotBlank(seriesId, "seriesId"));
if (optDCCatalog.isSome()) {
DublinCoreMetadataCollection dublinCoreMetadata = new DublinCoreMetadataCollection();
Set<String> emptyFields = new TreeSet<>(dublinCoreProperties.keySet());
getFieldValuesFromDublinCoreCatalog(dublinCoreMetadata, emptyFields, optDCCatalog.get());
populateEmptyFields(dublinCoreMetadata, emptyFields);
return Opt.some((MetadataCollection) dublinCoreMetadata);
} else {
return Opt.none();
}
}
use of org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataCollection in project opencast by opencast.
the class IndexServiceImplTest method testUpdateMediaPackageMetadata.
@Test
public void testUpdateMediaPackageMetadata() throws Exception {
// mock/initialize dependencies
String username = "user1";
String org = "mh_default_org";
String testResourceLocation = "/events/update-event.json";
String metadataJson = IOUtils.toString(getClass().getResourceAsStream(testResourceLocation));
MetadataCollection metadataCollection = new DublinCoreMetadataCollection();
metadataCollection.addField(MetadataField.createTextMetadataField("title", Opt.some("title"), "EVENTS.EVENTS.DETAILS.METADATA.TITLE", false, true, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
metadataCollection.addField(MetadataField.createTextLongMetadataField("creator", Opt.some("creator"), "EVENTS.EVENTS.DETAILS.METADATA.PRESENTERS", false, false, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
metadataCollection.addField(MetadataField.createTextMetadataField("isPartOf", Opt.some("isPartOf"), "EVENTS.EVENTS.DETAILS.METADATA.SERIES", false, false, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
MetadataList metadataList = new MetadataList(metadataCollection, metadataJson);
String eventId = "event-1";
Event event = new Event(eventId, org);
event.setTitle("Test Event 1");
SearchQuery query = EasyMock.createMock(SearchQuery.class);
EasyMock.expect(query.getLimit()).andReturn(100);
EasyMock.expect(query.getOffset()).andReturn(0);
EasyMock.replay(query);
SearchResultItemImpl<Event> searchResultItem = new SearchResultItemImpl<>(1.0, event);
SearchResultImpl<Event> searchResult = new SearchResultImpl<>(query, 0, 0);
searchResult.addResultItem(searchResultItem);
SecurityService securityService = setupSecurityService(username, org);
AbstractSearchIndex index = EasyMock.createMock(AbstractSearchIndex.class);
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(getClass().getResourceAsStream("/events/update-event-mp.xml"));
EasyMock.expect(index.getByQuery(EasyMock.anyObject(EventSearchQuery.class))).andReturn(searchResult);
EasyMock.replay(index);
Workspace workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.put(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyObject())).andReturn(getClass().getResource("/dublincore.xml").toURI()).anyTimes();
EasyMock.expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml")).anyTimes();
EasyMock.replay(workspace);
CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = setupCommonCatalogUIAdapter(workspace).getA();
// Using scheduler as the source of the media package here.
SchedulerService schedulerService = EasyMock.createMock(SchedulerService.class);
EasyMock.expect(schedulerService.getMediaPackage(EasyMock.anyString())).andReturn(mp);
Capture<Opt<MediaPackage>> mpCapture = new Capture<>();
schedulerService.updateEvent(EasyMock.anyString(), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.capture(mpCapture), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyString());
EasyMock.expectLastCall();
EasyMock.replay(schedulerService);
SeriesService seriesService = EasyMock.createMock(SeriesService.class);
DublinCoreCatalog seriesDC = DublinCores.read(getClass().getResourceAsStream("/events/update-event-series.xml"));
EasyMock.expect(seriesService.getSeries(EasyMock.anyString())).andReturn(seriesDC);
EasyMock.expect(seriesService.getSeriesAccessControl(EasyMock.anyString())).andReturn(null);
EasyMock.expect(seriesService.getSeriesElements(EasyMock.anyString())).andReturn(Opt.none());
EasyMock.replay(seriesService);
// create service
IndexServiceImpl indexService = new IndexServiceImpl();
indexService.setSecurityService(securityService);
indexService.setSchedulerService(schedulerService);
indexService.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
indexService.addCatalogUIAdapter(commonEventCatalogUIAdapter);
indexService.setSeriesService(seriesService);
indexService.setWorkspace(workspace);
MetadataList updateEventMetadata = indexService.updateEventMetadata(org, metadataList, index);
Assert.assertTrue(mpCapture.hasCaptured());
Assert.assertEquals("series-1", mp.getSeries());
Assert.assertEquals(1, mp.getCatalogs(MediaPackageElements.SERIES).length);
}
use of org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataCollection in project opencast by opencast.
the class ConfigurableEventDCCatalogUIAdapter method getRawFields.
@Override
public DublinCoreMetadataCollection getRawFields() {
DublinCoreMetadataCollection dublinCoreMetadata = new DublinCoreMetadataCollection();
Set<String> emptyFields = new TreeSet<>(dublinCoreProperties.keySet());
populateEmptyFields(dublinCoreMetadata, emptyFields);
return dublinCoreMetadata;
}
use of org.opencastproject.index.service.catalog.adapter.DublinCoreMetadataCollection in project opencast by opencast.
the class ConfigurableSeriesDCCatalogUIAdapter method getRawFields.
@Override
public MetadataCollection getRawFields() {
DublinCoreMetadataCollection dublinCoreMetadata = new DublinCoreMetadataCollection();
Set<String> emptyFields = new TreeSet<>(dublinCoreProperties.keySet());
populateEmptyFields(dublinCoreMetadata, emptyFields);
return dublinCoreMetadata;
}
Aggregations