Process Compilation Error: Drools can not be resolved

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Process Compilation Error: Drools can not be resolved

V Vignesh
Hi guys,

I am new new to Rule Flow.
I am using eclipse for rule flow.

In a new Drools-Project
in ProcessTest.java
I tried to insert a HashMap in a knowledge base session
-------------------------------------------------------
HashMap hMap = new HashMap();
            hMap.put("Id", "10");
            hMap.put("RollNumber", "456");
            FactHandle qMapHandle = ksession.insert(hMap);
            ksession.startProcess("sample.ruleflow");
            ksession.fireAllRules();  
------------------------------------------------------  

but in my ruleflow.rf
I added a script Task
when in its Action, i tried accessing this fact Handle i get an error
"Drools cannot be resolved"
---------------------------------------------
if(drools.getWorkingMemory().getFactHandles()){
System.out.println("Inside the Script Task");
}
---------------------------------------------

Can you please help me to figure out the Reasons for Compilation Error
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

salaboy
Yeah, that's because "drools" doesn't exist. 
I think that you can use the kcontext, in order to do that..
Try something like: 

kcontext.getKnowledgeRuntime().getFactHandles() instead of  drools.getWorkingMemory().getFactHandles()


On Tue, Aug 20, 2013 at 11:42 AM, V Vignesh <[hidden email]> wrote:
Hi guys,

I am new new to Rule Flow.
I am using eclipse for rule flow.

In a new Drools-Project
in ProcessTest.java
I tried to insert a HashMap in a knowledge base session
-------------------------------------------------------
HashMap hMap = new HashMap();
            hMap.put("Id", "10");
            hMap.put("RollNumber", "456");
            FactHandle qMapHandle = ksession.insert(hMap);
            ksession.startProcess("sample.ruleflow");
            ksession.fireAllRules();
------------------------------------------------------

but in my ruleflow.rf
I added a script Task
when in its Action, i tried accessing this fact Handle i get an error
"Drools cannot be resolved"
---------------------------------------------
if(drools.getWorkingMemory().getFactHandles()){
System.out.println("Inside the Script Task");
}
---------------------------------------------

Can you please help me to figure out the Reasons for Compilation Error



--
View this message in context: http://drools.46999.n3.nabble.com/Process-Compilation-Error-Drools-can-not-be-resolved-tp4025623.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
 - MyJourney @ http://salaboy.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar
 
 - Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

V Vignesh
Hi Mauricio

Thanks a lot buddy.
I would like to know how this syntax functions.
If i need the HashMap from process Test.java (as i have mentioned first)
how should i alter this line?
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

salaboy
The kcontext is a special variable of the type RuleContext. If you take a look at that interface and all the inheritance you will find out which methods you can use. 
You can do something like: 
kcontext.getKnowledgeRuntime().getObjects() and then look for the HashMap.
I'm not sure what do you want to achieve.. but as you may notice this is not a clean solution.. you probably can change the shape of your solution to something better, if you share with us what are you trying to achieve, maybe we can help.

Cheers



On Tue, Aug 20, 2013 at 12:33 PM, V Vignesh <[hidden email]> wrote:
Hi Mauricio

Thanks a lot buddy.
I would like to know how this syntax functions.
If i need the HashMap from process Test.java (as i have mentioned first)
how should i alter this line?



--
View this message in context: http://drools.46999.n3.nabble.com/Process-Compilation-Error-Drools-can-not-be-resolved-tp4025623p4025625.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
 - MyJourney @ http://salaboy.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar
 
 - Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

V Vignesh
Hi Mauricio

Thanks for your explanation buddy.
sure i will check on it.

Target to achieve:
==============
I have a HashMap in my ProcessTest.java as
---------------------------------------------
------------------------------------------------------
HashMap hMap = new HashMap();
           hMap.put("Id", "10");
           hMap.put("RollNumber", "456");
           FactHandle qMapHandle = ksession.insert(hMap);
           ksession.startProcess("sample.ruleflow");
           ksession.fireAllRules();
-----------------------------------------------------


Now i am trying to access this HashMap from ProcessTest.java for further calculations to proceed using its values, in my Script Task Action of ruleflow.rf.



Viki
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

salaboy
Yeah I noticed that you are trying to do that.. but my question is why are you doing that.
Are you using the hashmap in some rules?
Why are you using a script task? You can use a workItemHandler to have more control on the objects that you are using and also to have auto completion, compilation time validations and most importantly you can debug it.




On Tue, Aug 20, 2013 at 12:52 PM, V Vignesh <[hidden email]> wrote:
Hi Mauricio

Thanks for your explanation buddy.
sure i will check on it.

Target to achieve:
==============
I have a HashMap in my ProcessTest.java as
---------------------------------------------
------------------------------------------------------
HashMap hMap = new HashMap();
           hMap.put("Id", "10");
           hMap.put("RollNumber", "456");
           FactHandle qMapHandle = ksession.insert(hMap);
           ksession.startProcess("sample.ruleflow");
           ksession.fireAllRules();
-----------------------------------------------------


Now i am trying to access this HashMap from ProcessTest.java for further
calculations to proceed using its values, in my Script Task Action of
ruleflow.rf.



Viki




--
View this message in context: http://drools.46999.n3.nabble.com/Process-Compilation-Error-Drools-can-not-be-resolved-tp4025623p4025627.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
 - MyJourney @ http://salaboy.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar
 
 - Salatino "Salaboy" Mauricio -

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Process Compilation Error: Drools can not be resolved

V Vignesh
Ya i am using the hash map in my rules. (So i was wondering how to access it)

As I am new to Drools, I started doing samples with script task.
I will sure soon, learn to use workItemHandler and update you.