RE: [rules-users] How to use not operator in drool.

2007-09-17 Thread Arsalan S. Zaidi

Hi Edson

 

Thanks for your reply. I guess we'll try and code in a work around for
now. It would be great to have this feature though! :-)

 

I've created a feature request in Jira.
http://jira.jboss.com/jira/browse/JBRULES-1199

 

Regards,

_

Arsalan Zaidi / Capgemini - India (FS SBU) / Mumbai

Technical Architect
Mobile Phone: +91 - 9892 8970 03 / www.capgemini.com
http://www.capgemini.com/ 


Together: the Collaborative Business Experience
_



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 14 September 2007 18:42
To: Rules Users List
Subject: Re: [rules-users] How to use not operator in drool.

 


Arsalan,

Unfortunately Drools does not have a field constraint negation
operator, mostly because when writing rules, it was not needed, since
you can always negate the constraint itself. 
Although, I understand a agree with your use case. My suggestion is
for you to open a JIRA feature request and we will include that as soon
as possible in the product. 
Although, meanwhile, the only workaround I can see for your case is
to translate the expression you are using directly into a java or mvel
expression and write it inside an in-line eval.

[]s
Edson 

2007/9/14, Arsalan S. Zaidi [EMAIL PROTECTED]:

Hi 

 

I'll try to explain the situation that Gaurav finds himself in. We're
working on this problem together and so far, we haven't been able to
crack it.

 

We're using drools to handle the business rules for an application. The
rules however, are not provided to us in a .drl file, rather, we get an
XLS sheet from the analysts with rules in a different grammar.

 

We're using ANTLR to read and parse these rules to generate the drools
rules programmatically. However, we're running into problems with NOT.

 

The input rules (in the non-drools business language) have a NOT
operator which works like '!' in Java. It flips the Boolean around, so
to speak. So:

 

NOT((some sub expression which evaluates to TRUE)) == FALSE

 

MVEL doesn't seem to support this. So how do we simulate it?

 

If it were only being used with NOT IN, we could manage, but its use is
completely arbitrary. Changes to the input rules or to the input rules
grammar have been (ha ha) ruled out.

 

Any help would be appreciated.

 

Regards,

_

Arsalan Zaidi / Capgemini - India (FS SBU) / Mumbai

Technical Architect
Mobile Phone: +91 - 9892 8970 03 / www.capgemini.com
http://www.capgemini.com/  


Together: the Collaborative Business Experience
_



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anstis,
Michael (M.)
Sent: 13 September 2007 13:31
To: Rules Users List
Subject: RE: [rules-users] How to use not operator in drool.

 

What dialect do your rules use?

 

You could also simplify the logic using DeMorgans Theorem (which might
be troublesome to accomplish programmatically)

 

I don't know whether your example is flawed as the brackets don't match,
but assuming you mean something like this:-

 

(NOT (G13.1 IN (1,2,3) OR (G250.8 = Y)))

 

You can re-write this as 

 

 

(G13.1NOT IN (1,2,3) AND G250.8 != Y)

 

With kind regards,

 

Mike

 

 





From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JOSHI, GAURAV
Sent: 13 September 2007 08:20
To: Rules Users List
Subject: RE: [rules-users] How to use not operator in drool.

Thank's for your sugession of using not in instead of not
but my problem is that not can also come without in.

 

Actually I am making a generator of rule file from expression
like

 ((NOT (ENDS WITH (G10.2, ,)))

 

 ((NOT (G13.1 IN (1,2,3))) OR (G250.8 = Y)))

 

Where G13.2, G250.8, G10.2 are variables coming from a map
inserted in working memory.

 

I am accessing these variables from map.

 

My rules are as follows

 

This rule is working fine.

 

rule Editable_G10.3

when

 

 ((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19)))

 

then

System.out.println(comming
here-);

End

 

This is not working

 

rule Mandatory_G10.3

when

 (not((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19 

Then

System.out.println(comming
here-);

End

 

In also tried following approaches:

1)  eval(not((Map( this[G10.3] !=8))||(Map( this[G10.2]
==19 

 

2) eval(!((Map

RE: [rules-users] How to use not operator in drool.

2007-09-14 Thread Arsalan S. Zaidi

Hi 

 

I'll try to explain the situation that Gaurav finds himself in. We're
working on this problem together and so far, we haven't been able to
crack it.

 

We're using drools to handle the business rules for an application. The
rules however, are not provided to us in a .drl file, rather, we get an
XLS sheet from the analysts with rules in a different grammar.

 

We're using ANTLR to read and parse these rules to generate the drools
rules programmatically. However, we're running into problems with NOT.

 

The input rules (in the non-drools business language) have a NOT
operator which works like '!' in Java. It flips the Boolean around, so
to speak. So:

 

NOT((some sub expression which evaluates to TRUE)) == FALSE

 

MVEL doesn't seem to support this. So how do we simulate it?

 

If it were only being used with NOT IN, we could manage, but its use is
completely arbitrary. Changes to the input rules or to the input rules
grammar have been (ha ha) ruled out.

 

Any help would be appreciated.

 

Regards,

_

Arsalan Zaidi / Capgemini - India (FS SBU) / Mumbai

Technical Architect
Mobile Phone: +91 - 9892 8970 03 / www.capgemini.com
http://www.capgemini.com/ 


Together: the Collaborative Business Experience
_



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anstis,
Michael (M.)
Sent: 13 September 2007 13:31
To: Rules Users List
Subject: RE: [rules-users] How to use not operator in drool.

 

What dialect do your rules use?

 

You could also simplify the logic using DeMorgans Theorem (which might
be troublesome to accomplish programmatically)

 

I don't know whether your example is flawed as the brackets don't match,
but assuming you mean something like this:-

 

(NOT (G13.1 IN (1,2,3) OR (G250.8 = Y)))

 

You can re-write this as

 

 

(G13.1NOT IN (1,2,3) AND G250.8 != Y)

 

With kind regards,

 

Mike

 

 





From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JOSHI, GAURAV
Sent: 13 September 2007 08:20
To: Rules Users List
Subject: RE: [rules-users] How to use not operator in drool.

Thank's for your sugession of using not in instead of not
but my problem is that not can also come without in.

 

Actually I am making a generator of rule file from expression
like

 ((NOT (ENDS WITH (G10.2, ,)))

 

 ((NOT (G13.1 IN (1,2,3))) OR (G250.8 = Y)))

 

Where G13.2, G250.8, G10.2 are variables coming from a map
inserted in working memory.

 

I am accessing these variables from map.

 

My rules are as follows

 

This rule is working fine.

 

rule Editable_G10.3

when

 

 ((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19)))

 

then

System.out.println(comming
here-);

End

 

This is not working

 

rule Mandatory_G10.3

when

 (not((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19 

Then

System.out.println(comming
here-);

End

 

In also tried following approaches:

1)  eval(not((Map( this[G10.3] !=8))||(Map( this[G10.2]
==19 

 

2) eval(!((Map( this[G10.3] !=8))||(Map( this[G10.2]
==19 

 

But in both cases it is giving same error:

org.drools.rule.InvalidRulePackage: Rule Compilation error :
[Rule name=ValidationRuleExp_G10.3, agendaGroup=MAIN, salience=0,
no-loop=false]


com/telekurs/nva/mde/fe/ak/validation/Rule_ValidationRuleExp_G10_3_0.jav
a (11:495) : Cannot use this in a static context 


com/telekurs/nva/mde/fe/ak/validation/Rule_ValidationRuleExp_G10_3_0.jav
a (11:500) : Type mismatch: cannot convert from String to int

 

I am trying to find out some general concept so that I can
change just achieve the functionality of not.

 

Thanks

Gaurav 

 





From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: Wednesday, September 12, 2007 10:20 PM
To: Rules Users List
Subject: Re: [rules-users] How to use not operator in drool.

 


   Remove your eval and use or instead of || for the OR
CE.

   Although, I feel that this is not what you want... what you
want is simply:

when
Map( this['city'] not in ( mumbai, delhi ) ) 
then
//...
end
 
[]s
Edson

2007/9/12, Gaurav2007 [EMAIL PROTECTED]:


Hi 

RE: [rules-users] Dynamic changes to drl file

2007-08-23 Thread Arsalan S. Zaidi

Hi.

I'm no expert, but I think you have to 'recompile' the drl file using
PackageBuilder if you change it on disk and wish to use the new version.

--Arsalan

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of pns77
Sent: 23 August 2007 18:48
To: rules-users@lists.jboss.org
Subject: [rules-users] Dynamic changes to drl file


Have been stuck with this for quite some time now. Would appreciate if
anyone
could help me out.

I was checking if changes could be made to the rule file at runtime and
the
following is the block of code that i tried

RuleBase ruleBase = readRule();
WorkingMemory workingMemory =
ruleBase.newStatefulSession(false); // to keep reference
// Create a message object
workingMemory.insert( message );
workingMemory.fireAllRules();

When i try chaning the drl file at run time the change doesnt get
reflected. Is there anything else i need to be doing here?  Any
additional
jar files ?

To have this change take effect at runtime - do i need to create a new
session for each run or do i need to retain the session - i tried both
newStatefulSession(false) and newStatefulSession() - get the same
result
with both. 
-- 
View this message in context:
http://www.nabble.com/Dynamic-changes-to-drl-file-tf4317491.html#a122934
61
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] could not access property ('=')

2007-08-16 Thread Arsalan S. Zaidi

Hi.

 

Jira Bug created. http://jira.jboss.com/jira/browse/JBRULES-1089

 

BTW, the work around works just fine. 

 

Thanks!

 

--Arsalan

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 13 August 2007 22:16
To: Rules Users List
Subject: Re: [rules-users] could not access property ('=')

 



   This looks like an MVEL issue, since your expression is being
converted into an MVEL predicate. May I ask you please to open a JIRA
for that bug?

   Meanwhile, a workaround that shall work for you and may give you
improved perf is to split your pattern into 2 patterns using the from
keyword: 

 

when

   $dto : DTO( )

   W250_4_1( value in (0 ,1 ,6 ,7 ,A ,C ,D ,G
,L ,M ,P ,Q ,S ,V ,Z ) ) from $dto.w250_4_1

then


   Thanks, and hope it helps.

   Edson



2007/8/13, Arsalan S. Zaidi  [EMAIL PROTECTED]:

Hi.

 

I've currently evaluating Drools 4.0 for a project of ours and I'm
running into some problems.

 

I have a rule which looks like this:

 

rule W250.42 Editable

  when

DTO(w250_4_1.value in (0 ,1 ,6 ,7 ,A ,C ,D
,G ,L ,M ,P ,Q ,S ,V ,Z ) )

  then

System.out.println (0 );

Action action = createAction(W250.42 , false , true );

retList.add(action); 

end 

 

 

both DTO and w250_4_1 are extremely simple beans. w250_4_1 just has 1
property 'value' which is a String and DTO has one property w250_4_1
which is the bean w250_4_1 .

 

Now when I put 0 into w250_4_1 then everything works fine. The rule is
true and the 'then' portion is executed. However, if I set w250_4_1 to
6 (which is also present in the in (...)) then I get the following
error.

 

org.drools.RuntimeDroolsException : Exception executing predicate
[EMAIL PROTECTED]

  at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
97 )

  at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:122 )

  at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:317 )

  at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168 )

  at org.drools.reteoo.Rete.assertObject(Rete.java:168 )

  at org.drools.reteoo.ReteooRuleBase.assertObject(
ReteooRuleBase.java:190) 

  at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70 )

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:848 )

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:822 )

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:623 )

  at com.sample.DroolsTest.main( DroolsTest.java:34)

Caused by: org.mvel.PropertyAccessException: failed to access property:
== in: class com.sample.DTOShadowProxy

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:137 )

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccess
or(ReflectiveAccessorOptimizer.java:96 )

  at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194 )

  at org.mvel.ast.Or.getReducedValueAccelerated(Or.java:18 )

  at org.mvel.MVELRuntime.execute( MVELRuntime.java:87)

  at org.mvel.CompiledExpression.getValue(
CompiledExpression.java:98) 

  at org.mvel.MVEL.executeExpression( MVEL.java:202)

  at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpre
ssion.java:36 )

  at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
91 )

  ... 10 more

Caused by: org.mvel.PropertyAccessException: could not access property
('=') 

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropert
y(ReflectiveAccessorOptimizer.java:252 )

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:106 )

  ... 18 more

 

If I keep w250_4_1 as 0, but move 0 in the rule to any other place
place in the in() list (e.g. in (1,0,...), then I get a similar
error.

 

I get similar errors when trying to use 'not in' in the same
circumstance, except that then the property is ('!')

 

What seems to be the issue?

 

Thanks in advance!

 

Regards,

 

--Arsalan

This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is intended only for the
person to whom it is addressed. If you are not the intended recipient,
you are not authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies of this message. 


___
rules-users mailing list
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core

[rules-users] could not access property ('=')

2007-08-13 Thread Arsalan S. Zaidi

Hi.

 

I've currently evaluating Drools 4.0 for a project of ours and I'm
running into some problems.

 

I have a rule which looks like this:

 

rule W250.42 Editable

  when

DTO(w250_4_1.value in
(0,1,6,7,A,C,D,G,L,M,P,Q,S,V,Z) )

  then

System.out.println (0);

Action action = createAction(W250.42, false, true);

retList.add(action);

end

 

 

both DTO and w250_4_1 are extremely simple beans. w250_4_1 just has 1
property 'value' which is a String and DTO has one property w250_4_1
which is the bean w250_4_1.

 

Now when I put 0 into w250_4_1 then everything works fine. The rule is
true and the 'then' portion is executed. However, if I set w250_4_1 to
6 (which is also present in the in (...)) then I get the following
error.

 

org.drools.RuntimeDroolsException: Exception executing predicate
[EMAIL PROTECTED]

  at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
97)

  at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:122)

  at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:317)

  at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)

  at org.drools.reteoo.Rete.assertObject(Rete.java:168)

  at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)

  at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:848)

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:822)

  at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:623)

  at com.sample.DroolsTest.main(DroolsTest.java:34)

Caused by: org.mvel.PropertyAccessException: failed to access property:
== in: class com.sample.DTOShadowProxy

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:137)

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccess
or(ReflectiveAccessorOptimizer.java:96)

  at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194)

  at org.mvel.ast.Or.getReducedValueAccelerated(Or.java:18)

  at org.mvel.MVELRuntime.execute(MVELRuntime.java:87)

  at
org.mvel.CompiledExpression.getValue(CompiledExpression.java:98)

  at org.mvel.MVEL.executeExpression(MVEL.java:202)

  at
org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpre
ssion.java:36)

  at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:1
91)

  ... 10 more

Caused by: org.mvel.PropertyAccessException: could not access property
('=')

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanPropert
y(ReflectiveAccessorOptimizer.java:252)

  at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChai
n(ReflectiveAccessorOptimizer.java:106)

  ... 18 more

 

If I keep w250_4_1 as 0, but move 0 in the rule to any other place
place in the in() list (e.g. in (1,0,...), then I get a similar
error.

 

I get similar errors when trying to use 'not in' in the same
circumstance, except that then the property is ('!')

 

What seems to be the issue?

 

Thanks in advance!

 

Regards,

 

--Arsalan



This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] variables in rules

2007-08-13 Thread Arsalan S. Zaidi

Hi Mark.

 

Thanks for the quick reply! :-)

 

About question no. 2, is there anyway to do something like that with
Drools?

 

Regards,

 

--Arsalan

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 13 August 2007 18:03
To: Rules Users List
Subject: Re: [rules-users] variables in rules

 

yes you can use a variable, and no you cannot dynamically generate rules
in an eval.

Mark
Arsalan S. Zaidi wrote: 

Hi.

 

Two questions:

 

1.  Is it possible to use a variable in a IN(...) ? 

 

E.g.

 

when

$someVar : SomeObj()

(pqr in (abc, $someVar))

then

...

 

2.  Can I use strings in an eval() to dynamically generate rules?

 

E.g.

 

when

eval($aaa == 0)

then

...

 

Thanks in advance!

 

--Arsalan

This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is intended only for the
person to whom it is addressed. If you are not the intended recipient,
you are not authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies of this message.

 







 
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
  

 



This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient,  you are not authorized 
to read, print, retain, copy, disseminate,  distribute, or use this message or 
any part thereof. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users