[rules-users] if statement in MVEL consequence

Mark Proctor mproctor at codehaus.org
Tue Aug 14 14:42:44 EDT 2007


imperative logic is disable, it promotes bad rules, we don't plan to add 
it back in. We suggest you call a function that encapsulates this logic.

Mark
mark.mcnally at comcast.net wrote:
> Hello, 
>
> I would like to conditionally attempt logging in the consequence of each rule but it does not like the 'if' statement.
>
> Without the 'if', it works fine. It appears to work fine for the java dialect as well - only complains for MVEL dialect. 
> It does not appear to be related to the logger instance because even "if (true)"  causes similar Exception.
> I also tried with and without the curly braces.
>
>
> global org.apache.commons.logging.Log logger
>
> rule Language
>     dialect "mvel"
> 	salience 800
> 	when
> 	$pd : ParticipantDetails( $ptLanguage : participant.languagePreferenceCD  )
> 	$nd : NurseDetails( languages not contains $ptLanguage )	
> 	then	
>   	    if (logger.isDebugEnabled()) 
>   	         logger.debug("LanguageMismatch -  ptId: " + $pd.participant.id + ", Lang: " + $ptLanguage + ", staffId: "  + $nd.staffId );
>         [...]  	      
> end
>
>
>
> * (1,28) unable to resolve method using strict-mode: java.lang.Object.if(...)
> Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'primaryNurseAssignmentService' defined in class path resource 
> [...]
> nested exception is org.drools.rule.InvalidRulePackage: Unable to build expression for 'consequence' '  	    
> if (logger.isDebugEnabled()) 
>   	    logger.debug("LanguageMismatch -  ptId: " + $pd.participant.id + ", Lang: " + $ptLanguage + ", staffId: "  + $nd.staffId );
>
>
> Should what I am attempting work? 
>
> Thanks,
> Mark  
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>   




More information about the rules-users mailing list