Excel Syntax in Decision Tables

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Excel Syntax in Decision Tables

crosbis2
Hi,

I have a rule i created in Guvnor which works fine (see below)
But i can not create and import the same rule from a decision table. I can not get the syntax to match when i upload the xls and view source.
Everything below "when" i have as a Condition
Everything below "then" is an Action

Line 7: will not import. How do you create empty brackets in excel?
Line 9: how do i write this using the  pattern / constraint approach in excel? same with
Line 11 and 12?

Any help would be greatly appreciated.

1. | rule "DecisionA_OptionsAndFutures"
2. |    salience 0
3. |    dialect "mvel"
4. |    when
5. |        SCOProduct( productBookingPointId == 1 , productTypeId in ( 4, 5, 20 ) )
6. |        RuleSet( ruleSetName == "SCODecisionPointA" )
7. |        taskTemplates : TaskTemplates( )
8. |    then
9. |        TaskTemplate TaskTemplate1 = new TaskTemplate();
10. |        TaskTemplate1.setId( 12038 );
11. |        insert( TaskTemplate1 );
12. |        taskTemplates.addTaskTemplateIfNew( TaskTemplate1 );
13. | end


Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
Concerning line 7: You can prefix the empty pattern to another pattern:
    taskTemplates : TaskTemplates( )  RuleSet( r... )

Lines 9, 10, 11: You can't write this using the "pattern/constraint
approach", it's Java statements. See the documentation.

-W

On 12/05/2014, crosbis2 <[hidden email]> wrote:

> Hi,
>
> I have a rule i created in Guvnor which works fine (see below)
> But i can not create and import the same rule from a decision table. I can
> not get the syntax to match when i upload the xls and view source.
> Everything below "when" i have as a Condition
> Everything below "then" is an Action
>
> Line 7: will not import. How do you create empty brackets in excel?
> Line 9: how do i write this using the  pattern / constraint approach in
> excel? same with
> Line 11 and 12?
>
> Any help would be greatly appreciated.
>
> 1. | rule "DecisionA_OptionsAndFutures"
> 2. |    salience 0
> 3. |    dialect "mvel"
> 4. |    when
> 5. |        SCOProduct( productBookingPointId == 1 , productTypeId in ( 4,
> 5, 20 ) )
> 6. |        RuleSet( ruleSetName == "SCODecisionPointA" )
> 7. |        taskTemplates : TaskTemplates( )
> 8. |    then
> 9. |        TaskTemplate TaskTemplate1 = new TaskTemplate();
> 10. |        TaskTemplate1.setId( 12038 );
> 11. |        insert( TaskTemplate1 );
> 12. |        taskTemplates.addTaskTemplateIfNew( TaskTemplate1 );
> 13. | end
>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2


i'm still quite new to this i'm afriad.
 I've been able to get every line except 7 and 9 to import and look the exact same in "view source".  

I don't understand "prefix the empty pattern to another pattern:"? Say i only have one ruleset?
So it looks like if i don't enter a value in the "variable" cells the condition doesn't appear after import.
if i write TaskTemplates : TaskTemplates in the constraint cell and say 0 is the variable cell it imports correctly except for the unwanted 0. i.e.:

TaskTemplates : TaskTemplates(0)

if i don't enter a value in the "variable" cells the condition doesn't appear after import.

TaskTemplates : TaskTemplates()

same story applies with:
TaskTemplate TaskTemplate1 = new TaskTemplate();

 
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
On 12/05/2014, crosbis2 <[hidden email]> wrote:
> <http://drools.46999.n3.nabble.com/file/n4029529/Capture.png>
>
> i'm still quite new to this i'm afriad.
>  I've been able to get every line except 7 and 9 to import and look the
> exact same in "view source".
>
> I don't understand "prefix the empty pattern to another pattern:"? Say i
> only have one ruleset?

In this case you can use a more elaborate workaround
    TaskTemplates(/*$param*/)
and use an 'X' in all the rows ;-) But are you sure you need a
decision table for a table without a decision?


> So it looks like if i don't enter a value in the "variable" cells the
> condition doesn't appear after import.

That's the whole point. - Are you sure you are using the right rule
authoring mehtod?

> if i write TaskTemplates : TaskTemplates in the constraint cell and say 0
> is
> the variable cell it imports correctly except for the unwanted 0. i.e.:
>
> TaskTemplates : TaskTemplates(0)
>
> if i don't enter a value in the "variable" cells the condition doesn't
> appear after import.
>
> TaskTemplates : TaskTemplates()
>
> same story applies with:
> TaskTemplate TaskTemplate1 = new TaskTemplate();

Note that you can combine several Java statements into a single cell.
Typically, there should be at least one value to be inserted into this
code snippet and so you have something to put into the cells below.

-W

>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029529.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
Thanks for the quick replies!!

So am i naive in thinking if i get the source code of my imported decision table to match that of a predefined rule that the excel based rule will work?

Thats what i have now:
Example 1 is a validated working rule.
Example 2 is a rule i imported into drools, they are the exact same in my eyes except separate statements are on the same line.

the Validation image below is the error i received, how can this not validate if they are the same code?


Example 1

Example 2

Validation
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
The way it uploaded example 2 is the first image! example 1 corrosponds to decision A
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
In reply to this post by crosbis2
On 12/05/2014, crosbis2 <[hidden email]> wrote:

> Thanks for the quick replies!!
>
> So am i naive in thinking if i get the source code of my imported decision
> table to match that of a predefined rule that the excel based rule will
> work?
>
> Thats what i have now:
> Example 1 is a validated working rule.
> Example 2 is a rule i imported into drools, they are the exact same in my
> eyes except separate statements are on the same line.
>
> the Validation image below is the error i received, how can this not
> validate if they are the same code?

Nice try, but they are not the same code. An 's' is not equal to '1'.
-W



>
>
> <http://drools.46999.n3.nabble.com/file/n4029532/example1.png>
>
> <http://drools.46999.n3.nabble.com/file/n4029532/example2.png>
>
> <http://drools.46999.n3.nabble.com/file/n4029532/error.png>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029532.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
This post has NOT been accepted by the mailing list yet.
Hey,

Not over the finish line yet.
I tried to build the package with the source code looking the same as a previously built rule using the drools interface. I get the error below relating to the setId method. Am i defining the variable incorrectly, i tried $1 as well as $param?

Any ideas?

Error

Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
In reply to this post by crosbis2
Hey,

Not over the finish line yet,

I tried to build the package, after the rule validated correctly, but got the below error relating to the setId method. Have i defined the variable correctly i tried $1 and $param.

The view source code generated here looks the same as that of a previous rule i generated in guvnor that works.

Any Ideas?

Error


Code



Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
That's weird, and it looks like a bug in the build process to me: Java
literals are the same for byte, short and int. (CC-ing dev for
possible follow-up: You may be asked to furnish a minimal test case.)

As a workaround, use this in the Action column:
   ...; TaskTemplate1.setId( (short)$param );...

(Note 1: Using "short" is pretty pointless unless you need to store a
large number in an array. Note 2: Follow Java conventions for names
for class fields and variables.)

-W

On 13/05/2014, crosbis2 <[hidden email]> wrote:

> Hey,
>
> Not over the finish line yet,
>
> I tried to build the package, after the rule validated correctly, but got
> the below error relating to the setId method. Have i defined the variable
> correctly i tried $1 and $param.
>
> The view source code generated here looks the same as that of a previous
> rule i generated in guvnor that works.
>
> Any Ideas?
>
> <http://drools.46999.n3.nabble.com/file/n4029558/Capture2.png>
>
>
> <http://drools.46999.n3.nabble.com/file/n4029558/Capture3.png>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029558.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
Hi,

I'm sorry to disturb the forum with this one.

Working Rule

I want to replicate this code in a decision table. There is a parse exception when i try to convert a table due to  the code fatca : FATCA() i.e. There is Fatca [Fatca] even though the rule validates ok.

I know it is a pattern with no condition attached. so i tried putting it with the actual condition and also making it standalone with condition null. neither will convert to a decision table even though the syntax looks correct from the view source?


Decision Table

Anyone any ideas on what i need to do for this problem?
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
As the documentation tries to explain, there are four rows in the
heading of acondition column.

1 The first contains CONDITION (or condition).
2 The second defines the class for a Pattern.
3 The third one contains a constraint.
4 The fourth is for a comment.

So, use
   fatca: FATCA(); Classification()
for the second one and
    type == $param
for the fourth one.

-W

On 26/05/2014, crosbis2 <[hidden email]> wrote:

> Hi,
>
> I'm sorry to disturb the forum with this one.
>
> <http://drools.46999.n3.nabble.com/file/n4029686/FATCA1.png>
>
> I want to replicate this code in a decision table. There is a parse
> exception when i try to convert a table due to  the code fatca : FATCA()
> i.e. There is Fatca [Fatca] even though the rule validates ok.
>
> I know it is a pattern with no condition attached. so i tried putting it
> with the actual condition and also making it standalone with condition
> null.
> neither will convert to a decision table even though the syntax looks
> correct from the view source?
>
>
> <http://drools.46999.n3.nabble.com/file/n4029686/FATCA2.png>
>
> Anyone any ideas on what i need to do for this problem?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029686.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
Hi Laune,

I tried what you prescribed but get the following in the source code when i upload it.

 fatca: FATCA(Type == 3); Classification()


?
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
Which Drools version are you using?

The upper case 'T' in "Type == 3" is *very* unlikely.

And did you copy this exactly as I posted? Especially the final "()" is
essential in the second row.

-W

On 26/05/2014, crosbis2 <[hidden email]> wrote:

> Hi Laune,
>
> I tried what you prescribed but get the following in the source code when i
> upload it.
>
>  fatca: FATCA(Type == 3); Classification()
>
>
> ?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029690.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
It's guvnor-5.5.0.Final-jboss-as-7.0

Yes i copied your syntax



and got this


Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

laune
Oops, sorry: The constraint goes into the leftmost pair of parentheses.
Simply exchance to order of the patterns: Classification(); $f: FATCA();

-W

On 26/05/2014, crosbis2 <[hidden email]> wrote:

> It's guvnor-5.5.0.Final-jboss-as-7.0
>
> Yes i copied your syntax
>
> <http://drools.46999.n3.nabble.com/file/n4029693/FATCA3.png>
>
> and got this
>
> <http://drools.46999.n3.nabble.com/file/n4029693/FATCA5.png>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Excel-Syntax-in-Decision-Tables-tp4029520p4029693.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
Hi,

i tried
Classification(); $f: FATCA()
type == $param

$f is not recognized.

and regular rearranging

Classification(); fatca: FATCA()
type == $param

this doesn't give any errors but the rule doesn't work. I think fatca: FATCA() needs to be before Classification(type == 3);

Is there any other tricks to make this happen?
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Excel Syntax in Decision Tables

crosbis2
Thanks Wolfgang!!