Я пытаюсь написать правила слюни, используя два разных класса POJO, как показано ниже.
for (int i = 0; i < 5; i++) {
dbRules = new DbRules(i, "Rule Name - " + i, " $mdmContractHeader : MdmContractHeader(); $contractHeader1 : ContractHeader (supplierName==$mdmContractHeader.supplierName); "
+ " && contractHeader:ContractHeader(supplierId >= 100)",
"System.out.print(\"Test, Drools rule - " + i
+ ".! \"); System.out.println(contractHeader.getSupplierName());");
list.add(dbRules);
}
После выполнения я сталкиваюсь с нижеуказанным исключением.Похоже, что я получаю ошибку с объявлением класса pojo.
Exception in thread "main" java.lang.RuntimeException: Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:306 mismatched input '$contractHeader1' in rule "Rule Name - 0"]
Message [id=2, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:723 mismatched input '$contractHeader1' in rule "Rule Name - 1"]
Message [id=3, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1140 mismatched input '$contractHeader1' in rule "Rule Name - 2"]
Message [id=4, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1557 mismatched input '$contractHeader1' in rule "Rule Name - 3"]
Message [id=5, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=1, column=0
text=[ERR 102] Line 1:1974 mismatched input '$contractHeader1' in rule "Rule Name - 4"]
Message [id=6, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=0, column=0
text=Parser returned a null Package]
---
Warning Messages:
---
Info Messages:
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:467)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:453)
at com.sample.StringDroolsMdm.executeRules(StringDroolsMdm.java:118)
at com.sample.StringDroolsMdm.main(StringDroolsMdm.java:70)
Я обновил содержимое в StringBuffer, как показано ниже, но все еще получаю то же исключение.
import com.model.ContractHeader;
import com.model.MdmContractHeader;
import static com.service.SupplierService.isRuleAppliesToSupplier;
rule "Rule Name - 0"
when
cHeader:ContractHeader()
eval(isRuleAppliesToSupplier((cHeader.getSupplierName()) , 0 )) &&
(
$mdmContractHeader:MdmContractHeader($s : supplierName)
$myContractHeader:ContractHeader(supplierName == $s)
contractHeader:ContractHeader(supplierId >= 100)
)
then
System.out.print("Test, Drools rule - 0.! "); System.out.println(contractHeader.getSupplierName());
end;
И исключение:
Exception in thread "main" java.lang.RuntimeException: Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=10, column=0
text=[ERR 102] Line 10:1 mismatched input '$myContractHeader' in rule "Rule Name - 0"]
Message [id=2, kieBase=defaultKieBase, level=ERROR, path=rules/Sample.drl, line=0, column=0
text=Parser returned a null Package]
---