[jboss-jira] [JBoss JIRA] (JBRULES-2052) DrlDumper does wrong dumps, when lhs contains complex conditions with And.

Mark Proctor (JIRA) jira-events at lists.jboss.org
Mon Nov 12 04:17:18 EST 2012


     [ https://issues.jboss.org/browse/JBRULES-2052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor updated JBRULES-2052:
----------------------------------

    Fix Version/s: 6.0.0.Alpha1

    
> DrlDumper does wrong dumps, when lhs contains complex conditions with And.  
> ----------------------------------------------------------------------------
>
>                 Key: JBRULES-2052
>                 URL: https://issues.jboss.org/browse/JBRULES-2052
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 5.0.0.CR1
>            Reporter: Kateryna Rudenko
>            Assignee: Mario Fusco
>              Labels: DrlDumper, dump
>             Fix For: 6.0.0.Alpha1
>
>         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, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list