Search in sources :

Example 21 with DublinCoreCatalog

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);
    }
}
Also used : DublinCoreCatalogList(org.opencastproject.metadata.dublincore.DublinCoreCatalogList) SolrDocumentList(org.apache.solr.common.SolrDocumentList) SolrQuery(org.apache.solr.client.solrj.SolrQuery) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SeriesException(org.opencastproject.series.api.SeriesException) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) SolrDocument(org.apache.solr.common.SolrDocument) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog)

Example 22 with DublinCoreCatalog

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());
}
Also used : SeriesQuery(org.opencastproject.series.api.SeriesQuery) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Example 23 with DublinCoreCatalog

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
    }
}
Also used : NotFoundException(org.opencastproject.util.NotFoundException) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Example 24 with DublinCoreCatalog

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));
}
Also used : DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Example 25 with DublinCoreCatalog

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());
}
Also used : SeriesQuery(org.opencastproject.series.api.SeriesQuery) DublinCoreCatalogList(org.opencastproject.metadata.dublincore.DublinCoreCatalogList) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Aggregations

DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)117 MediaPackage (org.opencastproject.mediapackage.MediaPackage)51 NotFoundException (org.opencastproject.util.NotFoundException)46 Test (org.junit.Test)44 Date (java.util.Date)40 IOException (java.io.IOException)30 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)29 URI (java.net.URI)23 AccessControlList (org.opencastproject.security.api.AccessControlList)22 SeriesException (org.opencastproject.series.api.SeriesException)20 ArrayList (java.util.ArrayList)18 Catalog (org.opencastproject.mediapackage.Catalog)18 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)18 EName (org.opencastproject.mediapackage.EName)17 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)17 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)15 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)15 InputStream (java.io.InputStream)14 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)14