Using GetObjects command with ObjectFilter attribute in Drools-Server
by le_zurdo
In the Drools Integration User Guide there is an example to create XML
commands which can be used with Drools Server.
The documentation of the GetObjectsCommand specifies that you can set an
ObjectFilter to filter the objects returned:
GetObjectsCommand
<http://docs.jboss.org/drools/release/5.5.0.Final/droolsjbpm-integration-d...>
However, the documentation does not specify the format that must be used to
include the ObjectFilter.
I have tried creating an XML directly from a GetObjectsCommand object using
Xstream which results in the following XML command:
*<org.drools.command.runtime.rule.GetObjectsCommand>
<filter class="org.drools.runtime.ClassObjectFilter">
<clazz>com.sample.models.EstadoInformacional</clazz>
</filter>
</org.drools.command.runtime.rule.GetObjectsCommand>
*
Which is different from the xml format used in the User Guide. The command
works well with Drools Server, but it doesn't filter objects:
*<?xml version='1.0' encoding='UTF-8'?><execution-results><result
identifier="objects"><list><com.sample.models.Rol><rol>rol1</rol></com.sample.models.Rol><com.sample.models.EstadoInformacional><id>id1</id></com.sample.models.EstadoInformacional></list></result></execution-results>
*
I have also tried to modify the command used in the Drools User Guide
without success:
*<batch-execution lookup="ksession1">
<get-objects out-identifier="objects">
<org.drools.runtime.ClassObjectFilter>
<clazz>com.sample.models.EstadoInformacional</clazz>
</org.drools.runtime.ClassObjectFilter>
</get-objects>
</batch-execution>*
So my question is: What is the format to use an ObjectFilter with the
GetObjectsCommand?
--
View this message in context: http://drools.46999.n3.nabble.com/Using-GetObjects-command-with-ObjectFil...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Rule Templates - Conditionally Generate Rule based on Values in Data
by Jason Allen
All,
I saw this question was asked a couple of months ago with no reply, but thought I would try again.
In using a Rule Template, I'm trying to determine a way to dynamically generate rules based on a value in the data.
There is a data set, that has various pieces data, depending on a column value, the rule that is generated is relatively different. Different enough that I wouldn't want the generated a rule for each row of data, because many of the rules generated would never fire.
In the drools expert docs, it lists under 6.1.7 Rule Templates the ability to "conditionally generate rules based on the values in the data", but I can't seem to find the syntax for how to do that.
Does anyone know the answer to this?
I would picture it looking something like this
if ("@{RevenueCode}" == "NR")
rule "RevenueMapperRule_1"
when
claim1 : ClaimFact (ProgramType in ("FC", "FCP", "FALSE", "FALSE"),
ProcedureCode == "NR",
(serviceBegin >= "01-Oct-2003" && serviceBegin <= "31-Dec-2030"),
modifier1 in ("U"),
typeofBill == "3");
then
claim1.setResultSPCCode("507.11");
list.add(claim1);
end
end if
Essentially, the only time this rule would be generated is if RevenueCode in the Rules Spreadsheet had a value of "NR".
If this is not possible, how should I be thinking about this problem? Feels weird to generate a bunch of rules that will never fire, simply because there is no way to conditionally generate a rule. Maybe the answer is to create separate rule files and template definitions? That also feels like an over complication.
Thoughts?
Thanks in advance!
11 years, 6 months
Problem with Banking Tutorial
by Stefan Schuster
Hello,
I have a problem with the banking tutorial number 3, which is part of the
examples of drools expert.
It simply adds some Numbers as facts, and retracts them in an increasing
order.
It is very short, therefore I post the whole Code:
BankingExample3.java
_________________________________________________
package org.drools.tutorials.banking;
public class BankingExample3 {
public static void main(String[] args) {
Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(4),
wrap(1), wrap(5)};
new RuleRunner().runRules( new String[] { "Example3.drl" },
numbers );
}
private static Integer wrap(int i) {
return new Integer(i);
}
}
_________________________________________________
Example3.drl:
_________________________________________________
package org.drools.tutorials.banking
rule "Rule 01"
when
$number : Number()
not Number( intValue < $number.intValue )
then
System.out.println("Number found with value: " + $number.intValue()
);
retract( $number );
end
_________________________________________________
Output:
_________________________________________________
Loading file: Example3.drl
Inserting fact: 3
Inserting fact: 1
Inserting fact: 4
Inserting fact: 1
Inserting fact: 5
Number found with value: 1
Number found with value: 1
Number found with value: 3
Number found with value: 4
Number found with value: 5
_________________________________________________
that seams absolute logically to me.
But now I alter the Numbers in the Java-Part:
Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(2)};
and the output destroys everything I thought I understood:
Loading file: Example3.drl
Inserting fact: 3
Inserting fact: 1
Inserting fact: 2
Number found with value: 1
Number found with value: 3
Number found with value: 2
Can someone reproduce this behavior?? It seams absolutely strange to me. I
would have expected the order 1,2,3. Any explanations?
Thanks in advance for helping me!
11 years, 6 months
6.0.0-Beta3: Fibonacci example
by Wolfgang Laun
FibonacciExample.java:28
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
How can I tell - without running eclipse and whatnot - which file(s)
from the unzipped and unjarred sources are part of this?
-W
11 years, 6 months
Applying complex condition in excel while importing into drool
by ashish6276
Hi,
We are importing excel in drool by using drool API. we are facing issue in
applying multiple condition into
various columns. Defined excel rule for one particular column but we are not
able to get condition or rule in
.drl file.below is the code.
public class DroolExcelDemo {
public static final void main(final String[] args) {
// Create knowledge builder
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
// Create drl file from excel sheet
InputStream is =null;
try {
is= new FileInputStream("C:/POCExcel.xls");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// Create compiler class instance
SpreadsheetCompiler sc = new SpreadsheetCompiler();
// Compile the excel to generate the (.drl) file
StringBuffer drl=new StringBuffer(sc.compile(is,InputType.XLS));
// Insert dialect value into drl file
drl.insert(drl.indexOf("DROOLS")+40,"dialect \"mvel\""+"\n");
// Check the generated drl file
System.out.println("Generate DRL file is showing below–: ");
System.out.println("Value of xls in drl"+drl);
// writing string into a drl file
try {
BufferedWriter out = new BufferedWriter(new FileWriter("C:/rules.drl"));
out.write(drl.toString());
out.close();
//System.out.println("print content"+out.append(csq, start, end));
}
catch (IOException e){
System.out.println("Exception ");
}
// Wait before using the drl file in the next section.
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("testing");
// End creation of drl file from excel sheet
// Using DRL file
kbuilder.add(ResourceFactory.newClassPathResource("rules.drl",DroolMessage.class),ResourceType.DRL
);
// Check the builder for errors
if ( kbuilder.hasErrors() ) {
System.out.println("kbuilder has errors");
System.out.println( kbuilder.getErrors().toString());
}
// get the compiled packages (which are serializable)
final Collection pkgs = kbuilder.getKnowledgePackages();
can anyone help on this. Thanks in advance
--
View this message in context: http://drools.46999.n3.nabble.com/Applying-complex-condition-in-excel-whi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
dfreeman@gio.com.au
by FREEMAN, Darrell
Darrell Freeman
Architect, CD General Insurance
Suncorp Business Services
Phone +61 (02) 8121 0115 IPC 2BT080
Email: Darrell.freeman(a)suncorp.com.au<mailto:Darrell.freeman@suncorp.com.au>
Address, Level 7 Metcentre, 60 Margaret St, Sydney, Australia
________________________________
This e-mail is sent by GIO General Limited ABN 22 002 861 583 ("GIO").
GIO may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 10 10.
The content of this e-mail is the view of the sender or stated author and does not necessarily reflect the view of GIO. The content, including attachments, is a confidential communication between GIO and the intended recipient. If you are not the intended recipient, any use, interference with, disclosure or copying of this e-mail, including attachments, is unauthorised and expressly prohibited. If you have received this e-mail in error please contact the sender immediately and delete the e-mail and any attachments from your system.
If this e-mail constitutes a commercial message of a type that you no longer wish to receive please reply to this e-mail by typing Unsubscribe in the subject line.
11 years, 6 months