Re: [rules-users] Value is not reflected in Fact Object at Drool Client Side
by Esteban Aliverti
'*MortgageAgent'*is just the name you want to use for the agent. You could
use whatever name you want. The important parts of the code snippet are:
Resource changeset = ResourceFactory.newClassPathResource(
"org/drools/guvnor/examples/mortgage/mortgage-changeset.xml");
kagent.applyChangeSet(changeset);
Please take a look at the content of 'mortgage-changeset.xml' to get a
better understanding of how this works.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com
On Wed, Dec 5, 2012 at 10:44 AM, Hushen Savani
<hushen.savani(a)elitecore.com>wrote:
> MortgageAgent
13 years, 6 months
Re: [rules-users] Value is not reflected in Fact Object at Drool Client Side
by Esteban Aliverti
I'm wondering where did you get the content of that Guvnor.properties file.
The problem you are having is that the property file is not used to tell
the agent which resources should it use, but to set some of its internal
configurations such as:
- drools.agent.monitorChangeSetEvents (boolean)
- drools.agent.scanDirectories (boolean)
- drools.agent.scanResources (boolean)
- drools.agent.newInstance (boolean)
- drools.agent.useKBaseClassLoaderForCompiling (boolean)
- drools.agent.validationTimeout (long)
So, the properties you have there are not even being user, nor understood,
by drools.
In order to tell the agent which resources should it use, you must provide
a change-set pointing to those resources. You can find more information
about change-sets in Drools documentation.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com
On Wed, Dec 5, 2012 at 8:52 AM, Hushen Savani
<hushen.savani(a)elitecore.com>wrote:
> It seems that problem is with rule consumer (client), because even when
> I mess up with url of guvnor, it is giving me the same behavior:****
>
> ** **
>
> *Guvnor.properties*:****
>
> ** **
>
> url=http://localhost:10080/ *guvnor*-5.5.0.Final-*tomcat*
> -6.0/org.drools.guvnor.Guvnor/package/new *Pkg*/car111_*messed_up_url*****
>
> enableBasicAuthentication=true****
>
> username=*admin*****
>
> password=*admin*****
>
> name=*drooltest*
>
> * *
>
> ** **
>
> *Drool Consumer*:****
>
> ** **
>
> *package* kijanowski.eu;****
>
> ** **
>
> *import* java.util.Collection;****
>
> *import* java.util.Iterator;****
>
> ** **
>
> *import* org.drools.KnowledgeBase;****
>
> *import* org.drools.agent.KnowledgeAgent;****
>
> *import* org.drools.agent.KnowledgeAgentFactory;****
>
> *import* org.drools.runtime.StatefulKnowledgeSession;****
>
> ** **
>
> *public* *class* GuvnorTest {****
>
> ** **
>
> *public* *static* *final* *void* main(String[] args) {****
>
> ** **
>
> KnowledgeAgent agent = KnowledgeAgentFactory.*
> newKnowledgeAgent*("/Guvnor.properties"); ****
>
> KnowledgeBase ruleBase = agent.getKnowledgeBase();****
>
> ** **
>
> StatefulKnowledgeSession workingMemory =
> ruleBase.newStatefulKnowledgeSession();****
>
> ****
>
> Driver d = *new* Driver("Jarek", 20, *null*);****
>
> workingMemory.insert(d);****
>
> ** **
>
> workingMemory.fireAllRules();****
>
> ****
>
> *Collection* c = workingMemory.getObjects();****
>
> ****
>
> *for*(*Iterator* i = c.iterator(); i.hasNext();) {****
>
>
> //System.out.println(i.next().getClass().getCanonicalName());****
>
> Driver e = (Driver)i.next();****
>
> System.*out*.println(" Age: " + e.getAge() + " Name: "+ e.getName() + "
> Car: " + e.getCar() + " Object: " + e);****
>
> }****
>
> }****
>
> }****
>
> ** **
>
> Can anyone please suggest some pointers on the same.****
>
> ** **
>
> Thanks.****
>
> ** **
>
> Best Regards****
>
> *Hushen Savani*****
>
> ** **
>
> *From:* rules-users-bounces(a)lists.jboss.org [mailto:
> rules-users-bounces(a)lists.jboss.org] *On Behalf Of *Esteban Aliverti
> *Sent:* Tuesday, December 04, 2012 9:38 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Value is not reflected in Fact Object at
> Drool Client Side****
>
> ** **
>
> Sorry, I've just re-read your post and saw that you already mentioned that
> you are not seeing the system.out of your rule.****
>
> What you can do is to debug (or add some code) to see which rules do you
> have in the kbase returned by the kagent.****
>
> My guess is that your are not getting what you are expecting from Guvnor.*
> ***
>
> ** **
>
> Best Regards, ****
>
>
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Blog @ http://ilesteban.wordpress.com
>
> ****
>
> On Tue, Dec 4, 2012 at 5:03 PM, Esteban Aliverti <
> esteban.aliverti(a)gmail.com> wrote:****
>
> Do you see the message you are printing in the RHS of your rule?****
>
> ** **
>
> Best Regards,****
>
>
>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
> - Blog @ http://ilesteban.wordpress.com****
>
>
>
> ****
>
> On Tue, Dec 4, 2012 at 3:28 PM, Mister Nono <noel.maurice(a)univ-jfc.fr>
> wrote:****
>
> Hi,
>
> Have you try to add in the then of the drools rule the line : *update(a);*
>
> Best regards. ;)
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-Value-is-not-reflected-in-F...
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users****
>
> ** **
>
> ** **
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
13 years, 6 months
Guvnor and Global Functions
by Dean Whisnant
I'm using Drools/Guvnor version 5.1.1.
In the Global Area of Guvnor, under functions, I've created a function called splitDiagnosis.
In another package, we'll call it V222, I have a rule called LoadDiag.
In the Then section of the rule, I set the value of a field "=splitDiagnosis(diag,type)"
When run through our live software, the rule errors out because it evidently does not see the global area. If the rule is in the local package, then it works properly, but I have dozens of packages that all need access to this function and I don't want to keep copying it from one package to another.
I must be missing something to tell package V222 to include the global area. Any thoughts?
Thank you,
Dean Whisnant
13 years, 6 months
Value is not reflected in Fact Object at Drool Client Side
by Hushen Savani
Hi,
I m a newbie. Again, stuck with a problem.
I have created a package in Drools Guvnor as:
Created two POJO. Driver and Car as following:
Driver.java:
package kijanowski.eu;
public class Driver {
private String name;
private int age;
private Car car;
public Driver(String name, int age, Car car) {
this.name = name;
this.age = age;
this.car = car;
}
.
//Setter and Getters
.
}
Car.java:
package kijanowski.eu;
public class Car {
private String color;
private double value;
public Car() {}
public Car(String color, double value) {
this.color = color;
this.value = value;
}
.
//Setter and Getters
.
}
Prepared its jar and uploaded to Guvnor as following:
Both POJO are loaded successfully:
Then I created a new rule as following:
Then I verified, build and created Snapshot.
Now, I prepared a client program to consume rules deployed
in guvnor as following:
package kijanowski.eu;
import java.util.Collection;
import java.util.Iterator;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class GuvnorTest {
public static final void main(String[] args) {
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
KnowledgeBase kbase = kagent.getKnowledgeBase();
StatefulKnowledgeSession workingMemory =
kbase.newStatefulKnowledgeSession();
Driver d = new Driver("Jarek", 20, null);
workingMemory.insert(d);
workingMemory.fireAllRules();
Collection c = workingMemory.getObjects();
for (Iterator i = c.iterator(); i.hasNext();) {
d = (Driver)i.next();
System.out.println(" Age: " + d.getAge() + " Name: " +
d.getName() + " Car: " + d.getCar() + " Object: " + d);
}
}
}
And Guvnor.properties is as following:
url=http://localhost:10080/guvnor-5.5.0.Final-tomcat-6.0/org.drools.guvnor.G
uvnor/package/myNewPackage/car_example_snapshot
enableBasicAuthentication=true
username=admin
password=admin
name=drooltest
But when I run the client, I get following o/p:
Age: 20 Name: Jarek Car: null Object:
kijanowski.eu.Driver@15b9e68
I cannot see name changed to "Applicable" and cannot even see the o/p
of sysout on server side:
Can anyone please help me with this. Thanks.
Best Regards
Hushen Savani
13 years, 6 months
Rules Unit Testing
by John Poole
How is unit testing handled for rules? I'm playing with the nurse
rostering app and the only test I see is a performance test.
-John
13 years, 6 months
Using outcome of previous planning as input of new planning
by Michiel Vermandel
Hi,
We need to plan tasks over a period of 6 months.
But when the next planning is done (months after the first planning) we need to know some details about the previous planning.
For example, a person should not execute the same task twice in a row.
So I need to know who did a specific task in the previous planning in order to verify that it is not the same in this planning.
Do I need to persist the solution of the first planning?
Is there any example amongst the list of available examples which can give me a head-start on this?
Any help is greatly appreciated.
Regards,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 6 months
how to get first and last element of list of facts?
by Michiel Vermandel
Hi,
I need to plan some tasks within a nr of timeslots.
Until now a task was always done within the period of one timeslot and I could validate my rules since a task has a planning variablegetTimeSlot/ setTimeSlot.
Now requirements have changed and a task can take more than one timeslot to complete.
What is the best way to validate that the task is not started in a timeslot that would end the task after the last timeslot?
- Timeslots are always equally long (for example a week).
- All timeslots in the list of timeslots are sequential (no gaps).
So if I have a list of timeslots W18, W19, W20, W21 and I have a task taking 3 TimeSlots to complete, it should start in W18 or W19.
Should I create a single planningRange fact, holding the first and last slot?
Any directions would be appreciated.
Regards,
Michiel Vermandel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
13 years, 6 months
To access at the fact object
by Mister Nono
Hi,
I have the drools rule (made in guvnor server) :
1. | rule "driverRule"
2. | salience 10
3. | dialect "mvel"
4. | when
5. | Driver( driverAge : age > 18 && < 65 )
6. | then
7. | Driver fact0 = new Driver();
8. | fact0.setName( "TOTO" );
9. | insert( fact0 );
10. | end
... and the java code source :
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
KnowledgeBase ruleBase = agent.getKnowledgeBase();
StatefulKnowledgeSession workingMemory =
ruleBase.newStatefulKnowledgeSession();
Driver d = new Driver("Jack", 28, null);
workingMemory.insert(d);
workingMemory.fireAllRules();
for(Iterator i = workingMemory.getObjects().iterator(); i.hasNext();)
{
Object obj = i.next();
System.out.println(obj.getClass().getCanonicalName());
if (obj instanceof Driver)
{
System.out.println("Driver name => " + ((Driver)obj).getName());
System.out.println("Driver age => " + ((Driver)obj).getAge());
}
}
But the drools rule changes the driver name "Jack" by "TOTO", but in the
console the initial name "Jack" is always displayed.
How to access at the objet who is in knowledge base (the modified objet) ?
Thank. ;)
--
View this message in context: http://drools.46999.n3.nabble.com/To-access-at-the-fact-object-tp4021064....
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Different results with same fact base
by raffi
Hi,
I have a strange behavior with the Drools Expert 5.5.0. After running the
main class few times in a row, the results suddenly differ from the ones
before it. That means there are somtimes 3, 4 or 5 results shown in console.
I am using a statefulknowledgesession. Inserting of all facts is done with
normal java lists. For my last type of facts I insert one, call
fireAllRules(), and retract it again. Showing in console is solved with
queries. At the end I'm calling the dispose()-method. I added it to see if
there is a change in behavior. But with or without it there is the same
problem with different results after few directly runnings.
Rules and queries are defined in a drl-file and loaded via
knowledgebuilder's add()-method. I am working with eclipse and of course the
plugin for it.
Could it be a problem with something memory like (in a way like a cache or
similar to the garbage collection)?
I hope with this short explanation you can give me a feedback. If not its
not problem to describe in a more detailed way.
Thank you.
--
View this message in context: http://drools.46999.n3.nabble.com/Different-results-with-same-fact-base-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months