Search in sources :

Example 1 with MediaObjectQueryResult

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));
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectQueryResult(org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult) MediaObjectReader(org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)

Example 2 with MediaObjectQueryResult

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);
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectQueryResult(org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult) MediaObjectReader(org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)

Example 3 with MediaObjectQueryResult

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;
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectQueryResult(org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult) MediaSegmentQueryResult(org.vitrivr.cineast.api.messages.result.MediaSegmentQueryResult)

Example 4 with MediaObjectQueryResult

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()));
}
Also used : MediaObjectDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor) MediaObjectQueryResult(org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult) MediaObjectReader(org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)

Aggregations

MediaObjectQueryResult (org.vitrivr.cineast.api.messages.result.MediaObjectQueryResult)4 MediaObjectDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor)4 MediaObjectReader (org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)3 MediaSegmentQueryResult (org.vitrivr.cineast.api.messages.result.MediaSegmentQueryResult)1