Class Reference
IRIS for UNIX 2019.2
InterSystems: The power behind what matters   
Documentation  Search
  [ENSLIB] >  [Ens] >  [Rule] >  [RuleDefinition]
Private  Storage   

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

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.

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
3 20 23 4 1


Summary

Properties
%ErrorMsg %Reason %ReturnValue %StackLevel
CompileStatus ContextClass Description EffectiveBeginDateTime
EffectiveEndDateTime FullName HasErrors HostClass
Name Production ReportGroup ReportName
RoutineName ShortDescription TimeModified Version

Methods
%AddToSaveSet %AddToSyncSet %BMEBuilt %CheckConstraints
%CheckConstraintsForExtent %ClassIsLatestVersion %ClassName %ComposeOid
%ConstructClone %Delete %DeleteExtent %DeleteId
%DispatchClassMethod %DispatchGetModified %DispatchGetProperty %DispatchMethod
%DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty %Exists
%ExistsId %Extends %GUID %GUIDSet
%GetLock %GetParameter %GetSwizzleObject %Id
%InsertBatch %IsA %IsModified %IsNull
%KillExtent %KillExtentData %LoadFromMemory %LockExtent
%LockId %New %NormalizeObject %Notify
%ObjectIsNull %ObjectModified %Oid %OnBeforeAddToSync
%OnDelete %OnDetermineClass %Open %OpenId
%OriginalNamespace %PackageName %PhysicalAddress %PurgeIndices
%Reload %RemoveFromSaveSet %ResolveConcurrencyConflict %RollBack
%Save %SaveDirect %SaveIndices %SerializeObject
%SetModified %SortBegin %SortEnd %SyncObjectIn
%SyncTransport %UnlockExtent %UnlockId %ValidateIndices
%ValidateObject Compile ContextClassGet ConvertStorageGlobal
EffectiveBeginDateTimeSet EffectiveEndDateTimeSet Evaluate EvaluateRules
EvaluateRulesEx Exists GenerateCode GetLatestVersion
Load LoadFile NameSet Open
OpenEffective PurgeOldVersions PurgeRuleCache RecompileAll
XMLDTD XMLExport XMLExportToStream XMLExportToString
XMLNew XMLSchema XMLSchemaNamespace XMLSchemaType

Subclasses
Ens.Rule.Router.RoutingRule Ens.Rule.RuleSet

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 %Reason as %String(XMLPROJECTION="none") [ Transient ];
This property is used to pass back the Reason why this Rule is evaluated.
• property %ReturnValue as %String(XMLPROJECTION="none") [ Transient ];
This property is used to pass back the ReturnValue when this Rule is evaluated.
• property %StackLevel as %String(XMLPROJECTION="none") [ Transient ];
This property is used internally to prevent infinite recursion.
• property CompileStatus as %Status(XMLPROJECTION="none") [ InitialExpression = $$$OK,Transient ];
For compilable rules, this is the status of the compilation.
• property ContextClass as %String(MAXLEN=128,XMLNAME="context",XMLPROJECTION="attribute");
• property Description as %String(MAXLEN="",XMLNAME="description",XMLPROJECTION="element");
Optional description of this Rule Definition.
• 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 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 FullName as %String(MAXLEN=168) [ Required ];
The name and dates combination used in the IdKey
• property HasErrors as %Boolean(XMLPROJECTION="none");
Set true if this Rule Definition contains errors that will prevent it from running correctly.
• property HostClass as %String(MAXLEN=128,XMLNAME="host",XMLPROJECTION="attribute");
The class name of the Business Process this rule set is associated with.
• property Name as %String(COLLATION="EXACT",MAXLEN=128,XMLNAME="name",XMLPROJECTION="attribute") [ Required,Transient ];
The name of this Rule Definition.
• property Production as %String(MAXLEN=128,XMLNAME="production",XMLPROJECTION="attribute");
• property ReportGroup as %String(MAXLEN=2000,XMLNAME="reportGroup",XMLPROJECTION="element");
Value to be used to group rules for reporting
• property ReportName as %String(MAXLEN=2000,XMLNAME="reportName",XMLPROJECTION="element");
Display value for the rule report group
• 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 ShortDescription as %String(MAXLEN=2000,XMLNAME="shortDescription",XMLPROJECTION="element");
Optional short description of this Rule Definition.
• property TimeModified as Ens.DataType.UTC(XMLPROJECTION="none");
Time that this Rule Definition was last saved.
• 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.

Methods

• classmethod %Notify(pReason As %String, pRule As Ens.Rule.RuleDefinition) as %Status
• classmethod %OnDelete(oid As %ObjectIdentity) as %Status
delete trigger to make sure associated routine in rule cache is deleted. call notification
• method Compile() as %Status
Compile this rule into executable code
• method ContextClassGet() as %String
This is a Get accessor method for the ContextClass property.
• classmethod ConvertStorageGlobal() as %Status
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
This is a Set accessor method for the EffectiveBeginDateTime property.
• method EffectiveEndDateTimeSet(value As %String) as %Status
This is a Set accessor method for the EffectiveEndDateTime property.
• method Evaluate(pContext As %RegisteredObject) as %Status
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
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
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
Test of the given Rule Definition is stored in the database.
• method GenerateCode(pCompiler As Compiler) as %Status
Generate executable code for this Rule Override in subclass
• classmethod GetLatestVersion(pHostClass As %String, pName As %String) as %Integer
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
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
Load and save a RuleDefinition from an external file.
• method NameSet(value As %String) as %Status
This is a Set accessor method for the Name property.
• classmethod Open(pHostClass As %String, pName As %String, pVersion As %Integer = "", Output pStatus As %Status) as RuleDefinition
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
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
Delete older versions of this Rule Definition. pKeep is number of versions to keep.
• classmethod PurgeRuleCache() as %Status
Purge cached rules
• classmethod RecompileAll() as %Status
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.

Indices

•index (ID on HostClass,FullName,Version) [IdKey];


Copyright (c) 2019 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.