use of org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult in project cineast by vitrivr.
the class FindObjectGetHandler method doGet.
@Override
public MediaObjectQueryResult doGet(Context ctx) {
final Map<String, String> parameters = ctx.pathParamMap();
final String attribute = parameters.get(ATTRIBUTE_NAME);
final String value = parameters.get(VALUE_NAME);
final MediaObjectReader ol = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
MediaObjectDescriptor object = null;
switch(attribute.toLowerCase()) {
case "id":
{
object = ol.lookUpObjectById(value);
break;
}
case "name":
{
object = ol.lookUpObjectByName(value);
break;
}
case "path":
{
object = ol.lookUpObjectByPath(value);
break;
}
default:
{
LOGGER.error("Unknown attribute '{}' in FindObjectByActionHandler", attribute);
}
}
ol.close();
return new MediaObjectQueryResult("", Lists.newArrayList(object));
}
use of org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult in project cineast by vitrivr.
the class FindObjectAllGetHandler method doGet.
// public static final String ROUTE = "find/objects/all/:"+TYPE_NAME;
@Override
public MediaObjectQueryResult doGet(Context ctx) {
// TODO :type is not being used
final MediaObjectReader ol = new MediaObjectReader(Config.sharedConfig().getDatabase().getSelectorSupplier().get());
final List<MediaObjectDescriptor> multimediaobjectIds = ol.getAllObjects();
ol.close();
return new MediaObjectQueryResult("", multimediaobjectIds);
}
use of org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult in project cineast by vitrivr.
the class AbstractQueryMessageHandler method submitPrefetchedSegmentandObjectInformationfromIDs.
List<String> submitPrefetchedSegmentandObjectInformationfromIDs(Session session, String queryId, List<MediaSegmentDescriptor> segments, List<String> objectIds) {
LOGGER.trace("Loading object information");
final List<MediaObjectDescriptor> objects = this.loadObjects(objectIds, queryId.substring(0, 3));
if (segments.isEmpty() || objects.isEmpty()) {
LOGGER.traceEntry("Segment / Objectlist is Empty, ignoring this iteration");
}
LOGGER.trace("Writing results to the websocket");
/* Write segments, objects and similarity search data to stream. */
this.write(session, new MediaObjectQueryResult(queryId, objects));
this.write(session, new MediaSegmentQueryResult(queryId, segments));
return objectIds;
}
use of org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult 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()));
}
Aggregations