drl for Selection and Decreasing
by Al Ferguson
Hi,
I'd like to use the Planner to determine the location of items to be shipped
(aka Order Sourcing).
The Planning Entity is:
.---------------------.
| OrderLine |
| ------------------- |
| String productCode |
| int orderedQuantity |
| StockItem stockItem |
'---------------------'
The resource (Planning Variable) is:
.-----------------------.
| StockItem |
| --------------------- |
| String productCode |
| String warehouseId |
| int availableQuantity |
'-----------------------'
Solution Implementation is:
.-----------------.
| OrderPlanning |
| --------------- |
| score |
| orderLineList |
| stockItemList |
'-----------------'
Here's an example to be solved:
OrderLine [id=1, productCode=A, orderedQuantity=1]
OrderLine [id=2, productCode=B, orderedQuantity=2]
OrderLine [id=3, productCode=B, orderedQuantity=2]
StockItem [id=1, productCode=A, warehouseId=NYC, availableQuantity=1000]
StockItem [id=1, productCode=B, warehouseId=NYC, availableQuantity=1000]
StockItem [id=1, productCode=B, warehouseId=CHI, availableQuantity=1000]
Can you help me writing the required 'drl'?
- StockItem.productCode must be the OrderLine.productCode
- StockItem.availableQuantity must be decreased when an OrderLine is
allocated
Obviously the allocation rules are much more complex. But I'm starting with
the Planner and I need help to start.
Thanks,
Al
--
View this message in context: http://drools.46999.n3.nabble.com/drl-for-Selection-and-Decreasing-tp4022...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Issue with Rule X1 extends X2
by arul.prashanth@gmail.com
When two rules recide within a same drl extends works as expected.
rule "Base_Rule|1.1.2"
enabled false
when
$bdy : BDY()
Vehicles()
then
System.out.println(" >>>> 222 "+$bdy);
end
rule "TX_Rule|1.1.2" extends "Base_Rule|1.1.2"
when
then
System.out.println(" >>>> TX 222 "+$bdy);
end
When the super rule recides in a different DRL and child rule in a different
DRL the parent rule is not fired
rule "TX_Rule|1.1.1" extends "Base_Rule|1.1.0"
when
BDY();
then
System.out.println(" >>>> TX 111 "+$bdy);
end
Any thoughts ??
--
View this message in context: http://drools.46999.n3.nabble.com/Issue-with-Rule-X1-extends-X2-tp4023114...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Drools JPA Example
by Charles Moulliard
Hi,
I'm looking for a Drools JPA example. As the Drools Community Project does
not contain such example I contact the community to figure out if such
example exist and is available in a git repo
Regards,
--
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
12 years, 9 months
Working memory - database synchronisation approach
by riri
Hello everyone,
I am currently working on a Spring, Hibernate, Bitronix project and am
trying to integrate Drools functionality. I have a set of JPA Entities that
I can manage using Spring Data and Hibernate and I would like to use these
entities as facts inside a StatefulKnowledgeSession. As I understand it, I
need to have some mechanism of keeping the facts inside the working memory
in sync with the database and what I mean by that is:
1. update the facts in working memory when they are changed from outside
2. update the facts in the database when a RHS part of a rule changes
properties
This article http://www.ibm.com/developerworks/java/library/j-drools5/
<http://www.ibm.com/developerworks/java/library/j-drools5/> gives some
pointers on how to achieve 1. using AOP but in my case I do not have a
global knowledge session to insert, I need to be able to create a knowledge
base for each user of the application since each user will need to have his
own set of rules independent from other users.
What would be the best practices for achieving the synchronisation?
Currently for 1. I am updating the fact manually by retrieving the object
and calling update from java code. For 2. I have a
WorkingMemoryEventListener that is configured as a Spring @Component with
autowired services that can perform CRUD actions on entities and which are
called on objectUpdated.
I am new to all these technologies so I do not know if this is a good way to
go. I have a unit test where a rule modifies a property and the object is
updated in the database but if the Thread with the fireUntilHalt method is
not paused, the test finishes and the JTA manager is shut down before the
rules can fire and the transaction in the objectUpdated can be executed.
I would be very grateful for any insight from the more experienced users
that have come across such requirements before.
Best regards
--
View this message in context: http://drools.46999.n3.nabble.com/Working-memory-database-synchronisation...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Re: [rules-users] Upload POJO model, no facts are imported
by rjr201
When you upload the Jar file you have to then go to 'File'->'Save' and check
it in. If the objects still don't appear, try going to the edit tab on the
package and looking at the list under "Configuration: Imported types". If
there is nothing in this list, click on the green cross and see if you can
add your objects from there. If you can't then there is probably something
wrong with the Jar file you've uploaded. Make sure that's it's a non
compressed jar file, this has caused me problems in the past.
Hope that helps,
Rich.
--
View this message in context: http://drools.46999.n3.nabble.com/Upload-POJO-model-no-facts-are-imported...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Re: [rules-users] Importing existing drl into Guvnor
by droolist
"I have some requirement of building specific rules from same package , Can
we achieve this by maintaining guvnor repository from external RDBMS ?"
When you say build, I assume you mean packaging. Yes, Guvnor provides
selectors - built in selector using status and categories. And there is
custom selector where you can provide your selection logic.
"how can we achieve this requirement of firing specific rules under specific
conditions when I am using guvnor for managing rules"
Besides salience and agenda-group as mentioned by Abhinay, take a look at
AgendaFilters. You can use some custom metadata and use that in your custom
AgendaFitler to accept firing of certain rules.
--
View this message in context: http://drools.46999.n3.nabble.com/Importing-existing-drl-into-Guvnor-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months