There is UI already there to control rules. and perform operation like CRUD using drl file or even using dsl for easing making drl rules for nontech person for such operation. So, Is there any other way to create our own webpage to control such rules for even easy usability?
Is any way to edit source codes for available workbench UI?
Drools is open source and you can modify the UI if you want. You can also treat Drools like a component in your architecture by wrapping it in a service and calling it through your own simplified API. You can then call your API from your own web front end.
Related
I am exploring drools for my project I would like to know from more experienced people out there if there are any limitations on the type of rules we can create in drl, can we make an api call in a rule in drools? is it possible to pass extra data along with the pojo I want to apply rules on?
We are planning to use Drools/JBoss BRMS 6 for business rules management. Our plan is to write rules using the workbench, deploy the rules package in multiple Execution Servers and allow applications to access the Rules package by making calls to the REST API. We do not have any Java wrappers or custom classes in between the calling applications and the rules package.
I am trying to incorporate some logging into the rules engine. I understand that there are EventListener interfaces that can be implemented.
Please would you provide some information/guidance on how to implement Listeners in our kind of set up? Where will I create and store the Java classes/methods that would implement Event Listeners?
How can a calling application insert an Event Listener into the session? Will it be part of the xml/json payload?
Thanks
1. Where to implement the listeners?
The listeners must be obviously implemented in Java. One simple place I found to put those implementation is in a separate maven project. After all, a project in the kie-workbench is a maven project itself. So you can create a separate project (outside the kie-workbench) implement the listeners you want to and then add this new project as a dependency in your kie-workbench's project (check the documentation on how to do that).
The only problem I found with this approach is that once you defined the dependency between your projects, the kie-workbench will scan every single class of it and of any other dependency it has. Check this link for more information.
So, if your listener project doesn't have too many dependencies, you should be good to go. Please note that, in theory, you could add any kie/drools dependency you have in your listener project as <scope>provided</scope>.
2. How can I configure these listeners?
A trick that I always use is to have what I call a "configuration" rule to do this kind of job.
A "Configuration" rule is a rule without LHS (and, if you are distrustful, a high salience). This kind of rules are guaranteed to be executed only once. Just make sure that you call a fireAllRules() before the first interaction with the kie-server, or that the first interaction always starts with a fireAllRules command.
Your configuration rule could look like this:
/**
Configures the session's listeners.
**/
rule "[SUB-CONFIG] Listeners Configuration"
salience 1000
when
then
((org.drools.impl.StatefulKnowledgeSessionImpl)kcontext.getKnowledgeRuntime()).addEventListener(new MyWorkingMemoryEventListener());
((org.drools.impl.StatefulKnowledgeSessionImpl)kcontext.getKnowledgeRuntime()).addEventListener(new MyAgendaEventListener());
end
You can place this rule in your kie-server project.
Hope it helps,
I am new to drools. How will i integrate my drool rules with front end jsp ? For example: i have created a front end page registration page through jsp. now how will I apply rules on that page. Please Suggest with through this example that how will it be done
This question seems rather broad in the sense that it's not clear whether it's asking how to write a web application or whether it has anything particular to do with Drools.
To put it as simply as possible.
Your JSP page should have a form which posts back to the server.
There should be a controller which handles requests from that form.
The controller invokes a service which uses the Drools API to invoke your rules.
The controller takes the result from that service and passes it to a new JSP for rendering as HTML.
Anything beyond that requires you to learn how to interact with Drools via its API. Assuming that you can write code to do that, there's nothing different that you really need to do to use it within your web application. The documentation is here:
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/
In case you're interested in code examples of Drools within a web application, you could take a look at this:
https://github.com/gratiartis/sctrcd-payment-validation-web
Full disclosure - I wrote it. It's a Spring web application providing REST web services which interact with Drools.
I am interested in creating rules for Drools Planner. I want that a user can create his own rules in a java app before starting the Drools Planner. Maybe a Drools-rule-file could be generated after the user has added his rules. Would this be possible or do I have to create the rule-file while developing the whole java application?
Many thanks...
Yes it's possible.
The trick is to build your own RuleBase and set it in the Planner config.
See section "5.3.4.2.2. A RuleBase (possibly defined by Guvnor)" in the manual.
You can construct a RuleBase by several, depending on how you want your user to edit his/her rules:
From a DRL file. This presumes the user knows DRL. See Drools Expert manual.
From a DSL file. This allows you to use natural language.
From the guvnor webapp. This allows you to use the tooling Guvnor, such as a guided rule editor, a decision tables spreadsheet, ... You can even use a changeset.
From guvnor in eclipse or a standalone app (under development and experimental). There's some work being in this area, but it's still young.
Good day. I'm still learning GWT so please help me. I'm working on a project - Web Application with GWT on the Client Side. This app has lots of CRUD operations so I'd like to make a model for this. Can anyone suggest a prototype for my CRUD class?
CRUD on this app goes something like this:
When I clicked the Details button in a module, a popup will be shown that allows the user to do CRUD operations. This popup do have the module title, info on the selected item, and the buttons - Edit, New, Delete.
I have already finished building the base GUI for this project but I'm just starting to work on each module. I choose to begin on those module with CRUD operations. So, please help me and give your ideas on this project. Thanks in advance :)
Your question is a little bit general.
You probably have to deal with two questions which can be handled separately:
Communication with the backend.
GUI for CRUD operations
Communication with the backend:
It depends on which kind of backend you are using.
Java-backend:
For Java backends the recommended client-server communication protocol is RequestFactory.
Non-Java-backend: In case you are using a non-java backend (python, PHP, etc) you have to use RequestBuilder using JSON or XML (I would recommend JSON).
For mapping JSON/XML to DTO's and vice verca you can use different methods:
Third party tools like piriti which are based on GWT generators
Javascript Overlay Types (JSO)
GWT Autobean framework (which is used by RequestFactory btw).
GUI for CRUD operations
For mapping your DTOs to your UI and doing the CRUD operations you can do it either:
manually
with the Editor framework
I would recommend to use the Editor framework as it reduces the amount of boilerplate code
to move an object from your object graph to the UI and back.
The Editor framework works well with RequestFactory (RequestFactoryEditorDriver), Autobean (SimpleBeanEditorDriver) and Javascript Overlay Types.