GroupTable aggregation

I have following groupTable where I want to aggregate the value of field ScoreObtained by VendorEvaluationCriteriaType.

33%20PM

Based on the user guide, I tried the following but I get 0 result in the expected cell as you can see above.

public void setAggregation() {

    MetaPropertyPath metaPropertyPath = vendorEvaluationLineDs.getMetaClass().getPropertyPath("scoreObtained");

    AggregationInfo info = new AggregationInfo();
    info.setPropertyPath(metaPropertyPath);
    info.setStrategy(new VendorEvaluationTypeAggregation());

    vendorEvaluationLineGroupTable.getColumn("scoreObtained")
            .setAggregation(info);
}


public class VendorEvaluationTypeAggregation implements AggregationStrategy<VendorEvaluationCriteriaType, BigDecimal> {
    @Override
    public BigDecimal aggregate(Collection<VendorEvaluationCriteriaType> propertyValues) {
        BigDecimal sumValue = BigDecimal.ZERO;
        if (CollectionUtils.isNotEmpty(propertyValues)) {
            for (VendorEvaluationCriteriaType criteriaType :  vendorEvaluationCriteriaTypesDs.getItems()) {
                sumValue = getItem().getVendorEvaluationLine()
                        .stream()
                        .filter(e -> e.getVendorEvaluationCriteria().getVendorEvaluationCriteriaType().equals(criteriaType))
                        .map(VendorEvaluationLine::getScoreObtained)
                        .reduce(BigDecimal.ZERO, BigDecimal::add);
            }
        }

        if(sumValue==null) {
            sumValue = BigDecimal.ZERO;
            return sumValue;
        }

        return sumValue;
    }

    @Override
    public Class<BigDecimal> getResultClass() {
        return BigDecimal.class;
    }
}

Thanks for your help.

Hello @mortozakhan

Could you clarify your data model and how it is used?

Moreover types of your custom AggregationStrategy are strange - as I can see you’re trying to aggregate BigDecimal values from scoreObtained property, but the VendorEvaluationCriteriaType class is used as property values type (see AggregationStrategy JavaDoc), while the table contains items of this type. It seems that you have to declare custom aggregation strategy as AggregationStrategy<BigDecimal, BigDecimal>.

Please describe your task in more details.

Regards,
Daniil

Hi Daniil
Here is the details of the task.
This is related to after audit evaluation of vendors where there are different evaluation criterias to evaluate. Evaluation criterias are categorized called “VendorEvaluationCriteriaType”. This VendorEvaluationCriteriaType is an Entity.

Here is the List of Entities

  1. VendorEvaluation
  2. VendorEvaluationLine (composite of VendorEvaluation)
    You will find the image of the interface where the contents of VendorEvaluationLine is there where VendorEvaluationCriteriaType is a field in it which is another Entity by which I want to group the column value “ScoreObtained”.

I hope it is clear now!