Re: [rules-users] modify and update is not working in the rule file

2012-08-21 Thread FrankVhh
When a rule is activated where the auto-focus value is true and the rule's
agenda group does not have focus yet, then it is given focus, allowing the
rule to potentially fire. (c) Drools 5.4 Documentation


Rana wrote
 
 Ok it worked when I changed the rule file a little to add the negative
 rules.
 
 Focus on the Agenda should be dynamic so I have tried writing if-else
 stmts to focus on for different drugs?
 it did not work
 
 ksession.getAgenda().getAgendaGroup( AndroGel ).setFocus();
 
 Basically for every unit test even though I have set the focus, it is
 still siring all the rules of the other rule files also. How can I fix
 this.
 
 
 Also I have new requirement saying that when a rule satisfies, they only
 few rules to get fired based on the user input (like a grouped rules), so
 I thought I will use activation-groups apart from agenda-groups. But how
 can I focus on activating those activation-groups from Drools Rule File.
 
 Thanks.
 




--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019298.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-21 Thread Rana
I have a requirement which says that only few rules should be fired based on
the user group. How am I suppose to do that.

Only thing I think of is that I have to setFocus in the rules on either
Agenda-group or Activation-group.

please let me know.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019306.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-21 Thread Wolfgang Laun
Add a fact User with field group, set appropriately, and extend the
conditions of your rules as required.

I don't think that using agenda groups would be a good approach.

-W


On 21/08/2012, Rana ven12...@yahoo.com wrote:
 I have a requirement which says that only few rules should be fired based
 on
 the user group. How am I suppose to do that.

 Only thing I think of is that I have to setFocus in the rules on either
 Agenda-group or Activation-group.

 please let me know.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019306.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-21 Thread Davide Sottara
*DISCLAIMER: PLEASE NOTICE THAT THIS IS NOT RECOMMENDED, AND IN ANY CASE
SHOULD BE DONE WITH ***EXTREME*** CARE.*

This said, you need to create a KnowledgeBase passing a
RuleBaseConfiguration. 
Take a look at RuleBaseConfiguration.getComponentFactory(), which returns a
ReteooComponentFactory.
This class controls the sub-factories used to build parts of the RETE
network. In particular, you will
need to hack the NodeFactory (guess what it does :))

So, in reverse order: 

- Create a KnowledgeBase using a custom configuration
/KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( rbc );/

- When you create the configuration, do not use the interface, but the
actual implementation
/RuleBaseConfiguration rbc = (RuleBaseConfiguration)
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();/

- Set a custom NodeFactory in the configuration
/rbc.getComponentFactory().setNodeFactoryProvider( myNodeFactory );/

- The nodefactory should extend the appropriate methods and returned
customized nodes.
For example, to hack the alpha nodes:
/org.drools.reteoo.builder.NodeFactory myNodeFactory = new
DefaultNodeFactory() {
  public AlphaNode buildAlphaNode(int id, AlphaNodeFieldConstraint
constraint, ObjectSource objectSource, BuildContext context) {
return new MyAlphaNode( /* args from super constructor here */ );
  }
};/

- Your custom nodes should add the desired behaviour. For example, the
custom AlphaNode
could override the assertObject method
( see :
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
)

/
...
if ( isAllowed(...) ) {
  ...
} else {
  // not present in the original
  // here, a particular object failed to satisfy a given constraint
}
/





--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019334.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-20 Thread Rana
Hi David, you told me we can tweak the engine to know what are the failed
rules. Can you please let me know how to do that.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019287.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
How to use boolean variables in the rule. I want to do this

rule
   when
  //condition
   then
  set a boolean to true
end


Then check at the last rule if all the boolean in the rules are true, which
tells me that all the rules have passed.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019240.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
ok I have done this, please find the rule file


http://drools.46999.n3.nabble.com/file/n4019241/Rule.txt Rule.txt 


But it is still not setting the values for Program Fact in the rule file. I
am getting null as output. Do I need to return that object. If yes please
let me know and how can I get that back from WorkingMemory that I am using.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019241.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Wolfgang Laun
Although you can write

rule r
when ...
then
boolean b = true; ... x 
end

there is no way you can access these variables from anywhere else but
the place marked with x, i.e., inside the very same rule.

To see whether certain rules have fired in a certain interval, you'll
have to use some global data, either a DRL global or some other public
instance. At the beginning of the interval you'll have to clear the
variable, and at the end of the interval you'll have to iterate over
the accumulated collection.

For instance:

Java code:

SetString ruleNameSet = new HashSetString();
kSession.setGlobal( ruleNameSet, ruleNameSet );
//...
// Loop inserting a fact and firing all rules
for(...){
 ruleNameSet.clear();
 kSession.insert( anotherFact );
 kSession.fireAllRules();
 for( String ruleName: ruleNameSet ){
   //... ruleName has fired
 }
}

DRL code:

global Set ruleNameSet;

rule xyz
when...then...
ruleNameSet.add( drools.getRule().getName() );
end

Alternatively, to avoid the global and the addition to all right hand
sides, you can set up a listener and modify the SetString
ruleNameSet accordingly.

-W

On 17/08/2012, Rana ven12...@yahoo.com wrote:
 How to use boolean variables in the rule. I want to do this

 rule
when
   //condition
then
   set a boolean to true
 end


 Then check at the last rule if all the boolean in the rules are true, which
 tells me that all the rules have passed.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019240.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
I have done this. Please find the rule file attached.

http://drools.46999.n3.nabble.com/file/n4019243/Rule.txt Rule.txt 

But it is still not setting the values for Program Fact in the rule file. I
am getting null as output. Do I need to return that object. If yes please
let me know and how can I get that back from WorkingMemory that I am using. 

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019243.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Wolfgang Laun
You must not use this:
   eval( boolBrandName  boolProviderState  boolDrugStrength )
since changes in global variables are not visible to the Drools rule engine.

But you don't need this eval(...) line, since you have
   rule Brand Name
   rule Provider State extends Brand Name
   rule Drug Strength extends Provider State
   rule Check extends Drug Strength
and therefore Check will not fire unless Drug Strength fires;
Drug Strength will not fire unless Provider State fires;
Provider State will not fire unless Brand Name fires.

-W

On 17/08/2012, Rana ven12...@yahoo.com wrote:
 ok I have done this, please find the rule file


 http://drools.46999.n3.nabble.com/file/n4019241/Rule.txt Rule.txt


 But it is still not setting the values for Program Fact in the rule file. I
 am getting null as output. Do I need to return that object. If yes please
 let me know and how can I get that back from WorkingMemory that I am using.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019241.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
ok, thank you so much for your help. It works. Thanks.

But one tough question for you.

How can I know what was the reason a rule condition failed. Lets say

rule
  when
 test( a == b )
  then
 //consequence
end

I want to know what caused the condition a==b to fail was the value of a
is b or anything else. and I need to log this to a log file.

Somebody told me that Verifier does the trick, but we need to add some
custom rules to get to the values. I tried to google lot on this. But I
never got anything which do what I want to do.

Please help me on this.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019245.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Wolfgang Laun
Hasn't this been answered only recently on this list?

1) For simple conditions, a rule negating the condition of your rule
will fire if the other one fails:

rule a != b
when
  test( a != b )
then
  //consequence
end

2) If you have rules extending each other, the first one not firing
contains the condition(s) that are not fulfilled.

3) An individual analysis of the attributes of a fact can be done,
collecting the conditions that are fulfilled. At the end of the
analysis, you either have the situation that all required attributes
are fulfilled (and you can execute the consequence) or not, and thus
you know what's missing.

-W


On 17/08/2012, Rana ven12...@yahoo.com wrote:
 ok, thank you so much for your help. It works. Thanks.

 But one tough question for you.

 How can I know what was the reason a rule condition failed. Lets say

 rule
   when
  test( a == b )
   then
  //consequence
 end

 I want to know what caused the condition a==b to fail was the value of a
 is b or anything else. and I need to log this to a log file.

 Somebody told me that Verifier does the trick, but we need to add some
 custom rules to get to the values. I tried to google lot on this. But I
 never got anything which do what I want to do.

 Please help me on this.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019245.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
That's what our Business doesn't want me to do to write negative rules. In
this way there will be 2 rules to be written for 1 business rule.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Stephen Masters
It's worth thinking about it differently. A rule does not fail. It just defines 
the conditions under which it will activate.

If you wish to perform an action whether the condition is true or false, you 
have 2 options:

A positive and a negative condition:
when 
test(a == b)
then
...
when 
test(a != b)
then
…

A condition which is always true:
when
test()
then
if (a.equals(b)) {
...
} else {
...
}

To be honest whether you write 1 or 2 rules should not be a 'business' 
decision. Why does anybody think there should not be 2 rules?

It's probably worth considering what you're trying to achieve. Does logging of 
a fact value really need to be part of a rule?

For instance, if you're actually just looking for an audit trail, you can have 
a WorkingMemoryEventListener, which can listen for all of the fact insertions, 
updates and retractions. It can log them all as they happen. Combined with an 
AgendaEventListener, you can log what rules have activated and what the values 
of facts were at the time. Use an asynchronous logger and this will have very 
little impact on rules processing performance.

Alternatively if the business are writing rules, and only wish to write the 
positive match, then maybe you can create a DSL which generates the both the 
positive and negative rules behind the scenes.

A few ideas there for you to try...

Steve




On 17 Aug 2012, at 15:49, Rana ven12...@yahoo.com wrote:

 That's what our Business doesn't want me to do to write negative rules. In
 this way there will be 2 rules to be written for 1 business rule.
 
 Thanks.
 
 
 
 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Wolfgang Laun
To determine why some rule does not match, only proposals 2) and 3)
will work in the general case anyway.

If you're required to determine and log why rules do not fire, you'll
have to do what needs to be done. If you have, for example, 5
conditions, failure can be due to each, any combination and all of
them, and this information isn't available for free, and even your
Business should have enough savvy to understand that.

Either they drop the requirement, or they give you a free hand to fulfil it.

-W


On 17/08/2012, Rana ven12...@yahoo.com wrote:
 That's what our Business doesn't want me to do to write negative rules. In
 this way there will be 2 rules to be written for 1 business rule.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Davide Sottara
I agree with Stephen, if you need an action (e.g. logging) when a constraint
is violated, you are actually defining rules to handle the negative cases.
Drools verifier will not help you here, since knowing whether a fact
satisfied a constraint or not is a runtime problem and depends on the
combination of data and rules, whereas verifier looks at rules alone.
 
Could you please provide more details about your specific requirement? Do
you just need to know when a condition fails? Or do you need a full
analysis? I think we already discussed it: if you have a pattern with a
number of conditions, the engine will stop evaluating a fact as soon as the
first violation is encountered. Like in java,  evaluation is terminated
eagerly. (In this case, the not CE would help).

Also consider this remark: when a constraint such as field == value is not
satisfied, the engine *silently* stops propagating the fact along that
branch of the RETE. So, there is no way to be notified of the failure of a
constraint. 
The WorkingMemoryListener and the AgendaListener will report only events
with a coarser granularity, so they won't help you.

If you really really really ... really need it, you will have to tweak the
engine. I could show you a few possible ways to do that, but I'm a bit
reluctant...



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019256.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
Thanks for reply to all.

I would like to learn how to do that, but I don't want to implement now,
since I do not have time for that. But please do let me know about it.


Again, @Laune has helped me fix issues about I am getting null into
response, but I am back to that. Please find the rule file attached. Also in
rules the logs that I have, is not logging. Nothing is working, Logging,
Modify.

Also I want to know once the rules of a Rule file is fired and all is done
in the rule file. Will it end the process or not.

http://drools.46999.n3.nabble.com/file/n4019259/Rule.txt Rule.txt 


and this is how I am inserting facts

Logger logger1 = Logger.getRootLogger();  //log4j object
//  ProgramRuleValidationLog progRuleValidationLog = new
ProgramRuleValidationLog();

ksession.setGlobal(log, logger1);
//  ksession.setGlobal(progRuleValidationLog, 
progRuleValidationLog);

workingMemory = ksession;

workingMemory.insert(logger1);
//  workingMemory.insert(progRuleValidationLog);
workingMemory.insert(drug);
workingMemory.insert(address);
workingMemory.insert(program);

( (StatefulKnowledgeSession) workingMemory).fireAllRules();

logger =
KnowledgeRuntimeLoggerFactory.newFileLogger((KnowledgeRuntimeEventManager)
workingMemory, DroolsLog); //this is also not logging any thing except

object-stream
/object-stream

Please let me know the problems.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019259.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Wolfgang Laun
On 17/08/2012, Rana ven12...@yahoo.com wrote:
 Thanks for reply to all.

 I would like to learn how to do that, but I don't want to implement now,
 since I do not have time for that. But please do let me know about it.


 Again, @Laune has helped me fix issues about I am getting null into
 response, but I am back to that. Please find the rule file attached. Also
 in
 rules the logs that I have, is not logging. Nothing is working, Logging,
 Modify.


Did you set the agenda-group AndroGel? If not, see some previous
mail in this thread.



 Also I want to know once the rules of a Rule file is fired and all is done
 in the rule file. Will it end the process or not.

The next statement after fireAllRules() (see below!) is executed.


 http://drools.46999.n3.nabble.com/file/n4019259/Rule.txt Rule.txt


 and this is how I am inserting facts

   Logger logger1 = Logger.getRootLogger();  //log4j object
 //ProgramRuleValidationLog progRuleValidationLog = new
 ProgramRuleValidationLog();
   
   ksession.setGlobal(log, logger1);
 //ksession.setGlobal(progRuleValidationLog, 
 progRuleValidationLog);
   
   workingMemory = ksession;
   
   workingMemory.insert(logger1);
 //workingMemory.insert(progRuleValidationLog);
   workingMemory.insert(drug);
   workingMemory.insert(address);
   workingMemory.insert(program);

   ( (StatefulKnowledgeSession) 
 workingMemory).fireAllRules();

 logger =
 KnowledgeRuntimeLoggerFactory.newFileLogger((KnowledgeRuntimeEventManager)
 workingMemory, DroolsLog); //this is also not logging any thing except

 object-stream
 /object-stream


Why should it? It's all over after fireAllRules()

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
Yes I have that, but no luck. But again this should be dynamic so I am
guessing I should write if-else stmts to focus on?

ksession.getAgenda().getAgendaGroup( AndroGel ).setFocus(); 


* Logging is also not working in the rule file.
Logger logger = Logger.getRootLogger();

ksession.setGlobal(log, logger);

workingMemory = ksession;

workingMemory.insert(logger);
workingMemory.insert(drug);
workingMemory.insert(address);
workingMemory.insert(program);

( (StatefulKnowledgeSession) workingMemory).fireAllRules();


When it was working, I included a retract in my rule and flushed all the
facts from the memory and since then it is not working.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019262.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-17 Thread Rana
Ok it worked when I changed the rule file a little to add the negative rules.

But this should be dynamic so I am guessing I should write if-else stmts to
focus on for different drugs?

ksession.getAgenda().getAgendaGroup( AndroGel ).setFocus(); 


* Logging is also not working in the rule file.

Logger logger = Logger.getRootLogger();

ksession.setGlobal(log, logger);

Also I have new requirement saying that when a rule satisfies, they only few
rules to get fired based on the user input (like a grouped rules), so I
thought I will use activation-groups apart from agenda-groups. But how can I
focus on activating those activation-groups from Drools Rule File.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019263.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
See inline:

On 15/08/2012, Rana ven12...@yahoo.com wrote:
 Please let me know what is the problem in this. It does not update the
 values
 when I get the values, it gives me null in my unit test method.

Any stack trace?



 rule Drug Strength extends Provider State
   no-loop true
   dialect mvel
   agenda-group AndroGel
   when
   Drug( $drug.getStrength == 20.25 mg/1.25 gram (1.62 %) )

Do you have a field $drug in class Drug? Otherwise $drug isn't
defined, and this
rule should not compile at all.

   $p : Program()
   then
   #drools.getWorkingMemory().setGlobal(boolDrugStrength, true )
   modify( $p) {
   setProgramId( 610.conten...@samplemd.com ),
   setProgramName( AndroGel 1.62% Savings Card )
   };
   update( $p )

This is redundant because modify() does an update anyway.
-W

   #retract( $p )
   #retract( $drug )
   log.info(Prgram ID and Program Name is set for program Coupon 
 for
 Androgel);
   #drools.halt();
 end


 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
Hi this is my rule file, can you help me modify to make it work please.

http://drools.46999.n3.nabble.com/file/n4019187/Rule.txt Rule.txt 

Please let me know

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019187.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
This is the log I get, it is not able to set the values at all. I even try to
update in the code. but still there is no data that I am setting in rule is
set at all.



0[main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Drools Resource Scanner is set to 60 seconds
6[main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Drools Resource Change Scanner Service has started
8[main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Drools Resource Change Notifier Service has started
(null: 2, 171): cvc-elt.1: Cannot find the declaration of element
'change-set'.
1025 [main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Knowledge Agent Created for all the Drools Files
1071 [main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Knowledge Base is created and Session has started
Generic Name = AndroGel
1079 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Object
Inserted = org.apache.log4j.Logger@26a0e990
1088 [main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Activation Created Event = Brand Name
1090 [main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Activation Created Event = Provider State
1097 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Object
Inserted =
com.drfirst.pi.affiliate.json.Drug@63e708b2[ndcId=null,brandName=AndroGel,genericName=AndroGel,form=null,strength=20.25
mg/1.25 gram (1.62 %),strengthUnit=null,additionalProperties={}]
1099 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Object
Inserted =
com.drfirst.pi.affiliate.json.Address@49d31859[address1=null,address2=null,city=null,stateCode=MD,zipCode=null,additionalProperties={}]
1100 [main] INFO  com.drfirst.pi.affiliate.drools.DroolsKnowledgeObject  -
Activation Created Event = Drug Strength
1100 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Object
Inserted =
com.drfirst.pi.affiliate.json.Program@41e3a0ec[programId=null,programName=null,programDescription=null,programCategory=null,additionalProperties={}]
1100 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Rules are
Fired
1102 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  - Object Update
=
com.drfirst.pi.affiliate.json.Program@41e3a0ec[programId=null,programName=null,programDescription=null,programCategory=null,additionalProperties={}]
1108 [main] INFO  com.drfirst.pi.affiliate.drools.FireRules  -
org.drools.audit.KnowledgeRuntimeLoggerProviderImpl$KnowledgeRuntimeFileLoggerWrapper@3de6696c
Program ID = null
Program Name = null


Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019191.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
If you insert facts that have a chance to match, and if you
enable genda-group AndroGel then I see no reason why
it should not work.

-W


On 16/08/2012, Rana ven12...@yahoo.com wrote:
 Hi this is my rule file, can you help me modify to make it work please.

 http://drools.46999.n3.nabble.com/file/n4019187/Rule.txt Rule.txt

 Please let me know

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019187.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
Please find the project attached. Please check and help me out. I am now like
cat on that wall. The project team needs it and this is giving me hard time.
Please help


http://drools.46999.n3.nabble.com/file/n4019196/pi-affiliate-drools-rule-engine.zip
pi-affiliate-drools-rule-engine.zip 


Please help.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019196.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Esteban Aliverti
By the way, what are you trying to do in this piece of code?

CollectionObject objs = workingMemory.getObjects();
IteratorObject it = objs.iterator();

while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof Program) {
FactHandle fact = workingMemory.getFactHandle(obj);
workingMemory.update(fact, obj);
}
}

Best Regards,



Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com


On Thu, Aug 16, 2012 at 4:25 PM, Esteban Aliverti 
esteban.alive...@gmail.com wrote:

 The project doesn't compile since the parent pom is missing. You don't
 event have the Drug and Program classes in it!

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com



 On Thu, Aug 16, 2012 at 4:02 PM, Rana ven12...@yahoo.com wrote:

 Please find the project attached. Please check and help me out. I am now
 like
 cat on that wall. The project team needs it and this is giving me hard
 time.
 Please help



 http://drools.46999.n3.nabble.com/file/n4019196/pi-affiliate-drools-rule-engine.zip
 pi-affiliate-drools-rule-engine.zip


 Please help.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019196.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Esteban Aliverti
One last thing. Just like Wolfgang said: if you don't activate the
agenda-group where the rule is defined its activations are never going to
be executed.

Best Regards,



Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com


On Thu, Aug 16, 2012 at 4:29 PM, Esteban Aliverti 
esteban.alive...@gmail.com wrote:

 By the way, what are you trying to do in this piece of code?

 CollectionObject objs = workingMemory.getObjects();
 IteratorObject it = objs.iterator();

 while (it.hasNext()) {
 Object obj = it.next();
 if (obj instanceof Program) {
 FactHandle fact = workingMemory.getFactHandle(obj);
 workingMemory.update(fact, obj);
 }
 }

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com


 On Thu, Aug 16, 2012 at 4:25 PM, Esteban Aliverti 
 esteban.alive...@gmail.com wrote:

 The project doesn't compile since the parent pom is missing. You don't
 event have the Drug and Program classes in it!

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com



 On Thu, Aug 16, 2012 at 4:02 PM, Rana ven12...@yahoo.com wrote:

 Please find the project attached. Please check and help me out. I am now
 like
 cat on that wall. The project team needs it and this is giving me hard
 time.
 Please help



 http://drools.46999.n3.nabble.com/file/n4019196/pi-affiliate-drools-rule-engine.zip
 pi-affiliate-drools-rule-engine.zip


 Please help.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019196.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
Something like
  kSession.getAgenda().getAgendaGroup( AndroGel ).setFocus();

With the way the rules are written an agenda-group doesn't appear to
be required at all, but who knows.

-W



On 16/08/2012, Esteban Aliverti esteban.alive...@gmail.com wrote:
 One last thing. Just like Wolfgang said: if you don't activate the
 agenda-group where the rule is defined its activations are never going to
 be executed.

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com


 On Thu, Aug 16, 2012 at 4:29 PM, Esteban Aliverti 
 esteban.alive...@gmail.com wrote:

 By the way, what are you trying to do in this piece of code?

 CollectionObject objs = workingMemory.getObjects();
 IteratorObject it = objs.iterator();

 while (it.hasNext()) {
 Object obj = it.next();
 if (obj instanceof Program) {
 FactHandle fact = workingMemory.getFactHandle(obj);
 workingMemory.update(fact, obj);
 }
 }

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com


 On Thu, Aug 16, 2012 at 4:25 PM, Esteban Aliverti 
 esteban.alive...@gmail.com wrote:

 The project doesn't compile since the parent pom is missing. You don't
 event have the Drug and Program classes in it!

 Best Regards,

 

 Esteban Aliverti
 - Blog @ http://ilesteban.wordpress.com



 On Thu, Aug 16, 2012 at 4:02 PM, Rana ven12...@yahoo.com wrote:

 Please find the project attached. Please check and help me out. I am
 now
 like
 cat on that wall. The project team needs it and this is giving me hard
 time.
 Please help



 http://drools.46999.n3.nabble.com/file/n4019196/pi-affiliate-drools-rule-engine.zip
 pi-affiliate-drools-rule-engine.zip


 Please help.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019196.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users





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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
How can I fire one rule file if I have lot of rule files defined in my change
set. Right now I have written an if-else condition and checking if the input
is Androgel then fire Angrogel rule fire.

But how can I do that in real time.

Also I have a requirement which says it needs the reason why the rule
failed. So I have done this, I am setting all the actual and real values and
saving the data to database in my event listeners.

But I get this Cannot return a void result at line 6.


rule Brand Name
no-loop true
agenda-group AndroGel
when
$drug : Drug()
eval( progRuleValidationLog.setActualValue($drug.getBrandName()) )  
//line 6
eval( progRuleValidationLog.setRuleValue(AndroGel) )
Drug( brandName == AndroGel )
then
#drools.getWorkingMemory().setGlobal(boolBrandName, true);
log.info(Brand Name is AndroGel);
end


Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019202.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
On 16/08/2012, Rana ven12...@yahoo.com wrote:
 How can I fire one rule file if I have lot of rule files defined in my
 change
 set. Right now I have written an if-else condition and checking if the
 input
 is Androgel then fire Angrogel rule fire.

But a rule (as you have it) with
   Drug( brandName == AndroGel )
will take care of that automaticaliy. This can co-exist with lots of
similar rules for anything between Aspic to Zodiac.


 But how can I do that in real time.

 Also I have a requirement which says it needs the reason why the rule
 failed.

This is quite difficult if your rules are non-trivial except when there is a
restricted way facts are inserted and rules are fired. And even then it
requires a circumspect approach.

 So I have done this, I am setting all the actual and real values
 and
 saving the data to database in my event listeners.

Not clear what you gain by this.


 But I get this Cannot return a void result at line 6.

A method called in an eval must return a boolean, or has to be called
in a context that compares the result so that the comparison returns a
boolean. A void method can't be called at all.

-W


 rule Brand Name
   no-loop true
   agenda-group AndroGel
 when
   $drug : Drug()
 eval( progRuleValidationLog.setActualValue($drug.getBrandName()) )

 //line 6
 eval( progRuleValidationLog.setRuleValue(AndroGel) )
 Drug( brandName == AndroGel )
 then
   #drools.getWorkingMemory().setGlobal(boolBrandName, true);
   log.info(Brand Name is AndroGel);
 end


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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
I have written a function


function boolean logging(String actualValue, String ruleValue) {
 progRuleValidationLog.setActualValue(actualValue); //this is a pojo 
which
will give me what are the failed rules.
 progRuleValidationLog.setRuleValue(ruleValue);
 
 return true;
}


rule Brand Name
no-loop true
activation-group AndroGel
when
drug : Drug()
eval( logging(drug.getBrandName, AndroGel) )
Drug( brandName == AndroGel )
then
log.info(Brand Name is AndroGel);
end


These are my listeners.

@Override
public void 
activationCreated(ActivationCreatedEvent arg0) {
// TODO Auto-generated method stub
super.activationCreated(arg0);
String actualValue = 
progRuleValidationLog.getActualValue();
String ruleValue = 
progRuleValidationLog.getRuleValue();

progRuleService.saveOrUpdate(progRuleValidationLog);
log.info(Activation Created Event =
+arg0.getActivation().getRule().getName()+ because Rule passed.);
log.info(Reason for Rule passed is 
that the condition matched because
the Actual value = +actualValue+ did match with the Rule Value =
+ruleValue);
}

@Override
public void 
activationCancelled(ActivationCancelledEvent arg0) {
// TODO Auto-generated method stub
super.activationCancelled(arg0);
String actualValue = 
progRuleValidationLog.getActualValue();
String ruleValue = 
progRuleValidationLog.getRuleValue();

progRuleService.saveOrUpdate(progRuleValidationLog);
log.info(Activation Cancelled Event =
+arg0.getActivation().getRule().getName()+ because Rule failed.);
log.info(Reason for Rule failed is 
that the condition did not match
because the Actual value = +actualValue+ did not match with the Rule Value
= +ruleValue);
}


Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019208.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
The cancellation of an activation and the ensuing call to
activationCancelled() is NOT sufficient as an indication of the rule
not matching your fact data.

Scenario 1:
   - fact(s) inserted
   - activation created from rule R1
   - fireAllRules
   - activation of rule R1 fired

Scenario 2:
   - fact(s) inserted
   - activation created from rule R1
   - fireAllRules
   - fact(s) inserted/created/updated (due to another rule firing before R1)
   - activation from rule R1 cancelled

Scenario 3:
   - fact(s) inserted
   - fireAllRules
   - nothing happens

-W


On 16/08/2012, Rana ven12...@yahoo.com wrote:
 I have written a function


 function boolean logging(String actualValue, String ruleValue) {
progRuleValidationLog.setActualValue(actualValue); //this is a pojo 
 which
 will give me what are the failed rules.
  progRuleValidationLog.setRuleValue(ruleValue);

  return true;
 }


 rule Brand Name
   no-loop true
   activation-group AndroGel
 when
   drug : Drug()
   eval( logging(drug.getBrandName, AndroGel) )
   Drug( brandName == AndroGel )
 then
   log.info(Brand Name is AndroGel);
 end


 These are my listeners.

 @Override
   public void 
 activationCreated(ActivationCreatedEvent arg0) {
   // TODO Auto-generated method stub
   super.activationCreated(arg0);
   String actualValue = 
 progRuleValidationLog.getActualValue();
   String ruleValue = 
 progRuleValidationLog.getRuleValue();
   
 progRuleService.saveOrUpdate(progRuleValidationLog);
   log.info(Activation Created Event =
 +arg0.getActivation().getRule().getName()+ because Rule passed.);
   log.info(Reason for Rule passed is 
 that the condition matched because
 the Actual value = +actualValue+ did match with the Rule Value =
 +ruleValue);
   }
   
   @Override
   public void 
 activationCancelled(ActivationCancelledEvent arg0) {
   // TODO Auto-generated method stub
   super.activationCancelled(arg0);
   String actualValue = 
 progRuleValidationLog.getActualValue();
   String ruleValue = 
 progRuleValidationLog.getRuleValue();
   
 progRuleService.saveOrUpdate(progRuleValidationLog);
   log.info(Activation Cancelled Event =
 +arg0.getActivation().getRule().getName()+ because Rule failed.);
   log.info(Reason for Rule failed is 
 that the condition did not match
 because the Actual value = +actualValue+ did not match with the Rule
 Value
 = +ruleValue);
   }


 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019208.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
ok so what is the flow of  the failed condition of the rule. Also you did not
answer the first question of the function. It is not able to find my
function in the rule file.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019210.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
On 16/08/2012, Rana ven12...@yahoo.com wrote:
 ok so what is the flow of  the failed condition of the rule.

There is no flow for a rule not firing because one or more of its
conditions aren't met. Only recently I've suggested on this list a way
of determining why a rule does not fire. It requires a detailed,
individual investigation of the attributes contributing to the match.
Merely detecting that rules do not fire for a fact (or fact set) is
easier.

 Also you did
 not
 answer the first question of the function. It is not able to find my
 function in the rule file.

?

-W



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019210.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Rana
ok but why is it not able to find my function written and why is it not able
to find my global variable with it's name given.

Please help me fix this global variable thing. Rest I will look into it
later.

Thanks.



--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019212.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify and update is not working in the rule file

2012-08-16 Thread Wolfgang Laun
Do you mean this:

global ProgramRuleValidationLog progRuleValidationLog;

function boolean logging(String actualValue, String ruleValue) {
  progRuleValidationLog.setActualValue(actualValue);
   //...
}

with the message progRuleValidationLog cannot be resolved?

This is due to a restriction: globals are not global for, and
therefore not visible in, functions defined in DRL.

You might pass it in as an additional function parameter:
function boolean logging(String actualValue, String ruleValue,
ProgramRuleValidationLog progRuleValidationLog ) {
   //...
}

-W


On 16/08/2012, Rana ven12...@yahoo.com wrote:
 ok but why is it not able to find my function written and why is it not
 able
 to find my global variable with it's name given.

 Please help me fix this global variable thing. Rest I will look into it
 later.

 Thanks.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019212.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

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


Re: [rules-users] modify keyword cancels activation unexpectedly

2012-06-06 Thread Wolfgang Laun
On 06/06/2012, gboro54 gbor...@gmail.com wrote:
 I am using drools 5.4 and am running into a weird issue with using modify
 keyword. I have have two rules, both are similar in conditions(one rule
 catches 2 additional cases to modify the object with a generic message).
 Weather I add the checks for each rule into the into the generic rule or
 have a condition checking the object for the more specific messages to be
 added, the modify keyword seems to ignore this. In the case where the
 conditions are added to the generic rule independent the activation is
 cancelled. Any thoughts?

Yes: post more,  or nothing at all.
-W
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify keyword cancels activation unexpectedly

2012-06-06 Thread gboro54
Thanks for the insightI was able to figure it out with have the generic
rule listen for modifications to a certain property. The problem was that
the method being invoked by the other more specific rules was using a
convince method to modify the field so I needed to annotate the method with
the @Modifies method.  


laune wrote
 
 On 06/06/2012, gboro54 lt;gboro54@gt; wrote:
 I am using drools 5.4 and am running into a weird issue with using modify
 keyword. I have have two rules, both are similar in conditions(one rule
 catches 2 additional cases to modify the object with a generic message).
 Weather I add the checks for each rule into the into the generic rule or
 have a condition checking the object for the more specific messages to be
 added, the modify keyword seems to ignore this. In the case where the
 conditions are added to the generic rule independent the activation is
 cancelled. Any thoughts?
 
 Yes: post more,  or nothing at all.
 -W
 ___
 rules-users mailing list
 rules-users@.jboss
 https://lists.jboss.org/mailman/listinfo/rules-users
 


--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-keyword-cancels-activation-unexpectedly-tp4017772p4017775.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify keyword cancels activation unexpectedly

2012-06-06 Thread gboro54
Sorry for that. You are correct more information should have been provided to
allow for help. Usually I am better at this but hurried myself a little this
morning


gboro54 wrote
 
 Thanks for the insightI was able to figure it out with have the
 generic rule listen for modifications to a certain property. The problem
 was that the method being invoked by the other more specific rules was
 using a convince method to modify the field so I needed to annotate the
 method with the @Modifies method.  
 
 
 laune wrote
 
 On 06/06/2012, gboro54 lt;gboro54@gt; wrote:
 I am using drools 5.4 and am running into a weird issue with using
 modify
 keyword. I have have two rules, both are similar in conditions(one rule
 catches 2 additional cases to modify the object with a generic message).
 Weather I add the checks for each rule into the into the generic rule or
 have a condition checking the object for the more specific messages to
 be
 added, the modify keyword seems to ignore this. In the case where the
 conditions are added to the generic rule independent the activation is
 cancelled. Any thoughts?
 
 Yes: post more,  or nothing at all.
 -W
 ___
 rules-users mailing list
 rules-users@.jboss
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 


--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-keyword-cancels-activation-unexpectedly-tp4017772p401.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify, retract, setFocus and Salience

2012-04-27 Thread gboro54
I will take a stab at answering this:
-Modify and Retract will cause the tree to be re-evaluated for the current
facts in memory. This may cause new activations or cancellations to occur.
Be forewarned that a rule that modifies a fact may cause a continuous loop
if the conditions for that rule are always satisfied. If you wish to not
have this behavior look at no-loop

-Salience: Can be useful but I have found that using a controller fact to
order execution is more efficient. The problem with Salience is that it can
cause your tree to become to linear thus the behavior of the rules engine is
more like a bunch of if statements rather then being able to match patterns
and fire. I do use salience for some rules but try not to over do it

-setFocus: I don't have anything wrong with this. This allows you to
segments your rules into agenda groups.

I am sure someone else on here can add more. 
-Mike


aps4u wrote
 
 will these conditions make any trouble? waiting for a reply..
 


--
View this message in context: 
http://drools.46999.n3.nabble.com/modify-retract-setFocus-and-Salience-tp3942799p3944319.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Modify objects which are not part of the LHS

2010-07-10 Thread Mauricio Salatino
can you give us an example rule that explain us what do you want to achieve?

On Sat, Jul 10, 2010 at 7:17 PM, davids sosnacat...@gmail.com wrote:


 I am new to the tool and using guvnor to post and test my rules.
 I have about 10 rules which are executed based on adding more facts to the
 WM.
 in order to trigger the relevant rules ,I am using a temp object which is
 updated by a Modify statement.

 Is there any way on the RHS to modify objects which are not part of the LHS
 ?




 --
 View this message in context:
 http://drools-java-rules-engine.46999.n3.nabble.com/Modify-objects-which-are-not-part-of-the-LHS-tp957009p957009.html
 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




-- 
 - CTO @ http://www.plugtree.com
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jbug.com.ar

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


Re: [rules-users] Modify objects which are not part of the LHS

2010-07-10 Thread Mark Proctor
  On 10/07/2010 23:17, davids wrote:
 I am new to the tool and using guvnor to post and test my rules.
 I have about 10 rules which are executed based on adding more facts to the
 WM.
 in order to trigger the relevant rules ,I am using a temp object which is
 updated by a Modify statement.

 Is there any way on the RHS to modify objects which are not part of the LHS?

Something somewhere needs to have a reference to it, either a lookup via 
some gobal, or a variable from the LHS has a reference to it.

M




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


Re: [rules-users] modify facts problem

2009-08-28 Thread Vikram Pancholi
Hi,
   Any clues on the below mentioned problem. Some more information on it ,
  I am using 5.0.1 version of the API and core.

  After placing debugging logger i found out the following information,
   1) After I modify the user object in rule consequence , it raises the
object modified event but after some time.
   2) In the meanwhile the  Milestone that was waiting for the constraint
value ! = 1 gets passed ,,activaation created event
   3)  after milestone in the action node(where i m logging the value it
still prints 1 ..original unmodified value.
   4) After this i see the objectmodifiedevent being raised (the one the
stated above in point 1).

   I have also placed lock_on_active on rule, but still it raises the event
afterwards and other activations are using this object with an unmodified
value.

Please let me know if you know of any fix on this problem.

Thanks and Regards
Vikram Pancholi

On Thu, Aug 27, 2009 at 7:59 PM, Vikram Pancholi
vikram.panch...@gmail.comwrote:

 Hi,
   I am having problem about modifying certain fact.

   For example
   1) I have User status when inserted  set to value 1.
   2) in the modify in a rule block i m changing this  to 5.
   3)Now i have a flow where i have a wait which waits this user status is
 not value 1.
  After the rule is fired ans the status is changed to false, in the
 next step i am checking this status of user status in an XOR split
 constraints
 but i still get the status in the constraint as 1. I have got no
 clues whts going on. I tried printing this value in the getting the objects
 using classobjectfilter and then specyfing the class again, the value is
 still shown as 1. I am very much confused about this. Is this some effect
 of Shadow facts.
   awaiting your response.

 Regards
 Vikram Pancholi



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


Re: [rules-users] modify facts problem

2009-08-27 Thread Anstis, Michael (M.)
what version of Drools are you using?




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Vikram
Pancholi
Sent: 27 August 2009 15:30
To: rules-users@lists.jboss.org
Subject: [rules-users] modify facts problem


Hi,  
  I am having problem about modifying certain fact. 
 
  For example 
  1) I have User status when inserted  set to value 1.
  2) in the modify in a rule block i m changing this  to 5.
  3)Now i have a flow where i have a wait which waits this user
status is not value 1.
 After the rule is fired ans the status is changed to false,
in the next step i am checking this status of user status in an XOR
split constraints
but i still get the status in the constraint as 1. I have
got no clues whts going on. I tried printing this value in the getting
the objects using classobjectfilter and then specyfing the class again,
the value is still shown as 1. I am very much confused about this. Is
this some effect of Shadow facts. 
  awaiting your response.
 
Regards
Vikram Pancholi
 
 

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


RE: [rules-users] modify()

2008-04-11 Thread Anstis, Michael (M.)
I've got 4.0.5 and it mentions insert, update and retract throughout the
manual.

There was an API change some versions ago, but I forget when exactly.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of X10
Sent: 11 April 2008 12:34
To: Rules Users List
Subject: [rules-users] modify()

Hi,
I take it the modify() that's in the manual got replaced by
update()?

Christine

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify()

2008-04-11 Thread Mark Proctor

X10 wrote:

Hi,
I take it the modify() that's in the manual got replaced by
update()?
  
The meanings have changed, but both exist to some degree. modify() is a 
specail keyword used in the java/mvel consequence. Inside a consequence 
it is the preferred way modify facts, so that the engine is notified. 
Outside of consequence, in normal Java, one an object has been changed 
you need to notify the engine, this is done via the update() method, 
which tells the engine the fact has been updated.


The main difference is that update( handle ) only takes a single 
parameter where as modify( object ) { field1 = value1, field2 = value2 } 
takes key/value pair comma separated list of setters. the language used 
to apply those setters is dependant on whether you are using the mvel or 
java dialect.


Mark

Christine

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

  


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


RE: [rules-users] modify()

2008-04-11 Thread Anstis, Michael (M.)
I *seem* to be able to still use update in the RHS with 4.0.5.

Perhaps I've got my binaries mixed up. If I get the chance I'll do a clean
install.

Thanks for the clarification - I don't want to end up confusing matters with
my help ;-)

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 11 April 2008 12:51
To: [EMAIL PROTECTED]; Rules Users List
Subject: Re: [rules-users] modify()

X10 wrote:
 Hi,
 I take it the modify() that's in the manual got replaced by
 update()?
   
The meanings have changed, but both exist to some degree. modify() is a 
specail keyword used in the java/mvel consequence. Inside a consequence 
it is the preferred way modify facts, so that the engine is notified. 
Outside of consequence, in normal Java, one an object has been changed 
you need to notify the engine, this is done via the update() method, 
which tells the engine the fact has been updated.

The main difference is that update( handle ) only takes a single 
parameter where as modify( object ) { field1 = value1, field2 = value2 } 
takes key/value pair comma separated list of setters. the language used 
to apply those setters is dependant on whether you are using the mvel or 
java dialect.

Mark
 Christine

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

   

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] modify()

2008-04-11 Thread Mark Proctor

Anstis, Michael (M.) wrote:

I *seem* to be able to still use update in the RHS with 4.0.5.
  
yes update has not been removed, it's still part of the main api. If we 
removed it you would have no way to notify the engine of changes from 
outside the engine, and I expect some people might be upset if their 
drls broke if we removed it from consequences :)

Perhaps I've got my binaries mixed up. If I get the chance I'll do a clean
install.

Thanks for the clarification - I don't want to end up confusing matters with
my help ;-)

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 11 April 2008 12:51
To: [EMAIL PROTECTED]; Rules Users List
Subject: Re: [rules-users] modify()

X10 wrote:
  

Hi,
I take it the modify() that's in the manual got replaced by
update()?
  

The meanings have changed, but both exist to some degree. modify() is a 
specail keyword used in the java/mvel consequence. Inside a consequence 
it is the preferred way modify facts, so that the engine is notified. 
Outside of consequence, in normal Java, one an object has been changed 
you need to notify the engine, this is done via the update() method, 
which tells the engine the fact has been updated.


The main difference is that update( handle ) only takes a single 
parameter where as modify( object ) { field1 = value1, field2 = value2 } 
takes key/value pair comma separated list of setters. the language used 
to apply those setters is dependant on whether you are using the mvel or 
java dialect.


Mark
  

Christine

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

  



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



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


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


Re: [rules-users] Modify a global variable with mvel dialect

2008-02-06 Thread Joshua Jackson
That's exactly what I did. But it didn't work. :(

Best regards,

On Feb 5, 2008 3:49 PM, Mark Proctor [EMAIL PROTECTED] wrote:
 same as with java:
 drools.workingmemory.setGlobal( identifier, object );



-- 
It's not going to be like this forever

Blog: http://joshuajava.wordpress.com/
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Modify a global variable with mvel dialect

2008-02-05 Thread Mark Proctor

same as with java:
drools.workingmemory.setGlobal( identifier, object );

Mark
Joshua Jackson wrote:

Dear all,

How do we modify a global variable with mvel dialect inside rules file
without getting
java.lang.UnsupportedOperationException: External Variable
identifer='allowance' type='class java.lang.Double' is final, it
cannot be set
 [testng]   at 
org.drools.base.mvel.DroolsMVELGlobalVariable.setValue(DroolsMVELGlobalVariable.java:37)
   [testng] at
org.drools.base.mvel.DroolsMVELFactory.createVariable(DroolsMVELFactory.java:199)
   [testng] at
org.mvel.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:80)
   [testng] at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
   [testng] at
org.mvel.CompiledExpression.getValue(CompiledExpression.java:108)
   [testng] at org.mvel.MVEL.executeExpression(MVEL.java:230)
   [testng] at
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:47)
   [testng] at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
   [testng] at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
   [testng] at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
   [testng] at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)

This is how I did it:
Java file:
public void run(){
Double allowance = new Double(0);
workingMemory.setGlobal(allowance, allowance);

workingMemory.fireAllRules();
}


Rules:
global Double allowance

dialect mvel

rule Has Wife
no-loop 
salience 20
when
e: Employee()
income:Income()
eval( e.isWife() )
then
System.out.println(Has Wife);
allowance = allowance + 5000;
end

This works if I use java as the dialect.

Have I missed something?

Thanks in advance,
  


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