Search in sources :

Example 1 with DateAggregator

use of com.bakdata.conquery.models.query.queryplan.DateAggregator in project conquery by bakdata.

the class EntityDateQueryPlan method execute.

@Override
public Optional<MultilineEntityResult> execute(QueryExecutionContext ctx, Entity entity) {
    // Don't set the query date aggregator here because the subqueries should set their aggregator independently
    // Execute the prerequisite query
    Optional<EntityResult> preResult = query.execute(ctx, entity);
    if (preResult.isEmpty()) {
        return Optional.empty();
    }
    Optional<DateAggregator> validityDateAggregator = query.getValidityDateAggregator();
    if (validityDateAggregator.isEmpty()) {
        return Optional.empty();
    }
    final CDateSet aggregationResult = validityDateAggregator.get().createAggregationResult();
    aggregationResult.retainAll(dateRestriction);
    // Generate DateContexts in the provided resolutions
    List<DateContext> contexts = new ArrayList<>();
    for (CDateRange range : aggregationResult.asRanges()) {
        contexts.addAll(DateContext.generateAbsoluteContexts(range, resolutionsAndAlignments));
    }
    FormQueryPlan resolutionQuery = new FormQueryPlan(contexts, features);
    return resolutionQuery.execute(ctx, entity);
}
Also used : ArrayList(java.util.ArrayList) CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) EntityResult(com.bakdata.conquery.models.query.results.EntityResult) MultilineEntityResult(com.bakdata.conquery.models.query.results.MultilineEntityResult) DateContext(com.bakdata.conquery.models.forms.util.DateContext) DateAggregator(com.bakdata.conquery.models.query.queryplan.DateAggregator) CDateSet(com.bakdata.conquery.models.common.CDateSet)

Example 2 with DateAggregator

use of com.bakdata.conquery.models.query.queryplan.DateAggregator in project conquery by bakdata.

the class RelativeFormQueryPlan method getValidityDateAggregator.

@Override
public Optional<Aggregator<CDateSet>> getValidityDateAggregator() {
    DateAggregator agg = new DateAggregator(DateAggregationAction.MERGE);
    featureSubquery.getValidityDateAggregator().ifPresent(agg::register);
    outcomeSubquery.getValidityDateAggregator().ifPresent(agg::register);
    return agg.hasChildren() ? Optional.of(agg) : Optional.empty();
}
Also used : DateAggregator(com.bakdata.conquery.models.query.queryplan.DateAggregator)

Aggregations

DateAggregator (com.bakdata.conquery.models.query.queryplan.DateAggregator)2 CDateSet (com.bakdata.conquery.models.common.CDateSet)1 CDateRange (com.bakdata.conquery.models.common.daterange.CDateRange)1 DateContext (com.bakdata.conquery.models.forms.util.DateContext)1 EntityResult (com.bakdata.conquery.models.query.results.EntityResult)1 MultilineEntityResult (com.bakdata.conquery.models.query.results.MultilineEntityResult)1 ArrayList (java.util.ArrayList)1