hi,im new to drools..im trying to create a project as follows. i have a class called Monitor which monitors a folder and creates two lists called fileOld( which is the list of filenames in that folder at time t1) and fileNew(which is the list of filenames in that folder at time t2). i have another class called FileData which contains two members fileOld and fileNew (list of strings) with getters,setters and constructor. fileOld and fileNew from Monitor Class are passed to FileData class.
i also have another class called Event which is as follows:
public class Event {
public static String name;
private File source;
private Date timeStamp;
public static List<Event> listOfEvents = new ArrayList<Event>();
public Event(String name, File source, Date timeStamp) {
this.source = source;
this.timeStamp = timeStamp;
}
public String getName() {
return name;
}
public void setName(String name) {
}
public File getSource() {
return source;
}
public void setSource(File source) {
this.source = source;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}
now i have to compare these two lists(fileOld and fileNew) in a rule file and if they are not equal i have to create an event object for every file added and deleted and put it in the List<Event> listOfEvents.
here is my rule file:
rrule "files are equal"
when
FileData( fileOld == fileNew)
then
System.out.println("files are equal");
end
rule "files not equal"
when
FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
then
accumulate( $s : String( this not memberOf $old ) from $new, $plus : collectList( $s ) )
accumulate( $t : String( this not memberOf $new ) from $old, $mins : collectList( $t ) )
System.out.println("files added:" + $plus );
System.out.println( "files deleted:" + $mins );
end
how can i loop through each of the file added or deleted and create an Event Class object for every file added and deleted and finally add all the created objects to List<Event> listOfEvents..
Thanks.