use of org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter in project opencast by opencast.
the class SeriesEndpoint method getAllMetadata.
private Response getAllMetadata(String id) throws SearchIndexException {
Opt<Series> optSeries = indexService.getSeries(id, externalIndex);
if (optSeries.isNone())
return ApiResponses.notFound("Cannot find a series with id '%s'.", id);
MetadataList metadataList = new MetadataList();
List<SeriesCatalogUIAdapter> catalogUIAdapters = indexService.getSeriesCatalogUIAdapters();
catalogUIAdapters.remove(indexService.getCommonSeriesCatalogUIAdapter());
for (SeriesCatalogUIAdapter adapter : catalogUIAdapters) {
final Opt<MetadataCollection> optSeriesMetadata = adapter.getFields(id);
if (optSeriesMetadata.isSome()) {
metadataList.add(adapter.getFlavor(), adapter.getUITitle(), optSeriesMetadata.get());
}
}
MetadataCollection collection = getSeriesMetadata(optSeries.get());
ExternalMetadataUtils.changeSubjectToSubjects(collection);
ExternalMetadataUtils.changeTypeOrderedTextToText(collection);
metadataList.add(indexService.getCommonSeriesCatalogUIAdapter(), collection);
return okJson(metadataList.toJSON());
}
use of org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter in project opencast by opencast.
the class SeriesEndpoint method getMetadataByType.
private Response getMetadataByType(String id, String type) throws SearchIndexException {
Opt<Series> optSeries = indexService.getSeries(id, externalIndex);
if (optSeries.isNone())
return ApiResponses.notFound("Cannot find a series with id '%s'.", id);
// Try the main catalog first as we load it from the index.
if (typeMatchesSeriesCatalogUIAdapter(type, indexService.getCommonSeriesCatalogUIAdapter())) {
MetadataCollection collection = getSeriesMetadata(optSeries.get());
ExternalMetadataUtils.changeSubjectToSubjects(collection);
ExternalMetadataUtils.changeTypeOrderedTextToText(collection);
return ApiResponses.Json.ok(ApiVersion.VERSION_1_0_0, collection.toJSON());
}
// Try the other catalogs
List<SeriesCatalogUIAdapter> catalogUIAdapters = indexService.getSeriesCatalogUIAdapters();
catalogUIAdapters.remove(indexService.getCommonSeriesCatalogUIAdapter());
for (SeriesCatalogUIAdapter adapter : catalogUIAdapters) {
if (typeMatchesSeriesCatalogUIAdapter(type, adapter)) {
final Opt<MetadataCollection> optSeriesMetadata = adapter.getFields(id);
if (optSeriesMetadata.isSome()) {
return ApiResponses.Json.ok(ApiVersion.VERSION_1_0_0, optSeriesMetadata.get().toJSON());
}
}
}
return ApiResponses.notFound("Cannot find a catalog with type '%s' for series with id '%s'.", type, id);
}
Aggregations