[rules-users] Disabling strict mode in 5.4
Joe White
Joe.White at recondotech.com
Fri May 25 15:57:52 EDT 2012
Sorry about that. Here is the base rule:
rule "PEL_CHANGELIST_RES.AUTH.Actual Person Base"
when
$in : Map($merged : this['MERGED_EPISODE'] != null, $existing :
this['REFERENCE_EPISODE'] != null, $changeList :
this['AUTH_CHANGELIST'] != null)
not(String(this ==
EncounterConsts.Episode.PersonRole.Person.path) from $changeList)
DalMap($existingPersonRoles : this['EPISODE.PERSON_ROLE'] !=
null) from $existing
DalMap(this[EncounterConsts.PersonRole.RoleType] == 1,
$existingPersons : this['PERSON_ROLE.PERSON'] != null) from
$existingPersonRoles
DalMap($mergedPersonRoles : this['EPISODE.PERSON_ROLE'] != null)
from $merged
DalMap(this[EncounterConsts.PersonRole.RoleType] == 1,
$mergedPersons : this['PERSON_ROLE.PERSON'] != null) from
$mergedPersonRoles
$existingPerson : DalMap() from $existingPersons
$mergedPerson : DalMap() from $mergedPersons
then
end
And here is the original again:
rule "PEL_CHANGELIST_RES.AUTH.Actual First Name" extends
"PEL_CHANGELIST_RES.AUTH.Actual Person Base"
when
DalMap($existingValue : this['PERSON.FirstName'] != null) from
$existingPerson
DalMap($mergedValue : this['PERSON.FirstName'] != null) from
$mergedPerson
$lowerExisting : String() from $existingValue.toLowerCase()
String(this != $lowerExisting) from $mergedValue.toLowerCase()
then
$changeList.add(EncounterConsts.Episode.PersonRole.Person.path);
update($in);
end
In terms of your "why not" there is no reason not to structure it your
way other than I have lots of rules structured this way that I would
rather not re-write. If it helps in terms of getting strict mode
disabled I can find a more semantically pleasing example. The heart of
the problem is that you cannot interact with data that comes from a Map
with strict mode turned on.
-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Friday, May 25, 2012 1:40 PM
To: Rules Users List
Subject: Re: [rules-users] Disabling strict mode in 5.4
On 25/05/2012, Joe White <Joe.White at recondotech.com> wrote:
> The exception below is one of thousands like it. The problem is that
the
> data is coming from a Map and in strict mode mvel is unable to
determine
> the type. This rule works fine with strict mode off in 5.0.1 and 5.2.
>
> The rule is:
Well... Don't you mean "part of the rule is:"?
>
> rule "PEL_CHANGELIST_RES.AUTH.Actual First Name" extends
> "PEL_CHANGELIST_RES.AUTH.Actual Person Base"
> when
> DalMap($existingValue : this['PERSON.FirstName'] != null) from
> $existingPerson
Unlikely: Where is $existingPerson coming from?
> DalMap($mergedValue : this['PERSON.FirstName'] != null) from
> $mergedPerson
Unlikely: Where is $mergedPerson coming from?
> $lowerExisting : String() from $existingValue.toLowerCase()
> String(this != $lowerExisting) from $mergedValue.toLowerCase()
Why not simply:
eval( ! $existingValue.toLowerCase().equals(
$mergedValue.toLowerCase() ) )
> then
>
$changeList.add(EncounterConsts.Episode.PersonRole.Person.path);
$changeList ??
> update($in);
$in ??
> end
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Wolfgang
Laun
> Sent: Friday, May 25, 2012 12:43 PM
> To: Rules Users List
> Subject: Re: [rules-users] Disabling strict mode in 5.4
>
> Line 3 of the error message suggests that the parser isn't able to
> determine the type of $existingValue as java.lang.String. So, strict
> or no strict, the problem might be in the rule. Show?
>
> -W
>
>
>
> On 25/05/2012, Joe White <Joe.White at recondotech.com> wrote:
>> How do you disable strict mode in 5.4? We are using the code below
and
>> getting strict mode exceptions. It worked in prior versions. Do you
> have
>> to use the new APIs to disable strict mode?
>>
>>
>>
>>
>>
>> PackageBuilderConfiguration pkgBuilderCfg = new
>> PackageBuilderConfiguration();
>>
>> MVELDialectConfiguration mvelConf = (MVELDialectConfiguration)
>> pkgBuilderCfg.getDialectConfiguration( "mvel" );
>>
>> mvelConf.setStrict(false);
>>
>> mvelConf.setLangLevel(5);
>>
>> PackageBuilder builder = new PackageBuilder(pkgBuilderCfg);
>>
>> builder.addPackageFromDrl(new StringReader(drlString));
>>
>>
>>
>>
>>
>> An example exception:
>>
>> 1.
>>
>
19:17:51,137|ERROR|drools.DroolsMgr|DroolsMgr.java|159|deployRulesFromMo
>>
>
delForScope|org.apache.camel.spring.Main.main()|smf-rcp-SNAPSHOT|Failed
>> to deploy rules from model
>>
>> 2. com.recondotech.hre.rules.management.HRERulesManagmentException:
>> org.drools.rule.InvalidRulePackage: Unable to Analyse Expression
>> $existingValue.toLowerCase():
>>
>> 3. [Error: unable to resolve method using strict-mode:
>> java.lang.Object.toLowerCase()]
>>
>> 4. [Near : {... $existingValue.toLowerCase() ....}]
>>
>> 5. ^ : [Rule
>> name='PEL_CHANGELIST_RES.AUTH.Actual First Name']
>>
>>
>>
>>
>>
>> Thanks
>>
>> Joe
>>
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
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