Search in sources :

Example 1 with AggregationType

use of io.gravitee.rest.api.model.analytics.query.AggregationType in project gravitee-management-rest-api by gravitee-io.

the class EnvironmentAnalyticsResource method executeDateHisto.

private Analytics executeDateHisto(AnalyticsParam analyticsParam, String extraFilter) {
    DateHistogramQuery query = new DateHistogramQuery();
    query.setFrom(analyticsParam.getFrom());
    query.setTo(analyticsParam.getTo());
    query.setInterval(analyticsParam.getInterval());
    query.setQuery(analyticsParam.getQuery());
    List<Aggregation> aggregations = analyticsParam.getAggregations();
    if (aggregations != null) {
        List<io.gravitee.rest.api.model.analytics.query.Aggregation> aggregationList = aggregations.stream().map((Function<Aggregation, io.gravitee.rest.api.model.analytics.query.Aggregation>) aggregation -> new io.gravitee.rest.api.model.analytics.query.Aggregation() {

            @Override
            public AggregationType type() {
                return AggregationType.valueOf(aggregation.getType().name().toUpperCase());
            }

            @Override
            public String field() {
                return aggregation.getField();
            }
        }).collect(Collectors.toList());
        query.setAggregations(aggregationList);
    }
    addExtraFilter(query, extraFilter);
    return analyticsService.execute(query);
}
Also used : AggregationType(io.gravitee.rest.api.model.analytics.query.AggregationType) DateHistogramQuery(io.gravitee.rest.api.model.analytics.query.DateHistogramQuery) Aggregation(io.gravitee.rest.api.management.rest.resource.param.Aggregation) Function(java.util.function.Function)

Aggregations

Aggregation (io.gravitee.rest.api.management.rest.resource.param.Aggregation)1 AggregationType (io.gravitee.rest.api.model.analytics.query.AggregationType)1 DateHistogramQuery (io.gravitee.rest.api.model.analytics.query.DateHistogramQuery)1 Function (java.util.function.Function)1