2
votes

I start using KIE Drools Workbench and I practice in creating DRL files so I can tutor pepole that are not programmers in creating rules.

I know how to create a JAVA class within the Workbench but I need to know how to import a class I already wrote that will be part of the statement.

For example: Employer - class I create within the Workbench Employee - class I developed in eclipse and wish to import into the Workbench

So the drl could look like this:

when
 $employer:Employer(isHappy == true)
then
 Employee emp = new Employee();
 emp.setSalary(100);
 insert(emp);
end

Any idea how can I import JAVA bean to use in KIE Drools Workbench?

Thanks!

2
I don't think it can be done. And good luck with the non-programmers! - laune
You don't think this tool can be used by non-programmer? - RiskX
It depends on the level of the rules they'll ultimately have to write. - Look at the right hand side of your rule sample: is it the tip of an iceberg? Or just one of a dozen use cases they can adapt from a cheat sheet? - laune
No it will get more complex. So every object I write I need to re-write inside the workbench in order to use it? - RiskX
Unless someone comes up here with hotter news pretty soon: I'd post this question on the Drools User List groups.google.com/forum/#!forum/drools-usage . Maybe it even has an answer there - I'm not monitoring this list. - laune

2 Answers

5
votes
  1. Create a jar with the beans you want to use (use maven for convenience).
  2. Upload jar into workbench through Artifact Repository.
  3. Include dependency using project editor AND include all packages of the jar to the Package white list.
  4. Add the classes you need at the Data Objects menu of the rules to use them.
2
votes

What Stathis stated gives you one option to do this. Alternatively you can

  1. maven install your beans project (this will extract a jar in .m2 repository to use as a dependency)
  2. add a dependency with the jar extracted in .m2 in your project's pom

As for the tutoring part you should examine the possibility of using dsl (Domain Specific Language) for your rules. This and this (chapter 5.10) might be handy to you