How to use rule templates in Kie Workbench? - drools

I have installled and have deployed a few rules files to kie server using drools workbench. But now I want to use template files to be used and create drl files out it and then deploy those rules witk kie workbench. I have found an option to add template file such as Guided Rule Template. But the source cannot be edited. Usually when we define templates files we start with a template header. A sample template file is shown below.
template header
frequency
memory
power
package com.myspace.test;
import com.myspace.test.GPU;
template "power-for-gpu"
rule "Choice recommended power supply for GPU_#{row.rowNumber}"
when
$gpu : GPU(frequency ==#{frequency}, memory== #{memory})
then
$gpu.setPower(#{power})
end
end template
but the Guided Rule Template doesn't seems to be in the above manner. It starts with package and no template header can be found or created default. There is no option for defining variables. Its generated source looks like rule file and not template. Is there anyway to define and use templates in kie workbench.

Related

jruleImportException : the selected archive does not have descriptor.xml

I have created JAR file from decision service in IBM ODM. I was using that into datastage application to call rule app from datastage. while doing that I am getting error.
JruleImoprtException: the selected archive "filePath" is not valid ruleset archive.the file descriptor.xml could not be located in the archive.
I have used 8.10 version to create decision service. Datastage is using 8.8 version.
Is it creating error because of the conflicting version or I have created jar file wrong way ?
IBM has moved to Decision service from 8.10 onwards that uses Decision rule engine to creates dsar file for deployment. This dsar file has archive.xml to instruct the Jrule connector about the information of the rules.
In earlier versions - Rule projects are created using classic rule engine and jar file is required to deploy the project. In those version it has description.xml file that contains the metadata about the projects parameters.
As of now, you can switch to Classic Rule Engine option to create a JAR file that includes the description.xml. It is deprecated so not advisable.
In Eclipse -> Right click on the project -> Rule Execution server -> Select classic rule engine.

QBO3 database deployment does not create Entity view

When deploying a database theme to create a new QBO3 database, the Entity view was not created.
My theme includes references to the following .sqlproj projects:
Standard
Mortgage
Credit
Debt
And I see that the Standard.sqlproj > Scripts > Script.PostDeployment.sql includes creation of an Entity view if it does not already exist.
Do I need to deploy each project separately?
To include pre-and-post deployment scripts from "core" projects, modify your theme's pre-and-post deployment script to include the relevent scripts from the other projects.
For example:
:r ..\..\Standard\Scripts\Script.PostDeployment.sql
:r ..\..\Mortgage\Scripts\Mortgage.PostDeployment.sql
Note that the :r syntax is a SQLCMD convention to include external files. The included files will be run in the order in which they are included.

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.

KIE Workbench- Uploading Java Class For Use in Guided Rule

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

How to export and import a set of rules selected from the predefined rules in the rules configuration of the Eclipse Plugin PMD?

I am using the plugin PMD for Eclipse and have zeroed in on a set of rules preexisting in my PMD rules configuration. I want to share these set of rules with my team mates . But when i try and export the Rules from PMD, it either exports only one rule OR if I use Ctrl + A on all the rules, it exports the rules but doesn't remember which rule was checked and which was unchecked.
Deleting rules that are not useful and then exporting only selected rules leads to hardcoding of the loaction of the XML file in the rule set .
For Example, If my xml file is stored in location X in my local directory,
the rulesets become
<rule ref="X/custom_PMD_rules.xml/AbstractClassWithoutAbstractMethod"/>
What is the correct way of sharing a set of rules in a team in PMD? I was able to share the rules in Checkstyle and code templates using simple export and import. Then why not in PMD.
I use an XML ruleset file to share rules with teammates. The ruleset can use a relative path to refer to other files. Or if all the rules are in one file, you can just import them to Eclipse and the location doesn't matter.