@Test(expected = TDPException.class) public void shouldNotAggregateBecauseNoOperation() { service.aggregate(new AggregationParameters(), new DataSet()); }
public AggregationResult aggregate(AggregationParameters parameters, DataSet dataset) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new TDPException(CommonErrorCodes.BAD_AGGREGATION_PARAMETERS); } AggregationResult result = new AggregationResult(parameters.getOperations().get(0).getOperator()); Aggregator aggregator = factory.get(parameters); final DataSetMetadata metadata = dataset.getMetadata(); final RowMetadata rowMetadata = metadata != null ? metadata.getRowMetadata() : new RowMetadata(); final Predicate<DataSetRow> filter = filterService.build(parameters.getFilter(), rowMetadata); dataset.getRecords().filter(filter).forEach(row -> aggregator.accept(row, result)); aggregator.normalize(result); return result; }
AggregationService { public AggregationResult aggregate(AggregationParameters parameters, DataSet dataset) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new TDPException(CommonErrorCodes.BAD_AGGREGATION_PARAMETERS); } AggregationResult result = new AggregationResult(parameters.getOperations().get(0).getOperator()); Aggregator aggregator = factory.get(parameters); final DataSetMetadata metadata = dataset.getMetadata(); final RowMetadata rowMetadata = metadata != null ? metadata.getRowMetadata() : new RowMetadata(); final Predicate<DataSetRow> filter = filterService.build(parameters.getFilter(), rowMetadata); dataset.getRecords().filter(filter).forEach(row -> aggregator.accept(row, result)); aggregator.normalize(result); return result; } }
AggregationService { public AggregationResult aggregate(AggregationParameters parameters, DataSet dataset) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new TDPException(CommonErrorCodes.BAD_AGGREGATION_PARAMETERS); } AggregationResult result = new AggregationResult(parameters.getOperations().get(0).getOperator()); Aggregator aggregator = factory.get(parameters); final DataSetMetadata metadata = dataset.getMetadata(); final RowMetadata rowMetadata = metadata != null ? metadata.getRowMetadata() : new RowMetadata(); final Predicate<DataSetRow> filter = filterService.build(parameters.getFilter(), rowMetadata); dataset.getRecords().filter(filter).forEach(row -> aggregator.accept(row, result)); aggregator.normalize(result); return result; }  }
AggregationService { public AggregationResult aggregate(AggregationParameters parameters, DataSet dataset) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new TDPException(CommonErrorCodes.BAD_AGGREGATION_PARAMETERS); } AggregationResult result = new AggregationResult(parameters.getOperations().get(0).getOperator()); Aggregator aggregator = factory.get(parameters); final DataSetMetadata metadata = dataset.getMetadata(); final RowMetadata rowMetadata = metadata != null ? metadata.getRowMetadata() : new RowMetadata(); final Predicate<DataSetRow> filter = filterService.build(parameters.getFilter(), rowMetadata); dataset.getRecords().filter(filter).forEach(row -> aggregator.accept(row, result)); aggregator.normalize(result); return result; }  AggregationResult aggregate(AggregationParameters parameters, DataSet dataset); }
AggregationService { public AggregationResult aggregate(AggregationParameters parameters, DataSet dataset) { if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) { throw new TDPException(CommonErrorCodes.BAD_AGGREGATION_PARAMETERS); } AggregationResult result = new AggregationResult(parameters.getOperations().get(0).getOperator()); Aggregator aggregator = factory.get(parameters); final DataSetMetadata metadata = dataset.getMetadata(); final RowMetadata rowMetadata = metadata != null ? metadata.getRowMetadata() : new RowMetadata(); final Predicate<DataSetRow> filter = filterService.build(parameters.getFilter(), rowMetadata); dataset.getRecords().filter(filter).forEach(row -> aggregator.accept(row, result)); aggregator.normalize(result); return result; }  AggregationResult aggregate(AggregationParameters parameters, DataSet dataset);  }