FW: [rules-users] Parsing XML using Drools
by Anstis, Michael (M.)
Received from Anit, which might help others comment....
________________________________
From: Gupta, Ankit (Ankit) [mailto:gupta11@avaya.com]
Sent: 29 January 2009 10:04
To: Anstis, Michael (M.)
Subject: RE: [rules-users] Parsing XML using Drools
Hi Mike,
Thanks for prompt reply ,
Actually right now I am streaming the xml
<BenchmarkResultsFor>
<Benchmark>DataProcessing</Benchmark>
<Workload>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16</Workload>
<Memory>4, 4, 4, 8, 8, 12, 12, 16, 24, 24, 24, 24, 24, 24,
24, 24</Memory>
</BenchmarkResultsFor>
here we are using apache math api for interpolation
public MemoryBenchmarkResult(String name, double[] x, double[]
y) {
this.hostFunction = name;
// Create the interpolation function
SplineInterpolator i1 = new SplineInterpolator();
this.workload = x;
this.memory = y;
this.interpolator = i1.interpolate(this.workload, this.memory);
}
here we are passing the values of X Axis (Workload) and we get
the values of Y Axis (Memory ). Reading or Streaming of this XML are
doing using SAX .
This thing I want to do with Drools ...... as I know XML
Streaming is possible in Drools .
Regards
Ankit
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Thursday, January 29, 2009 2:48 PM
To: Rules Users List
Subject: RE: [rules-users] Parsing XML using Drools
It is not clear how you want to use the XML?
If the XML represents Facts then you could use a worker Fact and
"FROM" to deserialise them and make them available to WM. For example:-
rule "get some XML facts"
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
Obviously the XML need not be true serialised objects (in a JAXB
sense) but simply the properties that "getCheeseFromXML" rehydrates.
Drools is not exposing any of the XML libraries; they are merely
used by your code. The above would be (partially) equivalent to:-
Worker w = new Worker();
List<Cheese> cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
rule "Cheese pre-loaded"
when
Cheese( )
then
//Do something with cheese
end
Partially equivalent as you could retract Cheese( ) in the
second way which would affect truth maintenance whereas the first way
would (I believe) not.
With kind regards,
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Parsing XML using Drools
Hi All,
How can we read and parse a XML file using
drools ?
Does Drools support the SAX or DOM parsing .
Regards
Ankit
15 years, 11 months
Parsing XML using Drools
by Gupta, Ankit (Ankit)
Hi All,
How can we read and parse a XML file using drools ?
Does Drools support the SAX or DOM parsing .
Regards
Ankit
15 years, 11 months
Question about pulling data from external database
by Zhang Jing-A52198
Hi All,
When I use the "from" keyword to pull data from external database, will
those data get inserted to the current working memory? Do I need to
retract them after the rules are fired?
Thanks,
Jing
15 years, 11 months
Problems in Guvnor 5.0M4 with imported 4.0.7 repositories that use ruleflows
by Shahad Ahmed
Does anyone know if there is a way of specifying that the Guvnor 5.0M4
should migrate ruleflows from version 4.0 to 5.0 when importing a version
4.0 repository into the Guvnor, or is this bug/oversight in the Guvnor?
I'm trying to import a drools 4.0.7 repository into Guvnor 5.0M4 – the
repository was originally exported out of a drools 4.0.7 BRMS (i.e. in XML
format). However, when I try and build a package containing a ruleflow in
the imported repository it fails, but the same repository builds under the
drools 4.0.7 BRMS. Packages without ruleflows build okay, so it looks as if
the failure has to do with the ruleflows in packages.
I know that drools 4 ruleflows are not compatible with drools 5 ruleflows,
and that there's a drools property that allows the compiler to automatically
migrate ruleflows from 4.0 to 5.0. I had assumed the Guvnor applies this
migration as I see the following in the log when I import the repository,
but a quick look at code in the drools trunk suggests that this migration
simply changes version numbers in the repository, but does not migrate the
ruleflows:
17:27:59,931 INFO [STDOUT] AUTO MIGRATION: Performing drools.package
migration.
17:28:00,369 INFO [STDOUT] AUTO MIGRATION: drools.package migration
completed.
The reason I suspect it's something to do with ruleflows is that when I try
and do anything with the ruleflow assets in the Guvnor, I see the following
error:
17:30:40,634 INFO [STDOUT] (null: 1, 59): cvc-elt.1: Cannot find the
declaratio
n of element 'org.drools.ruleflow.core.impl.RuleFlowProcessImpl'.
When I try and build a package with a ruleflow I see the following error in
the log:
Caused by: java.lang.NullPointerException
at
org.drools.compiler.ProcessBuilder.buildProcess(ProcessBuilder.java:9
9)
at
org.drools.compiler.ProcessBuilder.addProcessFromFile(ProcessBuilder.
java:228)
at
org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.j
ava:435)
at
org.drools.compiler.PackageBuilder.addRuleFlow(PackageBuilder.java:40
7)
at
org.drools.guvnor.server.contenthandler.RuleFlowHandler.compile(RuleF
lowHandler.java:108)
at
org.drools.guvnor.server.builder.ContentPackageAssembler.buildAsset(C
ontentPackageAssembler.java:167)
at
org.drools.guvnor.server.builder.ContentPackageAssembler.buildPackage
(ContentPackageAssembler.java:154)
at
org.drools.guvnor.server.builder.ContentPackageAssembler.<init>(Conte
ntPackageAssembler.java:103)
at
org.drools.guvnor.server.builder.ContentPackageAssembler.<init>(Conte
ntPackageAssembler.java:116)
at
org.drools.guvnor.server.ServiceImplementation.buildPackage(ServiceIm
plementation.java:1370)
at
org.drools.guvnor.server.ServiceImplementation.buildPackage(ServiceIm
plementation.java:1354)
Regards
Shahad
15 years, 11 months
How to check diff objects in same condition.
by manyasri.m
Hi,
I write some rules related to discount price it's working fine.like
> Get Five BabySoap1 at 50% Discount
> Get Two BabySoap1 at 25% Discount
actually objects are available in working memory.But,I am giving some free
item.like,
> Buy BabySoap2 & Get BabySoap3 Free
how to find out.
List list = new ArrayList();
CashMemoHdr hdr = new CashMemoHdr();
hdr.setLineItems(2l);
List<CashMemoDtl> cashMemoDtls = new ArrayList<CashMemoDtl>();
CashMemoDtl dtl = new CashMemoDtl();
dtl.setArticleCode("BabySoap1");
dtl.setLineItemNumber(1);
dtl.setPrice(250L);
dtl.setLineDiscount(5L);
dtl.setQuantity(5l);
cashMemoDtls.add(dtl);
list.add(dtl);
dtl = new CashMemoDtl();
dtl.setArticleCode("BabySoap2");
dtl.setLineItemNumber(2);
dtl.setPrice(40L);
dtl.setLineDiscount(3L);
dtl.setQuantity(5l);
cashMemoDtls.add(dtl);
list.add(dtl);
dtl = new CashMemoDtl();
dtl.setArticleCode("BabySoap3");
dtl.setLineItemNumber(3);
dtl.setPrice(30L);
dtl.setLineDiscount(2L);
dtl.setQuantity(2l);
cashMemoDtls.add(dtl);
list.add(dtl);
hdr.setCashMemoDtls(list);
rule "Buy BabySoap2 & Get BabySoap3 Free"
when
> $h:
:CashMemoHdr(lineItems:lineItems,totalItems:totalItems,costAmt:costAmt
,cashMemoDtls:cashMemoDtls)
> $c
:CashMemoDtl(articleCode:articleCode,lineItemNumber:lineItemNumber,price:price,
netAmount:netAmount,lineDiscount:lineDiscount,quantity:quantity,
promotionId:promotionId)
//> eval($c.getArticleCode()== "BabySoap2")
>....................//how to test here
then
> System.out.println("=====================================");
> System.out.println("Buy BabySoap2 & Get BabySoap3 Free :"
+$c.getArticleCode());
> System.out.println("=====================================");
end
pls give me proper idea about of this.
Thanks,
-manya
--
View this message in context: http://www.nabble.com/How-to-check-diff-objects-in-same-condition.-tp2170...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 11 months
Drools Flow - 2 nice blogs
by Mark Proctor
Drools Flow - 2 nice blogs
http://blog.athico.com/2009/01/drools-5-holistic-approach-to-problem.html
/"the problem for business people to understand the differences between
business processes and rules, because from the point-of-view of business
use-cases they are integrated. why are there two tools / frameworks to
manage the same thing?
....
Now I read the documentation of Drools 5 and noticed that all is
availabe in ONE product: Drools 5. Thats really great news - I hope I
understood all well and I'll give it a try to do it with Drools only.
This gives me a better feeling than my previous decision. "/
http://blog.athico.com/2009/01/drools-flow-and-osworkflow-migration.html
/"We work together on projects for Argentina's biggest healthcare
provider, who are big OSWorkflow users. However with Drools offering a
much more powerful and complete framework, that integrates rules,
processes and event processing there is now a desire to move to this as
the standard. As part of this effort we need a migration path for al the
legacy OSWorkflow applications."/
15 years, 11 months
Nested objects in rules
by Costello, Robert
Got the Rule Execution Server running. Pretty cool. Next step is to
see how to incorporate nested objects.
I've seen the Game of Life example, but somehow missed how it uses
nested objects. In my case, the objects mimic a relational database,
so you might have
A Dog Kennel which contains many Pets, which have many owners. (maybe
more than one owner per pet, but I'm not really worried about that)
I'm wondering if there is a best practice in Drools for handling
relations. Would this be best handled at the time of fact insertion, or
is there a way to show the derivations of the fact types in the rules?
Perhaps this is best done in the DRL?
Thanks,
Robert Costello
15 years, 11 months
Rule package change listener
by Zhang Jing-A52198
Hi All,
I'm using Guvnor to create the business rules and using RuleAgent to
retrieve the rule package from the URL generated by Guvnor. Is there a
way for the RuleAgent to get notified when the rule package is modified?
Basically what I'm looking for is a listener mechanism so that the
RuleAgent would only update or retrieve the package when the package is
changed.
Thanks,
Jing
15 years, 11 months
Help on writing drl in excel file
by niraj manandhar
Dear Sir
Thanks for the answer by the way is there any way to slove my free item
problem .
I want to make a decison table in excel where my client will fill in the
item and free item list as
Purchased ITem No of purchase Free Item
No of free
==========================================================
Pen 2
Rubber 1
Pen 5
Pencil 1
Pen 10
Pencil 3
Pen 12
Pencil 4
Ink bottle 3
Sticker 1
Ink bottle 5
Sticker 2
Ink Bottle 10
Sticker 5
When a customer buys 19 pen then
his free item will be
4 pencil (due to first 12 pens)
5 pencil (due to remaining 5 pens)
1 rubber (due to 2 pens)
I have been trying to write the rule and fit into excel since from 1 week
but due to my limited knowledge of drl and decision tables in excel it is
taking a lot of time than writing code with lookup table and JAVA if else
Please help me to slove this riddle
Thanks
Niraj
15 years, 11 months
Cannot instantiate PackageBuilder object
by Kiran Narasareddy
Hi,
I am currently working on project which employs Drools 4.0.7 and
webServices using Axis2 . My code works well when I run it as standalone app
inside eclipse.
But as soon as I deploy the same code as a web service inside Axis2, I get
a *java.lang.NullPointerException*.
When I tried to debug it, I found that , When the service is deployed, the
PackageBuilder object cannot be created.. donno why..
PackageBuilder builder1 = new PackageBuilder();
Do I need to add sum thing else??
Itz not like the necessary libraries are not found, because the spreadsheet
compiler parsed the decision table(via excel sheet)...
Can anyone help me out??
Thanks in advance.
Kiran Narasareddy
Computers make very fast, very accurate mistakes.
15 years, 11 months