KIE Workbench- Uploading Java Class For Use in Guided Rule - drools

I'm somewhat new to drools. I'm using KIE workbench running on tomcat 8. I would like to upload a .jar file containing a Java class I wrote in Netbeans to Drools/KIE workbench THEN use it in the guided rule section of the workbench. I've figured out how to upload the .jar containing the class to my project and include it as a dependency, I've added it to project package whitelist. I am able to use this uploaded object in a new DRL file (new item > DRL file) where I write a rule by hand, but I'm unable to see or use this data model/object in parts of the wb like the guided rule creator (new item> guided rule) or tests (new item> test scenario).
Anyone have any idea if this is possible or know how to do it?
Thank you.

You need to go to the 'Data Objects' tab and import your class using 'New Item' and then picking your class in the dropdown.
Import Data Objects

Related

Drools guided rule editor and Eclipse Project

I have created a java project in eclipse which automatically picks up
all the .drl files from an external directory and executes all the
rules in that directory .So this enables the execution of dynamic
addition of new rules at anytime.
Now, instead of creating a new drool file and add it into that
directory, i want to use the guided rule editor to help non technical
users to add new rules into that directory.
I have started on with drools-workbench, but still i have no idea how
to integrate this eclipse project with the guided rule editor feature
available in drools-wb.
Is there any way in which i can export this project into the drools
workbench. If that is possible, then how can i deploy this directory
which contains all the .drl files into drools-wb and how these .drl
files can be used in the guided rule editor.
If your existing project is a maven project then you can import that project into drools-workbench, but there should be some required files(project.import,..etc) need to available specific to drools-workbench those should be available into project. We cant download any specific rule file from drools-workbench, workbench will create jar file which contains all the assets(rules and BPMN files), you can add this jar into classpath and create kieSession from there through which you can execute rules.

Importing JAVA bean into Drools Workbench

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!
Create a jar with the beans you want to use (use maven for convenience).
Upload jar into workbench through Artifact Repository.
Include dependency using project editor AND include all packages of the jar to the Package white list.
Add the classes you need at the Data Objects menu of the rules to use them.
What Stathis stated gives you one option to do this. Alternatively you can
maven install your beans project (this will extract a jar in .m2 repository to use as a dependency)
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

Sharing RemoteService implementations between 2 GWT projects

I have been struggling a while now to try to reuse the RemoteService implementation from one GWT project into a new one.
Here's the big picture:
I have a working smartgwt-mobile project and we now decided we wanted a desktop version of the same project, using regular smart-gwt. The GUI of this new app will obviously be different but the server side code will be exactly the same.
I tried to just "borrow" the RemoteService interface, its async counterpart and the whole server package by either linking the package folders in the other project inside the new source structure (I am using Eclipse with GWT plugin) or by adding the borrowed code path as a filtered source folder to the build path, and while this satisfies the Eclipse dependency checker, the GWT compiler is unable to find the borrowed code suggesting I need to add "inherit" declarations in the module .gwt.xml file.
When I do this and recompile it now expects a second module .gwt.xml file in the root of the borrowed code which is not acceptable because it would affect the other project.
I have been reading up on the GWT module documentation but I fail to see how to implement such a scheme. It may actually be impossible to do what I am trying to achieve.
I would be willing, if that solves the problem, to create a third project that simply defines a GWT RemoteService module that then will be inherited by both the mobile and desktop smartgwt projects.
Does anybody have suggestions about how to tackle this issue?
I'l agree to "third project that simply defines a GWT RemoteService module that then will be inherited by both the mobile and desktop smartgwt projects"
Why because, I'm just already doing this. Yes that is Obviously an DAO project(DB layer) which has all my DB business logic methods there.
And its always better to maintain separate DAO layer to expose your data to services(ex.webservices).
So here's how I solved the issue.
The problem with linking to an existing GWT project source folders is that the GWT compiler always (at least that's what it looks like) expects to find a GWT module definition file (.gwt.xml). I have not been able to link in the source folders in such a way that the GWT compiler is happy, even though the Eclipse dependency resolver has no problem with it.
So I created a third project using the GWT Eclipse plugin. I unchecked the "Create Sample Code" option, so I ended up with an empty GWT project. I then selected 'Add' > 'New' > 'Other' > 'Google' > 'Module', entered a module name, e.g. 'myModule', a package name, e.g. 'com.myCompany.myModule' and clicked 'Finish'. The GWT New Module wizard created the package and a child package under it named 'com.myCompany.myModule.client' and I created 'com.myCompany.myModule.server' myself.
Now I copied the RemoteService and related classes (The implementation and Async version ), plus all the server side code the RemoteService code calls from the original project I wanted to borrow from and pasted it into the new project. Very soon I had all dependencies satisfied and I opened the Build Path dialog on the new Smart-GWT web app project and included the GWT RemoteService Module Project in the projects tab. Last thing to do was adding an inherit element to the .gwt.xml file:
<inherits name='com.myCompany.myModule.MyModule'/>
Voilá: That's all there is to it. If you select 'GWT Compile Project' It compiles and runs in dev mode without warnings.
I now still have to delete the shared code from the first project and inherit from the module, bat that is simply a repetition of what I already did.
In the end this was much less painful as I imagined it to be, so I recommend this approach.

How to make iReport data source connection to java classes in NetBeans?

I'm working with the iReport plugin for NetBeans and need to use a class for my datasource. The documentation says you can add a link to datasources in jar files so that you can see the class fields when creating the report, by including that jar file in the iReport classpath list. The problem is that there is no jar file with the compiled classes in NetBeans.
Does anyone know a convenient way to make a datasource connection with classes in a NetBeans project?
Or, how can I compile the java code and place that in a jar file that can be used as a datasource for iReport?
Thanks

Importing a existing Web Application , into Eclipse

I need to import a existing Web Application , into Eclipse .
Please see the Structure of my Web Application as shown in the below figure .
http://imageshack.us/f/220/structurek.jpg/
From Eclipse IDE , while using import What option i need to select that is should i use
Existing projects into Eclipse
Archive File
File System
please see this image
http://imageshack.us/f/850/eclipseo.jpg/
Import existing projects into Eclipse works only for projects that were created in Eclipse.
And you're definitely not dealing with an Archive File here.
Import from the File System just copies the resources but does not actually create an Eclipse project for you.
What I would advise you, is to create a new Dynamic Web Project, configuring all the required facets, and then just copy all the contents of your existing app to the WebContent folder, either by drag'n'dropping it into the Project Explorer or by using Import from the File System, overwriting all the contents.
So far, there seems to be no other way to do it in Eclipse. However you may check out the similar post. The user #RC recommends using ant task for this process, but I'm more than sure that it won't configure all the required facets for you. It may work for some simple Java projects, but surely not enough for Java EE projects.