I created a simple project using Drools and Java basing on this tutorial. It worked perfectly, so I adapted it to what I wanted to do. My DRL files use mvel dialect (instead of Java dialect) and initializing takes place in rule "initial" inside DRL file. You can see this project (source code as well as libraries and DRL file) here. My DRL file looks more less like the following:
package omd
dialect "mvel"
declare ocenaKwalifikacji
value : Double
end
declare ocenaKandydata
value : Double
end
declare ocenaTestow
value : Double
end
declare ocenaRozmowy
value : Double
end
rule "ocenakandydata/1 "
when
$ocenaRozmowy : ocenaRozmowy(value==5.0000)
$ocenaKwalifikacji : ocenaKwalifikacji(value==5.0000)
$ocenaTestow : ocenaTestow(value==5.0000)
then
insert(new ocenaKandydata (5.0000))
System.out.println("ocenaKandydata setting to 5.0000)");
end
rule "ocenakandydata/2 "
when
$ocenaRozmowy : ocenaRozmowy(value==5.0000)
$ocenaKwalifikacji : ocenaKwalifikacji(value==4.0000)
$ocenaTestow : ocenaTestow(value==5.0000)
then
insert(new ocenaKandydata (5.0000))
System.out.println("ocenaKandydata setting to 5.0000)");
end
...
rule "ocenakandydata/64 "
when
$ocenaRozmowy : ocenaRozmowy(value==2.0000)
$ocenaKwalifikacji : ocenaKwalifikacji(value==2.0000)
$ocenaTestow : ocenaTestow(value==2.0000)
then
insert(new ocenaKandydata (2.0000))
System.out.println("ocenaKandydata setting to 2.0000)");
end
rule "initial"
when
then
/*DATA*/
insert(new ocenaKwalifikacji(5.0));
insert(new ocenaRozmowy(2.0));
insert(new ocenaTestow(2.0));
end
Everything works fine, but the package in the first line must be omd although all classes are in the com.sample package. When I changed the package name to com.sample, I got the following error:
Error creating field accessors for TypeDeclaration 'ocenaKandydata' for type 'ocenaKandydata'.
And now there is all the fun...
I created similar project for Android. I used the same code, but the libraries come from another example (the previous ones did put classes in java.* or javax.* packages, which is not allowed while programming for Android). You can see this project here. I put the psc-zatrudnienie-ocena_kandydata.drl file in the smartphone storage under /storage/emulated/0/drools/psc-zatrudnienie-ocena_kandydata.drl. When the package in the DRL file is pl.me.drools2tp (the same as all classes in Android app are placed in), I get following errors (similar to those ones above):
Error creating field accessors for TypeDeclaration 'ocenaKwalifikacji' for type 'ocenaKwalifikacji'
Error creating field accessors for TypeDeclaration 'ocenaKandydata' for type 'ocenaKandydata'
Error creating field accessors for TypeDeclaration 'ocenaTestow' for type 'ocenaTestow'
Error creating field accessors for TypeDeclaration 'ocenaRozmowy' for type 'ocenaRozmowy'
and when I change the package name in DRL file to something another, the errors are as following:
Class 'ocenaKwalifikacji' not found for type declaration of 'ocenaKwalifikacji'
Class 'ocenaKandydata' not found for type declaration of 'ocenaKandydata'
Class 'ocenaTestow' not found for type declaration of 'ocenaTestow'
Class 'ocenaRozmowy' not found for type declaration of 'ocenaRozmowy'
Could anybody give me some advice about this? What does exactly "field accessor for TypeDeclaration" mean? All the classes which are mentioned in declare part of the DRL file are also defined in Java, have value field and both getters and setters. The dekstop version uses Drools 5.3.0 (there is a huge sort of JAR files from http://download.jboss.org/drools/release/5.3.0.Final/ as it was said on TutorialsPoint site). There is also one question connected with mine: Integration of Drools (Expert System) with Android Projects
I will be very grateful for some help, tips or examples.
Best regards, Peter.
BTW I use IntelliJ and Android Studio.