Menu

How to set a Datatype's attribute using WebStudio in a Decision Table?

Help
2015-12-10
2015-12-12
  • James Dekker

    James Dekker - 2015-12-10

    Am using OpenL Tablets 5.16.2

    Suppose you have the following Datatype defined:

    Datatype Person
    int age
    boolean requirement

    Suppose you created the following DecisionTable through the wizard:

    SimpleRules Person ageRule(int age)

    age RETURN
    <=18 How to set the requirement attribute to true?

    Am trying to do this strictly in either Excel or the WebStudio wizard.

    Thank you for taking the time to read this.

     

    Last edit: James Dekker 2015-12-10
  • Sergey Zyrianov

    Sergey Zyrianov - 2015-12-10

    To learn about different Rule tables and their syntax check out our Tutorials. They will introduce you with initial set of features and their usage.

    For your case you will need to use regular Decision Table and not simplified version. The example is below.
    Usually you would like to return just the result, e.g. in your case boolean value. How to handle returns you will define in a separate rule. Check out our Examples (the same page as for tutorials)

    Rules Person ageRule(Person person)
    C1 RET1
    age person.requirement = ret; person
    IntRange boolean ret
    Age Return
    <=18 yes
    no
     

    Last edit: Sergey Zyrianov 2015-12-12
  • James Dekker

    James Dekker - 2015-12-11

    Hi Sergey,

    Thank you very much for replying... Your person example didn't work in WebStudio (attached is the ageRule.xls file). WebStudio reported a Problem: "Cannot parse cell value '<=18'.

    Also, when creating a new table, the drop down doesn't let the end user pick a regular decision table. See attachment.

    Have to manually pick Simple Rules and then export the Excel file and then edit it manually in Excel and change the Header from SimpleRules to Rules.

    A lot of your examples have Datatypes but do not show their usage inside Decision Tables. If you can show me a specific example that uses a simple "IF / THEN " with a DataType, I will be very grateful.

    What I am trying to do is evaluate this product to see if it can support a simple "IF / THEN"

    The Datatypes seems like a Java class.

    This is what I am trying to emulate (behind the scenes):

    public Person ageRule(int age) {
          Person person = new Person();
          if (person.age >= 18) {
                  person.requirement = true;
          }
          return person;
    }
    

    Am doing this to evaluate how hard it would be for a non-technical user (e.g. business analyst using WebStudio and / or Excel).

    I don't understand this part of the RET1 column cell:

    person.requirement = ret; person

    Would appreciate if if you could upload a simple Excel file to this thread which sets an attribute of a Datatype based on a specific "IF / THEN".

    Happy programming...

     

    Last edit: James Dekker 2015-12-11
  • Sergey Zyrianov

    Sergey Zyrianov - 2015-12-12

    James,
    Sorry, my bad. I forgot to add 'IntRange' to tip OpenL that there will be range value in C1 column (corrected my previous message). Simple rules will do this on their own. And I did something nobody of analysts will do, I provided you with the reply without even checking it.

    You identified rule table type correctly - you will use Rules, SimpleRules, SimpleLookup tables to capture logic which corresponds to "IF / THEN". These rule types are flavors of Decision Table. Check Tutorial 1 for more details.

    We have wizard only for SimpleRules table in WebStudio. You will need to use Excel to create more complex rules. WebStudio allows editing complex rules but not creating them from scratch. Analysts usually prefer flexibility of Excel to work with more complex rules and changes in them.

    For analysts I would recommend to define simple rules like "Boolean ageRule (Integer age)" as you initially defined, but returning Boolean value. Assignement of 'requirement' field in Person datatype I would put into separate rule, e.g. Spreadsheet table.

    SimpleRules Boolean ageRule(Integer age)
    Age Return
    <=18 yes
    no

    "person.requirement = ret; person" is a sequence of 2 statements:
    "person.requirement = ret" - it assigns value 'ret' from RET1 column to 'requirement' attribute of person
    "person" - returns 'person', can be also written as "return person"

    OpenL includes powerful scripting (business expressions + java + addional syntax sugar), but it shouldn't be used if you target business analysts. You would want to limit its usage to subset similar to Excel: formulas and functions,- and probably array index operators in addition.

     

    Last edit: Sergey Zyrianov 2015-12-12

Log in to post a comment.