0

Hello I it is my first time involved in drools project. I have created some simple rules that work fine, however I have trouble with more complex rules that use the accumulate function. Below I have this rule.

rule "1"
no-loop
when 
    $msg : Declaration(header.totalGrossMassMeasure != null, 
    header.totalGrossMassMeasure.compareTo(BigDecimal.ZERO) > 0 )
     result : ValidationResult()
    $netValue : Number() from accumulate (
    GoodsItemsType($net : netNetWeightMeasure),
    sum($net.doubleValue())
    )
eval($netValue.doubleValue() > ($msg.getHeader().getTotalGrossMassMeasure().doubleValue() + (0.45 * $msg.getGoodsItems().size())))
then
RulesValidationError error = new RulesValidationError();
error.setErrorType(ErrorType.INCORECT_VALUE);
result.getErrorsList().add(error);
end

the concept is to sum the net value from a list of goodsItemType object and compare the sum to the total gross mass measure multiplied by one buffer number. The problem is I have been trying last couple of days not being able to fire the rule with anything. Could someone please help me?

IsidIoan
  • 403
  • 2
  • 5
  • 13
  • You may have to show much more of code and data to get any help. At least, start with removing the `eval` and add a print for `$netValue.doubleValue()` and `$msg.getHeader().getTotalGrossMassMeasure().doubleValue() + 0.45 * $msg.getGoodsItems().size()` and add these values to your question. – laune Dec 01 '17 at 10:43
  • the problem is I am using the java client api and I have deployed my rules through drools workbench located in a different server. So I do not know if print would work – IsidIoan Dec 01 '17 at 11:06
  • Actually you are saying that you don't know where to find standard output from your applications... ? Did you try? – laune Dec 01 '17 at 12:42
  • ok the problem is that the sum value, in other words $netValue.doubleValue() equals to 0 – IsidIoan Dec 01 '17 at 13:43
  • The you don't have any `GoodsItemsType` facts inserted in Working Memory, or they all have `netNetWeightMeasure` set to zero, or their sum is zero. (Is `netNet...` correct?) – laune Dec 01 '17 at 15:23

0 Answers0