Value Evaluation Handler

This handler evaluates whether a value is valid based on a pattern or a list of patterns.

Type: value_evaluation_handler

Attributes

Here's an explanation of the available attributes:

  • to_evaluate: The input needs to match the defined pattern /s. If it matches, the input is valid.
  • code_word_evaluation: Speech input will only be checked if this attribute is set. It can be an empty string. If a speech input command starts with the given keyword, the rest of the command will be used for evaluation.
    • Required: False
    • Default value: None

Events

The handler emits the following events:

  • VALID: If the provided input matches the pattern.
  • ALREADY_VALID: If the provided input matches a pattern that has already been successfully validated.
  • ALL_VALID: If all elements of the to_evaluate collection have been validated successfully.
  • INVALID: If the provided input does not match any pattern.

The payload structure is as follows:

   {
          "command": "VALID",    
          "device":
          {
             "modality": "value-evaluation",
             "name": "value-evaluation",
             "source": "value-evaluation",
             "descriptor": "value-evaluation"
          },
          "payload":
          {
             "code": "i am legend"
          }
    }
   {
          "command": "INVALID",    
          "device":
          {
             "modality": "value-evaluation",
             "name": "value-evaluation",
             "source": "value-evaluation",
             "descriptor": "value-evaluation"
          },
          "payload":
          {
          }
    }

Example

<context>
    <param name="validations" type="string"></param>
</context>

<handlers>
    <value_evaluation_handler>
        <code_word_extraction>validate</code_word_extraction>
        <list name="to_evaluate" listType="UNNAMED">
            <elem>machine .+</elem>
            <elem>station .+</elem>
        </list>
    </value_evaluation_handler>
</handlers>

<states>
    <onevent>
        <rule id="is_valid">
            <expression>
                <![CDATA[ #{event(value-evaluation):command} == 'VALID' ]]>
            </expression>
            <actions>
                <setvar id="add_validation">
                    <context_of>step</context_of>
                    <context_update>
                        <param name="validations" type="string">#{validations} #{event:payload.code}</param>
                    </context_update>
                </setvar>
            </actions>
        </rule>

        <rule id="all_valid">
            <expression>
                <![CDATA[ #{event(value-evaluation):command} == 'ALL_VALID' ]]>
            </expression>
            <actions>
                <finish_workflow id="exit"/>
            </actions>
        </rule>

        <rule id="invalid_input">
            <expression>
                <![CDATA[ #{event(value-evaluation):command} == 'INVALID' ]]>
            </expression>
            <actions>
                <ui_notification id="invalid_value" type="ERROR" duration="SHORT" show_immediately="true">
                    <message>"Not a valid value!</message>
                </ui_notification>
            </actions>
        </rule>
    </onevent>
</states>

Value Extractor Handler

This handler is used to implement barcode scanning via dedicated scanning hardware. It extracts scanner or speech input based on a list of patterns and checks if at least one of these patterns is valid.

Type: value_extractor_handler

Attributes

Here's an explanation of the available attribute:

  • pattern: The input needs to match the defined pattern. If it matches, the defined groups can be extracted.
    • Required: Yes

Elements

The different elements are as follows:

  • grp: Stores the information in regard to how each item in the group should be extracted as a list of parameters.
    • Required: No
    • Default Value: Empty list
  • allowed_values: Allows to set a list of values to be checked after the pattern has been evaluated as correct. This cannot be used with regular expresssions containing or, because each group has to contain an allowed value or scan.
    • Required: No
    • Default Value: None
  • code_word_extraction: Speech input will only be checked if this attribute is set. It can be an empty string. If a speech input command starts with the given key word, the rest of the command will be used to extract the necessary information. Note that speech recognition via regular expressions is not possible. All potential values need to be added to the syntax via the corresponding action.
    • Required: No
    • Default Value: None
  • extract_to_workflow: By default, the resulting groups will be stored in the scope of the step. Setting this attribute to true will save store the variables in scopte of the workflow instead.
    • Required: No
    • Default Value: None
  • input: Allows you to pass an initial input to be checked on resume.
    • Required: No
    • Default Value: None

Events

The handler emits the following events:

  • VALID_EXTRACTION or INVALID_EXTRACTION: The handler will check any input event with the BARCODE and SPEECH modalities (if the code_word_extraction parameter is provided) and emit an event with the VALID_EXTRACTION or INVALID_EXTRACTION commands.
  • INVALID_PATTERN: If the provided pattern contains a syntax error, the handler will emit an event with the INVALID_PATTERN command .

The payload structure is as follows:

   {
          "command": "VALID_EXTRACTION",    
          "device":
          {
             "modality": "value_extractor",
             "name": "value_extractor",
             "source": "value_extractor",
             "descriptor": "value_extractor"
          },
          "payload":
          {
             "technology": "SCAN", // [SCAN, VOICE]
             "code": "123456789",
             "speech_command": "null"
          }
    }
   {
          "command": "INVALID_PATTERN",    
          "device":
          {
             "modality": "value_extractor",
             "name": "value_extractor",
             "source": "value_extractor",
             "descriptor": "value_extractor"
          },
          "payload":
          {
             "technology": "pattern",
             "code": "(.()*",
             "speech_command": "null"
          }
    }

Example

<value_extractor_handler pattern="(.+)_(.+)" code_word_extraction="USER">
    <grp>
        <param name="grp_1" type="string">prefix</param>
        <param name="grp_2" type="string">suffix</param>
    </grp>
</value_extractor_handler>

A code such as "test_user" will be successfully extracted. Afterwards, #{prefix} will contain "test" and #{suffix} will contain "user".

Extended example with the processing of emitted events

<context>
    <list name="user_name_list" listType="UNNAMED">
        <elem>barry</elem>
        <elem>white</elem>
    </list>
</context>

<handlers>
    <value_extractor_handler pattern="(.+)_(.+)">
        <code_word_extraction></code_word_extraction>
        <input>admin_barry</input>
        <extract_to_workflow>true</extract_to_workflow>
        <grp>
            <param name="grp_1" type="string">user_role</param>
            <param name="grp_2" type="string">user_name</param>
        </grp>
        <allowed_values>
            <list name="grp_1" listType="UNNAMED">
                <elem>admin</elem>
                <elem>supervisor</elem>
            </list>
            <param name="grp_2" type="object">#{user_name_list}</param>
        </allowed_values>
    </value_extractor_handler>
</handlers>

<states>
    <onevent>
        <rule id="set_user">
            <expression><![CDATA[ #{event(value_extractor):command} == 'VALID_EXTRACTION' && exists(#{user_role}) && exists(#{user_name}) ]]></expression>
            <actions>
                <setvar id="set_user">
                    <context_of>workflow</context_of>
                    <context_update>
                        <param name="userrole" type="string">#{user_role}</param>
                        <param name="username" type="string">#{user_name}</param>
                    </context_update>
                </setvar>
            </actions>
        </rule>

        <rule id="invalid_input">
            <expression><![CDATA[ #{event(value_extractor):command} == 'INVALID_EXTRACTION' && #{event:payload.technology} == 'SCAN' ]]></expression>    
            <actions>
                <ui_notification id="invalid_user" type="ERROR" duration="SHORT" show_immediately="true">
                   <message>"#{event:payload.code}" is not a valid user!</message>
                </ui_notification>
            </actions>
        </rule>
    </onevent>
</states>