rule "Inserting rule"
salience 10
when
then
Resource resource1 = new Resource();
resource1.setName("Resource 1");
resource1.setAmount("5");
insert(resource1);
System.out.println("Resource is set");
end
rule "Modifying rule"
salience 20
when
$resource1: Resource(name == "Resource 1")
then
modify($resource1) {setAmount("20")};
System.out.println("Resource is modified to 20");
end
rule "Accumulating rule"
salience 30
when
Resource(amount != "")
$total: Number() from accumulate(
Resource($amount: Double.parseDouble(amount)),
sum($amount))
then
System.out.println("Accumulated: " + $total);
end