Don't process rules when adding new package to rulebase
by Barraq
Hi there,
I'm developing a library that uses drools as a REAL-TIME rule engine. What
i'm a doing right now is to have a thread that wakes up each 100ms and do a
fireAllRules(1000).
I need to be able to load Facts and Rules on the fly, even after the
statefullsession is created. The problem is that when i add a new
RulePackage to the current rulebase's session, all the rules inside this
package are evaluated ! and so i never exit from this addPackage function !!
System.out.println("Start loading rules");
// build builder package configuration
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
conf.setClassLoader(factionary);
// Load file
File file = new File(chooser.getSelectedFile().getPath());
PackageBuilder builder = new PackageBuilder(conf);
builder.addPackageFromDrl(new FileReader(file));
// Load package to session
session.getRuleBase().addPackage(builder.getPackage()); // GET STUCK HERE
!!!!!!!!!!!
// Print success
jTextArea2.append(chooser.getSelectedFile().getPath()+"\n");
jTextArea2.setCaretPosition(jTextArea1.getDocument().getLength());
System.out.println("Done loading rules");
What i want is just to add the rules from the package that's all.... Since
i've a thread that call fireAllRules(1000) each 100ms the rules will get
proceced next time :)
Do you have any idea of how to do that ?
Thanks.
Barraquand Rémi
--
View this message in context: http://www.nabble.com/Don%27t-process-rules-when-adding-new-package-to-ru...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
how to write regular expressions in drools..
by Nagaraju runkana
HI Guys,
present i am using drools 4.0 in this case.now, i am writting some rules
validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
this..
--------------------
validation.dslr
--------------------
rule "email.mandatory:[insert][update][ui]"
when
There is an Order
Order email address checking for first letter
then
Reject with response : "email address must not start with @ "
end
rule "phone.mandatory:[insert][update][ui]"
when
There is an Order
Order phone number format should checking
then
Reject with response : "The phone number you entered is not valid.Please
enter a phone number with the format xxx-xxx-xxxx."\
end
-----------------------
validation.dsl
--------------------
[*][]Order email address checking for first letter= OrderBean(email matches
"@[A-Za-z0-9]*")
[*][]Order phone number format should checking=OrderBean( phone not matches
"(/\d{3}\-\d{3}\-\d{4}/)==-1)")
this rules are not working ...any one can help me.ASAP
thanks,
chanti
16 years, 4 months
Using global in LHS
by Markus Helbig
Hi,
again a question, any body had success using globals in LHS?
Following DSL
[condition][]is a Item=Item()
[condition][]-is of type Advertisment=advertisment contains catId
rule
when
$pli: is a Item
- is of type Advertisment
then
// do whatever you want
end
catId is a member of Item
advertisment is a Integer[] array set as global
comiling ends with:
Unable to create Field Extractor for 'advertisment' of '[ClassObjectType
It works fine if advertisment is a member of Item, but i want to have
it as global ...
Cheers
Markus
16 years, 4 months
Re: [rules-users] how to write regular expressions in drools..
by Christine
Chanti,
what exactly is your question?
I think that checking zipcode and credit card formats is easier to do in
java than with rules. Rules are more efficient in more complex situations,
like when you have multiple objects that need to meet various conditions.
Christine
On Fri, May 30, 2008 09:24, Nagaraju runkana wrote:
> HI Guys,
>
> present i am using drools 4.0 in this case.now, i am writting some rules
> validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
> this..
> --------------------
> validation.dslr
> --------------------
> rule "email.mandatory:[insert][update][ui]"
> when
> There is an Order
> Order email address checking for first letter
> then
> Reject with response : "email address must not start with @ "
> end
> rule "phone.mandatory:[insert][update][ui]"
> when
> There is an Order
> Order phone number format should checking
> then
> Reject with response : "The phone number you entered is not valid.Please
> enter a phone number with the format xxx-xxx-xxxx."\
> end
> -----------------------
> validation.dsl
> --------------------
> [*][]Order email address checking for first letter= OrderBean(email
> matches
> "@[A-Za-z0-9]*")
> [*][]Order phone number format should checking=OrderBean( phone not
> matches
> "(/\d{3}\-\d{3}\-\d{4}/)==-1)")
> this rules are not working ...any one can help me.ASAP
>
> thanks,
> chanti
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
16 years, 4 months
RE: [rules-users] Re: To know about correct Drools rule file (drl)syntaxes
by Christine
On Thu, May 29, 2008 16:17, Hareendra Pelige wrote:
> According to your experience, which rule file language is commonly used?
I would say that this syntax from your email is easiest to use. As Mark
explained, the xml-type language is old, version 2.0. You can define a
domain specific language, but that's worth the effort only in larger
projects, I'd say.
Christine
rule "Hello World"
when
m : Message( status == Message.HELLO, message : message)
then
System.out.println( message );
modify ( m ) { message = "Goodbyte cruel world",
status = Message.GOODBYE };
System.out.println( message );
end
16 years, 4 months