Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to retrieve the collection of conditions using Drools ?

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Using Drools, is there any way to retrieve all the conditions from the business rules document (excel sheet used). To be more specific, please refer to the attachment (The contents are deliberately removed).

As per the attachment, we have several conditions like cond1, cond2, cond3 and actions. As far as i understand drools (have not worked before), based on the condition, action is selected. i.e , if we select cond1, act1 is selected from "action2" column. Now, does drools provides any feature that lists out all the conditions, in some kind of a Set of strings etc.

The way I see this drools is, for a unique key, we get a row from excel. Initially, I was looking for a reverse lookup, i.e for a given action, find out the condition. This does not sound logical and makes sense, as we after all do not get the Key from value. So, then I'm thinking if there is any way, drools returns the list of all the conditions.

something, like Set<String> getConditions()

Is this possible at all ? if yes, can some body throw me some light.
rules.GIF
[Thumbnail for rules.GIF]
 
Kumar Raja
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts on this
 
Kumar Raja
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm thinking may be if I put some additional details, I would get response earlier.

For suppose I have the rules as given below in an excel sheet

--------------------------------------------------------------------------------
CONDITION | ACTION |
--------------------------------------------------------------------------------
CONDITION 1 | ACTION1 |
CONDITION 2 | ACTION2 |
CONDITION 3 | ACTION3 |
CONDITION 4 | ACTION4 |
CONDITION 5 | ACTION5 |
--------------------------------------------------------------------------------

In our code, currently we load the rules from excel sheet as below



Now I suppose ruleBase has the collection of all rules, which I assume that each row from excel is stored as a row in ruleBase, atleast as per theory. Please correct me if I'm wrong here.

Now, if I wanted to load a object, say a Map<Condition, Action> from this ruleBase. Does Drools provide any api to handle such requirement? If Drools does not have anything already available, can we accomplish that from ruleBase object in other ways. Hope I made this question as clear as possible and I would appreciate, if someone could guide me here.

By the way, the version of drools being used is 4.0.7
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic