A RecognitionPointsRuleType whose points calculation is implemented as a JS function, allowing apps to define custom points rules without adding Java code. Configured with an id, a display title, a set of ExtraField parameters shown to the admin when configuring the rule, and the name of a JS function to invoke. init(KademiScriptEngine) must be called before calcPoints is used, as the calculation is delegated to the named function on the given script engine. Written in configuration as a "recog-points-rule" element.

Group: Recognition

Implements: RecognitionPointsRuleType


Properties

PropertyReturnsDescription
fieldsList<ExtraField>The extra fields shown to an admin when configuring this rule, used to collect the parameters passed to the process function.
idStringUnique identifier for this rule type, used to select it when configuring a recognition award.
processFnStringThe name of the JS function invoked by calcPoints to calculate points.
titleStringDisplay title for this rule type, shown to an admin choosing a points rule.

Inherited from RecognitionPointsRuleType

Methods

buildDescription(Map<String,String> ruleParams)

Returns: String

Builds a short human-readable summary of the given configuration, formatted as "key=value; " pairs for each non-blank parameter, or "No configuration" if there are no parameters set. Used to show an admin what a configured rule does without opening its edit form.

ParameterDescription
ruleParamsthe configured parameter values for this rule type, may be null or empty

parseParamStringToMap(BaseRecognition recog)

Returns: Map<String,String>

Convenience method that decodes the given recognition's stored pointsRuleConfig string into the parameter map expected by calcPoints and buildDescription.

ParameterDescription
recogthe recognition whose points rule configuration is decoded

Methods

init(KademiScriptEngine engine)

Returns: void

Sets the script engine used to evaluate the configured process function, so that later calls to calcPoints can invoke it.

ParameterDescription
enginethe script engine that hosts the process function

getId()

Returns: String

Unique identifier for this rule type, used to select it when configuring a recognition award.

getFields()

Returns: List<ExtraField>

The extra fields shown to an admin when configuring this rule, used to collect the parameters passed to the process function.

getProcessFn()

Returns: String

The name of the JS function invoked by calcPoints to calculate points.

getTitle()

Returns: String

Display title for this rule type, shown to an admin choosing a points rule.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.