use of org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader in project cineast by vitrivr.
the class FindObjectByIdPostHandler method performPost.
@Override
public MediaObjectQueryResult performPost(IdList context, Context ctx) {
final Map<String, String> parameters = ctx.pathParamMap();
if (context == null || context.getIds().length == 0) {
return new MediaObjectQueryResult("", new ArrayList<>(0));
}
final MediaObjectReader ol = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
final Map<String, MediaObjectDescriptor> objects = ol.lookUpObjects(Arrays.asList(context.getIds()));
ol.close();
return new MediaObjectQueryResult("", new ArrayList<>(objects.values()));
}
use of org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader in project cineast by vitrivr.
the class CineastQueryService method getMediaObjects.
@Override
public void getMediaObjects(CineastGrpc.MediaObjectIdList request, StreamObserver<CineastGrpc.MediaObjectQueryResult> responseObserver) {
Set<String> ids = request.getIdsList().stream().map(CineastGrpc.MediaObjectId::getId).collect(Collectors.toSet());
MediaObjectReader reader = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
Map<String, MediaObjectDescriptor> objects = reader.lookUpObjects(ids);
CineastGrpc.MediaObjectQueryResult result = CineastGrpc.MediaObjectQueryResult.newBuilder().addAllObjects(objects.values().stream().map(MediaObjectUtil::fromMediaObjectDescriptor).collect(Collectors.toList())).build();
responseObserver.onNext(result);
responseObserver.onCompleted();
}
Aggregations