Accessing maps (hashmaps) keys and values in rules
by Ryan, Dennis (Dennis)
We are using Maps (HashMaps) in our rules and the only way we have found
to access keys and values in the Map in the "when" clauses is thru use
on eval() which I know is a big no-no by rules purists. Is there a
better way, maybe some shorthand I'm not familiar with to deal with Maps
in the when clause?
Thanks,
Dennis
16 years, 8 months
question about encoding in rules
by João Mota
Greetings,
I am having some issues with encoding in my rules. I am using a drl like
this:
package pt.xpto.mydroolstest
import pt.xpto.model.SimpleFact
import pt.xpto.model.SimpleResult
import java.util.ArrayList
import java.util.Collection
global Collection results
rule 'first-rule'
when
SimpleFact(description=="someDescription", value < "500") and
SimpleFact(description=="anotherDescription", value=="1");
then
SimpleResult result = new SimpleResult();
ArrayList aList= new ArrayList();
result.setDescription("Some String with portuguese chars like ç and à");
aList.add("Another String with portuguese chars like é and ã.");
result.setValue(aList);
results.add(result);
end
My problem is that when i retrieve the results from firing the rules, the
encoding of the strings with the portuguese chars is all messed up. From the
tests i did, this happens when the rules are compiled by drools.
If i make the following modification to the rules
result.setDescription(new String("Some String with portuguese chars
like ç and à".getBytes(),"utf-8"));
and load it like this, then the strings are retrieved ok.
RuleBase ruleBase = RuleBaseLoader.getInstance().loadFromReader(new
InputStreamReader(DroolsTest.class.getResourceAsStream( "Rules.drl" )));
Yet the same modification does not work if the rule is defined in the BRMS
and loaded by the rules agent.
I noticed that in the portuguese example shown in
http://labs.jboss.com/drools/ no portuguese special chars are used, is this
a limitation of the rules engine or am I just using wrong?
Can you point me in the right direction?
best regards,
João Mota
16 years, 8 months
Eclipse Drools Project external jar
by Krkvak
Hello,
I think I have a pretty trivial qeuestion, but still, I cannot come up
with an answer. I'm exploring drools and I have a little Drools
project in Eclipse, created using the drools plugin ver. 4.0.4.
I can include classes defined in the project in the guided editor, but
not classes that I added to the build path and imported using the
rule.package file.
How do I use the external jars in BRLs ?
Also, if I add the import to DRL, does the IDE supposed to throw an
error if that class is not found in any referenced jar ?
Thanks.
16 years, 8 months
How to block until RuleAgent has loaded up a ruleset?
by Irving Reid
I have an application built on Drools 4.0.3, using JBRMS to manage the rule base and the RuleAgent class to load the rules into my application.
My problem is that the application gets the rulebase from the agent and starts processing events (using a StatelessSession for each event) immediately at startup, *before* the agent has downloaded the rule package from the JBRMS.
I'm looking into using the RuleAgent callbacks to set a flag when the rule package has loaded, and have my event processor wait for the flag to be set.
If there's another way I'd love to hear it.
- irving -
16 years, 8 months
How do you use Ruleflows with StatelessSession's?
by Shahad Ahmed
Does anyone know if it's possible to use a ruleflow with a StatelessSession?
The current documentation and API seem to show examples with
StatefullSessions i.e.:
statefullSession.startProcess(id);
statefullSession.fireAllRules();
etc...
However, there doesn't seem to be anything equivalent in the API for
StatelessSesssion's. I'd really like to be able to use the new sequential
mode (i.e. with a StatelessSession) and ruleflow.
Regards,
Shahad
16 years, 8 months
How to create "dslr" file in Eclipse
by SB.Raghavendra
Hi All,
I am able to create files with .drl and .dsl extensions in Eclipse with
Drools version 4.0.But iam not able to create the rule file
with".dslr".Could anybody let me know how to create the same?
(With out renaming the created .drl file with .dslr)
--
Regards,
SB.Raghavendra.
16 years, 8 months
How to use Eclipse Rule Project in BRMS
by SB.Raghavendra
Hi All,
I have a Rule Project in Eclipse WorkSpace.Now i want to import this Rule
Project into Work Space.How can i import the same.
In BRMS there is an option in Admin called import from XML but my Rule
project does not have XML...
Could you please guide me how to import
--
Regards,
SB.Raghavendra.
16 years, 8 months
Drools 4.0.x branch has still some issues with serialization
by siddhartha banik
Hi Group Members,
I have checked out Drools source from
http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/ on 7th
March,2008.
After that I have tested some scenarios/use cases, which are required for
our use.
1. *'Add Pkg/Rule with serialized RuleBase & Working Memory'* use case is
working fine, except some special scenarios
[ I have mentioned them in the attached file DynamicRulesMoreTest)].
2. *'Remove Pkg/rule with serialized RuleBase & Working Memory'* use case is
not working.
I have attached the Test scenarios & Rule(s) .
Please help me, if I am doing some thing wrong. Above 2 use cases are very
important for us, to use *"Drool"* in our application*.*
Regards
Siddhartha
16 years, 8 months
Making my own agenda Filter
by Mehak
Hi I am using this code to make my own agenda filter. In this case if the
type of rule is agenda then agenda filter to focus on that agenda is set
else agenda filter for rule is set.
private static AgendaFilter buildAgendaFilter(RuleConfig rule)
{ final String searchName = rule.getRuleName();
final String type = rule.getRuleType();
AgendaFilter filter = new AgendaFilter() // The control doesnt go inside
this code
{
public boolean accept(Activation activation)
{ if(type == "AGENDA")
{
if((activation.getRule().getAgendaGroup()).equalsIgnoreCase(searchName))
{ System.out.println(searchName);
return true;
}
return false;
}
else
{
if((activation.getRule().getName()).equalsIgnoreCase(searchName))
{
return true;
}
return false;
}
}
};
return filter;
The problem is that the control doesnt go inside the new agenda creation.
Please let me know if something is wrong with the way I have used it.
Thanks
--
View this message in context: http://www.nabble.com/Making-my-own-agenda-Filter-tp15950765p15950765.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months