Class QueryServiceEndPoint


  • @Produces("application/json")
    @Consumes("application/json")
    @Path("/query")
    public class QueryServiceEndPoint
    extends Object
    A JAX-RS endpoint to perform queries against context-server data.
    • Constructor Detail

      • QueryServiceEndPoint

        public QueryServiceEndPoint()
    • Method Detail

      • setQueryService

        public void setQueryService​(QueryService queryService)
      • setLocalizationHelper

        public void setLocalizationHelper​(LocalizationHelper localizationHelper)
      • getAggregate

        @GET
        @Path("/{type}/{property}")
        public Map<String,​Long> getAggregate​(@PathParam("type")
                                                   String type,
                                                   @PathParam("property")
                                                   String property)
        Retrieves the number of items with the specified type as defined by the Item subclass public field ITEM_TYPE and aggregated by possible values of the specified property.
        Parameters:
        type - the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE field
        property - the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that value
        Returns:
        a Map associating a specific value of the property to the cardinality of items with that value
        See Also:
        Item for a discussion of
      • getAggregate

        @POST
        @Path("/{type}/{property}")
        public Map<String,​Long> getAggregate​(@PathParam("type")
                                                   String type,
                                                   @PathParam("property")
                                                   String property,
                                                   @QueryParam("optimizedQuery")
                                                   boolean optimizedQuery,
                                                   AggregateQuery aggregateQuery)
        TODO: rework, this method is confusing since it either behaves like getAggregate(String, String) if query is null but completely differently if it isn't Retrieves the number of items with the specified type as defined by the Item subclass public field ITEM_TYPE and aggregated by possible values of the specified property or, if the specified query is not null, perform that aggregate query. Also return the global count of document matching the ITEM_TYPE if you don't use optimizedQuery or set it to false, otherwise if optimizedQuery is set to true then it won't return the global count but the query will be executed much faster.
        Parameters:
        type - the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE field
        property - the property we're aggregating on, i.e. for each possible value of this property, we are counting how many items of the specified type have that value
        aggregateQuery - the AggregateQuery specifying the aggregation that should be performed
        optimizedQuery - the optimizedQuery specifying if we should optimized the aggregate query or not
        Returns:
        a Map associating a specific value of the property to the cardinality of items with that value
        See Also:
        Item for a discussion of
      • getMetric

        @POST
        @Path("/{type}/{property}/{metricTypes:((sum|avg|min|max)/?)*}")
        public Map<String,​Double> getMetric​(@PathParam("type")
                                                  String type,
                                                  @PathParam("property")
                                                  String property,
                                                  @PathParam("metricTypes")
                                                  String metricsType,
                                                  Condition condition)
        Retrieves the specified metrics for the specified field of items of the specified type as defined by the Item subclass public field ITEM_TYPE and matching the specified Condition.
        Parameters:
        condition - the condition the items must satisfy
        metricsType - a String specifying which metrics should be computed, separated by a slash (/) (possible values: sum for the sum of the values, avg for the average of the values, min for the minimum value and max for the maximum value)
        property - the name of the field for which the metrics should be computed
        type - the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE field
        Returns:
        a Map associating computed metric name as key to its associated value
        See Also:
        Item for a discussion of
      • getQueryCount

        @POST
        @Path("/{type}/count")
        public long getQueryCount​(@PathParam("type")
                                  String type,
                                  @QueryParam("validate")
                                  Boolean validate,
                                  Condition condition,
                                  @Context
                                  javax.servlet.http.HttpServletResponse response)
        Retrieves the number of items of the specified type as defined by the Item subclass public field ITEM_TYPE and matching the specified Condition.
        Parameters:
        condition - the condition the items must satisfy
        validate - optional parameter, in case of draft condition that have missing required parameters an IllegalArgumentException is throw and this end point will return status code 400, to avoid that you can set validate to false.
        type - the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE field
        response - the httpServletResponse
        Returns:
        the number of items of the specified type. 0 and status code 400 in case of IllegalArgumentException (bad condition) and validate null or true 0 and status code 200 in case of IllegalArgumentException (bad condition) and validate false
        See Also:
        Item for a discussion of