Get collection of resources Version 8 (Java)

Action group: Orchestrator  Subgroup: Resource queues


Description

The action searches for resources according to the specified conditions and returns all matching resources. If no matching resources are found, the action waits for them to appear for a specified timeout.

  1. The action sends a request to find resources that have parameters that match those specified in the action.
  2. The resource will be searched according to the following rules:

    • Eligible resources are those that satisfy all the specified search parameters. But it also takes into account the number of resources to be found:
      • If "Less or equal" is selected in the "Quantity rule", the action will return the result as soon as it finds at least one matching resource, i.e. before the timeout time expires. If there are n or more resources in the queue at once, the action will return strictly n resources, where n is the value from the "Number of resources" parameter. If there are less than n resources in the queue, the action will return all available resources at once (before the timeout expires).
      • If "Exact number" is selected in the "Quantity rule", the action will return a result only when there are n or more resources in the queue that match the search conditions. In this case, the action will return strictly n resources, even if there are more resources in the queue. 
      • If "All" is selected in "Quantity rule", the action will return the result immediately if it finds at least one matching resource, i.e. before the timeout expires. The value from "Number of resources" will be ignored, i.e. the action will return all matching resources it finds in the queue.
    • If "Deny writing" = true, the search ignores resources that are already blocked for writing. If = false, such resources will also be added to the list of suitable resources. At the same time, the same rule does not apply to reading denials, because if a resource has a reading denial, it will not be visible in any case when searching by the condition.
    • If some specific sorting is specified, a list of all matching resources will be collected first, then the resources will be sorted by the specified parameter; the resulting collection will have the resources written in the same order as the sorted list.
    • If there are no suitable resources in the queue, the action waits for at least one suitable resource to appear in the queue.

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
Resource queueThe name of the resource queue in which to look for resources.Robin.String
Yes
TagsA collection of strings where each element is a separate resource tag. The search will be among those resources that have at least one of the listed tags.Robin.Collection
No
StatusThe status the resources must have.Robin.String
Yes
Min. priorityThe lowest priority value that the resource can have. Together with the value from the «Max. priority» is the search range by priority.Robin.Numeric
No
Max. priorityThe highest priority value that the resource can have. Together with the value from the «Min. priority» is the search range by priority.Robin.Numeric
No
Min. date of creationThe smallest value of the creation date of the resource. Together with the value from the «Max. creation date» is the search range for creation date.Robin.DateTime
No
Max. date of creationThe largest value of the creation date of the resource. Together with the value from the «Min. creation date» is the search range for creation date.Robin.DateTime
No
Min. date of updateThe smallest value of the last update date of the resource. Together with the value from the «Max. date of creation» is the range of the search by the date of the update.Robin.DateTime
No
Max. date of updateThe largest value of the last update date of the resource. Together with the value from the «Min. date of creation» is the range of the search by the date of the update.Robin.DateTime
No
Sorting typeThe sort type of the found resources. The action sorts the found resources before writing them to the resulting collection.Robin.String
No
Deny readingIf the value is «true», the action will lock the found resources for reading and hide them in the queue. Other robots will not be able to find hidden resources when searching by condition.Robin.BooleantrueNo
Deny writingIf the value is «true», the action will lock the found resources for writing to other robots.Robin.BooleantrueNo
Finish processingIf the value is «true», the action will get the value and parameters of the resources and then change their status to «Processed». With this status, resources will be hidden for robots, even when searching by their ID.Robin.BooleantrueNo
Number of resourcesThe amount of resources the action should return. Taken into account together with the parameter «Quantity rule».Robin.Numeric
Yes
Quantity ruleA rule that specifies how to interpret the value from the field «Number of resources» . If «All» is selected, the action ignores the specified number of resources and returns all matching resources.Robin.String
Yes
Timeout, msWaiting time for the required number of resources to appear in the queue, matching the search conditions. If «-1» is specified, the action will wait indefinitely. Specified in milliseconds.Robin.Numeric
No
Results
ResultA collection in which each element is a dictionary containing the data of one of the found resources: value («Value» key), identifier («Id» key), tags («Tags» key), status («Status» key), priority («Priority» key), creation date ( «CreationDate» key) and update date («UpdateDate» key).Robin.Collection

Special conditions of use

  1. The action can block a resource for reading or writing if the corresponding input parameters are activated. When a resource is locked, this robot instance becomes the owner of the set lock type. Being the owner of a lock means that only the same robot instance can release such a lock. And 2 different launches of the same robot (2 different instances) are considered as different owners.
  2. The user has more authority than robots, so they can remove/set the lock regardless of who owns it.

Example of use

Task

There is a process where there is a queue with resources, it is necessary to get no more than 5 resources with the status "New", and also to get the date of creation of the 2nd count resource from the collection. 

Solution

Use the "Get collection of resources", "Get value by index", "Get value", "Message in log" actions.

Implementation

  1. Move the "Get collection of resources" action to the workspace and set its parameters:
    1. Specify the resource queue name where to look for the resources in the "Resource queue" field.
    2. Specify the status that all resources should have in the "Status" field. In this case, it is "New".
    3. Specify the number of resources the action is to return in the "Number of resources" field. In this case, it is 5.
    4. Specify the desired rule indicating how to correctly interpret the value from the "Number of Resources" field in the "Quantity rule" field. In this case, select "Less or equal".

  2. Move the "Get value by index" action to the workspace and set its parameters.
    1. Specify the result of the action "Get collection of resources" in the "Collection" field.
    2. Specify the order number of the position from which you want to extract values in the "Index" field. In this case, it is 1. (According to the task we need to pull out the 2nd resource, but since the count in the collection starts from 0, we specify the value 1 accordingly)

  3. Move the "Get value" action to the workspace and set its parameters.
    1. Specify the "Get value by index" action result in the "Dictionary" field. The result of this action in this case will be a dictionary with the data of the found resource.
    2. Specify the key that is used to search the dictionary in the "Key" field. In this case, the key will be the value "CreationDate" because the task requires that the creation date of the resource be taken away.
  4. Move the "Message in log" action to the workspace and set its parameters.
    1. Specify the text to be displayed in the message log file in the "Message" field. In this case, specify the "Get value" action result. This is the creation date of the resource.
  5. Click "Start" in the top panel to start the robot.
    • If you want to get a collection of resources with specific tags, you need to fill in the "Tags" field, specifying the names of the resource tags.
    • If you want to get a collection of resources with certain priorities, you should fill in the "Min. priority" and "Max. priority" fields.
    • If you want to get a collection of resources grouped by creation date (for example, from 12.08.2022 4:00 to 14.08.2022 4:00), you should specify the dates and times in the corresponding fields: "Min. date of creation", "Max. date of creation". 
    • If you want to get a collection of resources grouped by update date (for example, 15.08.2022 5:00 to 17.08.2022 5:00) you should specify the dates and times in the corresponding fields: "Min. date of update", "Max. date of update".
    • If you want to sort the found resources, you need to select the sorting type from the dropdown list of the "Sorting type" parameter. 
    • If you want to finish processing, you should set the "Finish processing" checkbox = true. 
    • If it is necessary to block resources for writing and/or reading, you should check the checkbox in the fields: "Deny reading"/"Deny writing". 

      Queue resources can be denied by the robot (reading or writing).

      • only reading - when resources are blocked for reading, by default they are also hidden in the queue (hidden for search), i.e. they cannot be retrieved by actions with search by condition; by action of retrieving by ID the resources will become visible, but the robot will freeze on the resource waiting for the blocking to be removed (depending on the timeout set).
      • writing only - when resources are blocked for writing (by a robot or a user), another robot cannot change their values.
      • both reading and writing - two conditions described above are simultaneously met, i.e., the robot can neither modify the resources nor read them.

Result

The program robot completed successfully.

A collection was retrieved, from which the 2nd resource with the status "New" was selected, and the creation date of this resource was logged.

  • Нет меток