[rules-users] rule help
Wolfgang Laun
wolfgang.laun at gmail.com
Sun Nov 8 12:40:23 EST 2009
In addition to what Nestor has said, you'll also have to make sure your
inserted facts objects contain values. You are just calling the default
constructors
Adattipus ertek = new Adattipus();
Mertadat mertekegyseg = new Mertadat ();
Mertadat mozgas = new Mertadat ();
workingMemory.insert( ertek );
workingMemory.insert( mertekegyseg );
workingMemory.insert( mozgas );
for Adattipus and Mertadat.
Also, it seems that you are confusing your Mertadat fields "mertekegyseg"
and "mozgas" with objects of the same name.
Minden jót!
-W
On Sun, Nov 8, 2009 at 12:16 PM, SzA84 <szepesiandras at citromail.hu> wrote:
>
> Hi I am working on a simple drools project.
> I have now one rule, but it not works.
>
> This is the drl:
>
> package orvosi;
> import orvosi.orvosimeres.Adattipus;
> import orvosi.orvosimeres.Mertadat;
>
> rule "Your First Rule"
>
> when
> Adattipus(ertek="heart_rate");
> Mertadat(ertek>180, mertekegyseg=="/min",
> mozgas==true);
> then
> System.out.println ("riasztas");
>
> end
>
> And this is the orvosi.java in the package but I think it's not good so.
> Suggest me any ideas how I can make it work.
> Thx!
>
> package orvosi;
>
> import java.io.InputStreamReader;
> import java.io.Reader;
>
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.compiler.PackageBuilder;
> import org.drools.rule.Package;
>
>
> public class orvosimeres {
>
>
> public static final void main(String[] args) {
> try {
> RuleBase ruleBase = readRule();
> WorkingMemory workingMemory =
> ruleBase.newStatefulSession();
> Adattipus ertek = new Adattipus();
> Mertadat mertekegyseg = new Mertadat ();
> Mertadat mozgas = new Mertadat ();
> workingMemory.insert( ertek );
> workingMemory.insert( mertekegyseg );
> workingMemory.insert( mozgas );
> workingMemory.fireAllRules();
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
>
> private static RuleBase readRule() throws Exception {
> Reader source = new InputStreamReader(
> orvosimeres.class.getResourceAsStream( "/vernyomas.drl" ) );
>
>
> PackageBuilder builder = new PackageBuilder();
>
> builder.addPackageFromDrl( source );
>
> Package pkg = builder.getPackage();
>
> RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> ruleBase.addPackage( pkg );
> return ruleBase;
> }
>
> public static class Adattipus{
> public int ertek;
> }
> public static class Mertadat{
> public int mertekegyseg;
> boolean mozgas=false;
> }
>
>
> }
> --
> View this message in context:
> http://old.nabble.com/rule-help-tp26245649p26245649.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091108/a86203c2/attachment.html
More information about the rules-users
mailing list