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.
now i have to compare these two lists in a rule file and if
they are not equal i have to print the lists of files added/
deleted. how to do this in drools.
here is my rule file:
rule "files are equal"
when
FileData(fileOld == fileNew)
then
System.out.println("files are equal");
end
rule "files not equal"
when
not FileData(fileOld == fileNew)
then
System.out.println("files are not equal");
difference(FileData.getFileOld(),FileData.getFileNew());
end
function void difference(List fileOld, List fileNew)
{
ArrayList<String> add = new
ArrayList<String>(fileNew);
add.removeAll(fileOld);
System.out.println("files Added: " + add);
ArrayList<String> remove = new
ArrayList<String>(fileOld);
remove.removeAll(fileNew);
System.out.println("files Removed: " + remove);
}
but this displays the following error...
Rule Compilation error : [Rule name='files not equal']
Cannot make a static reference to the non-static method
getFileOld() from the type FileData
Cannot make a static reference to the non-static method
getFileNew() from the type FileData
what can be done??