[rules-users] Using Advanced Enumeration Concepts in guvnor

abhinay_agarwal abhinay_agarwal at infosys.com
Tue Jan 7 08:30:50 EST 2014


The following sentences are taking directly from the user guide:

/ 'Person.age' : (new com.yourco.DataHelper()).getListOfAges()

This assumes you have a class called "DataHelper" which has a method
"getListOfAges()" which returns a List of strings (and is on the classpath).
You can of course mix these "dynamic" enumerations with fixed lists. You
could for example load from a database using JDBC. The data enumerations are
loaded the first time you use the guided editor in a session./

Now, I would like to know how guvnor would connect to the database ?

Inside the getListOfAges(), I want to hit the database and get the list of
ages, put it inside a Map<String, List&lt;String>>.

The example that is shown in the user guide is again hard coding the values.

>From the user guide :

/public class SampleDataSource2 {
    public Map<String>, List<String> loadData() {
       Map data = new HashMap();
       List d = new ArrayList();
       d.add("value1");
      d.add("value2");
      data.put("Fact.field", d);
      return data;
  }
}/


AFAIK, the jar of this class SampleDataSource2 will be uploaded to guvnor,
so should I keep the connection details to database inside the same class ?
If yes,

1. How will guvnor be able to directly connect to the database ? 
2. Should I add the jars for database connectivity as well ?
3. Is keeping the connection details inside the jar, not a security threat ?

I am not sure if I understand completely how this enumeration works, please
feel free to guide me, if I am wrong somewhere.

Regards,
Abhinay




--
View this message in context: http://drools.46999.n3.nabble.com/Using-Advanced-Enumeration-Concepts-in-guvnor-tp4027563.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list