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);
}
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);
}
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);
}
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));
}
}
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)));
}
Aggregations