Home > Class Reference > ENSLIB namespace > Ens.Rule.RuleDefinition

Ens.Rule.RuleDefinition

persistent class Ens.Rule.RuleDefinition extends %Library.Persistent, %XML.Adaptor

SQL Table Name: Ens_Rule.RuleDefinition

Legacy: defined the interface for Business rules.
Persistent routing rules and business rules were implemented as subclasses of this class. Now the EvaluateRulesEx() method serves as a passthrough to the new (as of Ensemble 2012.1) class-defined routing rules and business rules. The rest of the contents of this class serve for conversion from old rule imports to the new style rule class definitions, which are derived from Ens.Rule.Definition.

Property Inventory

Method Inventory

Parameters

parameter COMPILABLE = 0;
Indicates if this Rule Engine supports compilation.
parameter RULEEDITORURL;
URL (csp page) for Rule Editor associated with the Rule Definition class.
parameter XMLIGNORENULL = 1;
Ensure that we don't get $C(0) for values that are empty strings

Properties

property %ErrorMsg as %String (XMLPROJECTION = "none") [ Transient ];
This property is used to pass back a User Error message in the event of an error.
Property methods: %ErrorMsgDisplayToLogical(), %ErrorMsgGet(), %ErrorMsgIsValid(), %ErrorMsgLogicalToDisplay(), %ErrorMsgLogicalToOdbc(), %ErrorMsgNormalize(), %ErrorMsgSet()
property %Reason as %String (XMLPROJECTION = "none") [ Transient ];
This property is used to pass back the Reason why this Rule is evaluated.
Property methods: %ReasonDisplayToLogical(), %ReasonGet(), %ReasonIsValid(), %ReasonLogicalToDisplay(), %ReasonLogicalToOdbc(), %ReasonNormalize(), %ReasonSet()
property %ReturnValue as %String (XMLPROJECTION = "none") [ Transient ];
This property is used to pass back the ReturnValue when this Rule is evaluated.
Property methods: %ReturnValueDisplayToLogical(), %ReturnValueGet(), %ReturnValueIsValid(), %ReturnValueLogicalToDisplay(), %ReturnValueLogicalToOdbc(), %ReturnValueNormalize(), %ReturnValueSet()
property %StackLevel as %String (XMLPROJECTION = "none") [ Transient ];
This property is used internally to prevent infinite recursion.
Property methods: %StackLevelDisplayToLogical(), %StackLevelGet(), %StackLevelIsValid(), %StackLevelLogicalToDisplay(), %StackLevelLogicalToOdbc(), %StackLevelNormalize(), %StackLevelSet()
property CompileStatus as %Status (XMLPROJECTION = "none") [ InitialExpression = $$$OK , Transient ];
For compilable rules, this is the status of the compilation.
Property methods: CompileStatusGet(), CompileStatusIsValid(), CompileStatusLogicalToOdbc(), CompileStatusLogicalToXSD(), CompileStatusSet(), CompileStatusXSDToLogical()
property ContextClass as %String (MAXLEN = 128, XMLNAME = "context", XMLPROJECTION = "attribute");
Property methods: ContextClassDisplayToLogical(), ContextClassGet(), ContextClassGetStored(), ContextClassIsValid(), ContextClassLogicalToDisplay(), ContextClassLogicalToOdbc(), ContextClassNormalize(), ContextClassSet()
property Description as %String);
Optional description of this Rule Definition.
Property methods: DescriptionDisplayToLogical(), DescriptionGet(), DescriptionGetStored(), DescriptionIsValid(), DescriptionLogicalToDisplay(), DescriptionLogicalToOdbc(), DescriptionNormalize(), DescriptionSet()
property EffectiveBeginDateTime as %String (COLLATION = "EXACT", MAXLEN = 2000, XMLNAME = "effectiveBeginDateTime", XMLPROJECTION = "attribute") [ Transient ];
The time from which the rule starts to become active. The exact time is included in the active interval. The format is "2008-10-28T18:00:00". The time portion is optional and it is defaulted to "00:00:00"
Property methods: EffectiveBeginDateTimeCompute(), EffectiveBeginDateTimeDisplayToLogical(), EffectiveBeginDateTimeGet(), EffectiveBeginDateTimeIsValid(), EffectiveBeginDateTimeLogicalToDisplay(), EffectiveBeginDateTimeLogicalToOdbc(), EffectiveBeginDateTimeNormalize(), EffectiveBeginDateTimeSQLCompute(), EffectiveBeginDateTimeSet(), EffectiveBeginDateTimeSetT()
property EffectiveEndDateTime as %String (COLLATION = "EXACT", MAXLEN = 2000, XMLNAME = "effectiveEndDateTime", XMLPROJECTION = "attribute") [ Transient ];
The time by which the rule stops to be active. The exact time is excluded from the active interval. The format is "2008-10-28T18:00:00". The time portion is optional and it is defaulted to "24:00:00"
Property methods: EffectiveEndDateTimeCompute(), EffectiveEndDateTimeDisplayToLogical(), EffectiveEndDateTimeGet(), EffectiveEndDateTimeIsValid(), EffectiveEndDateTimeLogicalToDisplay(), EffectiveEndDateTimeLogicalToOdbc(), EffectiveEndDateTimeNormalize(), EffectiveEndDateTimeSQLCompute(), EffectiveEndDateTimeSet(), EffectiveEndDateTimeSetT()
property FullName as %String (MAXLEN = 168) [ Required ];
The name and dates combination used in the IdKey
Property methods: FullNameDisplayToLogical(), FullNameGet(), FullNameGetStored(), FullNameIsValid(), FullNameLogicalToDisplay(), FullNameLogicalToOdbc(), FullNameNormalize(), FullNameSet()
property HasErrors as %Boolean (XMLPROJECTION = "none");
Set true if this Rule Definition contains errors that will prevent it from running correctly.
Property methods: HasErrorsDisplayToLogical(), HasErrorsGet(), HasErrorsGetStored(), HasErrorsIsValid(), HasErrorsLogicalToDisplay(), HasErrorsLogicalToXSD(), HasErrorsNormalize(), HasErrorsSet(), HasErrorsXSDToLogical()
property HostClass as %String (MAXLEN = 128, XMLNAME = "host", XMLPROJECTION = "attribute") [ Required ];
The class name of the Business Process this rule set is associated with.
Property methods: HostClassDisplayToLogical(), HostClassGet(), HostClassGetStored(), HostClassIsValid(), HostClassLogicalToDisplay(), HostClassLogicalToOdbc(), HostClassNormalize(), HostClassSet()
property Name as %String (COLLATION = "EXACT", MAXLEN = 128, XMLNAME = "name", XMLPROJECTION = "attribute") [ Required , Transient ];
The name of this Rule Definition.
Property methods: NameCompute(), NameDisplayToLogical(), NameGet(), NameIsValid(), NameLogicalToDisplay(), NameLogicalToOdbc(), NameNormalize(), NameSQLCompute(), NameSet(), NameSetT()
property Production as %String (MAXLEN = 128, XMLNAME = "production", XMLPROJECTION = "attribute");
Property methods: ProductionDisplayToLogical(), ProductionGet(), ProductionGetStored(), ProductionIsValid(), ProductionLogicalToDisplay(), ProductionLogicalToOdbc(), ProductionNormalize(), ProductionSet()
property ReportGroup as %String (MAXLEN = 2000, XMLNAME = "reportGroup", XMLPROJECTION = "element");
Value to be used to group rules for reporting
Property methods: ReportGroupDisplayToLogical(), ReportGroupGet(), ReportGroupGetStored(), ReportGroupIsValid(), ReportGroupLogicalToDisplay(), ReportGroupLogicalToOdbc(), ReportGroupNormalize(), ReportGroupSet()
property ReportName as %String (MAXLEN = 2000, XMLNAME = "reportName", XMLPROJECTION = "element");
Display value for the rule report group
Property methods: ReportNameDisplayToLogical(), ReportNameGet(), ReportNameGetStored(), ReportNameIsValid(), ReportNameLogicalToDisplay(), ReportNameLogicalToOdbc(), ReportNameNormalize(), ReportNameSet()
property RoutineName as %String (MAXLEN = 255, XMLPROJECTION = "none");
For compilable rules, this number identifies the routine in the rule cache that contains the compiled code for this rule.
Property methods: RoutineNameDisplayToLogical(), RoutineNameGet(), RoutineNameGetStored(), RoutineNameIsValid(), RoutineNameLogicalToDisplay(), RoutineNameLogicalToOdbc(), RoutineNameNormalize(), RoutineNameSet()
property ShortDescription as %String (MAXLEN = 2000, XMLNAME = "shortDescription", XMLPROJECTION = "element");
Optional short description of this Rule Definition.
Property methods: ShortDescriptionDisplayToLogical(), ShortDescriptionGet(), ShortDescriptionGetStored(), ShortDescriptionIsValid(), ShortDescriptionLogicalToDisplay(), ShortDescriptionLogicalToOdbc(), ShortDescriptionNormalize(), ShortDescriptionSet()
property TimeModified as Ens.DataType.UTC (XMLPROJECTION = "none");
Time that this Rule Definition was last saved.
Property methods: TimeModifiedDisplayToLogical(), TimeModifiedGet(), TimeModifiedGetStored(), TimeModifiedIsValid(), TimeModifiedLogicalToDisplay(), TimeModifiedLogicalToOdbc(), TimeModifiedNormalize(), TimeModifiedOdbcToLogical(), TimeModifiedSet(), TimeModifiedStorageToLogical(), TimeModifiedtimeCmp(), TimeModifiedtimeDiff(), TimeModifiedtimeLocal(), TimeModifiedtimeLocaltoUTC(), TimeModifiedtimeUTC(), TimeModifiedtimeUTCH(), TimeModifiedtimeUTCHtoUTC(), TimeModifiedtimeUTCtoLocal(), TimeModifiedtimeUTCtoUTCH()
property Version as %Integer (XMLPROJECTION = "none") [ InitialExpression = $I(^Ens.Rule.RuleDefinitionC) , Required ];
Rules are identified by Business Host class, ruledef name, and version. The version number for this Rule Definition.
Property methods: VersionDisplayToLogical(), VersionGet(), VersionGetStored(), VersionIsValid(), VersionLogicalToDisplay(), VersionNormalize(), VersionSet(), VersionXSDToLogical()

Methods

classmethod %Notify(pReason As %String, pRule As Ens.Rule.RuleDefinition) as %Status [ Language = objectscript ]
classmethod %OnDelete(oid As %ObjectIdentity) as %Status [ Language = objectscript ]
delete trigger to make sure associated routine in rule cache is deleted. call notification
method Compile() as %Status [ Language = objectscript ]
Compile this rule into executable code
method ContextClassGet() as %String [ Language = objectscript ]
classmethod ConvertStorageGlobal() as %Status [ Language = objectscript ]
This method converts the rule storage global to fix a bug in the storage subscript allocation. This method will be run automatically during the installation. Users do not need to run this method explicitly. Running this method over the already converted structure does no harm.
method EffectiveBeginDateTimeSet(value As %String) as %Status [ Language = objectscript ]
method EffectiveEndDateTimeSet(value As %String) as %Status [ Language = objectscript ]
method Evaluate(pContext As %RegisteredObject) as %Status [ Language = objectscript ]
Evaluate the rules associated with this RuleDefinition. This is overridden by subclasses.
classmethod EvaluateRules(pHostClass As %String, pRuleName As %String, pContext As %RegisteredObject, pActivityName As %String, Output pReturnValue As %String, Output pReason As %String, pLevel As %Integer) as %Status [ Language = objectscript ]
This method is Deprecated. It was only called by the tag. Now it is included only for back-compatibility of customer BP's that have not been recompiled yet. It assumes that pContext.%Process.%SessionId exists and if pName is a fullname of a rule, then pHostClass is ignored.
final classmethod EvaluateRulesEx(pRuleName As %String, pSessionId As %String = "", pContext As %RegisteredObject, pActivityName As %String = "", Output pReturnValue As %String, Output pReason As %String, pLevel As %Integer = 1, pLogLevel As %String = $$$eRuleLogTypeReturn) as %Status [ Language = objectscript ]
Open a stored RuleDefinition and evaluate it.
If pRuleName is a fullname of a rule, pHostClass is ignored.
If pSessionId not given, it assumes that pContext.%Process.%SessionId exists.
If rule is compilable, it uses the pre-compiled version in cache if present.
classmethod Exists(pHostClass As %String, pName As %String, pVersion As %Integer = "") as %Boolean [ Language = objectscript ]
Test of the given Rule Definition is stored in the database.
method GenerateCode(pCompiler As Compiler) as %Status [ Language = objectscript ]
Generate executable code for this Rule Override in subclass
classmethod GetLatestVersion(pHostClass As %String, pName As %String) as %Integer [ Language = objectscript ]
Return latest version number for a specific Rule Definition. Returns "" if this rule definition does not exist.
classmethod Load(pType As %String, pSource As %String, pVerbose As %Boolean = 1, Output pLastObj, pHostClass As %String = "", pName As %String = "") as %Status [ Language = objectscript ]
Load and save a RuleDefinition from an xml document. pType is the type of document: "file","string","stream"
pSource is the source document.
pVerbose, if true, indicates that messages should be written to the current device.
pHostClass and pName, if present, override the values in the document.
classmethod LoadFile(pFile As %String, pVerbose As %Boolean = 1, Output pLastObj) as %Status [ Language = objectscript ]
Load and save a RuleDefinition from an external file.
method NameSet(value As %String) as %Status [ Language = objectscript ]
classmethod Open(pHostClass As %String, pName As %String, pVersion As %Integer = "", Output pStatus As %Status) as RuleDefinition [ Language = objectscript ]
Open and return a saved RuleDefinition object. If pVersion is not provided, open the most recent version.
classmethod OpenEffective(pHostClass As %String, pName As %String, pVersion As %Integer = "", Output pStatus As %Status) as RuleDefinition [ Language = objectscript ]
Open and return a saved RuleDefinition object. If pVersion is not provided, open the most recent version. This method opens the rule that is currently effective, as defined by EffectiveBeginDateTime and EffectiveEndDateTime.
classmethod PurgeOldVersions(pHostClass As %String, pName As %String, pKeep As %Integer = 5) as %Status [ Language = objectscript ]
Delete older versions of this Rule Definition. pKeep is number of versions to keep.
classmethod PurgeRuleCache() as %Status [ Language = objectscript ]
Purge cached rules
classmethod RecompileAll() as %Status [ Language = objectscript ]
Recompile all rule definitions

Queries

query EnumerateRuleNames()
SQL Query:
SELECT DISTINCT Name FROM RuleDefinition ORDER BY Name
Provide a list of available Business Rule names.
query EnumerateRules()
SQL Query:
SELECT %ID, HostClass As Package, Name, EffectiveBeginDateTime, EffectiveEndDateTime, case when x__ClassName='~Ens.Rule.Router.RoutingRule~' then 'RoutingRule' else 'GeneralRule' end As RuleType, TimeModified, $Piece(x__classname,'~',2) As Type FROM Ens_Rule.RuleDefinition A WHERE A.Version=(SELECT MAX(Version) FROM Ens_Rule.RuleDefinition B WHERE B.HostClass=A.HostClass AND B.FullName=A.FullName) GROUP BY HostClass,FullName ORDER BY HostClass,FullName
Provide a list of available Business Rules.
query EnumerateRulesForProcess(pHostClass As %String = "")
SQL Query:
SELECT %ID, HostClass As Package, Name, EffectiveBeginDateTime, EffectiveEndDateTime, case when x__ClassName='~Ens.Rule.Router.RoutingRule~' then 'RoutingRule' else 'GeneralRule' end As RuleType, TimeModified, $Piece(x__classname,'~',2) As Type FROM Ens_Rule.RuleDefinition A WHERE A.Version=(SELECT MAX(Version) FROM Ens_Rule.RuleDefinition B WHERE B.HostClass=A.HostClass AND B.FullName=A.FullName) AND HostClass = :pHostClass GROUP BY HostClass,FullName ORDER BY HostClass,FullName
Provide a list of available Business Rules for a Business Process.
query EnumerateSameNameRules(pHost="", pName="")
SQL Query:
SELECT %ID, HostClass As Package, Name, EffectiveBeginDateTime, EffectiveEndDateTime, case when x__ClassName='~Ens.Rule.Router.RoutingRule~' then 'RoutingRule' else 'GeneralRule' end As RuleType, TimeModified, $Piece(x__classname,'~',2) As Type FROM RuleDefinition A WHERE A.Version=(SELECT MAX(Version) FROM Ens_Rule.RuleDefinition B WHERE B.HostClass=A.HostClass AND B.FullName=A.FullName) AND HostClass = :pHost AND Name = :pName GROUP BY HostClass,FullName ORDER BY HostClass,FullName
Provide a list of available Business Rules.

Indexes

index (ID on HostClass,FullName,Version) [IdKey, Type = key];
Index methods: IDCheck(), IDDelete(), IDExists(), IDOpen(), IDSQLCheckUnique(), IDSQLExists(), IDSQLFindPKeyByConstraint(), IDSQLFindRowIDByConstraint()

Inherited Members

Inherited Methods

Storage

Storage Model: Storage (Ens.Rule.RuleDefinition)

^Ens.Rule.RuleDefinitionD(ID)
=
%%CLASSNAME
Description
HostClass
Name
TimeModified
Version
HasErrors
RoutineName
ContextClass
ReportGroup
ReportName
ShortDescription
Production

Subclasses

Feedback