[rules-users] How to get handle to stateful session in rule RHS ?

2011-09-13 Thread eskomk
Hi all,

I need to retract events from StatefulKnowledgeSession in rule's
consequences section.
How do I get a handle to the session in rule's RHS ?

When I get this session handle I will try to use its retract method:
void retract(FactHandle handle)
(which is derived from WorkingMemoryEntryPoint interface)

to remove the event which caused the rule to fire.

thanks, Esko
--
Esko Hujanen
http://www.ebsolut.fi

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-get-handle-to-stateful-session-in-rule-RHS-tp3332730p3332730.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] How to get handle to stateful session in rule RHS ?

2011-09-13 Thread Wolfgang Laun
Usually you don't need this; a plain
   retract( $boundToEventFact );
is sufficient.
-W

On 13 September 2011 16:16, eskomk esko.huja...@ebsolut.fi wrote:

 Hi all,

 I need to retract events from StatefulKnowledgeSession in rule's
 consequences section.
 How do I get a handle to the session in rule's RHS ?

 When I get this session handle I will try to use its retract method:
 void retract(FactHandle handle)
 (which is derived from WorkingMemoryEntryPoint interface)

 to remove the event which caused the rule to fire.

 thanks, Esko
 --
 Esko Hujanen
 http://www.ebsolut.fi

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-get-handle-to-stateful-session-in-rule-RHS-tp3332730p3332730.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] How to get handle to stateful session in rule RHS ?

2011-09-13 Thread Wolfgang Laun
Subsection The Right Hand Side (then) of the Expert manual explains
some details about the implicit variables. E.g.:

   kcontext.getKnowledgeRuntime()

-W


On 13 September 2011 16:16, eskomk esko.huja...@ebsolut.fi wrote:

 Hi all,

 I need to retract events from StatefulKnowledgeSession in rule's
 consequences section.
 How do I get a handle to the session in rule's RHS ?

 When I get this session handle I will try to use its retract method:
 void retract(FactHandle handle)
 (which is derived from WorkingMemoryEntryPoint interface)

 to remove the event which caused the rule to fire.

 thanks, Esko
 --
 Esko Hujanen
 http://www.ebsolut.fi

 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/How-to-get-handle-to-stateful-session-in-rule-RHS-tp3332730p3332730.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] How to get handle to stateful session in rule RHS ?

2011-09-13 Thread eskomk
Hi laune / W

Thanks, the plain retract seems to do the trick.

and thanks also for pointing me to right direction,
I must dig in more in the doc ;)

cheers, Esko
--
Esko Hujanen
http://www.ebsolut.fi

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-get-handle-to-stateful-session-in-rule-RHS-tp3332730p3332887.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] Call a Drools application

2011-09-13 Thread John
Are the drools libs also in the classpath of your application when you run it
externally as they appear to be when you run in eclipse?

--
View this message in context: 
http://drools.46999.n3.nabble.com/Call-a-Drools-application-tp3332048p138.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] Call a Drools application

2011-09-13 Thread Michael Anstis
Whether they are in the classpath is a choice made by the developer of your
application.

Whether they need to be in the classpath is another question, to which I
would answer yes.

Chapter 3. Installation and Setup of droolsjbpm-introduction-docs.pdf in
the binaries folder of the download gives more details.

With kind regards,

Mike

On 13 September 2011 17:33, John jfull...@progeny.net wrote:

 Are the drools libs also in the classpath of your application when you run
 it
 externally as they appear to be when you run in eclipse?

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Call-a-Drools-application-tp3332048p138.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


[rules-users] Problem evaluating with Enum

2011-09-13 Thread Hezi Stern
I have encountered the following problem using enums in drools.

 

I have an enum defined called ETimeConstraint, something of the sort:

 

public enum ETimeConstraint {

  NO_CONSTRAINT,

  TODAY,

TOMORROW,

;

}

 

Now I wish to filter sentences which reside in the working memory based on a
time constraint which is of this enum type.

I created the following test rule

 

rule My Test

  when

$sentences:   ArrayList() 

from collect (IPhoneSentences.Sentence(

 
descriptor contains ETimeConstraint

 
))

  then

//something

end

 

this does not work meaning no sentence are selected although I know that
there are sentences in the working memory. 

but when I add ETimeConstraint.name it does:

 

rule My Test

  when

$sentences:   ArrayList() 

from collect (IPhoneSentences.Sentence(

 
descriptor contains ETimeConstraint.name  

 
))

  then

//something

end

 

I can stick to this workaround but it becomes very problematic to work this
way. Furthermore once I wish to define a variable for example defining
$timeConstraint :

 

rule My Test

  when

  $cm:  Condition(

$timeConstraint:
contextIntention,

)

  

 

$sentences:   ArrayList() 

from collect (IPhoneSentences.Sentence(

 
descriptor contains $timeConstraint

 
))

  then

//something

end

 

 

this will not work because I can't put $timeConstraint.name

 

any suggestions?

 

I am running:

-  Drools 5.2.0

-  Eclipse Helios 

-  JBoss 5.1.0

 

 

Thanks

Hezi

 

 

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


Re: [rules-users] Memory leak in 5.2/5.3

2011-09-13 Thread vadlam

we are seeing similar memory leak with 5.2.0.Cr1 version of drools.

are there any other alternatives such as using a different version of jbpm
jar if that is the cause of the problem?
we are currently using the jbpm-flow-5.1.0.Cr1.jar.

If not,

is there a method that removes all the facts from the ksession so that it
can be reused?

for ex, the existing code (simplified) is as follows:

ksession = knowledgeBase.newStatefulKnowledgeSession();

for (Object obj : objList)
{
ksession.insert(obj);

}
 ksession.startProcess(ruleFlowProcessName);
ksession.fireAllRules();
 do some response processing here 


ksession.dispose();

Thomas,

Can you please elaborate on what you did to clean out the facts from the
memory ?




--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Memory-leak-in-5-2-5-3-tp3280351p3334543.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] Problem evaluating with Enum

2011-09-13 Thread Greg Barton
If the attribute IPhoneSentences.Sentence.descriptor is a 
CollectionETimeConstraint then this makes perfect sense.  The elements are 
instances of ETimeConstraint (what your second rule tests for) not instances of 
the enum class definition ETimeConstraint. (what your first rule tests 
for...maybe...) However, I'm wondering why the first version of the My Test 
rule compiles at all.  It doesn't when I try it.
--- On Tue, 9/13/11, Hezi Stern he...@delegatecom.com wrote:

From: Hezi Stern he...@delegatecom.com
Subject: [rules-users] Problem evaluating with Enum
To: rules-users@lists.jboss.org
Date: Tuesday, September 13, 2011, 3:54 PM

I have encountered the following problem using enums in drools.  I have an enum 
defined called ETimeConstraint, something of the sort:  public enum 
ETimeConstraint {  NO_CONSTRAINT,  TODAY,TOMORROW,;}  Now I wish to 
filter sentences which reside in the working memory based on a time constraint 
which is of this enum type.I created the following test rule  rule My Test    
  when        
$sentences:   ArrayList()     from collect 
(IPhoneSentences.Sentence(  
  descriptor contains ETimeConstraint   
  
      ))  then    //somethingend  
this does not work meaning no sentence are selected although I know that there 
are sentences in the working memory. but when I add ETimeConstraint.name it 
does:  rule My Test      when     
   $sentences:   ArrayList()     
from collect (IPhoneSentences.Sentence(     
   descriptor contains ETimeConstraint.name     
        ))  
then   
 //somethingend  I can stick to this workaround but it becomes very problematic 
to work this way. Furthermore once I wish to define a variable for example 
defining $timeConstraint :  rule My Test      
when      
$cm:  Condition(        
$timeConstraint: contextIntention,      
      )        
$sentences:   ArrayList()     from collect 
(IPhoneSentences.Sentence( 
   descriptor 
contains $timeConstraint        
       ))  then    //somethingend    this will not work 
because I can’t put $timeConstraint.name  any suggestions?  I am 
running:-  Drools 5.2.0-  Eclipse Helios -  JBoss 5.1.0 
   ThanksHezi    
-Inline Attachment Follows-

___
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] Problem evaluating with Enum

2011-09-13 Thread Wolfgang Laun
ETimeConstraint is a (Java) identifier, for the enum type. There is no
way this can be contains-ed in any collection.

ETimeConstraint.name isn't any proper way of accessing anything in
connection with enum type ETimeConstraint.

Correct would be
descriptor contains ETimeConstraint.TODAY

and, provided that contextIntention is of type ETimeConstraint, so is

$cm: Condition( $timeConstraint: contextIntention )
$sentences: ArrayList() from
 collect (IPhoneSentences.Sentence(descriptor contains $timeConstraint

Notice that a ListObject descriptor could contain
   ETimeConstraint.TODAY.name()
which is a String value.

-W


2011/9/13 Hezi Stern he...@delegatecom.com:
 I have encountered the following problem using enums in drools.



 I have an enum defined called ETimeConstraint, something of the sort:



 public enum ETimeConstraint {

   NO_CONSTRAINT,

   TODAY,

 TOMORROW,

 ;

 }



 Now I wish to filter sentences which reside in the working memory based on a
 time constraint which is of this enum type.

 I created the following test rule



 rule My Test

   when

     $sentences:   ArrayList()

     from collect (IPhoneSentences.Sentence(


 descriptor contains ETimeConstraint


    ))

   then

     //something

 end



 this does not work meaning no sentence are selected although I know that
 there are sentences in the working memory.

 but when I add ETimeConstraint.name it does:



 rule My Test

   when

     $sentences:   ArrayList()

     from collect (IPhoneSentences.Sentence(


 descriptor contains ETimeConstraint.name


    ))

   then

     //something

 end



 I can stick to this workaround but it becomes very problematic to work this
 way. Furthermore once I wish to define a variable for example defining
 $timeConstraint :



 rule My Test

   when

   $cm:  Condition(

         $timeConstraint:
 contextIntention,

     )





 $sentences:   ArrayList()

     from collect (IPhoneSentences.Sentence(


 descriptor contains $timeConstraint


    ))

   then

     //something

 end





 this will not work because I can’t put $timeConstraint.name



 any suggestions?



 I am running:

 -  Drools 5.2.0

 -  Eclipse Helios

 -  JBoss 5.1.0





 Thanks

 Hezi





 ___
 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] Problem evaluating with Enum

2011-09-13 Thread Wolfgang Laun
If the purpose of your constraint would be to test whether some
CollectionObject *contains any object of a certain type*, then, sorry:
there is no such thing in Drools, not out of the box.

You could write a function, use some (static) Java method, or implement a
constraint operator containsInstanceOf which would have a java.lang.Class
object as its second argument.

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