Question
Soufiane Amroun · Sep 7, 2017

how to have access to the bpl set rules in programming

hi world, how can i have access to the BPL set rules in programming ?

for information: all logical rules are stored in routine data base, but i don't know how to have access to its corresponding name space.

thank you for helping

1
0 351
Discussion (3)1
Log in or sign up to continue

To programmatically access the raw BPL XML...

ENSDEMO>set className="Demo.Loan.FindRateDecisionProcessBPL"
 
ENSDEMO>set xdata=##class(%Dictionary.XDataDefinition).%OpenId(className_"||BPL",.sc)                                                        

To then access the BPL data as objects...

ENSDEMO>set parser=##class(Ens.BPL.Parser).%New()
 
ENSDEMO>set sc=parser.ParseStream(xdata.Data,.bpl)

E.g.


ENSDEMO>zw bpl
bpl=<OBJECT REFERENCE>[7@Ens.BPL.Process]
+----------------- general information ---------------
|      oref value: 7
|      class name: Ens.BPL.Process
| reference count: 4
+----------------- attribute values ------------------
|          Component = ""
|  ContextSuperClass = ""
|     DerivedVersion = ""
|             Height = 2000
|           Includes = ""
|           Language = "objectscript"
|             Layout = ""
|            Package = ""
|            Request = "Demo.Loan.Msg.Application"
|           Response = ""
|            Version = ""
|              Width = 2635
+----------------- swizzled references ---------------
|          i%Context = ""
|          r%Context = "8@Ens.BPL.Context"
|           i%Parent = ""
|           r%Parent = ""
|         i%Sequence = ""
|         r%Sequence = "17@Ens.BPL.Sequence"
+-----------------------------------------------------

ENSDEMO>set context=bpl.Context
 
ENSDEMO>zw context
context=<OBJECT REFERENCE>[8@Ens.BPL.Context]
+----------------- general information ---------------
|      oref value: 8
|      class name: Ens.BPL.Context
| reference count: 9
+----------------- attribute values ------------------
|           (none)
+----------------- swizzled references ---------------
|           i%Parent = ""
|           r%Parent = "7@Ens.BPL.Process"
|       i%Properties = ""
|       r%Properties = "9@Ens.BPL.PropertyList"
+-----------------------------------------------------

Business Rule Definition is stored as XML in XData block named RuleDefinition inside rule class and can be (de)serialized as an object of Ens.Rule.Model.ruleDefinition class. Some utility methods are available there.

Here's an example of modifying Demo.ComplexMap.Rule.SemesterBatchRouting rule in ENSDEMO class. It modifies "when" condition from 1 to 0.

zn "ENSDEMO"
set ruleClass = "Demo.ComplexMap.Rule.SemesterBatchRouting"
set sc = ##class(Ens.Rule.Model.ruleDefinition).LoadFromClass(ruleClass, .rule)
set rule.ruleSets.GetAt(1).actions.GetAt(1).whens.GetAt(1).condition=0
w rule.SaveAs(ruleClass)
set sc=$system.OBJ.Compile(ruleClass,"k-d")

That said, I think the better approach would be to use (in order of
increasing implementation difficulty):

  • Context Class
  • Temporary Variables
  • Rule Assist Class

So the rule by itself does not change but values supplied by Context Class/Temporary Variables/etc do.