use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceSolrIndex method search.
/**
* {@inheritDoc}
*/
@Override
public DublinCoreCatalogList search(SeriesQuery query) throws SeriesServiceDatabaseException {
// default to 20 items if not specified
int count = query.getCount() > 0 ? query.getCount() : 20;
// default to page zero
int startPage = query.getStartPage() > 0 ? query.getStartPage() : 0;
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(count);
solrQuery.setStart(startPage * count);
String solrQueryString = null;
solrQueryString = buildSolrQueryString(query, query.isEdit());
solrQuery.setQuery(solrQueryString);
if (query.getSort() != null) {
SolrQuery.ORDER order = query.isSortAscending() ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc;
solrQuery.addSortField(getSortField(query.getSort()) + "_sort", order);
}
if (!SeriesQuery.Sort.CREATED.equals(query.getSort())) {
solrQuery.addSortField(getSortField(SeriesQuery.Sort.CREATED) + "_sort", SolrQuery.ORDER.desc);
}
List<DublinCoreCatalog> result;
try {
QueryResponse response = solrServer.query(solrQuery);
SolrDocumentList items = response.getResults();
result = new LinkedList<DublinCoreCatalog>();
// Iterate through the results
for (SolrDocument doc : items) {
DublinCoreCatalog item = parseDublinCore((String) doc.get(SolrFields.XML_KEY));
result.add(item);
}
return new DublinCoreCatalogList(result, response.getResults().getNumFound());
} catch (Exception e) {
logger.error("Could not retrieve results: {}", e.getMessage());
throw new SeriesServiceDatabaseException(e);
}
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceImplTest method testSeriesFuzzyIdSearchQuery.
@Test
public void testSeriesFuzzyIdSearchQuery() throws Exception {
testCatalog.set(DublinCore.PROPERTY_IDENTIFIER, "20160119999");
seriesService.updateSeries(testCatalog);
SeriesQuery q = new SeriesQuery().setSeriesId("201601");
q.setFuzzyMatch(true);
List<DublinCoreCatalog> result = seriesService.getSeries(q).getCatalogList();
Assert.assertEquals(1, result.size());
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceImplTest method testSeriesManagement.
@Test
public void testSeriesManagement() throws Exception {
testCatalog.set(DublinCore.PROPERTY_TITLE, "Some title");
seriesService.updateSeries(testCatalog);
DublinCoreCatalog retrivedSeries = seriesService.getSeries(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.assertEquals("Some title", retrivedSeries.getFirst(DublinCore.PROPERTY_TITLE));
testCatalog.set(DublinCore.PROPERTY_TITLE, "Some other title");
seriesService.updateSeries(testCatalog);
retrivedSeries = seriesService.getSeries(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.assertEquals("Some other title", retrivedSeries.getFirst(DublinCore.PROPERTY_TITLE));
seriesService.deleteSeries(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
try {
seriesService.getSeries(testCatalog.getFirst(DublinCore.PROPERTY_IDENTIFIER));
Assert.fail("Series should not be available after removal.");
} catch (NotFoundException e) {
// expected
}
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceImplTest method testDublinCoreCatalogEquality2.
@Test
public void testDublinCoreCatalogEquality2() {
DublinCoreCatalog a = DublinCores.mkOpencast().getCatalog();
DublinCoreCatalog b = DublinCores.mkOpencast().getCatalog();
a.set(DublinCore.PROPERTY_DESCRIPTION, "this is a test lecture");
a.set(DublinCore.PROPERTY_SPATIAL, "room1");
a.set(DublinCore.PROPERTY_IDENTIFIER, "123");
a.set(DublinCore.PROPERTY_CONTRIBUTOR, list(DublinCoreValue.mk("Peter"), DublinCoreValue.mk("Paul")));
b.set(DublinCore.PROPERTY_CONTRIBUTOR, list(DublinCoreValue.mk("Peter"), DublinCoreValue.mk("Paul")));
b.set(DublinCore.PROPERTY_DESCRIPTION, "this is a test lecture");
b.set(DublinCore.PROPERTY_SPATIAL, "room1");
b.set(DublinCore.PROPERTY_IDENTIFIER, "123");
assertTrue(DublinCoreUtil.equals(a, b));
}
use of org.opencastproject.metadata.dublincore.DublinCoreCatalog in project opencast by opencast.
the class SeriesServiceSolrTest method testSpecialOrgId.
@Test
public void testSpecialOrgId() throws Exception {
String seriesId = "09157c61-d886-4b4a-a7b1-48da8618e780";
DublinCoreCatalog firstCatalog = dcService.newInstance();
firstCatalog.add(DublinCore.PROPERTY_IDENTIFIER, seriesId);
firstCatalog.add(DublinCore.PROPERTY_TITLE, "Cats and Dogs");
firstCatalog.add(DublinCore.PROPERTY_CREATED, "2007-05-03");
index.updateIndex(firstCatalog);
SeriesQuery q = new SeriesQuery().setSeriesId(seriesId);
DublinCoreCatalogList result = index.search(q);
Assert.assertTrue("One series satisfy id", result.size() == 1);
Assert.assertEquals(1, index.count());
index.delete(seriesId);
result = index.search(q);
Assert.assertTrue("No series satisfy id", result.size() == 0);
Assert.assertEquals(0, index.count());
}
Aggregations