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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to