[
https://issues.redhat.com/browse/DROOLS-5655?page=com.atlassian.jira.plug...
]
Mario Fusco resolved DROOLS-5655.
---------------------------------
Resolution: Explained
The ObjectDataCompiler is actually unaware of drl syntax. It doesn't know what a
constraint is and remove it from the generated text in case of a null value. What it does
instead when a line is bound to one or more nulls is omitting the entire line from the
drl. In your case you could workaround the problem and obtain the result you want (if I
have understood correctly) by simply putting a constraint per line and paying attention
when the comma separating the 2 constraints should or shouldn't be added. Something
like that should work for you
{code:java}
$p : Person(
age >= @{minage}
@if{minage != null && maxage != null},@end{}
age < @{maxage}
) {code}
ObjectDataCompiler converter does not compile all template rules
----------------------------------------------------------------
Key: DROOLS-5655
URL:
https://issues.redhat.com/browse/DROOLS-5655
Project: Drools
Issue Type: Bug
Reporter: Oualid AMCHAYD
Assignee: Mario Fusco
Priority: Major
Attachments: image-2020-09-18-11-31-28-879.png
When trying to compile a rule template with a datasource, the compilers does
not compiles the rows with empty fields.
Here is the code I am using:
{code:java}
ObjectDataCompiler converter = new ObjectDataCompiler();
Collection<MyRule> rulesRep = rulerepo.findAll();
InputStream personInputStream = null;
try {
personInputStream =
ResourceFactory.newClassPathResource("rules.drt").getInputStream(); // convert
sample.drt in resource to input stream
} catch (IOException e) {
e.printStackTrace();
}
KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
String personDrl = converter.compile(rulesRep, personInputStream);
kieFileSystem.write("src/main/resources/person_rule.drl",
kieServices.getResources().newReaderResource(new StringReader(personDrl)));
{code}
This is my datasource, which have two empty fields in two rows.
!image-2020-09-18-11-31-28-879.png!
And this is the result i got for the two rows with an empty fields :
{code:java}
rule "ageRule_1"
when
then
$person.setStatus("Infant");
end
rule "ageRule_8"
when
then
$person.setStatus("Old Aged");
end
{code}
As you see the LHS are is generated in two rules.
Am i missing something or this is a normal behaviour when having empty fields.
Thanks in advance.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)