use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceSolrTest method testMergingAndRetrieving.
@Test
public void testMergingAndRetrieving() throws Exception {
DublinCoreCatalog secondCatalog = dcService.newInstance();
secondCatalog.add(DublinCore.PROPERTY_IDENTIFIER, testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
secondCatalog.add(DublinCore.PROPERTY_TITLE, "Test Title");
index.updateIndex(testCatalog);
index.updateIndex(secondCatalog);
Assert.assertTrue("Index should contain one instance", index.count() == 1);
DublinCoreCatalog returnedCatalog = index.getDublinCore(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.assertTrue("Unexpected Dublin Core", "Test Title".equals(returnedCatalog.getFirst(DublinCore.PROPERTY_TITLE)));
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceSolrTest method testQueryIdTitleMap.
@Test
public void testQueryIdTitleMap() throws Exception {
Map<String, String> emptyResult = index.queryIdTitleMap();
Assert.assertTrue("The result should be empty", emptyResult.isEmpty());
DublinCoreCatalog firstCatalog = dcService.newInstance();
firstCatalog.add(DublinCore.PROPERTY_IDENTIFIER, "10.0000/1");
firstCatalog.add(DublinCore.PROPERTY_TITLE, "Cats and Dogs");
firstCatalog.add(DublinCore.PROPERTY_DESCRIPTION, "This lecture tries to give an explanation...");
DublinCoreCatalog secondCatalog = dcService.newInstance();
secondCatalog.add(DublinCore.PROPERTY_IDENTIFIER, "10.0000/2");
secondCatalog.add(DublinCore.PROPERTY_TITLE, "Nature of Dogs");
secondCatalog.add(DublinCore.PROPERTY_DESCRIPTION, "Why do dogs chase cats?");
index.updateIndex(firstCatalog);
index.updateIndex(secondCatalog);
Map<String, String> queryResult = index.queryIdTitleMap();
Assert.assertEquals(2, queryResult.size());
Assert.assertTrue("The result contains the first series catalog Id", queryResult.containsKey("10.0000/1"));
Assert.assertEquals("The result matches the first series title", "Cats and Dogs", queryResult.get("10.0000/1"));
Assert.assertTrue("The result contains the second series catalog Id", queryResult.containsKey("10.0000/2"));
Assert.assertEquals("The result matches the second series title", "Nature of Dogs", queryResult.get("10.0000/2"));
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceSolrTest method testSearchingByTitleAndFullText.
@Test
public void testSearchingByTitleAndFullText() throws Exception {
DublinCoreCatalog firstCatalog = dcService.newInstance();
firstCatalog.add(DublinCore.PROPERTY_IDENTIFIER, "10.0000/1");
firstCatalog.add(DublinCore.PROPERTY_TITLE, "Cats and Dogs");
firstCatalog.add(DublinCore.PROPERTY_DESCRIPTION, "This lecture tries to give an explanation...");
DublinCoreCatalog secondCatalog = dcService.newInstance();
secondCatalog.add(DublinCore.PROPERTY_IDENTIFIER, "10.0000/2");
secondCatalog.add(DublinCore.PROPERTY_TITLE, "Nature of Dogs");
secondCatalog.add(DublinCore.PROPERTY_DESCRIPTION, "Why do dogs chase cats?");
index.updateIndex(firstCatalog);
index.updateIndex(secondCatalog);
SeriesQuery q = new SeriesQuery().setSeriesTitle("cat");
DublinCoreCatalogList result = index.search(q);
Assert.assertTrue("Only one title contains 'cat'", result.size() == 1);
q = new SeriesQuery().setSeriesTitle("dog");
result = index.search(q);
Assert.assertTrue("Both titles contains 'dog'", result.size() == 2);
q = new SeriesQuery().setText("cat");
result = index.search(q);
Assert.assertTrue("Both Dublin Cores contains 'cat'", result.size() == 2);
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesWorkflowOperationHandlerTest method testExtraMetadataDefaultNS.
@Test
public void testExtraMetadataDefaultNS() throws WorkflowOperationException {
final EName customProperty = new EName(DublinCores.OC_PROPERTY_NS_URI, "my-custom-property");
final String customValue = "my-custom-value";
// Add extra metadata to the series catalog.
seriesCatalog.set(DublinCore.PROPERTY_LANGUAGE, "Opencastian");
seriesCatalog.set(DublinCore.PROPERTY_CONTRIBUTOR, Arrays.asList(new DublinCoreValue[] { DublinCoreValue.mk("Mr. Contry Bute"), DublinCoreValue.mk("Mrs. Jane Doe") }));
seriesCatalog.set(customProperty, customValue);
// Prepare "copy metadata" property
// All field names without namespace
// However, in the series metadata, the third one has a different NS than the other two
String[] extraMetadata = { DublinCore.PROPERTY_LANGUAGE.getLocalName(), DublinCore.PROPERTY_CONTRIBUTOR.getLocalName(), customProperty.getLocalName() };
WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
ops.add(operation);
instance.setOperations(ops);
instance.setMediaPackage(mp);
MediaPackage clone = (MediaPackage) mp.clone();
operation.setConfiguration(SeriesWorkflowOperationHandler.SERIES_PROPERTY, "series1");
operation.setConfiguration(SeriesWorkflowOperationHandler.ATTACH_PROPERTY, "*");
operation.setConfiguration(SeriesWorkflowOperationHandler.APPLY_ACL_PROPERTY, "false");
operation.setConfiguration(SeriesWorkflowOperationHandler.COPY_METADATA_PROPERTY, StringUtils.join(extraMetadata, ", "));
// Set the namespace of the third, custom property as the default
operation.setConfiguration(SeriesWorkflowOperationHandler.DEFAULT_NS_PROPERTY, DublinCores.OC_PROPERTY_NS_URI);
WorkflowOperationResult result = operationHandler.start(instance, null);
Assert.assertEquals(Action.CONTINUE, result.getAction());
MediaPackage resultingMediapackage = result.getMediaPackage();
Assert.assertEquals("series1", resultingMediapackage.getSeries());
Assert.assertEquals("Series 1", resultingMediapackage.getSeriesTitle());
Assert.assertEquals(clone.getElements().length + 1, resultingMediapackage.getElements().length);
// Get episode DublinCore
DublinCoreCatalog episodeCatalog = DublinCores.read(capturedStream.getValue());
// Only the later metadatum should have been resolved. The other had a different namespace.
Assert.assertFalse(episodeCatalog.hasValue(DublinCore.PROPERTY_CONTRIBUTOR));
Assert.assertFalse(episodeCatalog.hasValue(DublinCore.PROPERTY_LANGUAGE));
Assert.assertTrue(episodeCatalog.hasValue(customProperty));
Assert.assertEquals(seriesCatalog.get(customProperty), episodeCatalog.get(customProperty));
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class EmailSchedulerConflictNotifierTest method testEmailSchedulerConflict.
@Test
public void testEmailSchedulerConflict() throws Exception {
Set<String> userIds = new HashSet<>();
userIds.add("user1");
userIds.add("user2");
Map<String, String> caProperties = new HashMap<String, String>();
caProperties.put("test", "true");
caProperties.put("clear", "all");
Map<String, String> wfProperties = new HashMap<String, String>();
wfProperties.put("test", "false");
wfProperties.put("skip", "true");
final String mpId = "1234";
final TechnicalMetadata technicalMetadata = new TechnicalMetadataImpl(mpId, "demo", new Date(), new Date(new Date().getTime() + 10 * 60 * 1000), false, userIds, wfProperties, caProperties, null);
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mp.setIdentifier(new IdImpl(mpId));
mp.add(DublinCores.mkOpencastEpisode().getCatalog());
DublinCoreCatalog extendedEvent = DublinCores.mkStandard();
extendedEvent.setFlavor(new MediaPackageElementFlavor("extended", "episode"));
mp.add(extendedEvent);
final SchedulerEvent schedulerEvent = EasyMock.createNiceMock(SchedulerEvent.class);
EasyMock.expect(schedulerEvent.getTechnicalMetadata()).andReturn(technicalMetadata).anyTimes();
EasyMock.expect(schedulerEvent.getMediaPackage()).andReturn(mp).anyTimes();
EasyMock.expect(schedulerEvent.getEventId()).andReturn(mpId).anyTimes();
EasyMock.expect(schedulerEvent.getVersion()).andReturn("2").anyTimes();
EasyMock.replay(schedulerEvent);
ConflictingEvent conflictingEvent = EasyMock.createNiceMock(ConflictingEvent.class);
EasyMock.expect(conflictingEvent.getOldEvent()).andReturn(schedulerEvent).anyTimes();
EasyMock.expect(conflictingEvent.getNewEvent()).andReturn(schedulerEvent).anyTimes();
EasyMock.expect(conflictingEvent.getConflictStrategy()).andReturn(Strategy.NEW).anyTimes();
EasyMock.replay(conflictingEvent);
List<ConflictingEvent> conflicts = new ArrayList<>();
conflicts.add(conflictingEvent);
final Integer[] counter = new Integer[1];
counter[0] = 0;
SmtpService smtpService = new SmtpService() {
@Override
public void send(MimeMessage message) throws MessagingException {
counter[0]++;
}
};
conflictNotifier.setSmtpService(smtpService);
conflictNotifier.notifyConflicts(conflicts);
Assert.assertEquals(1, counter[0].intValue());
}
Aggregations