All map keys
See also: Map item
Value resolver – Abstract
Purpose: Returns a list of all key values of a map or all field names of a 'client object' in the input value.
The 'All map keys' value resolver expects either a map or a 'client object' as input value and returns either a list of key values (map) or field names ('client object').
The Is collection of and Key type parameters are essentially used to declare the data type of the expected return value for the context of the configuration.
If the input object is a 'client object', however, the Key type String, which is not an alternative in this context, must be selected explicitly.
In the context of a map, there are no restrictions on the data type of key values. Lists or complex data objects can also be used as keys.
All key values of a map typically correspond to the same type. If this is known for the specific use case, then this type should be selected as the Key type.
However, the same map can easily contain key values of different types. In this case, the selection for the Key type should be omitted unless a parent class can be selected as the Key type which corresponds to all key values used in the map.
►IMPORTANT◄ Unlike many other value resolvers that offer a 'type' selection in conjunction with an Is collection of option, the 'All map keys' value resolver ignores the selection for the Key type when the Is collection of option is checked. Therefore, by combining the two parameters, it is not possible to specify that all key values must be of a certain type. Nevertheless, for the context of the configuration, the return value is declared accordingly, e.g. Long[][], i.e. a list of key values which in turn list Long values. An individual 'check' per key value – i.e. a check whether its entries correspond to the Key type – does not take place.
Configuration
The following table defines the characteristics of the value resolver per case distinction for all technically representable variants independent of their practical relevance:
Input value type |
'Is collection of' option |
'Key type' |
Return value |
Notes |
Map |
irrelevant |
List |
List of all key values, |
List items relevant to the check are...
The term 'entry' always refers to the list of key values of the map and not a list that is used as a key value within a map. The sequence of the key values of a map does not generally correspond to the sequence in which they were added to the map. ►IMPORTANT◄ No automatic type conversion takes place in the context of checking against a Key type. However, the Key type can be a parent class (e.g. 'Entity' or 'Interface > User') to which various other classes correspond. |
|
other type than List |
|||
|
other types |
List of all key values, |
||
no selection |
List of all key values |
none |
||
Client object |
|
String |
List of all field names of the 'client object' |
|
irrelevant |
other type than String or |
'No value' ($null) |
||
|
any type |
Examples
Simple use case: Loop over all data in a map
A map is used to represent the seat reservation for a scheduled flight. The map uses the alphanumeric identifiers of the seats as key values, which consists of the number of the seat row (1, 2, ...) and the code letter of the seat position within the row (A, B, C, ...). If there is a reservation for a seat, the corresponding key value is assigned a string that identifies the passenger in the usual manner <last name>/<first name[n]><address>. The assumption is that there is a key value in the map only for reserved seats.
In the context of event handling, all existing reservations for a specific flight are already available as data in this map. For control purposes, a notification is to be issued for each reservation.
Configuration:
In the header of the For each loop shown on the right, the All map keys value resolver is used to obtain a list of the seat numbers for all reserved seats.
Within the loop, a Show alert (Popup) event action outputs the seat reservation information contained in the map as a notification of Type 'Info':
Runtime example: (Extract from a longer 'passenger list')
|
|
Simple use case: List field names of a 'client object'
In the context of event handling, a SELECT statement is executed via a Value from SQL query value resolver for a database table in a database that can be accessed by the Lobster Data Platform / Orchestration server via an alias.
If the specific SELECT statement returns any result rows at all, the value resolver returns them as a list of 'client objects', each of which represents a data set. The fields of each of these client objects contain the data of the data set. The field names are derived from the projections in the SELECT statement.
In the example, we execute a PostgreSQL statement according to the schema SELECT * FROM <table_name> LIMIT 1 to read the first row of a database table completely without having to know its structure explicitly. Afterwards, a list of field names is output informatively via a notification.
Configuration:
The Execute with event action shown on the right defines the first 'result row' from the SQL statement defined in the Value from SQL query value resolver as the reference object for the output of the notification in the action part.
|
|
Runtime example:
In the example, the SQL statement was: SELECT * FROM dw_log LIMIT 1 ... with the 'Alias' hub (default for the database of the embedded data) ►NOTE◄ In the context of a loop, a list of field name/field value pairs could also be output, where the All map keys value resolver and the Map item value resolver must be used in tandem, similar to the previous example. |