Search in sources :

Example 16 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class EventDurationSumAggregator method acceptEvent.

@Override
public void acceptEvent(Bucket bucket, int event) {
    if (validityDateColumn == null) {
        return;
    }
    if (!bucket.has(event, validityDateColumn)) {
        return;
    }
    final CDateRange value = bucket.getAsDateRange(event, validityDateColumn);
    if (value.isOpen()) {
        return;
    }
    set.maskedAdd(value, dateRestriction);
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange)

Example 17 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class QuarterAggregator method acceptEvent.

@Override
public void acceptEvent(Bucket bucket, int event) {
    if (getColumn() == null || !bucket.has(event, getColumn())) {
        return;
    }
    final CDateRange value = bucket.getAsDateRange(event, getColumn());
    if (value.isOpen()) {
        return;
    }
    set.maskedAdd(value, dateRestriction);
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange)

Example 18 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class DateRestrictingNode method isOfInterest.

@Override
public boolean isOfInterest(Bucket bucket) {
    CBlock cBlock = Objects.requireNonNull(preCurrentRow.get(bucket));
    if (validityDateColumn == null) {
        // If there is no validity date set for a concept there is nothing to restrict
        return super.isOfInterest(bucket);
    }
    CDateRange range = cBlock.getEntityDateRange(entity.getId());
    return restriction.intersects(range) && super.isOfInterest(bucket);
}
Also used : CBlock(com.bakdata.conquery.models.events.CBlock) CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange)

Example 19 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class CDateSet method maskedAdd.

public void maskedAdd(CDateRange toAdd, CDateSet mask) {
    if (mask.isEmpty()) {
        return;
    }
    if (mask.isAll()) {
        add(toAdd);
        return;
    }
    if (toAdd.isAll()) {
        addAll(mask);
        return;
    }
    if (toAdd.isExactly() && mask.contains(toAdd.getMinValue())) {
        add(toAdd);
        return;
    }
    // Look for start and end of iteration.
    Integer search = null;
    if (toAdd.hasLowerBound()) {
        search = mask.rangesByLowerBound.floorKey(toAdd.getMinValue());
    }
    if (search == null) {
        search = mask.rangesByLowerBound.firstKey();
    }
    Integer searchEnd = null;
    if (toAdd.hasUpperBound()) {
        searchEnd = mask.rangesByLowerBound.floorKey(toAdd.getMaxValue());
    }
    if (searchEnd == null) {
        searchEnd = mask.rangesByLowerBound.lastKey();
    }
    while (search != null && search <= searchEnd) {
        final CDateRange range = mask.rangesByLowerBound.get(search);
        search = mask.rangesByLowerBound.higherKey(search);
        int min = range.getMinValue();
        int max = range.getMaxValue();
        if (max < toAdd.getMinValue()) {
            continue;
        }
        if (min < toAdd.getMinValue()) {
            min = toAdd.getMinValue();
        }
        if (max > toAdd.getMaxValue()) {
            max = toAdd.getMaxValue();
        }
        // value was not contained
        if (min > max) {
            continue;
        }
        add(CDateRange.of(min, max));
    }
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange)

Example 20 with CDateRange

use of com.bakdata.conquery.models.common.daterange.CDateRange in project conquery by bakdata.

the class RangeTest method coveredQuartersNotAFullQuarter.

@Test
public void coveredQuartersNotAFullQuarter() {
    CDateRange dateRange = CDateRange.of(LocalDate.of(2000, 1, 10), LocalDate.of(2000, 3, 15));
    assertThat(dateRange.getCoveredQuarters()).containsExactlyInAnyOrder(CDateRange.of(LocalDate.of(2000, 1, 10), LocalDate.of(2000, 3, 15)));
}
Also used : CDateRange(com.bakdata.conquery.models.common.daterange.CDateRange) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CDateRange (com.bakdata.conquery.models.common.daterange.CDateRange)25 Test (org.junit.jupiter.api.Test)8 DateContext (com.bakdata.conquery.models.forms.util.DateContext)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CDateSet (com.bakdata.conquery.models.common.CDateSet)3 ArrayList (java.util.ArrayList)3 ExportForm (com.bakdata.conquery.apiv1.forms.export_form.ExportForm)2 LocalDate (java.time.LocalDate)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Column (com.bakdata.conquery.models.datasets.Column)1 Table (com.bakdata.conquery.models.datasets.Table)1 CBlock (com.bakdata.conquery.models.events.CBlock)1 ParsingException (com.bakdata.conquery.models.exceptions.ParsingException)1 DateAggregator (com.bakdata.conquery.models.query.queryplan.DateAggregator)1 EntityResult (com.bakdata.conquery.models.query.results.EntityResult)1 MultilineEntityResult (com.bakdata.conquery.models.query.results.MultilineEntityResult)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1