[jboss-jira] [JBoss JIRA] (DROOLS-423) Wrong variable substitution when using date regex in dsl [when] construct

jan klok (JIRA) issues at jboss.org
Fri Feb 7 02:08:28 EST 2014


jan klok created DROOLS-423:
-------------------------------

             Summary: Wrong variable substitution when using date regex in dsl [when] construct
                 Key: DROOLS-423
                 URL: https://issues.jboss.org/browse/DROOLS-423
             Project: Drools
          Issue Type: Feature Request
      Security Level: Public (Everyone can see)
    Affects Versions: 6.0.1.Final
         Environment: windows 7
            Reporter: jan klok
            Assignee: Mark Proctor
            Priority: Critical


I have created an dsl with (among others) contains the following substitution rules;
[when][]{day:((0)?[1-9]|[12][0-9]|3[01])}[-/ ]{month:((0)?[1-9]|1[012])}[-/ ]{year:(19|20)\d\d}=%{day}/{month}/{year}%


when the following dslr rule is transformed using this dsl  : 

rule "validation_4"
 no-loop true
    dialect "mvel"
when
  Als bij een "vrijstellingsaanvraag" dossier de
     - gebDat is 25-08-1990 
 then
  Log "Validation_4 Ok : gebDat is 25-08-1990"
end

the date 25-08-1990 is transformed to %25/25/null%.

This is the complete dsl :
=========================================================
#/ result steps
//------------------------------------------------------------
//                    operator mappings
//------------------------------------------------------------

[when][](is )?groter (dan)?(als)?(of)? gelijk( aan)?=<=
[when][](is )?kleiner( dan)?( als)?=<
[when][](is )?groter( dan)?( als)?=>
[when][](is )?gelijk( aan)?===
[when][](is )?ongelijk( aan)?=!=
[when][]is===

//------------------------------------------------------------
//                    value mappings
//------------------------------------------------------------

[when][](waar|ja)=true
[when][](niet waar|onwaar|nee)=false
[when][](leeg|niet gevuld)=null

[when][]{year:(19|20)\d\d}[-/ ]{month:((0)?[1-9]|1[012])}[-/ ]{day:((0)?[1-9]|[12][0-9]|3[01])}=%{day}/{month}/{year}%
[when][]{day:((0)?[1-9]|[12][0-9]|3[01])}[-/ ]{month:((0)?[1-9]|1[012])}[-/ ]{year:(19|20)\d\d}=%{day}/{month}/{year}%

//------------------------------------------------------------
//                    condition mappings
//------------------------------------------------------------
[when][]Als bij een "{folderDefName}" dossier de=$FLDR : FolderInf(getDefinition().getName() == "{folderDefName}")
[when][]- {field:\w*} {operator} {value:(true|false)}=getAttribute('{field}').getBoolean().booleanValue() {operator} {value} 
[when][]- {field:\w*} {operator} "{value:.+}"=getAttribute('{field}').getString() {operator} '{value}'
[when][]- {field:\w*} {operator} %{value:.+}%=getAttribute('{field}').getDate().getTime() {operator} LocalDate.parse('{value}',DateTimeFormat.forPattern('d-MM-yyyy')).toDate().getTime()

[when][]- {field:\w*} {operator} {value:\d+}=getAttribute('{field}').getLong().intValue() {operator} {value}  
[when][]- {field:\w*} {operator} {value:null}=getAttribute('{field}') {operator} {value} 


=========================================================

This is the DRL: 

=======================================================
package org.drools.examples.templates;
import nl.caci.folderengine.domain.FolderInf;
import nl.caci.folderengine.domain.definition.FolderDefinition;
expander lisaconcepts.dsl

rule "validation_4"
 no-loop true
    dialect "mvel"
when
  Als bij een "vrijstellingsaanvraag" dossier de
     - gebDat is 25-08-1990 
 then
  Log "Validation_4 Ok : gebDat is 25-08-1990"
end


--
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