Fuego.Papi : InstanceFilter

An instance of the InstanceFilter component defines a set of conditions to search for process instances.

To create an instance of InstanceFilter, you need to pass an instance of ProcessService (or ClientProcessService) to the InstanceFilter.create() method.

You define the filter with two sets of conditions:
  • Logical expressions: A set of "variable OPERATOR value" conditions. The filter excludes process instances for which the expressions do not evaluate to true.
  • Scope: Restricts the filter further depending on the status of the process instances (see StatusScope) and on which Participants have access to the process instances (see ParticipantScope).

To search for process instances matching the criteria defined by an InstanceFilter object, use method getInstancesByFilter() of ProcessService (and ClientProcessService).

You can also obtain instances of InstanceFilter using ProcessService's getFilterFor(viewId) method, which returns an InstanceFilter object representing the conditions defined by a particular View.

Example 1

The following example uses InstanceFilter to retrieve those process instances that are in-process (that is, not aborted nor completed) and are assigned to a participant "test":

do
  connectTo ProcessService 
    using url = Fuego.Server.directoryURL,
    user = "test", password = "password"  

  create InstanceFilter 
    using processService = ProcessService

  InstanceFilter.searchScope = SearchScope(
		     participantScope : ParticipantScope.PARTICIPANT ,
		     statusScope : StatusScope.ONLY_INPROCESS) 

  instances = getInstancesByFilter(ProcessService,
                                   filter : InstanceFilter)  

  return instances
on exit
  disconnectFrom ProcessService
end

Example 2

The following example uses InstanceFilter to retrieve those process instances that are in-process (that is, not aborted nor completed) and have a deadline time greater than now:

do
  connectTo ClientProcessService 

  create InstanceFilter 
    using processService = ClientProcessService 

  InstanceFilter.searchScope = SearchScope(
                     participantScope : ParticipantScope.ALL ,
                     statusScope : StatusScope.ONLY_INPROCESS)  

  addAttributeTo InstanceFilter 
    using variable = VarDefinition.DEADLINE_ID, 
        comparator = Comparison.GREATER_THAN, 
             value = 'now' // shorthand for "Time.now()"

  instances = getInstancesByFilter(ClientProcessService,
                                   filter : InstanceFilter)

  return instances
on exit
  disconnectFrom ClientProcessService
end
Related reference
Fuego.Papi : ProcessService
Fuego.Papi : ClientProcessService
Fuego.Papi : VarDefinition
Fuego.Papi : SearchScope
Fuego.Papi : ParticipantScope
Fuego.Papi : StatusScope