0
votes

I am using KIE Workbench (version 7.0.0.Final) to create rules using Guided editor. I am perfectly able to create the rules with .drl files but am having issues creating the same rules with the editor. Consider the below examples:

I have created the below rule in editor which translates to this in the "Source" tab:

package com.myteam.orica;

import java.lang.String;

rule "Home Phone"
   dialect "java"
when
    sampleAttributes : SampleAttributes( homePhoneNumber : homePhoneNumber != null )
then
    sampleAttributes.setHomePhoneNumber( homePhoneNumber.replaceAll( "[^\\d]", "" ) );
end

Ideally, I want it to be something like this:

package com.myteam.orica;

import java.lang.String;

rule "Home Phone"
   dialect "java"
when
    sampleAttributes : SampleAttributes( homePhoneNumber : homePhoneNumber != null )
then
    String str = homePhoneNumber.replaceAll( "[^\\d]", "" );
    sampleAttributes.setHomePhoneNumber( str );
end

basically store the result of the method call (replaceAll) on homePhoneNumber to a temp/local variable which I can then set as a part of homePhoneNumber attribute of my SampleAttributes DataObject, but to be done with the Guided editor. I have tried using the Global variables, but am not able to set it in the editor.

Can someone please let me know how can I achieve the above with the Guided rule editor?

Thanks

1
The Guided Editor has been designed for Dummies. It will not let you create code that Dummies won't understand. Either you descend to Dummy level and accept whatever the GE thinks is best for you, or stick with a text editor and roll your own DRL code.laune

1 Answers

0
votes

You can write your own .dsl file, asset type 'Domain Specific Language Definitions', in the same project as the guided rules one, you can use drools dsl to write what you need.

Use 'Guided Rules (with DSL)' instead of just 'Guided Rules'

In 'Guided Rules (with DSL)' model tab, when adding a new line, you should be able to see the rule you've written in the .dsl file