[rules-users] write a rule file, longest matching?

merry0900 m1e1r1r1y at 163.com
Fri Jan 3 23:43:06 EST 2014


hello,here is my java code

main(){
MyPojo myPojo=new MyPojo();
myPojo.setA("aaa")
myPojo.setB("bbb")...
.
.
.
List<MyPojo> myPojos=getAllFromDb()// get all object by mybatis form
database ,and each one is        different from another.

  ksession.setGlobal("myPojos", myPojos);
  ksession.insert(myPojo);
}


class MyPojo {
private Long id;
private String a;
private String b;
private String c;
private String d;
//getters;
//setters;
}


i want to write a drl file whitch can find a List<MyPojo> myPojoSub that
Each MyPojo From myPojoSub is come from myPojos and limited by some rules。
for example:


myPojos={{id:1,a:"kkk",b:"iii",c:"ppp"},{id:2,a:"kkk",b:"iii"},{id:3,a:"kkk"},{id:4,a:"kkk",b:"iii",c:"ooo"},{id:5,a:"mmm",b:"fff",c:"ttt"}}

and if there is a myPojo{a:kkk,b:"iii",c:"ppp"}  then
{id:1,a:"kkk",b:"iii",c:"ppp"} from myPojos is a member of myPojoSub

 if there is a myPojo{a:kkk,b:"iii",c:"ttt"}  then
{id:2,a:"kkk",b:"iii",}from myPojos is a member of myPojoSub

if there is a myPojo{a:kkk,b:"fff",c:"ttt"}  then {id:3,a:"kkk"}from myPojos
is a member of myPojoSub
if there is a myPojo{a:"lll",b:"fff",c:"ttt"} then
{id:5,a:"mmm",b:"fff",c:"ttt"}from myPojos is a member of myPojoSub

if there is a myPojo{a:"ppp",b:"jjj",c:"zzz"} then no any MyPojo from
myPojos is a member of myPojoSub


how do i write my drl rules?    any one can help me or give some
suggestions?  thank you

here is a rule file templet:

package com.test.tules;

import com.test.MyPojo; 
import java.util.List; 
 
globle List<com.test.MyPojo> myPojos;
rule "aaaaa"
salience 65523

when 

then







--
View this message in context: http://drools.46999.n3.nabble.com/write-a-rule-file-longest-matching-tp4027514.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list