Filtering in QPR ProcessAnalyzer Queries

From QPR ProcessAnalyzer Wiki
Revision as of 08:10, 13 October 2018 by Ollvihe (talk | contribs)
Jump to navigation Jump to search

QPR ProcessAnalyzer analyses can be filtered enabling to include only defined data to the analysis calculation. QPR ProcessAnalyzer analysis requests have parameter Filter which is used to pass a JSON formatted filter definition for the analysis. This filter definition is combined with the stored filter object, which is provided as the FilterId parameter. Influence analyses have also parameter Comparison which divides the analyzed data into two parts to compare them in the analysis. Comparison parameter has the same JSON syntax as in the Filter parameter.

When performing analyses, different filter specifications are applied in the following order (from first to last):

  1. Filter rules defined by a stored filter (the FilterId parameter) (this is mandatory as it also defines the model to use)
  2. Filter rules defined in the Filter parameter
  3. Other filtering related parameters, such as SelectedActivities or SelectedTransitions

Filter and Comparison parameters are only supported in the In-Memory core.

Filter parameter JSON syntax

The filter definition has syntax demonstrated by the following example:

{
  Items: [
    {
      Type: "IncludeCases",
      Items: [
        {
          Type: "EventType",
          Values: ["Sales Order Created", "Payment Received"]
        },
        {
          Type: "CaseAttributeValue",
          Attribute: "Region",
          Values: ["Dallas", "Austin"]
        }
      ]
    },
    {
      Type: "ExcludeCases",
      Items: [
        {
          Type: "Case",
          Values: ["Case1", "Case2", "Case3"]
        },
        {
          Type: "flow",
          Values: [
            {
              From: "Shipment",
              To: "Invoice"
            }
          ]
        }
      ]
    }
  ]
}

The outmost JSON object has a property Items which is an array of object with following properties:

  • Type: Specifies the type of the filtering operation with following options:
    • IncludeCases: Include only cases. All filter rule types can be used with this option.
    • ExcludeCases: Exclude cases. All filter rule types can be used with this option.
    • IncludeEventTypes: Include only event types. Only Event type and Expression filter rule types can be used with this option.
    • ExcludeEventTypes: Exclude event types. Only Event type and Expression filter rule types can be used with this option.
    • IncludeCaseAttributes: Include only given case attributes.
    • ExcludeCaseAttributes: Exclude given case attributes.
    • IncludeEventAttributes: Include only given event attributes.
    • ExcludeEventAttributes: Exclude given event attributes.
    • Union: Select objects that belong to union of all the given child selections.
    • Intersection: Select objects that belong to intersection of all the given child selections.
    • Negate: Negate the filtered objects of given type.
    • ClearFilters: Clear filter for given type of objects.
  • Items: Specifies selected model objects. It is used when the Type is IncludeCases, ExcludeCases, IncludeEventTypes or ExcludeEventTypes. The following chapter define all possibilities that can be used here.
  • ChildItems: Specifies the selections to be combined using a set operation. Applicable only when the Type is Union or Intersection.
  • Attributes: Specifies an array of attribute names. Applicable when the Type is IncludeCaseAttributes, ExcludeCaseAttributes, IncludeEventAttributes or IncludeEventAttributes.
  • TargetObjectType: Specifies the type of objects the operation is targeted to. Supported values are EventType and Case. It is applicable when the Type is ClearFilters or Negate.

The following chapters list all filter rule types that can be used in the above defined Items property.

Filter rule types

Expression

Filter rule type ExpressionValue selects cases or event types that match the given expression. It has property Configuration which contains the following properties:

  • Root: Specifies the root expression returning objects to be used as context for evaluating the expressions. If not defined, all the cases in the current event log are used as root objects. Allowed types for the root expression are Case, Event, EventType, Variation, Flow, FlowOccurrence.
  • Expressions: An array of expressions specifying the actual filter. All the root objects for which all (AND logic) the expressions return true will be converted into corresponding cases or event types. If not defined, all the objects returned from the Root expression will be selected. Properties:
    • Expression: Expression that is evaluated using the context of the root object.
    • Values: An array of values to match to the expression result.
  • Variables: An object specifying key-value pairs, where each key-value pair generates one variable into the expression language where key is the name of the variable and value is its value. The values will be converted to strings.

Examples:

{
  Type: "ExpressionValue",
  Configuration: {
    Root: "Cases",
    Expressions: [
      {
        Expression: "Name",
        Values: ["case1", "case2"]
      }
    ]
  }
}

Select cases named "case1" and "case2".

{
  Type: "ExpressionValue",
  Configuration: {
    Root: "Cases.Where(Duration.TotalDays > 1)"
  }
}
Selects cases whose duration is longer than one day.

{
  Type: "ExpressionValue",
  Configuration: {
    Variables: {
      bpmnXml: "<XML BPMN model>"
    },
    Root: "Let(\"myConformanceModel\", ConformanceModelFromXml(bpmnXml));Cases.Where(IsConformant(myConformanceModel));"
  }
}

Returns all cases that are conformant with the specified BPNM model.

Case names

Filter rule type Case selects individual cases. It supports property Values which is an array of case names (strings).

Example:

{
  Type: "Case",
  Values: ["case1", "case2", "case3"]
}

Same example in the whole JSON configuration:

{
  Items: [
    {
      Type: "IncludeCases",
      Items: [
        {
          Type: "Case",
          Values: ["case1", "case2", "case3"]
        }
      ]
    }
  ]
}

Case attribute values

Filter rule type CaseAttributeValue selects cases having given value in given case attribute. Properties:

  • Attribute: Case attribute name.
  • Values: Array of case attribute values in string format.

Example:

{
  Type: "CaseAttributeValue",
  Attribute: "Region",
  Values: ["Dallas", "Austin", "New York"]
}

Event attribute values

Filter rule type EventAttributeValue selects cases having events with given event attribute values. Properties:

  • Attribute: Name of the event attribute.
  • Values: An array of event attribute values in string format.

Example:

{
  Type: "EventAttributeValue",
  Attribute: "Organization",
  Values: ["Organization 1", "Organization 2"]
}

Event type

Filter rule type EventType selects cases containing selected event types (Type=IncludeCases/ExcludeCases) or selects event types (Type=IncludeEventTypes/ExcludeEventTypes). It has property Values which is an array of event type names.

Example:

{
  Type: "EventType",
  Values: ["Sales Order Created", "Payment Received", "Delivery Sent"]
}

Variation

Filter rule type Variation selects cases belonging to selected variations. It has the property Paths which is an array of variations. Each variation is a string array of event type names in the variation.

Example:

{
  Type: "Variation",
  Paths: [
    ["Activity 1", "Activity 2", "Activity 3"],
    ["Activity 3"],
    ["Activity 2", "Activity 4"]
  ]
}

Flow

Filter rule type Flow selects cases having the defined flows. It has property Flows which selects an array of objects with following properties:

  • From: Event type name which starts the flow.
  • To: Event type name into which the flow goes.
  • Occurrence: Zero-based occurrence index of the selected flow within its case. If not specified, represents all occurrences.

Example:

{
  Type: "Flow",
  Flows: [ {From: "EventType1", To: "EventType2", "Occurrence": 1} ]
}

Legacy Filter Rules in QPR ProcessAnalyzer Queries

Examples

{
  Items: [
    {
      Type: "Union",
      ChildItems: [
        {
          Items: [
            {
              Type: "IncludeCases",
              Items: [
                {
                  Type: "Case",
                  Values: ["c1", "c3"]
                }
              ]
            }
          ]
        },
        {
          Items: [
            {
              Type: "IncludeCases",
              Items: [
                {
                  Type: "Case",
                  Values: ["c1"]
                }
              ]
            },
            {
              Type: "Negate",
              TargetObjectType: "Case"
            }
          ]
        }
      ]
    }
  ]
}