Re: [rules-users] simple subtraction in drools 5.3 fires rules

2012-06-22 Thread oranoh
didn´t try that, but I think it´s better to use a version that is more
robust.

--
View this message in context: 
http://drools.46999.n3.nabble.com/simple-subtraction-in-drools-5-3-fires-rules-tp4018141p4018155.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] Someone can help me by answering at this question?

2012-06-22 Thread paco


--
View this message in context: 
http://drools.46999.n3.nabble.com/Help-please-tp4018136p4018156.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] Accumulator being executed depending on the number of events

2012-06-22 Thread e...@yahoo.com
Hi Wolfgang,

I couldn't agree more with your analysis unfortunately it seems that or i
have something wrong with my rule or there is something wrong with the
implementation?

First off all the reserve was set to false this would mean that once the
rule is finished the context shouldn't be available any more and therefore
not updated when the rule is executed again  (as recalculation would require
all the facts to be processed again anyway). Now if my understanding is
correct then this is not how drools behaves, you can see evidence of this in
the trace of the first post.

I tried returning true for the reverse but the behaviour is exactly the
same. Each new fact creates a new context then for all matching facts the
accuulate is called on that context. The accumulate method is called on all
existing contexts for the new fact.

Here is the rule (test just makes a sum of the values)

import eu.mc2bis.drools.TestEvent;

declare TestEvent
@role(event)
@timestamp( eventDate )
end

rule test accumulator
  salience 100 // Make sure this rule is always executed by giving it a very
high salience
  no-loop true
when
$event: TestEvent( $key:key)
$total : Number( )  from accumulate( event : TestEvent( key == $key  ) ,  
test( 1 ) ) 
then
System.out.println(-- Rule output Total for key: + $key +  total:  +
$total);
end


here is the output with reverse:false

Main:inserting event with key:0
- Accumulator: Context created:553
- Accumulator: Init called for context:553
- Accumulator: getResults() called for context:553
- Accumulator: accumulate called for context:553 key:553 value:1
- Accumulator: getResults() called for context:553
Main:fireAllRules start
-- Rule output Total for key:0 total:1
Main:fireAllRules finished
Main:inserting event with key:0
- Accumulator: Context created:454
- Accumulator: Init called for context:454
- Accumulator: accumulate called for context:454 key:454 value:1
- Accumulator: getResults() called for context:454
- Accumulator: accumulate called for context:553 key:553 value:1
- Accumulator: accumulate called for context:454 key:454 value:1
- Accumulator: getResults() called for context:454
- Accumulator: getResults() called for context:553
Main:fireAllRules start
-- Rule output Total for key:0 total:2
-- Rule output Total for key:0 total:2
Main:fireAllRules finished
Main:inserting event with key:0
- Accumulator: Context created:695
- Accumulator: Init called for context:695
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: getResults() called for context:695
- Accumulator: accumulate called for context:553 key:553 value:1
- Accumulator: accumulate called for context:454 key:454 value:1
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: getResults() called for context:695
- Accumulator: getResults() called for context:454
- Accumulator: getResults() called for context:553
Main:fireAllRules start
-- Rule output Total for key:0 total:3
-- Rule output Total for key:0 total:3
-- Rule output Total for key:0 total:3
Main:fireAllRules finished
Time (ms) required to update: 100k profiles = 30
Ended

I would have expected:

Main:inserting event with key:0
- Accumulator: Context created:553
- Accumulator: Init called for context:553
- Accumulator: getResults() called for context:553
- Accumulator: accumulate called for context:553 key:553 value:1
- Accumulator: getResults() called for context:553
Main:fireAllRules start
-- Rule output Total for key:0 total:1
Main:fireAllRules finished
Main:inserting event with key:0
- Accumulator: Context created:454
- Accumulator: Init called for context:454
- Accumulator: accumulate called for context:454 key:454 value:1
- Accumulator: getResults() called for context:454
- Accumulator: accumulate called for context:454 key:454 value:1
- Accumulator: getResults() called for context:454
Main:fireAllRules start
-- Rule output Total for key:0 total:2
Main:fireAllRules finished
Main:inserting event with key:0
- Accumulator: Context created:695
- Accumulator: Init called for context:695
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: getResults() called for context:695
- Accumulator: accumulate called for context:695 key:695 value:1
- Accumulator: getResults() called for context:695
Main:fireAllRules start
-- Rule output Total for key:0 total:3
Main:fireAllRules finished
Time (ms) required to update: 100k profiles = 30
Ended


Here is the output with reverse:true

Main:inserting event with key:0
- Accumulator: Context created:943
- Accumulator: Init called for context:943
- Accumulator: getResults() called for context:943
- Accumulator: accumulate called for context:943 key:943 value:1
- Accumulator: getResults() called for context:943

[rules-users] Drools JBPM Persistence

2012-06-22 Thread Alberto R. Galdo
Hi,

   I'm opening this thread in the aim of generating a debate about the
approach to session persistence in Drools and JBPM for BPMN processes which
by definition are able to generate asynchronous human tasks.

   IMHO the current approach needs to be refactored in favor of joining the
management of the different Drools and JBPM entities in an unique manager.

   The current implementation offers two managers one in Drools, one in
JBPM. Each of this managers are wrappers of a shared JPA EntityManager
context and manage their own entities.

   When the integration of JBPM into Drools was done ( leaving behind
drools flow ), the approach seemed to be to make the entities in JBPM (
workitems, processinstance and so on ) look like the entities in Drools. As
a result, the implementation of those entities in JBPM now implement the
interfaces of the same entities in Drools. That looked like a good
approach, but the experience, at least mine, seems to reveal it as not that
good.

   In my opinion, the first problem with that approach is that Drools, the
reteoo algorithm, runs in a single-threaded environment. Drools persistence
was designed having this in mind, so for the code in Drools, there's no
doubt that when in a persistent enviroment, the transaction, if any, will
be bound to the same thread as the one in which the reteoo algorithm is
executed. That leads to situations where whenever a class in JBPM calls
drools in a JBPM's thread ( the mina handler thread, a NIO one for instance
), Drools thinks that is being executed in it's own thread ( where things
are expected, as the JTA transaction bound for example ) and clearly, in
some situations it is not the case. Then Drools expects to find certain
resources and certain environment which are not always there. Leading to
failure.

   As Drools now is a dependency for JBPM through the Knowledge-API, I
think that the management of the persistence for Drools and JBPM should be
merged in one that makes no assumptions and manages the needs for
persistence in a coherent way for both products.

   What do you think?


There can be only one -
http://en.wikipedia.org/wiki/Highlander_%28film%29


Alberto R. Galdo
arga...@gmail.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Workitems doesn't get persisted when completing a task after rehydrating a knowledge session is some circumstances.

2012-06-22 Thread Mauricio Salatino
  We are unable to complete a human task after rehydrating a Drools
knowledge session because in some circunstances the generated Drools'
workitems don't get persisted in the database after the completion of a
previous task

They are never persisted, they are runtime information that you must
re-register after rehydrating the session. Are you doing that?
Cheers

On Fri, Jun 22, 2012 at 7:34 AM, Alberto R. Galdo arga...@gmail.com wrote:

 Hi,

We have a fairly large BPMN process running inside a JPA persisted
 StatefulKnowledgeSession using Drools 5.4  JBPM 5.3. Our process involves
 timers, automated tasks, human tasks  most of them are long-running
 processes, so a fault-tolerant scenario is a must.

 We've found what seems to be a weird, weird bug in JBPM-Drools
 regarding the execution of BPMN processes. This is by best to summarize the
 problem:

  We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 So, as the workitem is not in the database, when a human task client
 completes a task that is related to that non-existent workitem, the process
 doesn't get restarted. And the process fails.

 ¿Why does this happens? Lets see:

  When the processs is executed, different workitems get created,
 updated and eventually deleted during the execution of a process up until a
 human task is created ( in our process ). When living in a persistet
 knowledge session, the transaction that is associated to Drools' thread is
 commited right after the human task is created in the human task server ...
 as it is a safe point. Nothing here. Everithing is consistent, if you
 look at the database you will see your session instance, your process
 instance, and the final human task workitem as it is the only workitem
 survivor after the execution ( whatever hadler-managed automated task that
 were executed before the human task are deleted and the human task workitem
 needs to survive as it's completion depends on asyncronous client
 interaction ).

  Now, if you connect to the human task server and complete that human
 task, a message is sent to the Drools session to update the state of the
 work item. The workitem gets updated, the process get restarted and the
 flow continues ... maybe generating a new human task ( which is our case ).
 At this very moment, if you take a look at the database, there are no
 automated-handled-task workitems ( as expected ) but there isn't any human
 task related work item, even worse, the task at the human task server is
 created, persisted and has a reference to the non-existant workitem.

 Days of debugging led us to what we think is the source of the
 problem:

 We found that the execution of the process after completing a task is
 being executed in the same thread as the one that receives the mina message
 that the human task server sends whenever a task is completed. This thread
 is not the same thread that executes the knowledgesession ( where the
 reteoo lives ) and so it doesn't have a transaction. By the way, we found
 that for  workitem persistence the JPAWorkitemManager never joins an active
 transaction. :(

 That's why invoking the persistence of a workitem as a consequence of
 restarting the execution of a process inside the thread that receives the
 mina messages makes the database inconsistent, and so invalidating all
 means to make JBPM fault tolerant by making Drools session persistent.

 We found a way to circunvent this problem, making all our human task
 nodes be followed by a event timer. That way, when the timer gets completed
 we force the execution of the process to live in the same thread that the
 reteoo session lives where a transaction is available and things get back
 to normal. But this is really dirty and wrong.

 Any thoughts?

 We are really eager to be wrong whith this. :'(

 Greets,



 Alberto R. Galdo
 arga...@gmail.com



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




-- 
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - 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] Drools JBPM Persistence

2012-06-22 Thread Mauricio Salatino
Both persistence mechanisms are already unified.
the jBPM-persistence module extends the Drools one adding the relevant
entities by the processes.

You can be having problems with the Mina Server, did you try the local
configuration? The Mina Server was designed to run in a different JVM than
the session, as a standalone component, if you are running it in the same
JVM that can be causing some transactional problems as you mention. If you
need to run it in the same JVM you can use the local configuration, did you
try that?
Cheers

On Fri, Jun 22, 2012 at 8:31 AM, Alberto R. Galdo arga...@gmail.com wrote:

 Hi,

I'm opening this thread in the aim of generating a debate about the
 approach to session persistence in Drools and JBPM for BPMN processes which
 by definition are able to generate asynchronous human tasks.

IMHO the current approach needs to be refactored in favor of joining
 the management of the different Drools and JBPM entities in an unique
 manager.

The current implementation offers two managers one in Drools, one in
 JBPM. Each of this managers are wrappers of a shared JPA EntityManager
 context and manage their own entities.

When the integration of JBPM into Drools was done ( leaving behind
 drools flow ), the approach seemed to be to make the entities in JBPM (
 workitems, processinstance and so on ) look like the entities in Drools. As
 a result, the implementation of those entities in JBPM now implement the
 interfaces of the same entities in Drools. That looked like a good
 approach, but the experience, at least mine, seems to reveal it as not that
 good.

In my opinion, the first problem with that approach is that Drools, the
 reteoo algorithm, runs in a single-threaded environment. Drools persistence
 was designed having this in mind, so for the code in Drools, there's no
 doubt that when in a persistent enviroment, the transaction, if any, will
 be bound to the same thread as the one in which the reteoo algorithm is
 executed. That leads to situations where whenever a class in JBPM calls
 drools in a JBPM's thread ( the mina handler thread, a NIO one for instance
 ), Drools thinks that is being executed in it's own thread ( where things
 are expected, as the JTA transaction bound for example ) and clearly, in
 some situations it is not the case. Then Drools expects to find certain
 resources and certain environment which are not always there. Leading to
 failure.

As Drools now is a dependency for JBPM through the Knowledge-API, I
 think that the management of the persistence for Drools and JBPM should be
 merged in one that makes no assumptions and manages the needs for
 persistence in a coherent way for both products.

What do you think?


 There can be only one -
 http://en.wikipedia.org/wiki/Highlander_%28film%29


 Alberto R. Galdo
 arga...@gmail.com


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




-- 
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - 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] Workitems doesn't get persisted when completing a task after rehydrating a knowledge session is some circumstances.

2012-06-22 Thread Alberto R. Galdo
No, I'm not registering pending workitems at rehydration. That's why I'm
using Drools  JBPM persistence ;-). I don't want to write my own state
persistence, as I am a mere user of JBPM  Drools services.

 They are never persisted

This several methods in org.drools.persitence.jpa.JPAPersistenceContext
seem to say just the opposite:

public void persist(WorkItemInfo workItemInfo)
public void remove(WorkItemInfo workItemInfo)
public WorkItemInfo merge(WorkItemInfo workItemInfo)

The fact that lots of workitems get created, persisted, merged and finally
removed during the life of the process doesn't hide the fact that they're
in fact,  well, persisted.

If you take a look at the changes in the database whenever a human task is
involved in a BPMN process that is executed inside a Drools  JBPM JPA
persisted environment you will realize that indeed the human task are
*persisted* and like so, rehydrated when loading the session in Drools.  In
fact, those human task related workitems are never removed from the
database, but that's another bug ... :(

Any insight?

Alberto R. Galdo
arga...@gmail.com


On Fri, Jun 22, 2012 at 2:15 PM, Mauricio Salatino sala...@gmail.comwrote:

   We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 They are never persisted, they are runtime information that you must
 re-register after rehydrating the session. Are you doing that?
 Cheers

 On Fri, Jun 22, 2012 at 7:34 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

We have a fairly large BPMN process running inside a JPA persisted
 StatefulKnowledgeSession using Drools 5.4  JBPM 5.3. Our process involves
 timers, automated tasks, human tasks  most of them are long-running
 processes, so a fault-tolerant scenario is a must.

 We've found what seems to be a weird, weird bug in JBPM-Drools
 regarding the execution of BPMN processes. This is by best to summarize the
 problem:

  We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 So, as the workitem is not in the database, when a human task client
 completes a task that is related to that non-existent workitem, the process
 doesn't get restarted. And the process fails.

 ¿Why does this happens? Lets see:

  When the processs is executed, different workitems get created,
 updated and eventually deleted during the execution of a process up until a
 human task is created ( in our process ). When living in a persistet
 knowledge session, the transaction that is associated to Drools' thread is
 commited right after the human task is created in the human task server ...
 as it is a safe point. Nothing here. Everithing is consistent, if you
 look at the database you will see your session instance, your process
 instance, and the final human task workitem as it is the only workitem
 survivor after the execution ( whatever hadler-managed automated task that
 were executed before the human task are deleted and the human task workitem
 needs to survive as it's completion depends on asyncronous client
 interaction ).

  Now, if you connect to the human task server and complete that human
 task, a message is sent to the Drools session to update the state of the
 work item. The workitem gets updated, the process get restarted and the
 flow continues ... maybe generating a new human task ( which is our case ).
 At this very moment, if you take a look at the database, there are no
 automated-handled-task workitems ( as expected ) but there isn't any human
 task related work item, even worse, the task at the human task server is
 created, persisted and has a reference to the non-existant workitem.

 Days of debugging led us to what we think is the source of the
 problem:

 We found that the execution of the process after completing a task is
 being executed in the same thread as the one that receives the mina message
 that the human task server sends whenever a task is completed. This thread
 is not the same thread that executes the knowledgesession ( where the
 reteoo lives ) and so it doesn't have a transaction. By the way, we found
 that for  workitem persistence the JPAWorkitemManager never joins an active
 transaction. :(

 That's why invoking the persistence of a workitem as a consequence of
 restarting the execution of a process inside the thread that receives the
 mina messages makes the database inconsistent, and so invalidating all
 means to make JBPM fault tolerant by making Drools session persistent.

 We found a way to circunvent this problem, making all our human task
 nodes be followed by a event timer. That way, when the timer gets completed
 we force the execution of the process to live in 

Re: [rules-users] Drools JBPM Persistence

2012-06-22 Thread Alberto R. Galdo
No, I didn't. I need to be able to deploy the human task server and my
knowledge session in separate JVM's. And Mina is on my way.

The fact that I am able to do things in some other way doesn't make this
very problem dissapear ... :(. In fact, this will never dissapear unless
some communication mechanism between Drools  JBPM is developed to allow
the processes to be executed  inside Drools Reteoo thread.

Isn't that so?


Alberto R. Galdo
arga...@gmail.com


On Fri, Jun 22, 2012 at 2:17 PM, Mauricio Salatino sala...@gmail.comwrote:

 Both persistence mechanisms are already unified.
 the jBPM-persistence module extends the Drools one adding the relevant
 entities by the processes.

 You can be having problems with the Mina Server, did you try the local
 configuration? The Mina Server was designed to run in a different JVM than
 the session, as a standalone component, if you are running it in the same
 JVM that can be causing some transactional problems as you mention. If you
 need to run it in the same JVM you can use the local configuration, did you
 try that?
 Cheers

 On Fri, Jun 22, 2012 at 8:31 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

I'm opening this thread in the aim of generating a debate about the
 approach to session persistence in Drools and JBPM for BPMN processes which
 by definition are able to generate asynchronous human tasks.

IMHO the current approach needs to be refactored in favor of joining
 the management of the different Drools and JBPM entities in an unique
 manager.

The current implementation offers two managers one in Drools, one in
 JBPM. Each of this managers are wrappers of a shared JPA EntityManager
 context and manage their own entities.

When the integration of JBPM into Drools was done ( leaving behind
 drools flow ), the approach seemed to be to make the entities in JBPM (
 workitems, processinstance and so on ) look like the entities in Drools. As
 a result, the implementation of those entities in JBPM now implement the
 interfaces of the same entities in Drools. That looked like a good
 approach, but the experience, at least mine, seems to reveal it as not that
 good.

In my opinion, the first problem with that approach is that Drools,
 the reteoo algorithm, runs in a single-threaded environment. Drools
 persistence was designed having this in mind, so for the code in Drools,
 there's no doubt that when in a persistent enviroment, the transaction, if
 any, will be bound to the same thread as the one in which the reteoo
 algorithm is executed. That leads to situations where whenever a class in
 JBPM calls drools in a JBPM's thread ( the mina handler thread, a NIO one
 for instance ), Drools thinks that is being executed in it's own thread (
 where things are expected, as the JTA transaction bound for example ) and
 clearly, in some situations it is not the case. Then Drools expects to find
 certain resources and certain environment which are not always there.
 Leading to failure.

As Drools now is a dependency for JBPM through the Knowledge-API, I
 think that the management of the persistence for Drools and JBPM should be
 merged in one that makes no assumptions and manages the needs for
 persistence in a coherent way for both products.

What do you think?


 There can be only one -
 http://en.wikipedia.org/wiki/Highlander_%28film%29


 Alberto R. Galdo
 arga...@gmail.com


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




 --
  - MyJourney @ http://salaboy.wordpress.com
  - Co-Founder @ http://www.jugargentina.org
  - 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


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


Re: [rules-users] Workitems doesn't get persisted when completing a task after rehydrating a knowledge session is some circumstances.

2012-06-22 Thread Mauricio Salatino
There are two concepts here:
1) WorkItem - Persist the state of the activity
2) WorkItemHandlers - Never Persisted

Are you re-registering the WorkItemHandlers at rehydratation?
WorkItemHandlers are part of the runtime status and don't get persisted.
Cheers

On Fri, Jun 22, 2012 at 9:39 AM, Alberto R. Galdo arga...@gmail.com wrote:

 No, I'm not registering pending workitems at rehydration. That's why I'm
 using Drools  JBPM persistence ;-). I don't want to write my own state
 persistence, as I am a mere user of JBPM  Drools services.

  They are never persisted

 This several methods in org.drools.persitence.jpa.JPAPersistenceContext
 seem to say just the opposite:

 public void persist(WorkItemInfo workItemInfo)
 public void remove(WorkItemInfo workItemInfo)
 public WorkItemInfo merge(WorkItemInfo workItemInfo)

 The fact that lots of workitems get created, persisted, merged and finally
 removed during the life of the process doesn't hide the fact that they're
 in fact,  well, persisted.

 If you take a look at the changes in the database whenever a human task is
 involved in a BPMN process that is executed inside a Drools  JBPM JPA
 persisted environment you will realize that indeed the human task are
 *persisted* and like so, rehydrated when loading the session in Drools.  In
 fact, those human task related workitems are never removed from the
 database, but that's another bug ... :(

 Any insight?

 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:15 PM, Mauricio Salatino sala...@gmail.comwrote:

   We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 They are never persisted, they are runtime information that you must
 re-register after rehydrating the session. Are you doing that?
 Cheers

 On Fri, Jun 22, 2012 at 7:34 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

We have a fairly large BPMN process running inside a JPA persisted
 StatefulKnowledgeSession using Drools 5.4  JBPM 5.3. Our process involves
 timers, automated tasks, human tasks  most of them are long-running
 processes, so a fault-tolerant scenario is a must.

 We've found what seems to be a weird, weird bug in JBPM-Drools
 regarding the execution of BPMN processes. This is by best to summarize the
 problem:

  We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 So, as the workitem is not in the database, when a human task client
 completes a task that is related to that non-existent workitem, the process
 doesn't get restarted. And the process fails.

 ¿Why does this happens? Lets see:

  When the processs is executed, different workitems get created,
 updated and eventually deleted during the execution of a process up until a
 human task is created ( in our process ). When living in a persistet
 knowledge session, the transaction that is associated to Drools' thread is
 commited right after the human task is created in the human task server ...
 as it is a safe point. Nothing here. Everithing is consistent, if you
 look at the database you will see your session instance, your process
 instance, and the final human task workitem as it is the only workitem
 survivor after the execution ( whatever hadler-managed automated task that
 were executed before the human task are deleted and the human task workitem
 needs to survive as it's completion depends on asyncronous client
 interaction ).

  Now, if you connect to the human task server and complete that
 human task, a message is sent to the Drools session to update the state of
 the work item. The workitem gets updated, the process get restarted and the
 flow continues ... maybe generating a new human task ( which is our case ).
 At this very moment, if you take a look at the database, there are no
 automated-handled-task workitems ( as expected ) but there isn't any human
 task related work item, even worse, the task at the human task server is
 created, persisted and has a reference to the non-existant workitem.

 Days of debugging led us to what we think is the source of the
 problem:

 We found that the execution of the process after completing a task
 is being executed in the same thread as the one that receives the mina
 message that the human task server sends whenever a task is completed. This
 thread is not the same thread that executes the knowledgesession ( where
 the reteoo lives ) and so it doesn't have a transaction. By the way, we
 found that for  workitem persistence the JPAWorkitemManager never joins an
 active transaction. :(

 That's why invoking the persistence of a workitem as a consequence
 of restarting the execution of a process inside the thread that 

Re: [rules-users] Drools JBPM Persistence

2012-06-22 Thread Mauricio Salatino
I think that you are mixing things up.
Did you take a look at the CommandBasedStatefulKnowledgeSession?
Every command that represent an operation against the knowledge session is
being executed inside a transaction, for both rules and processes. As soon
as a safe point is found (for both processes and rules) the persistence
mechanism commits the transaction.

In fact, this will never dissapear unless some communication mechanism
between Drools  JBPM is developed to allow the processes to be executed
inside Drools Reteoo thread.
Take a look at the class that I mention and then try to explain me what you
mean with the previous sentence.

Cheers

On Fri, Jun 22, 2012 at 9:45 AM, Alberto R. Galdo arga...@gmail.com wrote:


 No, I didn't. I need to be able to deploy the human task server and my
 knowledge session in separate JVM's. And Mina is on my way.

 The fact that I am able to do things in some other way doesn't make this
 very problem dissapear ... :(. In fact, this will never dissapear unless
 some communication mechanism between Drools  JBPM is developed to allow
 the processes to be executed  inside Drools Reteoo thread.

 Isn't that so?


 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:17 PM, Mauricio Salatino sala...@gmail.comwrote:

 Both persistence mechanisms are already unified.
 the jBPM-persistence module extends the Drools one adding the relevant
 entities by the processes.

 You can be having problems with the Mina Server, did you try the local
 configuration? The Mina Server was designed to run in a different JVM than
 the session, as a standalone component, if you are running it in the same
 JVM that can be causing some transactional problems as you mention. If you
 need to run it in the same JVM you can use the local configuration, did you
 try that?
 Cheers

 On Fri, Jun 22, 2012 at 8:31 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

I'm opening this thread in the aim of generating a debate about the
 approach to session persistence in Drools and JBPM for BPMN processes which
 by definition are able to generate asynchronous human tasks.

IMHO the current approach needs to be refactored in favor of joining
 the management of the different Drools and JBPM entities in an unique
 manager.

The current implementation offers two managers one in Drools, one in
 JBPM. Each of this managers are wrappers of a shared JPA EntityManager
 context and manage their own entities.

When the integration of JBPM into Drools was done ( leaving behind
 drools flow ), the approach seemed to be to make the entities in JBPM (
 workitems, processinstance and so on ) look like the entities in Drools. As
 a result, the implementation of those entities in JBPM now implement the
 interfaces of the same entities in Drools. That looked like a good
 approach, but the experience, at least mine, seems to reveal it as not that
 good.

In my opinion, the first problem with that approach is that Drools,
 the reteoo algorithm, runs in a single-threaded environment. Drools
 persistence was designed having this in mind, so for the code in Drools,
 there's no doubt that when in a persistent enviroment, the transaction, if
 any, will be bound to the same thread as the one in which the reteoo
 algorithm is executed. That leads to situations where whenever a class in
 JBPM calls drools in a JBPM's thread ( the mina handler thread, a NIO one
 for instance ), Drools thinks that is being executed in it's own thread (
 where things are expected, as the JTA transaction bound for example ) and
 clearly, in some situations it is not the case. Then Drools expects to find
 certain resources and certain environment which are not always there.
 Leading to failure.

As Drools now is a dependency for JBPM through the Knowledge-API, I
 think that the management of the persistence for Drools and JBPM should be
 merged in one that makes no assumptions and manages the needs for
 persistence in a coherent way for both products.

What do you think?


 There can be only one -
 http://en.wikipedia.org/wiki/Highlander_%28film%29


 Alberto R. Galdo
 arga...@gmail.com


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




 --
  - MyJourney @ http://salaboy.wordpress.com
  - Co-Founder @ http://www.jugargentina.org
  - 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



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




-- 
 - MyJourney @ http://salaboy.wordpress.com
 - Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

 - Salatino Salaboy Mauricio -

Re: [rules-users] Workitems doesn't get persisted when completing a task after rehydrating a knowledge session is some circumstances.

2012-06-22 Thread Alberto R. Galdo
Sure, WorkItemHandlers are never persisted. I re-register those handlers
before staring the session, just because I want my tasks to be properly
executed.

:(


Alberto R. Galdo
arga...@gmail.com


On Fri, Jun 22, 2012 at 2:46 PM, Mauricio Salatino sala...@gmail.comwrote:

 There are two concepts here:
 1) WorkItem - Persist the state of the activity
 2) WorkItemHandlers - Never Persisted

 Are you re-registering the WorkItemHandlers at rehydratation?
 WorkItemHandlers are part of the runtime status and don't get persisted.
 Cheers

 On Fri, Jun 22, 2012 at 9:39 AM, Alberto R. Galdo arga...@gmail.comwrote:

 No, I'm not registering pending workitems at rehydration. That's why I'm
 using Drools  JBPM persistence ;-). I don't want to write my own state
 persistence, as I am a mere user of JBPM  Drools services.

  They are never persisted

 This several methods in org.drools.persitence.jpa.JPAPersistenceContext
 seem to say just the opposite:

 public void persist(WorkItemInfo workItemInfo)
 public void remove(WorkItemInfo workItemInfo)
 public WorkItemInfo merge(WorkItemInfo workItemInfo)

 The fact that lots of workitems get created, persisted, merged and
 finally removed during the life of the process doesn't hide the fact that
 they're in fact,  well, persisted.

 If you take a look at the changes in the database whenever a human task
 is involved in a BPMN process that is executed inside a Drools  JBPM JPA
 persisted environment you will realize that indeed the human task are
 *persisted* and like so, rehydrated when loading the session in Drools.  In
 fact, those human task related workitems are never removed from the
 database, but that's another bug ... :(

 Any insight?

 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:15 PM, Mauricio Salatino sala...@gmail.comwrote:

   We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 They are never persisted, they are runtime information that you must
 re-register after rehydrating the session. Are you doing that?
 Cheers

 On Fri, Jun 22, 2012 at 7:34 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

We have a fairly large BPMN process running inside a JPA persisted
 StatefulKnowledgeSession using Drools 5.4  JBPM 5.3. Our process involves
 timers, automated tasks, human tasks  most of them are long-running
 processes, so a fault-tolerant scenario is a must.

 We've found what seems to be a weird, weird bug in JBPM-Drools
 regarding the execution of BPMN processes. This is by best to summarize the
 problem:

  We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 So, as the workitem is not in the database, when a human task
 client completes a task that is related to that non-existent workitem, the
 process doesn't get restarted. And the process fails.

 ¿Why does this happens? Lets see:

  When the processs is executed, different workitems get created,
 updated and eventually deleted during the execution of a process up until a
 human task is created ( in our process ). When living in a persistet
 knowledge session, the transaction that is associated to Drools' thread is
 commited right after the human task is created in the human task server ...
 as it is a safe point. Nothing here. Everithing is consistent, if you
 look at the database you will see your session instance, your process
 instance, and the final human task workitem as it is the only workitem
 survivor after the execution ( whatever hadler-managed automated task that
 were executed before the human task are deleted and the human task workitem
 needs to survive as it's completion depends on asyncronous client
 interaction ).

  Now, if you connect to the human task server and complete that
 human task, a message is sent to the Drools session to update the state of
 the work item. The workitem gets updated, the process get restarted and the
 flow continues ... maybe generating a new human task ( which is our case ).
 At this very moment, if you take a look at the database, there are no
 automated-handled-task workitems ( as expected ) but there isn't any human
 task related work item, even worse, the task at the human task server is
 created, persisted and has a reference to the non-existant workitem.

 Days of debugging led us to what we think is the source of the
 problem:

 We found that the execution of the process after completing a task
 is being executed in the same thread as the one that receives the mina
 message that the human task server sends whenever a task is completed. This
 thread is not the same thread that executes the knowledgesession ( where
 the reteoo lives ) and so it 

Re: [rules-users] Drools JBPM Persistence

2012-06-22 Thread Alberto R. Galdo
I see your point, but IMHO that doesn't mean that in certain circumstances,
when the process is being executed in a thread that it is no the same
thread as the one in which drools is executing leads to a situation in
which the persistence mechanisms are not enough to allow a fault tolerant
JBPM for long-time running processes.

As mentioned, there is at least one scenario, at least when mina is
involved, where things are broken.

Alberto R. Galdo
arga...@gmail.com


On Fri, Jun 22, 2012 at 2:50 PM, Mauricio Salatino sala...@gmail.comwrote:

 I think that you are mixing things up.
 Did you take a look at the CommandBasedStatefulKnowledgeSession?
 Every command that represent an operation against the knowledge session is
 being executed inside a transaction, for both rules and processes. As soon
 as a safe point is found (for both processes and rules) the persistence
 mechanism commits the transaction.

 In fact, this will never dissapear unless some communication mechanism
 between Drools  JBPM is developed to allow the processes to be executed
 inside Drools Reteoo thread.
 Take a look at the class that I mention and then try to explain me what
 you mean with the previous sentence.

 Cheers


 On Fri, Jun 22, 2012 at 9:45 AM, Alberto R. Galdo arga...@gmail.comwrote:


 No, I didn't. I need to be able to deploy the human task server and my
 knowledge session in separate JVM's. And Mina is on my way.

 The fact that I am able to do things in some other way doesn't make this
 very problem dissapear ... :(. In fact, this will never dissapear unless
 some communication mechanism between Drools  JBPM is developed to allow
 the processes to be executed  inside Drools Reteoo thread.

 Isn't that so?


 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:17 PM, Mauricio Salatino sala...@gmail.comwrote:

 Both persistence mechanisms are already unified.
 the jBPM-persistence module extends the Drools one adding the relevant
 entities by the processes.

 You can be having problems with the Mina Server, did you try the local
 configuration? The Mina Server was designed to run in a different JVM than
 the session, as a standalone component, if you are running it in the same
 JVM that can be causing some transactional problems as you mention. If you
 need to run it in the same JVM you can use the local configuration, did you
 try that?
 Cheers

 On Fri, Jun 22, 2012 at 8:31 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

I'm opening this thread in the aim of generating a debate about the
 approach to session persistence in Drools and JBPM for BPMN processes which
 by definition are able to generate asynchronous human tasks.

IMHO the current approach needs to be refactored in favor of joining
 the management of the different Drools and JBPM entities in an unique
 manager.

The current implementation offers two managers one in Drools, one in
 JBPM. Each of this managers are wrappers of a shared JPA EntityManager
 context and manage their own entities.

When the integration of JBPM into Drools was done ( leaving behind
 drools flow ), the approach seemed to be to make the entities in JBPM (
 workitems, processinstance and so on ) look like the entities in Drools. As
 a result, the implementation of those entities in JBPM now implement the
 interfaces of the same entities in Drools. That looked like a good
 approach, but the experience, at least mine, seems to reveal it as not that
 good.

In my opinion, the first problem with that approach is that Drools,
 the reteoo algorithm, runs in a single-threaded environment. Drools
 persistence was designed having this in mind, so for the code in Drools,
 there's no doubt that when in a persistent enviroment, the transaction, if
 any, will be bound to the same thread as the one in which the reteoo
 algorithm is executed. That leads to situations where whenever a class in
 JBPM calls drools in a JBPM's thread ( the mina handler thread, a NIO one
 for instance ), Drools thinks that is being executed in it's own thread (
 where things are expected, as the JTA transaction bound for example ) and
 clearly, in some situations it is not the case. Then Drools expects to find
 certain resources and certain environment which are not always there.
 Leading to failure.

As Drools now is a dependency for JBPM through the Knowledge-API, I
 think that the management of the persistence for Drools and JBPM should be
 merged in one that makes no assumptions and manages the needs for
 persistence in a coherent way for both products.

What do you think?


 There can be only one -
 http://en.wikipedia.org/wiki/Highlander_%28film%29


 Alberto R. Galdo
 arga...@gmail.com


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




 --
  - MyJourney @ http://salaboy.wordpress.com
  - Co-Founder @ http://www.jugargentina.org
  - Co-Founder @ 

Re: [rules-users] Workitems doesn't get persisted when completing a task after rehydrating a knowledge session is some circumstances.

2012-06-22 Thread Mauricio Salatino
So, can you create an isolated test where you reproduce:

We are unable to complete a human task after rehydrating a Drools
knowledge session because in some circunstances the generated Drools'
workitems don't get persisted in the database after the completion of a
previous task

And I can take a look on that.. Please create Jira issue for that.
Without a concrete situation it's very difficult to analyze.. Did you check
your transactions not being rolledback.. That's the only situation where I
think that the workItem information will not be persisted.

Cheers

On Fri, Jun 22, 2012 at 9:55 AM, Alberto R. Galdo arga...@gmail.com wrote:


 Sure, WorkItemHandlers are never persisted. I re-register those handlers
 before staring the session, just because I want my tasks to be properly
 executed.

 :(


 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:46 PM, Mauricio Salatino sala...@gmail.comwrote:

 There are two concepts here:
 1) WorkItem - Persist the state of the activity
 2) WorkItemHandlers - Never Persisted

 Are you re-registering the WorkItemHandlers at rehydratation?
 WorkItemHandlers are part of the runtime status and don't get persisted.
 Cheers

 On Fri, Jun 22, 2012 at 9:39 AM, Alberto R. Galdo arga...@gmail.comwrote:

 No, I'm not registering pending workitems at rehydration. That's why I'm
 using Drools  JBPM persistence ;-). I don't want to write my own state
 persistence, as I am a mere user of JBPM  Drools services.

  They are never persisted

 This several methods in org.drools.persitence.jpa.JPAPersistenceContext
 seem to say just the opposite:

 public void persist(WorkItemInfo workItemInfo)
 public void remove(WorkItemInfo workItemInfo)
 public WorkItemInfo merge(WorkItemInfo workItemInfo)

 The fact that lots of workitems get created, persisted, merged and
 finally removed during the life of the process doesn't hide the fact that
 they're in fact,  well, persisted.

 If you take a look at the changes in the database whenever a human task
 is involved in a BPMN process that is executed inside a Drools  JBPM JPA
 persisted environment you will realize that indeed the human task are
 *persisted* and like so, rehydrated when loading the session in Drools.  In
 fact, those human task related workitems are never removed from the
 database, but that's another bug ... :(

 Any insight?

 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:15 PM, Mauricio Salatino sala...@gmail.comwrote:

   We are unable to complete a human task after rehydrating a Drools
 knowledge session because in some circunstances the generated Drools'
 workitems don't get persisted in the database after the completion of a
 previous task

 They are never persisted, they are runtime information that you must
 re-register after rehydrating the session. Are you doing that?
 Cheers

 On Fri, Jun 22, 2012 at 7:34 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

We have a fairly large BPMN process running inside a JPA persisted
 StatefulKnowledgeSession using Drools 5.4  JBPM 5.3. Our process involves
 timers, automated tasks, human tasks  most of them are long-running
 processes, so a fault-tolerant scenario is a must.

 We've found what seems to be a weird, weird bug in JBPM-Drools
 regarding the execution of BPMN processes. This is by best to summarize 
 the
 problem:

  We are unable to complete a human task after rehydrating a
 Drools knowledge session because in some circunstances the generated
 Drools' workitems don't get persisted in the database after the completion
 of a previous task

 So, as the workitem is not in the database, when a human task
 client completes a task that is related to that non-existent workitem, the
 process doesn't get restarted. And the process fails.

 ¿Why does this happens? Lets see:

  When the processs is executed, different workitems get created,
 updated and eventually deleted during the execution of a process up until 
 a
 human task is created ( in our process ). When living in a persistet
 knowledge session, the transaction that is associated to Drools' thread is
 commited right after the human task is created in the human task server 
 ...
 as it is a safe point. Nothing here. Everithing is consistent, if you
 look at the database you will see your session instance, your process
 instance, and the final human task workitem as it is the only workitem
 survivor after the execution ( whatever hadler-managed automated task that
 were executed before the human task are deleted and the human task 
 workitem
 needs to survive as it's completion depends on asyncronous client
 interaction ).

  Now, if you connect to the human task server and complete that
 human task, a message is sent to the Drools session to update the state of
 the work item. The workitem gets updated, the process get restarted and 
 the
 flow continues ... maybe generating a new human task ( which is our case 
 ).
 At this very moment, if you 

Re: [rules-users] Drools JBPM Persistence

2012-06-22 Thread Mauricio Salatino
Drools and jBPM are being executed in the same thread, in your set up mina
is not. Is that what are you pointing out?
Did you really need to have mina in a separate JVM or you can use the Local
Implementation?
Cheers

On Fri, Jun 22, 2012 at 10:00 AM, Alberto R. Galdo arga...@gmail.comwrote:


 I see your point, but IMHO that doesn't mean that in certain
 circumstances, when the process is being executed in a thread that it is no
 the same thread as the one in which drools is executing leads to a
 situation in which the persistence mechanisms are not enough to allow a
 fault tolerant JBPM for long-time running processes.

 As mentioned, there is at least one scenario, at least when mina is
 involved, where things are broken.

 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:50 PM, Mauricio Salatino sala...@gmail.comwrote:

 I think that you are mixing things up.
 Did you take a look at the CommandBasedStatefulKnowledgeSession?
 Every command that represent an operation against the knowledge session
 is being executed inside a transaction, for both rules and processes. As
 soon as a safe point is found (for both processes and rules) the
 persistence mechanism commits the transaction.

 In fact, this will never dissapear unless some communication mechanism
 between Drools  JBPM is developed to allow the processes to be executed
 inside Drools Reteoo thread.
 Take a look at the class that I mention and then try to explain me what
 you mean with the previous sentence.

 Cheers


 On Fri, Jun 22, 2012 at 9:45 AM, Alberto R. Galdo arga...@gmail.comwrote:


 No, I didn't. I need to be able to deploy the human task server and my
 knowledge session in separate JVM's. And Mina is on my way.

 The fact that I am able to do things in some other way doesn't make this
 very problem dissapear ... :(. In fact, this will never dissapear unless
 some communication mechanism between Drools  JBPM is developed to allow
 the processes to be executed  inside Drools Reteoo thread.

 Isn't that so?


 Alberto R. Galdo
 arga...@gmail.com



 On Fri, Jun 22, 2012 at 2:17 PM, Mauricio Salatino sala...@gmail.comwrote:

 Both persistence mechanisms are already unified.
 the jBPM-persistence module extends the Drools one adding the relevant
 entities by the processes.

 You can be having problems with the Mina Server, did you try the local
 configuration? The Mina Server was designed to run in a different JVM than
 the session, as a standalone component, if you are running it in the same
 JVM that can be causing some transactional problems as you mention. If you
 need to run it in the same JVM you can use the local configuration, did you
 try that?
 Cheers

 On Fri, Jun 22, 2012 at 8:31 AM, Alberto R. Galdo arga...@gmail.comwrote:

 Hi,

I'm opening this thread in the aim of generating a debate about the
 approach to session persistence in Drools and JBPM for BPMN processes 
 which
 by definition are able to generate asynchronous human tasks.

IMHO the current approach needs to be refactored in favor of
 joining the management of the different Drools and JBPM entities in an
 unique manager.

The current implementation offers two managers one in Drools, one
 in JBPM. Each of this managers are wrappers of a shared JPA EntityManager
 context and manage their own entities.

When the integration of JBPM into Drools was done ( leaving behind
 drools flow ), the approach seemed to be to make the entities in JBPM (
 workitems, processinstance and so on ) look like the entities in Drools. 
 As
 a result, the implementation of those entities in JBPM now implement the
 interfaces of the same entities in Drools. That looked like a good
 approach, but the experience, at least mine, seems to reveal it as not 
 that
 good.

In my opinion, the first problem with that approach is that Drools,
 the reteoo algorithm, runs in a single-threaded environment. Drools
 persistence was designed having this in mind, so for the code in Drools,
 there's no doubt that when in a persistent enviroment, the transaction, if
 any, will be bound to the same thread as the one in which the reteoo
 algorithm is executed. That leads to situations where whenever a class in
 JBPM calls drools in a JBPM's thread ( the mina handler thread, a NIO one
 for instance ), Drools thinks that is being executed in it's own thread (
 where things are expected, as the JTA transaction bound for example ) and
 clearly, in some situations it is not the case. Then Drools expects to 
 find
 certain resources and certain environment which are not always there.
 Leading to failure.

As Drools now is a dependency for JBPM through the Knowledge-API, I
 think that the management of the persistence for Drools and JBPM should be
 merged in one that makes no assumptions and manages the needs for
 persistence in a coherent way for both products.

What do you think?


 There can be only one -
 http://en.wikipedia.org/wiki/Highlander_%28film%29


 Alberto R. 

[rules-users] Detect conflit between rules with Drools Verifier

2012-06-22 Thread paco
I want to detect the conflict between the rules with Drools Verifier. For
example the first condition of the second rule is present in the first rule
and the actions to perform are the same in both rules as they demonstrate in
the following case. It works very well when these rules belong to the same
drl file. 
- fichier  a.drl---
rule a
no-loop true
ruleflow-group group1
dialect mvel
when
A==0
then
Action1
end
rule b
no-loop true
ruleflow-group group1
dialect mvel
when
A==0  B==1
then
Action1
end

The problem arises when I separated its rules and that I have to put each in
its own file
  a.drl
rule a
no-loop true
ruleflow-group group1
dialect mvel
when
A==0
then
Action1
end

--b.drl
rule b
no-loop true
ruleflow-group group1
dialect mvel
when
A==0  B==1
then
Action1
end
I can no longer detect this problem with Drools Verifier.
Does anyone ever encountered this problem?
How can I do to write a small program to audit if this case?


--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-verifier-tp2681002p4018170.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] Trouble wrapping my head around window.length(1)

2012-06-22 Thread Ladd
I'm new to Drools and have what I think should be a simple use case.  But I'm
getting some puzzling results from my tests.

I have a simple class with just a key and value.  What I want to detect is
when the last occurrence with key X has a value of ALARM and the last
occurrence with key Y has a value of ALARM.

Could someone please either educate me or point me to the documentation that
explains how this would be done?  Many thanks in advance!!

Here's my test code and results:

*The event class:*
public class MyEvent {

String key;
String value;

public MyEvent( String key, String value ) {
this.key = key;
this.value = value;
}

public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

*The test runner:*
@Test
public void testWindowLen1() {

StringBuilder sb = new StringBuilder();

sb.append( import drools.tests.MyEvent \n );
sb.append(  \n );

sb.append( declare MyEvent @role(event) end \n ); 
sb.append(  \n );

sb.append( rule \Any event detected\ \n );
sb.append(  \n );
sb.append( salience 10 \n );
sb.append( when \n );
sb.append( f : MyEvent() \n );
sb.append( then \n );
sb.append( System.out.println( \ fault seen 
with key \ +
f.getKey() + \ value \ + f.getValue() ); \n );
sb.append( end \n );
sb.append(  \n );

sb.append( rule \Faults coincide\ \n );
sb.append(  \n );
sb.append( when \n );
sb.append( f1 : MyEvent( key == \faultType1\, value == 
\ALARM\ )
over window:length( 1 ) \n );
sb.append( f2 : MyEvent( key == \faultType2\, value == 
\ALARM\ )
over window:length( 1 ) \n );
sb.append( then \n );
sb.append( System.out.println( \ both faults 
are active!
f1.key = \ + f1.getKey() + \ f2.key = \ + f2.getKey() ); \n );
sb.append( end \n );
sb.append(  \n );

sb.append( rule \Faults don't coincide\ \n );
sb.append(  \n );
sb.append( when \n );
sb.append( f1 : MyEvent( key == \faultType1\, value != 
\ALARM\ )
over window:length( 1 ) \n );
sb.append( or \n );
sb.append( f2 : MyEvent( key == \faultType2\, value != 
\ALARM\ )
over window:length( 1 ) \n );
sb.append( then \n );
sb.append( System.out.println( \ at least one 
fault isn't
active!\ ); \n );
sb.append( end \n );


StatefulKnowledgeSession ksession = null;
KnowledgeBase kbase = null;
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.STREAM );

kbase = KnowledgeBaseFactory.newKnowledgeBase( config );

ksession = kbase.newStatefulKnowledgeSession();

KnowledgeBuilder kbuilder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();

kbuilder.add( ResourceFactory.newByteArrayResource(
sb.toString().getBytes() ), ResourceType.DRL );
if( kbuilder.hasErrors() ) {
System.err.println( kbuilder.getErrors().toString() );
} else {
kbase.addKnowledgePackages( 
kbuilder.getKnowledgePackages() );
}

// Inject the first fault = ALARM
MyEvent faultType1Alarm = new MyEvent( faultType1, ALARM );
System.out.println( Firing fault1 = ALARM );
ksession.insert( faultType1Alarm );
ksession.fireAllRules();

// Inject the second fault = ALARM
// Want this to trigger the Faults concide rule
MyEvent faultType2Alarm = new MyEvent( faultType2, ALARM );
System.out.println( Firing fault2 = ALARM );
ksession.insert( faultType2Alarm );
ksession.fireAllRules();

// Inject the first fault = OK
// Want this to trigger the Faults don't concide rule
MyEvent faultType1OK = new MyEvent( faultType1, OK 

[rules-users] News functionalies on Drools verifier

2012-06-22 Thread paco
Hi everybody

Is it possible to add new functionalies on Drools verifier?


--
View this message in context: 
http://drools.46999.n3.nabble.com/News-functionalies-on-Drools-verifier-tp4018172.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] Setting unused globals on a session

2012-06-22 Thread gqmulligan
Vincent,

I am looking at using your third option but when I call
kSession.getGlobals() but there aren't any global variables set in there.  I
looked at the source to see what setGlobal was doing and that looks like it
checks the Globals on the internal session which gets it from its internal
rule base.

I don't have access to the internal rule base's globals from the
StatefulKnowledgeSession interface and would have to do a cast in order to
get the internal rule base to get the global list I need.

Does this sound like the right answer or am I missing something simple?  I
am using Drools 5.3 by the way in case that makes a difference.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Setting-unused-globals-on-a-session-tp4018146p4018173.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] Error deploying drools-spring (5.4.0.Final) on ServiceMix 4.4.1

2012-06-22 Thread Nicholas Hemley
Hello,

I have deployed drools-spring on ServiceMix 4.4.1 and suffer the following 
error:

java.lang.NullPointerException
at 
org.apache.felix.framework.resolver.ResolverImpl.toStringBlame(ResolverImpl.java:1521)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]
at 
org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:943)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]
at 
org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:130)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]
at 
org.apache.felix.framework.Felix$StatefulResolver.resolve(Felix.java:4129)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]
at 
org.apache.felix.framework.Felix.resolveBundle(Felix.java:3459)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]
at 
org.apache.felix.framework.Felix.startBundle(Felix.java:1739)[org.apache.felix.framework-3.0.9-fuse-07-03.jar:]

Nothing further in the log, so I am a bit stumped as to what the actual problem 
is.

Has anyone successfully deployed drools 5.4.0.Final to ServiceMix 4.4.x, please?

Cheerio,
Nic

Nicholas Hemley
Direct: +44 (0) 117 231 0003

Scott Logic  | 10 Victoria Street, Bristol, BS1 6BN
Reception: +44 (0) 117 231 


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


[rules-users] Does Guvnor Support Traits?

2012-06-22 Thread BenjaminWolfe
I'm pretty new to developer forums.  If my question is best asked in a
different venue, feel free to point me there.  And if it's vague (see the
full version below), please ask clarifying questions.  Thank you!

I was just reading in the 5.4 docs about traits, donning the isA keyword...
pretty exciting stuff.  It allows me a lot of flexibility as a rule-writer. 
But my company's upcoming implementation of Drools is going to feature
Guvnor pretty prominently.  (We're in the process of rolling it out.)  Does
Guvnor support traits?

I should mention that I'm an analyst, and our developers are new to Drools
and Guvnor as well.  Traits are coming up in one of our early projects, as
we consider whether to squish two similar things into the same fact type (so
that we can easily use the same rules on both) or separate them out into
two.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176.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] Accumulator being executed depending on the number of events

2012-06-22 Thread Wolfgang Laun
(Something strange is indeed going on which does result in differences
between accumulate functions with and without reverse. But I see now
that this is not what worries you. Sorry - but read on.)

This particular condition:
  when
 $event: TestEvent( $key:key)   
 $total : Number( )  from accumulate( event : TestEvent( key ==
$key  ) , test( 1 ) )
  then

results in a first evaluation for the first TestEvent(), creating one
activation, binding $event to this TestEvent(). When the second
TestEent() is inserted, another activation is added, this time with
$event bound to the second TestEvent(), and another accumulate is
required. The first accumulate is extended to include the second
TestEvent; the second accumulate computes, from scratch, for both. The
same thing happens with the third TestEvent so that you now have three
separate accumulates.

If you want to compute once and only once for each value of
TestEvent.key, you'll have to avoid the spurious activations for
successive TestEvents with the same key, e.g.,
  when
 $event: TestEvent( $key:key )
 not TestEvent( key == $key, this after $event )
 $total : Number( )  from accumulate( event : TestEvent( key ==
$key  ) , test( 1 ) )
  then

-W









On 22/06/2012, e...@yahoo.com e...@yahoo.com wrote:
 Hi Wolfgang,

 I couldn't agree more with your analysis unfortunately it seems that or i
 have something wrong with my rule or there is something wrong with the
 implementation?

 First off all the reserve was set to false this would mean that once the
 rule is finished the context shouldn't be available any more and therefore
 not updated when the rule is executed again  (as recalculation would
 require
 all the facts to be processed again anyway). Now if my understanding is
 correct then this is not how drools behaves, you can see evidence of this
 in
 the trace of the first post.

 I tried returning true for the reverse but the behaviour is exactly the
 same. Each new fact creates a new context then for all matching facts the
 accuulate is called on that context. The accumulate method is called on all
 existing contexts for the new fact.

 Here is the rule (test just makes a sum of the values)

 import eu.mc2bis.drools.TestEvent;

 declare TestEvent
   @role(event)
   @timestamp( eventDate )
 end

 rule test accumulator
   salience 100 // Make sure this rule is always executed by giving it a
 very
 high salience
   no-loop true
 when
   $event: TestEvent( $key:key)
 $total : Number( )  from accumulate( event : TestEvent( key == $key  ) ,

 test( 1 ) )   
 then
   System.out.println(-- Rule output Total for key: + $key +  total:  +
 $total);
 end


 here is the output with reverse:false

 Main:inserting event with key:0
 - Accumulator: Context created:553
 - Accumulator: Init called for context:553
 - Accumulator: getResults() called for context:553
 - Accumulator: accumulate called for context:553 key:553 value:1
 - Accumulator: getResults() called for context:553
 Main:fireAllRules start
 -- Rule output Total for key:0 total:1
 Main:fireAllRules finished
 Main:inserting event with key:0
 - Accumulator: Context created:454
 - Accumulator: Init called for context:454
 - Accumulator: accumulate called for context:454 key:454 value:1
 - Accumulator: getResults() called for context:454
 - Accumulator: accumulate called for context:553 key:553 value:1
 - Accumulator: accumulate called for context:454 key:454 value:1
 - Accumulator: getResults() called for context:454
 - Accumulator: getResults() called for context:553
 Main:fireAllRules start
 -- Rule output Total for key:0 total:2
 -- Rule output Total for key:0 total:2
 Main:fireAllRules finished
 Main:inserting event with key:0
 - Accumulator: Context created:695
 - Accumulator: Init called for context:695
 - Accumulator: accumulate called for context:695 key:695 value:1
 - Accumulator: accumulate called for context:695 key:695 value:1
 - Accumulator: getResults() called for context:695
 - Accumulator: accumulate called for context:553 key:553 value:1
 - Accumulator: accumulate called for context:454 key:454 value:1
 - Accumulator: accumulate called for context:695 key:695 value:1
 - Accumulator: getResults() called for context:695
 - Accumulator: getResults() called for context:454
 - Accumulator: getResults() called for context:553
 Main:fireAllRules start
 -- Rule output Total for key:0 total:3
 -- Rule output Total for key:0 total:3
 -- Rule output Total for key:0 total:3
 Main:fireAllRules finished
 Time (ms) required to update: 100k profiles = 30
 Ended

 I would have expected:

 Main:inserting event with key:0
 - Accumulator: Context created:553
 - Accumulator: Init called for context:553
 - Accumulator: getResults() called for context:553
 - Accumulator: accumulate called for context:553 key:553 value:1
 - Accumulator: getResults() called for context:553
 Main:fireAllRules start
 -- 

Re: [rules-users] News functionalies on Drools verifier

2012-06-22 Thread Wolfgang Laun
On 22/06/2012, paco fifi_nji...@yahoo.fr wrote:
 Hi everybody

 Is it possible to add new functionalies on Drools verifier?


Yes. It only needs someone to do it.
-W
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Does Guvnor Support Traits?

2012-06-22 Thread Michael Anstis
Guvnor only supports traits in technical rules (which are effectively
free-format DRL, i.e. text).

I think traits are still considered experimental at this stage (Sotty, Mark
can you confirm?) so we'd be reluctant to introduce better UI support at
this time.

The need to add at some stage has been identified, but not yet.

On 22 June 2012 18:13, BenjaminWolfe benjamin.e.wo...@gmail.com wrote:

 I'm pretty new to developer forums.  If my question is best asked in a
 different venue, feel free to point me there.  And if it's vague (see the
 full version below), please ask clarifying questions.  Thank you!

 I was just reading in the 5.4 docs about traits, donning the isA keyword...
 pretty exciting stuff.  It allows me a lot of flexibility as a rule-writer.
 But my company's upcoming implementation of Drools is going to feature
 Guvnor pretty prominently.  (We're in the process of rolling it out.)  Does
 Guvnor support traits?

 I should mention that I'm an analyst, and our developers are new to Drools
 and Guvnor as well.  Traits are coming up in one of our early projects, as
 we consider whether to squish two similar things into the same fact type
 (so
 that we can easily use the same rules on both) or separate them out into
 two.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176.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] Setting unused globals on a session

2012-06-22 Thread gqmulligan
I actually found this method by Wolfgang in an earlier post from over a year
ago:

KnowledgePackage kPackage = ...;
KnowledgePackageImp kPackageImp = (KnowledgePackageImp)kPackage;
org.drools.rule.Package package_ = kPackageImp.pkg;

// globals: key is name, value is type name
MapString, String name2global = package_.getGlobals();

Is this still the accepted method of getting globals?

Thanks.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Setting-unused-globals-on-a-session-tp4018146p4018180.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] Setting unused globals on a session

2012-06-22 Thread Wolfgang Laun
Mind you, it's not in the stable API, but I suppose it still works with 5.4.0.

It's one of the several thing I keep nagging about: that what you can
program in DRL - which is considered to be stable - you should be able
to retrieve via the stable API, at runtime.

Preaching to deaf ears. :-\
-W



On 22/06/2012, gqmulligan gqmulli...@gmail.com wrote:
 I actually found this method by Wolfgang in an earlier post from over a
 year
 ago:

 KnowledgePackage kPackage = ...;
 KnowledgePackageImp kPackageImp = (KnowledgePackageImp)kPackage;
 org.drools.rule.Package package_ = kPackageImp.pkg;

 // globals: key is name, value is type name
 MapString, String name2global = package_.getGlobals();

 Is this still the accepted method of getting globals?

 Thanks.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Setting-unused-globals-on-a-session-tp4018146p4018180.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] drools planner ConstraintOccurrence

2012-06-22 Thread Ricardo
Hi,
I am learning drools planner,  please explain to me about the
ConstraintOccurrence (Int, Double,Long and Umweighted) object used in the
then part of the drools planner drl file. My doubt is when to use this each
type of this class and how it makes changes in the score calculations.
note: Already search the mailing list, src code and read the user guide but
no details available

best regards,

-
with kind regards,

--
View this message in context: 
http://drools.46999.n3.nabble.com/drools-planner-ConstraintOccurrence-tp4018182.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] 2d contraints in the drools planner drl accumulate function

2012-06-22 Thread Ricardo
Is any one knows how to use 2d constraint(Object(String attr1, String attr2))
in the drools planner, planing entity to create drl file (may be in
accumulate function).

thanks,

-
with kind regards,

--
View this message in context: 
http://drools.46999.n3.nabble.com/2d-contraints-in-the-drools-planner-drl-accumulate-function-tp4018183.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] Trouble wrapping my head around window.length(1)

2012-06-22 Thread Wolfgang Laun
The first firing of Faults coincide is a bug.

Rule Faults don't coincide doesn't do what I think you want it to do
- or is inclusive, not exclusive.

I'd recommend using this rule:
rule Detect
when
f1 : MyEvent( key == faultType1, value == ALARM )
 not MyEvent( key == faultType1, this after f1 )
f2 : MyEvent( key == faultType2, value == ALARM )
 not MyEvent( key == faultType2, this after f2 )
then
System.out.println(  BOTH FAULTS ARE ACTIVE! f1.key =
 + f1.getKey() +  f2.key =  + f2.getKey() );
end

-W


On 22/06/2012, Ladd l...@codemettle.com wrote:
 I'm new to Drools and have what I think should be a simple use case.  But
 I'm
 getting some puzzling results from my tests.

 I have a simple class with just a key and value.  What I want to detect is
 when the last occurrence with key X has a value of ALARM and the last
 occurrence with key Y has a value of ALARM.

 Could someone please either educate me or point me to the documentation
 that
 explains how this would be done?  Many thanks in advance!!

 Here's my test code and results:

 *The event class:*
 public class MyEvent {
   
   String key;
   String value;
   
   public MyEvent( String key, String value ) {
   this.key = key;
   this.value = value;
   }
   
   public String getKey() {
   return key;
   }
   public void setKey(String key) {
   this.key = key;
   }
   public String getValue() {
   return value;
   }
   public void setValue(String value) {
   this.value = value;
   }
 }

 *The test runner:*
   @Test
   public void testWindowLen1() {
   
   StringBuilder sb = new StringBuilder();
   
   sb.append( import drools.tests.MyEvent \n );
   sb.append(  \n );
   
   sb.append( declare MyEvent @role(event) end \n );
   sb.append(  \n );
   
   sb.append( rule \Any event detected\ \n );
   sb.append(  \n );
   sb.append( salience 10 \n );
   sb.append( when \n );
   sb.append( f : MyEvent() \n );
   sb.append( then \n );
   sb.append( System.out.println( \ fault seen 
 with key \ +
 f.getKey() + \ value \ + f.getValue() ); \n );
   sb.append( end \n );
   sb.append(  \n );
   
   sb.append( rule \Faults coincide\ \n );
   sb.append(  \n );
   sb.append( when \n );
   sb.append( f1 : MyEvent( key == \faultType1\, value == 
 \ALARM\ )
 over window:length( 1 ) \n );
   sb.append( f2 : MyEvent( key == \faultType2\, value == 
 \ALARM\ )
 over window:length( 1 ) \n );
   sb.append( then \n );
   sb.append( System.out.println( \ both faults 
 are active!
 f1.key = \ + f1.getKey() + \ f2.key = \ + f2.getKey() ); \n );
   sb.append( end \n );
   sb.append(  \n );
   
   sb.append( rule \Faults don't coincide\ \n );
   sb.append(  \n );
   sb.append( when \n );
   sb.append( f1 : MyEvent( key == \faultType1\, value != 
 \ALARM\ )
 over window:length( 1 ) \n );
   sb.append( or \n );
   sb.append( f2 : MyEvent( key == \faultType2\, value != 
 \ALARM\ )
 over window:length( 1 ) \n );
   sb.append( then \n );
   sb.append( System.out.println( \ at least one 
 fault isn't
 active!\ ); \n );
   sb.append( end \n );
   
   
   StatefulKnowledgeSession ksession = null;
   KnowledgeBase kbase = null;
   KnowledgeBaseConfiguration config =
 KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
   config.setOption( EventProcessingOption.STREAM );
   
   kbase = KnowledgeBaseFactory.newKnowledgeBase( config );
   
   ksession = kbase.newStatefulKnowledgeSession();
   
   KnowledgeBuilder kbuilder =
 KnowledgeBuilderFactory.newKnowledgeBuilder();
   
   kbuilder.add( ResourceFactory.newByteArrayResource(
 sb.toString().getBytes() ), ResourceType.DRL );
   if( kbuilder.hasErrors() ) {
   System.err.println( kbuilder.getErrors().toString() );
   } else {
   kbase.addKnowledgePackages( 
 kbuilder.getKnowledgePackages() );
   }
   
   // Inject the first fault = ALARM
   MyEvent faultType1Alarm = new MyEvent( faultType1, ALARM );
   System.out.println( Firing fault1 = ALARM );
   ksession.insert( faultType1Alarm );
   ksession.fireAllRules();
   
   

Re: [rules-users] Trouble wrapping my head around window.length(1)

2012-06-22 Thread Ladd
Thanks a lot for the reply W!  I tried your suggested alternative and it
worked as I need it to.

- Ladd

--
View this message in context: 
http://drools.46999.n3.nabble.com/Trouble-wrapping-my-head-around-window-length-1-tp4018171p4018186.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] drools planner ConstraintOccurrence

2012-06-22 Thread Geoffrey De Smet
Most use case use IntConstraintOccurence because they have an int hard 
score and an int soft score, for example in the cloud balancing example, ...
The int is the weight.

Take a look at the examples cloudBalancing, nqueens, ... and the manual 
chapter about score calculation.

Op 22-06-12 20:18, Ricardo schreef:
 Hi,
 I am learning drools planner,  please explain to me about the
 ConstraintOccurrence (Int, Double,Long and Umweighted) object used in the
 then part of the drools planner drl file. My doubt is when to use this each
 type of this class and how it makes changes in the score calculations.
 note: Already search the mailing list, src code and read the user guide but
 no details available

 best regards,

 -
 with kind regards,

 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/drools-planner-ConstraintOccurrence-tp4018182.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


-- 
With kind regards,
Geoffrey De Smet


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


Re: [rules-users] drools planner ConstraintOccurrence

2012-06-22 Thread Ricardo
Hi thanks lot, for the last one week I am breaking my head to understand the
drools planner. 

I have two questions...
1) When to use Unweighted constrains?
2) Is any way I can combine the following two rules in to one rule, I mean
writing length and width in one rule condition instead of two. I tried but I
dont know how to use the accumulate for 2d constraint. Is any alternate way
to write this condition.

I really appreciate your patients and time, thanks lot again

//

// Hard constraints
//

rule requiredLengthTotal
when
$room : Room($length : length)
$requiredSpaceTotal : Number(intValue  $length) from accumulate(
Table(
room == $room, 
$tablelength : length),
sum($tablelength)
)
then
insertLogical(new IntConstraintOccurrence(requiredLengthTotal,
ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $length,
$room));
end

rule requiredWidthTotal
when
$room : Room($width : width)
$requiredSpaceTotal : Number(intValue  $width) from accumulate(
Table(
room == $room, 
$tablewidth : width),
sum($tablewidth)
)
then
insertLogical(new IntConstraintOccurrence(requiredWidthTotal,
ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $width,
$room));
end

-
with kind regards,

--
View this message in context: 
http://drools.46999.n3.nabble.com/drools-planner-ConstraintOccurrence-tp4018182p4018189.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] Does Guvnor Support Traits?

2012-06-22 Thread BenjaminWolfe
Sure.

So if I did author rules in Guvnor using traits, I would (1) write a
technical rule to declare the trait, (2) write a technical rule to don that
trait given whatever LHS pattern, and (3) write another technical rule to
make use of the trait in a useful way -- all of which I would do without a
GUI, but that's OK if I can handle some rules syntax.  Did I get that right?

Also, when I run test cases will Guvnor know what to do with the traits? 
(My hunch is yes, because the stuff behind the scenes is all the same.)

Lastly -- again I'm a greenhorn -- does experimental mean you might abandon
the feature, or just that it might need honing?

By the way, in the etiquette, it just means not to send entire messages just
to say Thanks, right?  I mean it's not just that programmers are so cranky
they don't want you to be nice? :D

--
View this message in context: 
http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176p4018191.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] Does Guvnor Support Traits?

2012-06-22 Thread Michael Anstis
Hi Benjamin,

Your assumptions are correct - not so green after all :)

Technical Rules are just plain text DRL, so whatever drools-expert supports
is possible.

TBH, I've not heard of anybody else using traits (or attempting to) in
Guvnor, so any feedback would be great.

AFAIK, experimental means some things might need smoothing out - sotty or
conan will know exactly the status; I'm pretty confident they are to remain.

With kind regards,

Mike

On 22 June 2012 22:33, BenjaminWolfe benjamin.e.wo...@gmail.com wrote:

 Sure.

 So if I did author rules in Guvnor using traits, I would (1) write a
 technical rule to declare the trait, (2) write a technical rule to don that
 trait given whatever LHS pattern, and (3) write another technical rule to
 make use of the trait in a useful way -- all of which I would do without a
 GUI, but that's OK if I can handle some rules syntax.  Did I get that
 right?

 Also, when I run test cases will Guvnor know what to do with the traits?
 (My hunch is yes, because the stuff behind the scenes is all the same.)

 Lastly -- again I'm a greenhorn -- does experimental mean you might abandon
 the feature, or just that it might need honing?

 By the way, in the etiquette, it just means not to send entire messages
 just
 to say Thanks, right?  I mean it's not just that programmers are so
 cranky
 they don't want you to be nice? :D

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176p4018191.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] Does Guvnor Support Traits?

2012-06-22 Thread Davide Sottara
Experimental means it has not been tested thoroughly yet, so it might be
subject to improvements and even some language changes. Also, it means that
the docs are really lacking! :) (shame on me!).

I have never tried to use traits in guvnor yet, but my first impression is
that you don't really need 
anything special. All the type declarations are managed with annotations,
and the rules are transparent.

1) Consider that 
declare trait X
can also be written
declare X @kind(trait)

2) donning is a RHS action, you'd just need to write a free action

3) Trait types are compiled into interfaces, so you can just use them in the
LHS exactly in the same way you'd use a declared class - i.e. to write
patterns!. 

Feel free to contact me for feedback/bugs/requests/questions and let me know
if you want to get involved!
Best
Davide
dso...@gmail.com




--
View this message in context: 
http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176p4018193.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] JBPM ontology

2012-06-22 Thread Davide Sottara
Hi Olfa,
sorry, I've been travelling in the last 3 weeks, I'll answer your emails
shortly after.
Now, for a general, public answer: integrating business processes and
ontologies is a very broad question...
Some possible interpretations include:

1) Using a BP ontology as a meta-model of BPs, so that BPMN processes would
be recognized as instances of the concepts defined in that ontology. You can
then reason over the precesses themselves.
2) Using a BP to orchestrate Semantic Web Services
3) Using the ontology as a data/domain model, shared between the tasks, to
exchange information
4) Use a BP to express the transformations to be applied to a set of data
defined in an ontology
5) Any combination of the above and more...

you can google up a number of papers, reports, standards, works etc for any
of them and possibly more
JBPM people, feel free to pick up the lines ;)
Best
Davide

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-JBPM-ontology-tp4018187p4018194.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] Does Guvnor Support Traits?

2012-06-22 Thread Michael Anstis
Thanks Davide, your comments are much appreciated.

sent on the move

On 22 Jun 2012 22:52, Davide Sottara dso...@gmail.com wrote:

 Experimental means it has not been tested thoroughly yet, so it might be
 subject to improvements and even some language changes. Also, it means that
 the docs are really lacking! :) (shame on me!).

 I have never tried to use traits in guvnor yet, but my first impression is
 that you don't really need
 anything special. All the type declarations are managed with annotations,
 and the rules are transparent.

 1) Consider that
 declare trait X
 can also be written
 declare X @kind(trait)

 2) donning is a RHS action, you'd just need to write a free action

 3) Trait types are compiled into interfaces, so you can just use them in
 the
 LHS exactly in the same way you'd use a declared class - i.e. to write
 patterns!.

 Feel free to contact me for feedback/bugs/requests/questions and let me
 know
 if you want to get involved!
 Best
 Davide
 dso...@gmail.com




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Does-Guvnor-Support-Traits-tp4018176p4018193.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] planner score calculation error...

2012-06-22 Thread Ricardo

Hi when i use the following drl file for score calculation It assign a
bigger table into the smaller room. help will be appreciated

console output is as follows..

*Solved Organizer with 2 rooms and 3 tables:
  Table 1 - Room 1
  Table 2 - Room 2
  Table 3 - Room 2*

test data:
Room room1 = new Room(10, 10);
room1.setId((long) 1);

Room room2 = new Room(10, 10);
room2.setId((long) 2);


   Table table1 = new Table(10, 10);
table1.setId((long) 1);

Table table2 = new Table(9, 9);
table2.setId((long) 2);

Table table3 = new Table(9, 9);
table3.setId((long) 3);

drl file for score calculation...

//created on: Jun 18, 2012
package org.drools.planner.organizer;
dialect java 
//list any import classes here.

import
org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder;
import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
import org.drools.planner.core.score.constraint.ConstraintType;


import org.drools.planner.organizer.domain.Room;
import org.drools.planner.organizer.domain.Table;

//declare any global variables here

global HardAndSoftScoreHolder scoreHolder;


//

// Hard constraints
//

rule requiredLengthTotal
when
$room : Room($length : length)
$requiredSpaceTotal : Number(intValue  $length) from accumulate(
Table(
room == $room, 
$tablelength : length),
sum($tablelength)
)
then
insertLogical(new IntConstraintOccurrence(requiredLengthTotal,
ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $length,
$room));
end

rule requiredWidthTotal
when
$room : Room($width : width)
$requiredSpaceTotal : Number(intValue  $width) from accumulate(
Table(
room == $room, 
$tablewidth : width),
sum($tablewidth)
)
then
insertLogical(new IntConstraintOccurrence(requiredWidthTotal,
ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $width,
$room));
end
//

// Soft constraints
//

rule roomLengthCapacity
when
$room : Room($length : length)
$table : Table(room == $room, length  $length, $tablelength :
length)
then
insertLogical(new IntConstraintOccurrence(roomLengthCapacity,
ConstraintType.NEGATIVE_SOFT,
($tablelength - $length),
$room, $table));
end


rule roomWidthCapacity
when
$room : Room($width : width)
$table : Table(room == $room, width  $width, $tablewidth : width)
then
insertLogical(new IntConstraintOccurrence(roomWidthCapacity,
ConstraintType.NEGATIVE_SOFT,
($tablewidth - $width),
$room, $table));
end
//

// Calculate score
//


// Accumulate hard constraints
rule hardConstraintsBroken
salience -1 // Do the other rules first (optional, for performance)
when
$hardTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight) 
)
then
scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
end

// Accumulate soft constraints
rule softConstraintsBroken
salience -1 // Do the other rules first (optional, for performance)
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_SOFT, $weight : weight),
sum($weight) 
)
then
scoreHolder.setSoftConstraintsBroken($softTotal.intValue());
end

-
with kind regards,

--
View this message in context: 
http://drools.46999.n3.nabble.com/planner-score-calculation-error-tp4018196.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] planner score calculation error...

2012-06-22 Thread Cedric Hurst
Offhand, it seems like the room needs to maintain a 'grid' of x and y tiles and 
which tables occupy each tile.  That way you can plan while making sure that no 
two tables overlap.

Sent from my iPhone

On Jun 22, 2012, at 5:55 PM, Ricardo sprabak...@gmail.com wrote:

 
 Hi when i use the following drl file for score calculation It assign a
 bigger table into the smaller room. help will be appreciated
 
 console output is as follows..
 
 *Solved Organizer with 2 rooms and 3 tables:
  Table 1 - Room 1
  Table 2 - Room 2
  Table 3 - Room 2*
 
 test data:
Room room1 = new Room(10, 10);
room1.setId((long) 1);
 
Room room2 = new Room(10, 10);
room2.setId((long) 2);
 
 
   Table table1 = new Table(10, 10);
table1.setId((long) 1);
 
Table table2 = new Table(9, 9);
table2.setId((long) 2);
 
Table table3 = new Table(9, 9);
table3.setId((long) 3);
 
 drl file for score calculation...
 
 //created on: Jun 18, 2012
 package org.drools.planner.organizer;
 dialect java 
 //list any import classes here.
 
 import
 org.drools.planner.core.score.buildin.hardandsoft.HardAndSoftScoreHolder;
 import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
 import org.drools.planner.core.score.constraint.ConstraintType;
 
 
 import org.drools.planner.organizer.domain.Room;
 import org.drools.planner.organizer.domain.Table;
 
 //declare any global variables here
 
 global HardAndSoftScoreHolder scoreHolder;
 
 
 //
 
 // Hard constraints
 //
 
 rule requiredLengthTotal
when
$room : Room($length : length)
$requiredSpaceTotal : Number(intValue  $length) from accumulate(
Table(
room == $room, 
$tablelength : length),
sum($tablelength)
)
then
insertLogical(new IntConstraintOccurrence(requiredLengthTotal,
 ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $length,
$room));
 end
 
 rule requiredWidthTotal
when
$room : Room($width : width)
$requiredSpaceTotal : Number(intValue  $width) from accumulate(
Table(
room == $room, 
$tablewidth : width),
sum($tablewidth)
)
then
insertLogical(new IntConstraintOccurrence(requiredWidthTotal,
 ConstraintType.NEGATIVE_HARD,
$requiredSpaceTotal.intValue() - $width,
$room));
 end
 //
 
 // Soft constraints
 //
 
 rule roomLengthCapacity
when
$room : Room($length : length)
$table : Table(room == $room, length  $length, $tablelength :
 length)
then
insertLogical(new IntConstraintOccurrence(roomLengthCapacity,
 ConstraintType.NEGATIVE_SOFT,
($tablelength - $length),
$room, $table));
 end
 
 
 rule roomWidthCapacity
when
$room : Room($width : width)
$table : Table(room == $room, width  $width, $tablewidth : width)
then
insertLogical(new IntConstraintOccurrence(roomWidthCapacity,
 ConstraintType.NEGATIVE_SOFT,
($tablewidth - $width),
$room, $table));
 end
 //
 
 // Calculate score
 //
 
 
 // Accumulate hard constraints
 rule hardConstraintsBroken
salience -1 // Do the other rules first (optional, for performance)
when
$hardTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
 ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight) 
)
then
scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
 end
 
 // Accumulate soft constraints
 rule softConstraintsBroken
salience -1 // Do the other rules first (optional, for performance)
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
 ConstraintType.NEGATIVE_SOFT, $weight : weight),
sum($weight) 
)
then
scoreHolder.setSoftConstraintsBroken($softTotal.intValue());
 end
 
 -
 with kind regards,
 
 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/planner-score-calculation-error-tp4018196.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] traits - don more than 3 pojos, got IllegalArgumentException

2012-06-22 Thread Davide Sottara
I tried to repdroduce the issue, but I couldn't get the same error.. could
you provide a test case?
Also notice that I made some fixes in a pull request which has been out
there for a while, waiting
to get approved.. it may be the case that the fix is already contained in
there
Davide

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-traits-don-more-than-3-pojos-got-IllegalArgumentException-tp3788670p4018198.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] traits - don more than 3 pojos, got IllegalArgumentException

2012-06-22 Thread Davide Sottara
The DRL you reported is working for me with both stateful and stateless.. it
may indeed be the case that I have already fixed the issue as a part of
another fix :) The PR should be confirmed in a few days

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-traits-don-more-than-3-pojos-got-IllegalArgumentException-tp3788670p4018199.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