Subjects
The shared context in a CCOW session is in essence a key-value store where the keys are termed subjects and usually have a specific format indicating the origin, type etc. of the information stored for the key. The concept of a subject is re-used in Cuesta as a key for identifying both flows to execute and extracting structured information from the UI of an application.
Subjects are defined in terms of a name, a key (the actual subject) and a regular expression. The regular expression is used to determine whether the subject is present in a string extracted from e.g. the UI of an application.
Creating subjects
Subjects are created by entering the name and key (use something suitably unique here, preferably a proper CCOW subject) and a regular expression.
Regular expressions for subjects
When you specify a regular expression and you have a flow that uses the subject as a type for one of its inputs then Manatee will try to extract information from the location of your click when you use the right-click menu to show a list of flows to run. A flow will only be shown in this list if the subject regular expression can match the context (the text surrounding it) of the click location.
Regular expression requirements
The regular expression should contain at least one group. The group is used to extract the actual value for the subject. A named group (with name value) can designate a single group if used. If the value named group is not present then all named groups are used and the extracted information is made available to a flow as a stringified JSON object with group names as key and group values as values.
A few examples may help clarify the use of subjects:
Example 1: The regular expression (?<value>\d{10})
will match any 10-digit number and extract it as a string value for the subject. You can access the value in a flow as Inputs[<the-name-you-have-given-your-input-variable>]
.
Example 2: The regular expression (?<id>\d{10})-(?<name>\w+)
will match a 10-digit number followed by a dash and then a word. The value for the subject will be a JSON object with the keys id
and name
and the values extracted from the regular expression. You can access the value in a flow:
// We need to parse the string as JSON
var subjectInput = JSON.parse(Inputs[<the-name-you-have-given-your-input-variable>]);
var id = subjectInput.id;
var name = subjectInput.name;