Re: [rules-users] collection question

2010-07-21 Thread Wolfgang Laun
Things would be smpler if you could avoid re-creating Product objects
because adding an identical Object does not change the Set. (This
could be implemented with the help of a global MapString,Product,)

Second, overriding equals (and hashCode) in Product would also avoid adding
an evil twin in your rule code - as it is!

Even simpler is a solution where the relevant Product objects are inserted
as facts, so that
   $cd1 : Product( name == cd1 )
   $bonus_cd : Product( name == bonus_cd )
   $order : ShippingOrder( products contains $cd1, products not
contains $bonus_cd )
is true (again, with equals and hashCode being overridden).

Given your solution with collect, an additional eval testing for
bonus_cd not being the
name of the single Product in List $productList might be more
efficient than iterating
all products a second time.

-W

On 21 July 2010 00:41, javaj jmill...@ameritech.net wrote:

 I'm trying to write a rule to add an object to a collection if the collection
 already contained a certain object with a specific attribute.

 I developed a small example so maybe that will make more sense:

 Use Case: In a product shipping applicaiton, anytime a product with the name
 cd1 is in the shipping order, a bonus product named bonus_cd needs to be
 added to the shipping order.  The bonus cd should not be added if it's
 already in the shipping order.

 Shipping Order:

 public class ShippingOrder {

        private SetProduct products;

        public ShippingOrder() {}

        public SetProduct getProducts() {
                return products;
        }

        public void setProducts(SetProduct products) {
                this.products = products;
        }

 }

 Product:

 public class Product {

        private String name;

        public Product(){}

        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }

 }


 Rule:

 rule AddBonusCd

        when
                $so : ShippingOrder()
                $productList : ArrayList(size == 1) from collect( Product(name 
 matches
 cd1|bonus_cd) from $so.products)
        then
                System.out.println(Adding Bonus Cd);

                SetProduct productSet = new 
 HashSetProduct($so.getProducts());

                Product bonusCd = new Product();
                bonusCd.setName(bonus_cd);
                productSet.add(bonusCd);

                modify($so) {
                        setProducts(productSet);
                }
 end

 The Shipping Order object is inserted as the fact.

 The rule is valid if only cd1 or cd_bonus is in the shipping order.  I only
 want the rule to run when cd1 is in the product set but cd_bonus is not.
 Makes sense?

 Thanks,
 J
 --
 View this message in context: 
 http://drools-java-rules-engine.46999.n3.nabble.com/collection-question-tp982769p982769.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] Drools Planner or Drools Solver

2010-07-21 Thread Geoffrey De Smet
The new docs will be published soon after the release of CR1 (including 
planner 5.1.0.CR1).
It's best to use the latest documentation (unless you're using 5.0.1): 
wait a few days, build them from source (mvn clean install 
drools-docs) or look up the latest successful build on hudson.

With kind regards,
Geoffrey De Smet

Op 20-07-10 03:27, Nick Heudecker schreef:
 Thanks Mark.

 2010/7/19 Mark Proctor mproc...@codehaus.org
 mailto:mproc...@codehaus.org

 On 20/07/2010 01:05, Nick Heudecker wrote:
 I'm confused as to the naming of Drools Solver.  The docs all say
 Solver, but when I look for a current snapshot [1] and available
 downloads, I'm only seeing Planner.  Which is it?  Thanks for the
 clarification.

 [1] https://repository.jboss.org/nexus/content/repositories/snapshots
 It was renamed from solver to planner.

 Mark


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



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

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


Re: [rules-users] DroolsFlow with foreach node stops execution of entire flow on empty collection

2010-07-21 Thread Kris Verlaenen
Ivan,

You are correct, if the collection is empty, the process waieds for these 
elements to complete, even though there are none.  I just committed a fix 
for this on trunk.  Now, the for each node continues if the collection is 
empty (or null).

Kris

- Original Message - 
From: vasilievip vasilie...@ukr.net
To: rules-users@lists.jboss.org
Sent: Monday, July 19, 2010 3:05 PM
Subject: Re: [rules-users] DroolsFlow with foreach node stops execution of 
entire flow on empty collection



 I've just tried 5.1.M2 - problem still exists.

 Thanks,
 Ivan

 -- 
 View this message in context: 
 http://drools-java-rules-engine.46999.n3.nabble.com/DroolsFlow-with-foreach-node-stops-execution-of-entire-flow-on-empty-collection-tp978149p978416.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Implementing Timers With Drools PersistenceEnabled

2010-07-21 Thread Kris Verlaenen
Santosh,

Based on your description, different processes should be started.  Do you have 
a simple standalone example that shows this behaviour, so I can take a look?  
If not, using an audit logger might help in determining which rules are fired 
and which processes are being started.

Kris

  - Original Message - 
  From: santosh mukherjee 
  To: Rules Users List 
  Sent: Tuesday, July 20, 2010 10:03 AM
  Subject: Re: [rules-users] Implementing Timers With Drools PersistenceEnabled


  Hi,


  I have a sample drl file in which I have written multiple rules. For each 
different rules when get fired I have started different processes.
  for eg:


  Rule1
  when: some condition
  then:
  drools.getWorkingMemory.startprocess(id1);


  Rule2
  when: some condition
  then:
  drools.getWorkingMemory.startprocess(id2);


  But the problem is that only that rule flow process gets fired every time 
which I have added to builder last. Also it is clear that it goes inside the 
then clause of Rule2 suppose but then again it starts process with id1.


  Any help on how to resolve this or why is it happening is welcom,
  Thanks
  Santosh  Mukherjee


  On Tue, Jul 13, 2010 at 3:39 AM, nanic23 nani...@hotmail.com wrote:


Hi cafebabe,

Thanks for your comment. I agree with you that work item ids are database
primary keys but in this simple (very simple) case I just decided to
harcoded as I know for a fact that the work item id is 1 because that is the
only work item and each time I run the test the tables are dropped and
recreated. So, there is never more than one row in the workItemInfo table
and the only row always has 1 as its id.
I could have stored the work item id or a work item object as a variable
(like you mentioned) but in this case wouldn't make a difference for the
timers.

Are timers working for you when you use persistence? I do complete work
items by workItem.getId() in all my code (other than this simple example
:)). My problem is NOT completing the work item, my problem is triggering
timers when persistence is enabled. The timers don't even trigger, thing
that should happen before even trying to complete the work item.

Thanks,

Nick.


--
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-Timers-With-Drools-Persistence-Enabled-tp923142p961658.html

Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





--


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

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway (Diverge) : Split Node - Priority Does not Work

2010-07-21 Thread Kris Verlaenen
Vijay,

This is a known limitation when using BPMN2.  Check out the documentation, that 
describes which features are implemented already in the BPMN2 implementation:
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html/ch13.html

Priorities are not yet implemented as it seems the BPMN2 spec simply does not 
define something like this.  If we want to support something like this, we will 
probably have to define a custom extension (but we didn't do this yet as we 
wanted to wait until the spec was final before starting to add too much custom 
extensions).

A workaround would be to use mutually exclusive conditions for now ...

Kris

  - Original Message - 
  From: Vijay K Pandey 
  To: rules-users@lists.jboss.org 
  Sent: Wednesday, July 21, 2010 5:45 AM
  Subject: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway (Diverge) 
: Split Node - Priority Does not Work


  Hi All,

   

  In the Drools Flow 5.1 latest snapshot , for the node (Gateway (Diverge) : 
Split Node), somehow priority does not work. If we set some value, lets say 100 
and open the process file(BPMN2) again and check the priority - somehow it 
doesn't retains the priority value and reports the value always as 0.

   

  I am trying to make use one of the feature of XOR type node where one of the 
constraint is always true with the highest priority. I hope my understanding 
is right.

   

  This is what the Drools Flow Doc says:

   

  XOR means that exactly one of the outgoing connections will be chosen. The 
decision is made by evaluating the constraints that are linked to each of the 
outgoing connections. Constraints are specified using the same syntax as the 
left-hand side of a rule. The constraint with the lowest priority number that 
evaluates to true is selected. Note that you should always make sure that at 
least one of the outgoing connections will evaluate to true at runtime (the 
ruleflow will throw an exception at runtime if it cannot find at least one 
outgoing connection). For example, you could use a connection which is always 
true (default) with a high priority number to specify what should happen if 
none of the other connections can be taken.

   

  Has anyone faced this issue?

   

  Thanks

  Vijay

   



--


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

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] java.lang.NoSuchMethodError on every Action node

2010-07-21 Thread Kris Verlaenen
Hi,

This indeed seems to be related to a conflict of actions.  I assume you are 
using the same knowledge builder for adding both the main and the sub 
process (as that is responsible for resolving possible conflicts)?  If so, 
could you provide a simple, standalone example that demonstrates this 
behaviour so I can take a look?

Kris

- Original Message - 
From: retoy reto.lampre...@allianz-suisse.ch
To: rules-users@lists.jboss.org
Sent: Monday, July 19, 2010 12:45 PM
Subject: Re: [rules-users] java.lang.NoSuchMethodError on every Action node



 I've been struggling with a NoSuchMethodError as well whenever I added any
 simple Action to my ruleflow:

 java.lang.NoSuchMethodError:
 my.package.Process_my_package_0.action0(Lorg/drools/spi/KnowledgeHelper;Ljava/lang/Object;Lorg/drools/spi/ProcessContext;)V
 at
 my.package.Process_my_package_0Action0Invoker.execute(Process_my_package_0Action0Invoker.java:21)
 at
 org.drools.workflow.instance.impl.ExtendedNodeInstanceImpl.executeAction(ExtendedNodeInstanceImpl.java:66)
 at
 org.drools.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerEvent(ExtendedNodeInstanceImpl.java:45)
 at
 org.drools.workflow.instance.impl.ExtendedNodeInstanceImpl.internalTrigger(ExtendedNodeInstanceImpl.java:28)
 at
 org.drools.workflow.instance.node.EventBasedNodeInstance.internalTrigger(EventBasedNodeInstance.java:30)
 at
 org.drools.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:80)
 at
 org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:111)
 at
 org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:141)
 at
 org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:128)
 at
 org.drools.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)
 at
 org.drools.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)
 at
 org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:111)
 at
 org.drools.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:16)
 at
 org.drools.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:185)
 at
 org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:230)
 at
 org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1639)
 at
 org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:46)
 at
 org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:10)
 at
 org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:229)
 at
 org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:163)


 In my scenario I have two ruleflows in the knowledge base. One is the
 subflow of the other one and both contain an action.

 To localize the cause of the problem, I only started the subflow 
 separately
 and finally found that the NoSuchMethodError does NOT occur if
 - the subprocess is added to the knowledge base AFTER the main process.
 - the two processes don't have the same package name

 So it seems like there is a name collision. The generated action of the
 second ruleflow seems to overwrite the generated action of the first one.
 Since both processes dont just execute the same action after that, but
 instead the action of the first process is not found, I assume this is a
 bug...

 The workaround is to simply use different package names.

 -- 
 View this message in context: 
 http://drools-java-rules-engine.46999.n3.nabble.com/java-lang-NoSuchMethodError-on-every-Action-node-tp60886p978186.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway(Diverge) : Split Node - Priority Does not Work

2010-07-21 Thread Kris Verlaenen
Santosh,

I think you need to add it as part of a META-INF directory inside a source dir. 
 There's a screencast that shows you how to get a simple example working, try 
following that and let me know if you still have issues with that:
http://people.redhat.com/kverlaen/DomainSpecificWorkItem.swf

Kris

- Original Message - 
  From: santosh mukherjee 
  To: Rules Users List 
  Sent: Wednesday, July 21, 2010 8:54 AM
  Subject: Re: [rules-users] Drools Flow 5.1 - latest snapshot -- 
Gateway(Diverge) : Split Node - Priority Does not Work


  Hi,


  I have added my MyWorkDefinitions.conf and drools.rulebase.conf file in a 
source folder named resources inside my project. But then also my work items 
are not showing in the flow editor. Can anybody tell me why this is so?


  Thanks
  Santosh Mukherjee.


  2010/7/21 Vijay K Pandey vpan...@mdes.ms.gov

Hi All,



In the Drools Flow 5.1 latest snapshot , for the node (Gateway (Diverge) : 
Split Node), somehow priority does not work. If we set some value, lets say 100 
and open the process file(BPMN2) again and check the priority – somehow it 
doesn’t retains the priority value and reports the value always as 0.



I am trying to make use one of the feature of XOR type node where one of 
the constraint is “always true” with the highest priority. I hope my 
understanding is right.



This is what the Drools Flow Doc says:



XOR means that exactly one of the outgoing connections will be chosen. The 
decision is made by evaluating the constraints that are linked to each of the 
outgoing connections. Constraints are specified using the same syntax as the 
left-hand side of a rule. The constraint with the lowest priority number that 
evaluates to true is selected. Note that you should always make sure that at 
least one of the outgoing connections will evaluate to true at runtime (the 
ruleflow will throw an exception at runtime if it cannot find at least one 
outgoing connection). For example, you could use a connection which is always 
true (default) with a high priority number to specify what should happen if 
none of the other connections can be taken.



Has anyone faced this issue?



Thanks

Vijay




___
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

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Flow - Human Task

2010-07-21 Thread jawa

Hi,

Thanks for your reply.

What I am trying to do is create a task which needs human input. Like I said
above my post that there will be two tasks. One will be 'Ask User a
Question', this will let my front end know to display next question to user.
We'll have to wait for user's answer and flow should stop here until user
answers the question and front end let drools flow know that an answer is
received. So I want my flow to continue where it stopped last time which I
think I can do with StatefulKnowledgeSession and store it in db? The Other
task will be 'Record Answer', this will record answer to db.

So I need to write that Ask question handler somehow to let drools flow know
to stop at this task and when an answer is received just mark this task as
complete and move to next node.

Thanks
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Human-Task-tp966015p983956.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Flow - Human Task

2010-07-21 Thread Kris Verlaenen
How about simply reusing the human task node for this.  Your process is then 
a simple sequence of 2 human task nodes.  You can use the properties of the 
human task node (like name, description, content and input/output mapping to 
add the necessary information).  Instead of using the default human task 
service for executing these tasks, you can then just write your own work 
item handler that notifies your UI when a task is created.  Your UI should 
also notify the handler when a task is completed.

Regarding continuing where you stopped last time, this happens 
automatically.  When a work item is encountered, the process will halt until 
that work item has been completed.  You should just keep your session alive, 
or if you use persistence you can simply restore the state from db as well.

Kris

- Original Message - 
From: jawa ago...@gmail.com
To: rules-users@lists.jboss.org
Sent: Wednesday, July 21, 2010 1:02 PM
Subject: Re: [rules-users] Drools Flow - Human Task



 Hi,

 Thanks for your reply.

 What I am trying to do is create a task which needs human input. Like I 
 said
 above my post that there will be two tasks. One will be 'Ask User a
 Question', this will let my front end know to display next question to 
 user.
 We'll have to wait for user's answer and flow should stop here until user
 answers the question and front end let drools flow know that an answer is
 received. So I want my flow to continue where it stopped last time which I
 think I can do with StatefulKnowledgeSession and store it in db? The Other
 task will be 'Record Answer', this will record answer to db.

 So I need to write that Ask question handler somehow to let drools flow 
 know
 to stop at this task and when an answer is received just mark this task as
 complete and move to next node.

 Thanks
 -- 
 View this message in context: 
 http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Human-Task-tp966015p983956.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] ParseException: MessageFormat parse error!

2010-07-21 Thread mash

Hello,

i am new to mailing list and i am also a new Drools User. I already searched
in archive for this error. But found nothing. There 
(http://community.jboss.org/thread/152613) i just found the hint on mailing
list here. Desperately there was no solution. 

Problem: I downloaded the Drools Example Project imported the maven project
to Eclipse and try to run. It aborts with the ParseException. I didn't
changed the location or the stocktickstream.dat itself. 

Do i have to configure something for the persister?

Thx in advance!


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/ParseException-MessageFormat-parse-error-tp984013p984013.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] ParseException: MessageFormat parse error!

2010-07-21 Thread Swindells, Thomas
I think I answered this on the mailing list before,
From what I can remember the currency parser that is being used is locale 
specific, you either need to configure your locale or change your dat file to 
make sure the prices are in your local currency.

Hopefully that will fix it,

Thomas

 -Original Message-
 From: rules-users-boun...@lists.jboss.org [mailto:rules-users-
 boun...@lists.jboss.org] On Behalf Of mash
 Sent: 21 July 2010 12:50
 To: rules-users@lists.jboss.org
 Subject: [rules-users] ParseException: MessageFormat parse error!


 Hello,

 i am new to mailing list and i am also a new Drools User. I already searched
 in archive for this error. But found nothing. There
 (http://community.jboss.org/thread/152613) i just found the hint on mailing
 list here. Desperately there was no solution.

 Problem: I downloaded the Drools Example Project imported the maven project
 to Eclipse and try to run. It aborts with the ParseException. I didn't
 changed the location or the stocktickstream.dat itself.

 Do i have to configure something for the persister?

 Thx in advance!


 --
 View this message in context: http://drools-java-rules-
 engine.46999.n3.nabble.com/ParseException-MessageFormat-parse-error-
 tp984013p984013.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**

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


Re: [rules-users] ParseException: MessageFormat parse error!

2010-07-21 Thread mash

@Thomas

thx for the reply and the correct hint. I just had to use the EventGenerator
to create a new event file which is different to the original one.

See here:

Original:
--
0;SAP;$110.87
0;RHT;$75.20

Generated:
--
0;SAP;59,34 €
0;RHT;117,37 €

Thx a lot! 

Marcel
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/ParseException-MessageFormat-parse-error-tp984013p984130.html
Sent from the Drools - User mailing list archive at Nabble.com.

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


Re: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway (Diverge) : Split Node - Priority Does not Work

2010-07-21 Thread Vijay K Pandey
Thanks Kris.

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Kris Verlaenen
Sent: Wednesday, July 21, 2010 4:56 AM
To: rules-users@lists.jboss.org; Vijay K Pandey
Subject: Re: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway 
(Diverge) : Split Node - Priority Does not Work

Vijay,

This is a known limitation when using BPMN2.  Check out the documentation, that 
describes which features are implemented already in the BPMN2 implementation:
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html/ch13.html

Priorities are not yet implemented as it seems the BPMN2 spec simply does not 
define something like this.  If we want to support something like this, we will 
probably have to define a custom extension (but we didn't do this yet as we 
wanted to wait until the spec was final before starting to add too much custom 
extensions).

A workaround would be to use mutually exclusive conditions for now ...

Kris

- Original Message -
From: Vijay K Pandeymailto:vpan...@mdes.ms.gov
To: rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org
Sent: Wednesday, July 21, 2010 5:45 AM
Subject: [rules-users] Drools Flow 5.1 - latest snapshot -- Gateway (Diverge) : 
Split Node - Priority Does not Work

Hi All,

In the Drools Flow 5.1 latest snapshot , for the node (Gateway (Diverge) : 
Split Node), somehow priority does not work. If we set some value, lets say 100 
and open the process file(BPMN2) again and check the priority - somehow it 
doesn't retains the priority value and reports the value always as 0.

I am trying to make use one of the feature of XOR type node where one of the 
constraint is always true with the highest priority. I hope my understanding 
is right.

This is what the Drools Flow Doc says:

XOR means that exactly one of the outgoing connections will be chosen. The 
decision is made by evaluating the constraints that are linked to each of the 
outgoing connections. Constraints are specified using the same syntax as the 
left-hand side of a rule. The constraint with the lowest priority number that 
evaluates to true is selected. Note that you should always make sure that at 
least one of the outgoing connections will evaluate to true at runtime (the 
ruleflow will throw an exception at runtime if it cannot find at least one 
outgoing connection). For example, you could use a connection which is always 
true (default) with a high priority number to specify what should happen if 
none of the other connections can be taken.

Has anyone faced this issue?

Thanks
Vijay


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

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm for more 
information.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Timers' Week :)

2010-07-21 Thread nanic23

Hi retov,

Given that the timers do not work when using persistence I haven't been able
to test the scenario you described. I did test timer behavior when an
exception is thrown from within the workItemHandler that has a timer
attached to it. And in this case the timer keeps working, that is, it does
not stop if you exit workItemHandler abnormally. But  remember, this is
without  persistence enabled.
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Timers-Week-tp912807p984236.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] collection question

2010-07-21 Thread Steve Ronderos
Hi J,

In your example I don't think that the collect is necessary.

I believe the following will work:

rule AddBonusCd

  when
$so : ShippingOrder()
Product(name == cd1) from $so.products
not (Product(name == bonus_cd) from $so.products)
  then
System.out.println(Adding Bonus Cd);
 
SetProduct productSet = new HashSetProduct($so.getProducts());
 
Product bonusCd = new Product();
bonusCd.setName(bonus_cd);
productSet.add(bonusCd);
 
modify($so) {
  setProducts(productSet);
}
end

You don't need the collects because you are just checking for 
existence/non-existence of facts within the products collection.

Good luck!
Steve


rules-users-boun...@lists.jboss.org wrote on 07/21/2010 01:59:40 AM:

 From:
 
 Wolfgang Laun wolfgang.l...@gmail.com
 
 To:
 
 Rules Users List rules-users@lists.jboss.org
 
 Date:
 
 07/21/2010 02:02 AM
 
 Subject:
 
 Re: [rules-users] collection question
 
 Sent by:
 
 rules-users-boun...@lists.jboss.org
 
 Things would be smpler if you could avoid re-creating Product objects
 because adding an identical Object does not change the Set. (This
 could be implemented with the help of a global MapString,Product,)
 
 Second, overriding equals (and hashCode) in Product would also avoid 
adding
 an evil twin in your rule code - as it is!
 
 Even simpler is a solution where the relevant Product objects are 
inserted
 as facts, so that
$cd1 : Product( name == cd1 )
$bonus_cd : Product( name == bonus_cd )
$order : ShippingOrder( products contains $cd1, products not
 contains $bonus_cd )
 is true (again, with equals and hashCode being overridden).
 
 Given your solution with collect, an additional eval testing for
 bonus_cd not being the
 name of the single Product in List $productList might be more
 efficient than iterating
 all products a second time.
 
 -W
 
 On 21 July 2010 00:41, javaj jmill...@ameritech.net wrote:
 
  I'm trying to write a rule to add an object to a collection if 
thecollection
  already contained a certain object with a specific attribute.
 
  I developed a small example so maybe that will make more sense:
 
  Use Case: In a product shipping applicaiton, anytime a product with 
the name
  cd1 is in the shipping order, a bonus product named bonus_cd needs 
to be
  added to the shipping order.  The bonus cd should not be added if it's
  already in the shipping order.
 
  Shipping Order:
 
  public class ShippingOrder {
 
 private SetProduct products;
 
 public ShippingOrder() {}
 
 public SetProduct getProducts() {
 return products;
 }
 
 public void setProducts(SetProduct products) {
 this.products = products;
 }
 
  }
 
  Product:
 
  public class Product {
 
 private String name;
 
 public Product(){}
 
 public String getName() {
 return name;
 }
 
 public void setName(String name) {
 this.name = name;
 }
 
  }
 
 
  Rule:
 
  rule AddBonusCd
 
 when
 $so : ShippingOrder()
 $productList : ArrayList(size == 1) from collect( 
 Product(name matches
  cd1|bonus_cd) from $so.products)
 then
 System.out.println(Adding Bonus Cd);
 
 SetProduct productSet = new HashSetProduct
 ($so.getProducts());
 
 Product bonusCd = new Product();
 bonusCd.setName(bonus_cd);
 productSet.add(bonusCd);
 
 modify($so) {
 setProducts(productSet);
 }
  end
 
  The Shipping Order object is inserted as the fact.
 
  The rule is valid if only cd1 or cd_bonus is in the shipping order.  I 
only
  want the rule to run when cd1 is in the product set but cd_bonus is 
not.
  Makes sense?
 
  Thanks,
  J
  --
  View this message in context: http://drools-java-rules-engine.
 46999.n3.nabble.com/collection-question-tp982769p982769.html
  Sent from the Drools - User mailing list archive at Nabble.com.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 ___
 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] Drools and mvel

2010-07-21 Thread Edson Tirelli
Hi Paul,

Your analysis is correct. The problem is that these configurations in
MVEL are made using static properties and so they affect all uses of MVEL in
a single classloading hierarchy. Unfortunately, I don't think there is
anything you can do right now, other than open a JIRA in MVEL to help
convince Mike to make all configurations non-static in MVEL:

http://jira.codehaus.org/browse/MVEL

Edson

2010/7/21 Paul Edwards paul.edwa...@hyro.com

 Hi guys,

 I have an issue which involves smooks, drools and mvel.

 Quick explanation, the unit test is just a smooks run. Nothing complicated.
 The test passes happily. It contains an expression that involves an MVEL
 IF statement.

 Now if I add a drools startup (I'm not using drools in the test, I'm just
 initialising it), the unit test now fails on the IF statement. The
 exception received is:

 org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize
 method 'initialize' on class 'org.milyn.javabean.BeanInstancePopulator'.
at
 org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:457)
at
 org.milyn.cdr.annotation.Configurator.initialise(Configurator.java:439)
at
 org.milyn.cdr.annotation.Configurator.configure(Configurator.java:91)
at
 org.milyn.cdr.annotation.Configurator.configure(Configurator.java:66)
at
 org.milyn.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:63)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:623)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:548)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:536)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:711)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:690)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:484)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:349)
at
 org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146)
at
 org.milyn.container.standalone.StandaloneExecutionContext.init(StandaloneExecutionContext.java:91)
at
 org.milyn.container.standalone.StandaloneExecutionContext.init(StandaloneExecutionContext.java:65)
at org.milyn.Smooks.createExecutionContext(Smooks.java:383)
at org.milyn.Smooks.createExecutionContext(Smooks.java:346)
at
 com.hyro.telstrapoc.smooks.SmooksTransformTest.runSmooksTransform(SmooksTransformTest.java:215)
at
 com.hyro.telstrapoc.smooks.SmooksTransformTest.testSmooks(SmooksTransformTest.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at
 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
 

Re: [rules-users] collection question

2010-07-21 Thread Earnest Dyke
Very clean.

Earnie!





From: Steve Ronderos steve.ronde...@ni.com
To: Rules Users List rules-users@lists.jboss.org
Sent: Wed, July 21, 2010 9:56:56 AM
Subject: Re: [rules-users] collection question

Hi J, 

In your example I don't think that the collect is necessary. 

I believe the following will work: 

rule AddBonusCd

 when
   $so : ShippingOrder()
   Product(name == cd1) from $so.products
   not (Product(name == bonus_cd) from $so.products)
 then
   System.out.println(Adding Bonus Cd);
 
   SetProduct productSet = new HashSetProduct($so.getProducts());
 
   Product bonusCd = new Product();
   bonusCd.setName(bonus_cd);
   productSet.add(bonusCd);
 
   modify($so) {
 setProducts(productSet);
   }
end 

You don't need the collects because you are just checking for 
existence/non-existence of facts within the products collection. 


Good luck! 
Steve 


rules-users-boun...@lists.jboss.org wrote on 07/21/2010 01:59:40 AM:

 From: 
 
 Wolfgang Laun wolfgang.l...@gmail.com 
 
 To: 
 
 Rules Users List rules-users@lists.jboss.org 
 
 Date: 
 
 07/21/2010 02:02 AM 
 
 Subject: 
 
 Re: [rules-users] collection question 
 
 Sent by: 
 
 rules-users-boun...@lists.jboss.org 
 
 Things would be smpler if you could avoid re-creating Product objects
 because adding an identical Object does not change the Set. (This
 could be implemented with the help of a global MapString,Product,)
 
 Second, overriding equals (and hashCode) in Product would also avoid adding
 an evil twin in your rule code - as it is!
 
 Even simpler is a solution where the relevant Product objects are inserted
 as facts, so that
$cd1 : Product( name == cd1 )
$bonus_cd : Product( name == bonus_cd )
$order : ShippingOrder( products contains $cd1, products not
 contains $bonus_cd )
 is true (again, with equals and hashCode being overridden).
 
 Given your solution with collect, an additional eval testing for
 bonus_cd not being the
 name of the single Product in List $productList might be more
 efficient than iterating
 all products a second time.
 
 -W
 
 On 21 July 2010 00:41, javaj jmill...@ameritech.net wrote:
 
  I'm trying to write a rule to add an object to a collection if thecollection
  already contained a certain object with a specific attribute.
 
  I developed a small example so maybe that will make more sense:
 
  Use Case: In a product shipping applicaiton, anytime a product with the name
  cd1 is in the shipping order, a bonus product named bonus_cd needs to be
  added to the shipping order.  The bonus cd should not be added if it's
  already in the shipping order.
 
  Shipping Order:
 
  public class ShippingOrder {
 
 private SetProduct products;
 
 public ShippingOrder() {}
 
 public SetProduct getProducts() {
 return products;
 }
 
 public void setProducts(SetProduct products) {
 this.products = products;
 }
 
  }
 
  Product:
 
  public class Product {
 
 private String name;
 
 public Product(){}
 
 public String getName() {
 return name;
 }
 
 public void setName(String name) {
 this.name = name;
 }
 
  }
 
 
  Rule:
 
  rule AddBonusCd
 
 when
 $so : ShippingOrder()
 $productList : ArrayList(size == 1) from collect( 
 Product(name matches
  cd1|bonus_cd) from $so.products)
 then
 System.out.println(Adding Bonus Cd);
 
 SetProduct productSet = new HashSetProduct
 ($so.getProducts());
 
 Product bonusCd = new Product();
 bonusCd.setName(bonus_cd);
 productSet.add(bonusCd);
 
 modify($so) {
 setProducts(productSet);
 }
  end
 
  The Shipping Order object is inserted as the fact.
 
  The rule is valid if only cd1 or cd_bonus is in the shipping order.  I only
  want the rule to run when cd1 is in the product set but cd_bonus is not.
  Makes sense?
 
  Thanks,
  J
  --
  View this message in context: http://drools-java-rules-engine.
 46999.n3.nabble.com/collection-question-tp982769p982769.html
  Sent from the Drools - User mailing list archive at Nabble.com.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 ___
 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] Timers' Week :)

2010-07-21 Thread Kris Verlaenen
I probably missed quite a few emails on the mailing list lately (sorry), but 
what's the exact problem with timers and persistence (and does it still 
exist in the latest trunk, as I know various improvements / bug fixes have 
been applied in the last few weeks as well)?

There's a simple test that shows the use of timers and persistence together: 
testPersistenceTimer() in 
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-persistence-jpa/src/test/java/org/drools/persistence/session/PersistentStatefulSessionTest.java

If you are having issues, please let me know (and if possible provide a test 
case like the one above that shows this behaviour ;)) and I'll take a look.

Kris

- Original Message - 
From: nanic23 nani...@hotmail.com
To: rules-users@lists.jboss.org
Sent: Wednesday, July 21, 2010 3:33 PM
Subject: Re: [rules-users] Timers' Week :)



 Hi retov,

 Given that the timers do not work when using persistence I haven't been 
 able
 to test the scenario you described. I did test timer behavior when an
 exception is thrown from within the workItemHandler that has a timer
 attached to it. And in this case the timer keeps working, that is, it does
 not stop if you exit workItemHandler abnormally. But  remember, this is
 without  persistence enabled.
 -- 
 View this message in context: 
 http://drools-java-rules-engine.46999.n3.nabble.com/Timers-Week-tp912807p984236.html
 Sent from the Drools - User mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] collection question

2010-07-21 Thread javaj

Thanks everyone for your suggestions.  I agree with Earnie that Steve's
example is very clean and works like a charm.

J
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/collection-question-tp982769p984439.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Rules not firing when expected after retracting object in list

2010-07-21 Thread Justin Beltran
Hi, 

I'm coming across some weird behavior in Drools 4.0.7, but maybe it's just
cause I don't understand I how Drools works.  Assume, there's a class A
that has a property called property. 

As facts, I have the following list of A's: 
A1, property = 123 
A2, property = 345 
A3, property = 123 

I have two rules as follows: 

rule Rule 1 - Remove all A's that have property set to 123 
  salience 1000 
  lock-on-active true 
when 
  $listOfAs : ArrayList collect(A( property == 123 )) 
then 
  for (Object a: $listOfAs ) {   
  retract (a) 
  } 
end 

rule Rule 2 - Do stuff with remaining A's 
  salience 900 
  lock-on-active true 
when 
  $listOfAs : ArrayList collect(A()) 
then 
... 
end 

My understanding is Rule 1 will remove the facts of class A that have
property to 123.  When it gets to Rule 2, shouldn't the listOfAs only
have that one A that remains (i.e. the one where property is set to 345).
What I'm noticing is that Rule 2 just doesn't execute at all even though
I'm assuming there is still one A object that hasn't been retracted.  If I
comment out the retract it executes Rule 2 fine. 

Am I missing something about these rules work? 

Thanks. 
Justin

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


Re: [rules-users] Rules not firing when expected after retracting object in list

2010-07-21 Thread Swindells, Thomas
Why is rule 1 written the way it is? Why can't you just do:
rule Rule 1 - Remove all A's that have property set to 123
  salience 1000
when
  $anA : A( property == 123 )
then
  retract ($anA)
end

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Justin Beltran
Sent: 21 July 2010 16:28
To: rules-users@lists.jboss.org
Subject: [rules-users] Rules not firing when expected after retracting object 
in list

Hi,

I'm coming across some weird behavior in Drools 4.0.7, but maybe it's just 
cause I don't understand I how Drools works.  Assume, there's a class A that 
has a property called property.

As facts, I have the following list of A's:
A1, property = 123
A2, property = 345
A3, property = 123

I have two rules as follows:

rule Rule 1 - Remove all A's that have property set to 123
  salience 1000
  lock-on-active true
when
  $listOfAs : ArrayList collect(A( property == 123 ))
then
  for (Object a: $listOfAs ) {
  retract (a)
  }
end

rule Rule 2 - Do stuff with remaining A's
  salience 900
  lock-on-active true
when
  $listOfAs : ArrayList collect(A())
then
...
end

My understanding is Rule 1 will remove the facts of class A that have 
property to 123.  When it gets to Rule 2, shouldn't the listOfAs only have 
that one A that remains (i.e. the one where property is set to 345).   What 
I'm noticing is that Rule 2 just doesn't execute at all even though I'm 
assuming there is still one A object that hasn't been retracted.  If I 
comment out the retract it executes Rule 2 fine.

Am I missing something about these rules work?

Thanks.
Justin



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules not firing when expected after retracting object in list

2010-07-21 Thread Justin Beltran
Thanks for the reply.

 

What if you have multiple A's set with 123?  Don't you need to collect them
to retract all A's that match that property?

 

My main concern is if you retract one or more of the A's, it's possible that
you should still have some A's that are NOT retracted, so rule B should
still fire right?

 

Justin

 

 

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas
Sent: Wednesday, July 21, 2010 8:39 AM
To: Rules Users List
Subject: Re: [rules-users] Rules not firing when expected after retracting
object in list

 

Why is rule 1 written the way it is? Why can't you just do:

rule Rule 1 - Remove all A's that have property set to 123 
  salience 1000 
when 
  $anA : A( property == 123 )
then 
  retract ($anA) 
end

 

Thomas

 

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Justin Beltran
Sent: 21 July 2010 16:28
To: rules-users@lists.jboss.org
Subject: [rules-users] Rules not firing when expected after retracting
object in list

 

Hi, 

I'm coming across some weird behavior in Drools 4.0.7, but maybe it's just
cause I don't understand I how Drools works.  Assume, there's a class A
that has a property called property. 

As facts, I have the following list of A's: 
A1, property = 123 
A2, property = 345 
A3, property = 123 

I have two rules as follows: 

rule Rule 1 - Remove all A's that have property set to 123 
  salience 1000 
  lock-on-active true 
when 
  $listOfAs : ArrayList collect(A( property == 123 )) 
then 
  for (Object a: $listOfAs ) {   
  retract (a) 
  } 
end 

rule Rule 2 - Do stuff with remaining A's 
  salience 900 
  lock-on-active true 
when 
  $listOfAs : ArrayList collect(A()) 
then 
... 
end 

My understanding is Rule 1 will remove the facts of class A that have
property to 123.  When it gets to Rule 2, shouldn't the listOfAs only
have that one A that remains (i.e. the one where property is set to 345).
What I'm noticing is that Rule 2 just doesn't execute at all even though
I'm assuming there is still one A object that hasn't been retracted.  If I
comment out the retract it executes Rule 2 fine. 

Am I missing something about these rules work? 

Thanks. 
Justin

 

  _  



**
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmas...@nds.com and delete it from your system as well as any copies. The
content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
4EX, United Kingdom. A company registered in England and Wales. Registered
no. 3080780. VAT no. GB 603 8808 40-00

**

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


Re: [rules-users] Rules not firing when expected after retracting object in list

2010-07-21 Thread Swindells, Thomas
No the rule is run multiple times, once per a matching A.
If you did only want the rule to run once regardless of how many matching As 
you have then you would use exists:
Exists A( property == 123 )


From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Justin Beltran
Sent: 21 July 2010 16:47
To: 'Rules Users List'
Subject: Re: [rules-users] Rules not firing when expected after retracting 
object in list

Thanks for the reply.

What if you have multiple A's set with 123?  Don't you need to collect them to 
retract all A's that match that property?

My main concern is if you retract one or more of the A's, it's possible that 
you should still have some A's that are NOT retracted, so rule B should still 
fire right?

Justin


From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas
Sent: Wednesday, July 21, 2010 8:39 AM
To: Rules Users List
Subject: Re: [rules-users] Rules not firing when expected after retracting 
object in list

Why is rule 1 written the way it is? Why can't you just do:
rule Rule 1 - Remove all A's that have property set to 123
  salience 1000
when
  $anA : A( property == 123 )
then
  retract ($anA)
end

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Justin Beltran
Sent: 21 July 2010 16:28
To: rules-users@lists.jboss.org
Subject: [rules-users] Rules not firing when expected after retracting object 
in list

Hi,

I'm coming across some weird behavior in Drools 4.0.7, but maybe it's just 
cause I don't understand I how Drools works.  Assume, there's a class A that 
has a property called property.

As facts, I have the following list of A's:
A1, property = 123
A2, property = 345
A3, property = 123

I have two rules as follows:

rule Rule 1 - Remove all A's that have property set to 123
  salience 1000
  lock-on-active true
when
  $listOfAs : ArrayList collect(A( property == 123 ))
then
  for (Object a: $listOfAs ) {
  retract (a)
  }
end

rule Rule 2 - Do stuff with remaining A's
  salience 900
  lock-on-active true
when
  $listOfAs : ArrayList collect(A())
then
...
end

My understanding is Rule 1 will remove the facts of class A that have 
property to 123.  When it gets to Rule 2, shouldn't the listOfAs only have 
that one A that remains (i.e. the one where property is set to 345).   What 
I'm noticing is that Rule 2 just doesn't execute at all even though I'm 
assuming there is still one A object that hasn't been retracted.  If I 
comment out the retract it executes Rule 2 fine.

Am I missing something about these rules work?

Thanks.
Justin



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] How to work with org.drools.repository

2010-07-21 Thread wilsonywx

Hi. I am in the process of figuring out how to build an interface between the
drools repository and a drl file. Basically, I want to find a way to:

--push the data from a drl file into a drools repository
--pull the data from drools repository into a drl file. 

This would essentially form the part where an app using the rules engine
would pull the rules from a repository. 


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/How-to-work-with-org-drools-repository-tp984680p984680.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to work with org.drools.repository

2010-07-21 Thread wilsonywx

To be more concrete: 

First step: 
Say I have test.drl. How to go from test.drl - RuleModel object - put into
the drools repository (jackrabbit)? I don't see any documentation about what
methods I should call in RuleRepository.java to interact with the
repository. 

and how to do the reverse:

Start with RuleRepository - Extract out RuleModel objects -- somehow
convert to .drl files. 

I've been reading 
http://arhipov.blogspot.com/2009/09/jboss-drools-content-repository.html
http://arhipov.blogspot.com/2009/09/jboss-drools-content-repository.html 
which outlines a rudimentary way to do this, but it doesn't provide much
pointer to exactly how to do any of these things. It would be great if
someone who tried this or one of the developers can answer my questions. 
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/How-to-work-with-org-drools-repository-tp984680p984767.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools and mvel

2010-07-21 Thread Mark Proctor
  On 22/07/2010 00:49, Paul Edwards wrote:
 Hi Mark,

 I assume you are referring to: drools.dialect.mvel.strict =true|false  as I 
 cannot see any other config items. I have already tried setting that to false 
 (I should have put that in the first email) but it didn't work.

 I'm guessing that leaves me needing to raise a Jira issue???
MVELDialectConfiguration
 public void setLangLevel(int langLevel) {


 --
 Paul Edwards
 Solutions Engineer
 Identity Solutions Practice
 -
 hyro

 P Oz +61 2 9215 4347
 M NZ +64 21 2588695
 M Oz +61 4 2091 3987
 W www.hyro.com
 E paul.edwa...@hyro.com
 
 From: rules-users-boun...@lists.jboss.org 
 [rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor 
 [mproc...@codehaus.org]
 Sent: Thursday, 22 July 2010 1:01 a.m.
 To: Rules Users List
 Subject: Re: [rules-users] Drools and mvel

 It is possible to turn off the language constraint for MVEL in drools, see 
 KnowledgeBuilderConfiguration, which should cause the static field not to be 
 set.

 Mark
 On 21/07/2010 15:02, Edson Tirelli wrote:

  Hi Paul,

  Your analysis is correct. The problem is that these configurations in 
 MVEL are made using static properties and so they affect all uses of MVEL in 
 a single classloading hierarchy. Unfortunately, I don't think there is 
 anything you can do right now, other than open a JIRA in MVEL to help 
 convince Mike to make all configurations non-static in MVEL:

 http://jira.codehaus.org/browse/MVEL

  Edson

 2010/7/21 Paul Edwardspaul.edwa...@hyro.commailto:paul.edwa...@hyro.com
 Hi guys,

 I have an issue which involves smooks, drools and mvel.

 Quick explanation, the unit test is just a smooks run. Nothing complicated. 
 The test passes happily. It contains an expression that involves an MVEL IF 
 statement.

 Now if I add a drools startup (I'm not using drools in the test, I'm just 
 initialising it), the unit test now fails on the IF statement. The 
 exception received is:

 org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize method 
 'initialize' on class 'org.milyn.javabean.BeanInstancePopulator'.
 at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:457)
 at 
 org.milyn.cdr.annotation.Configurator.initialise(Configurator.java:439)
 at 
 org.milyn.cdr.annotation.Configurator.configure(Configurator.java:91)
 at 
 org.milyn.cdr.annotation.Configurator.configure(Configurator.java:66)
 at 
 org.milyn.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:63)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:623)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:548)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:536)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:711)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:690)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:484)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:349)
 at 
 org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146)
 at 
 org.milyn.container.standalone.StandaloneExecutionContext.init(StandaloneExecutionContext.java:91)
 at 
 org.milyn.container.standalone.StandaloneExecutionContext.init(StandaloneExecutionContext.java:65)
 at org.milyn.Smooks.createExecutionContext(Smooks.java:383)
 at org.milyn.Smooks.createExecutionContext(Smooks.java:346)
 at 
 com.hyro.telstrapoc.smooks.SmooksTransformTest.runSmooksTransform(SmooksTransformTest.java:215)
 at 
 com.hyro.telstrapoc.smooks.SmooksTransformTest.testSmooks(SmooksTransformTest.java:139)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at 
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at 
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at 
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at