problems with desicion tables
by Vanina Beraudo
Hi,
I am working with decition tables, I have differents xls files with
rules and I want to add multiple xls files to the same rulebase and
they will be merged into a single package.
I do the following:
private static RuleBase readTablaDecision() throws Exception {
//read in the source
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
final String drl = converter.compile( "/reglaPrincipal.xls",
InputType.XLS );
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new StringReader( drl ) );
final String drl2, drl3;
if((dj.getVersion()!=null)&&(dj.getVersion().compareTo("Version
1")==0)){
drl2 = converter.compile( "/reglaVersion1.xls",
InputType.XLS );
builder.addPackageFromDrl( new StringReader( drl2 ) );
}
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
When I run the program, the following error message appear:
org.drools.compiler.PackageBuilder$PackageMergeException: Can't merge
packages with different names. This package: com.ReglaPrincipal - New
package: com.reglaVersion1
at org.drools.compiler.PackageBuilder.validatePackageName(PackageBuilder.java:325)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:236)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
Can I work with severals xls files?
--
Lic. Vanina Beraudo
15 years, 9 months
problems with decition tables
by Vanina Beraudo
Hi,
I am working with decition tables, I have differents xls files with
rules and I want to add multiple xls files to the same rulebase and
they will be merged into a single package.
I do the following:
private static RuleBase readTablaDecision() throws Exception {
//read in the source
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
final String drl = converter.compile( "/reglaPrincipal.xls",
InputType.XLS );
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new StringReader( drl ) );
final String drl2, drl3;
if((dj.getVersion()!=null)&&(dj.getVersion().compareTo("Version 1")==0)){
drl2 = converter.compile( "/reglaVersion1.xls", InputType.XLS );
builder.addPackageFromDrl( new StringReader( drl2 ) );
}
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
When I run the program, the following error message appear:
org.drools.compiler.PackageBuilder$PackageMergeException: Can't merge
packages with different names. This package: com.ReglaPrincipal - New
package: com.reglaVersion1
at org.drools.compiler.PackageBuilder.validatePackageName(PackageBuilder.java:325)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:236)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
Can I work with severals xls files?
--
Lic. Vanina Beraudo
15 years, 9 months
generic properties
by thomas kukofka
Hello,
I want to use a generic Input-Object for drools which can i.g. access String
properties:
private HashMap<Parameter, String> stringParameter;
with methods:
public String getStringPropertyValue(Parameter parameter) {
return stringParameter.get(parameter);
}
public void setStringPropertyValue(Parameter parameter, String value) {
stringParameter.put(parameter, value);
}
My problem is can I use in drl something like :
when
io: InputObject (getStringPropertyValue("propertyname") == "something")
regards
thomas
15 years, 9 months
RE: [rules-users] How to check for a variable number of "conditions" ina rule?
by Ron Kneusel
Mike,
I think the collect will work, I'll have to look at it more closely because the ordering of elements in the array is significant so I'm not sure I can just break the elements up into facts and let collect group them however it will.
As a follow up, while my solution of using a global in the LHS works, is the problem with changing the global simply that the engine will not see the changes? For my case, the global is set before the rules engine is called and it will not change while the engine runs.
Ron
Mike wrote:
>Have a look at the "Alarms" example for "Collect" in the (4.0.5) manual.
>
>This should give you a good starting point.
>
>Cheers,
>
>Mike
_________________________________________________________________
With Windows Live for mobile, your contacts travel with you.
http://www.windowslive.com/mobile/overview.html?ocid=TXT_TAGLM_WL_mobile_...
15 years, 9 months
InvalidClassException: When creating RuleAgent
by Felbecker, Tobias
When I create a new RuleAgent with a package created with the BRMS
following Exception is thrown:
RuleAgent(BusinessRuleEngine) INFO (Wed Jul 23 12:00:32 CEST 2008):
Configuring with newInstance=true, secondsToRefresh=30
RuleAgent(BusinessRuleEngine) INFO (Wed Jul 23 12:00:32 CEST 2008):
Configuring package provider : FileScanner scanning:
D:\...\mypackage.pkg
RuleAgent(BusinessRuleEngine) EXCEPTION (Wed Jul 23 12:00:33 CEST 2008):
org.drools.base.mvel.DroolsMVELFactory; Serializable incompatible with
Externalizable. Stack trace should follow.
java.io.InvalidClassException: org.drools.base.mvel.DroolsMVELFactory;
Serializable incompatible with Externalizable
...
It works fine with another package created earlier. So it could be
something wrong with my fact model.
I couldn't find any useful information about the Serializeable
incompatible with Externalizable on the web.
15 years, 9 months
How to check for a variable number of "conditions" in a rule?
by Ron Kneusel
Greetings!
I want to create a rule that checks a fact which contains an array to see if n or more of the elements of that array have a specific value. The number of elements to check will vary from invocation to invocation of the rules engine and will likely be added as a global.
I can do this by using a helper function. Say, for example, I have:
rule "fire_when_testFlags_true"
when
eval(testFlags(flags, limit.intValue()));
then
System.out.println("Yup, " + limit + " or more flags are true!");
end
Where flags and limit are both globals. Then I can define testFlags as:
function boolean testFlags(Flags flags, int threshold) {
int count = 0;
for(int i=0; i < flags.getSize(); i++) {
if (flags.getValue(i)) {
count++;
if (count>= threshold) {
return true;
}
}
}
return false;
}
This works but violates the warning not to use a global that isn't immutable in the LHS of a rule. Does anyone have an idea about how to implement a rule that in effect has an arbitrary number of conditions to be tested?
Ron
_________________________________________________________________
Keep your kids safer online with Windows Live Family Safety.
http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_...
15 years, 9 months
RuleFlow Spanning Multiple Packages
by Carlsen, Len
Hi All,
Is it possible to define a rule flow that spans multiple packages
(rulesets).
Currently we have the 3 packages (and we are planning on dividing them
into more sub-packages):
Package1: 10,000 rules
Package2: 5000 rules
Package3: 1000 rules
And we would like to create one rule flow for all 3 packages.
I have looked through the documentation and it seems that you can only
create one rule flow per package.
Am I right or have I missed something somewhere?
We are using Drools 4.0.7
Thanks,
Len
15 years, 9 months