[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2052) DrlDumper does wrong dumps, when lhs contains complex conditions with And.
Kateryna Rudenko (JIRA)
jira-events at lists.jboss.org
Thu Apr 9 03:42:22 EDT 2009
[ https://jira.jboss.org/jira/browse/JBRULES-2052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kateryna Rudenko updated JBRULES-2052:
--------------------------------------
Attachment: DrlDumper.java.patch
Proposed temporary solution: DrlDumper dumps lhs in one string and encloses all OR conditions' operands in brackets.
> DrlDumper does wrong dumps, when lhs contains complex conditions with And.
> ----------------------------------------------------------------------------
>
> Key: JBRULES-2052
> URL: https://jira.jboss.org/jira/browse/JBRULES-2052
> Project: JBoss Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core
> Affects Versions: 5.0.0.CR1
> Reporter: Kateryna Rudenko
> Assignee: Mark Proctor
> Attachments: DrlDumper.java.patch
>
>
> DrlDumper does wrong dumps, when lhs contains complex conditions with And.
> When there is ConditionalElementDescr in other ConditionalElementDescr, DrlDumper prints condition without round brackets. But should, because formed text can not be parsed with DrlParser into the same tree structure.
> Example 1.
> rule in file "Test1.drl":
> rule "continued_rule"
> no-loop true
> when
> ($a : Action1() || $b : Action2())
> &&
> ($c : Action3() || $d : Action4())
> then
> System.out.println("Fired.");
> end
> And method:
> public void test1() throws DroolsParserException
> {
> DrlParser parser = new DrlParser();
> final InputStream drl = getClass().getResourceAsStream(
> "Test1.drl");
> final PackageDescr packageDescr = parser.parse(drl);
> if (parser.hasErrors())
> {
> Assert.fail(parser.getErrors().toString());
> }
> final String dump = new DrlDumper().dump(packageDescr);
> System.out.println(dump);
> }
> Output is:
> rule "continued_rule"
> no-loop true
> when
> $a : Action1( ) || $b : Action2( ) && $c : Action3( ) || $d : Action4( )
> then
> System.out.println("Fired.");
> end
> According to operation priority in this case will be
> $a : Action1( ) || ($b : Action2( ) && $c : Action3( )) || $d : Action4( )
> and it is quite another operation.
> DrlDumper should support brackets to save operation grouping.
> Example 2.
> Rule
> rule "continued_rule2"
> no-loop true
> when
> ($a : Action1() && $b : Action2())
> ||
> ($c : Action3() && $d : Action4())
> then
> System.out.println("Fired.");
> end
> Out after performing test1() from Example 1:
> rule "continued_rule"
> no-loop true
> when
> $a : Action1( ) || $c : Action3( )
> then
> System.out.println("Fired.");
> end
> DrlDumper lost $b : Action2() and $d : Action4()! It happened because processOrDescrList in DrlDumper.
> In string
> if ( descrString.endsWith( DrlDumper.eol ) ) {
> descrString = descrString.substring( 0,
> descrString.indexOf( DrlDumper.eol ) );
> }
> we lose all subconditions except first line. It should be
> if ( descrString.endsWith( DrlDumper.eol ) ) {
> descrString = descrString.substring( 0,
> descrString.LastIndexOf( DrlDumper.eol ) );
> }.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list