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.

images/download/attachments/177910371/image-2024-9-10_9-15-3-version-1-modificationdate-1725952502792-api-v2.png

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'
parameter

Return value

Notes

Map





irrelevant

List

List of all key values,
IF they correspond to the type 'list' at check-relevant list positions
– OTHERWISE: 'No value' ($null)

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTION images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg


List items relevant to the check are...

  • in the server context: only the first 5 entries,

  • in the client context: all entries.

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.

IMPORTANTNo 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.

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg selected

other type than List
or
no selection

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/error.svg deselected

other types

List of all key values,
IF these correspond to the Key type at check-relevant list positions
– OTHERWISE: 'No value' ($null)

no selection

List of all key values

none

Client object

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/error.svg deselected

String

List of all field names of the 'client object'

irrelevant

other type than String or
no selection

'No value' ($null)

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/check.svg selected

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.

  • The Save map in variable parameter is used to access the map as a whole via the bookings variable when it is no longer a reference object within the loop.

  • The Key type 'String' should only be selected if it is ensured that the map contains only key values that correspond to this type.

  • The Is collection of option must not be checked. Although a list of 'text keys' (String[], see image) is expected as return value, each individual key value is supposed to be a simple String (and not a list).

Within the loop, a Show alert (Popup) event action outputs the seat reservation information contained in the map as a notification of Type 'Info':

  • In the Title, this accesses the key value itself, whose String value is present in the loop as a reference object. The Object property value resolver (without field) supplies this reference object of the iteration completely.

  • The Message, on the other hand, is intended to identify the passenger for whom the seat reservation is made:

    • To do this, the entire map must first be accessed via the variable bookings using the Variable value resolver.

    • The concatenated Map item value resolver addresses the Key for the current seat within the map. To identify this, the Variable value resolver is used again, this time to read the reference object within the iteration, which the system automatically provides via the entity variable. Here the expected Item type ('string') is specified.

Runtime example: (Extract from a longer 'passenger list')

images/download/attachments/177910371/image2022-11-22_12-23-58-version-1-modificationdate-1725892531751-api-v2.png

images/download/attachments/177910371/image-2024-9-10_8-48-43-version-1-modificationdate-1725950923180-api-v2.png images/download/attachments/177910371/image-2024-9-10_8-50-5-version-1-modificationdate-1725951004621-api-v2.png

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.

  • Since the Value from SQL query value resolver also returns a 'list' if a query returns exactly one 'row' as a result, the List item value resolver is used here, which addresses the first list entry by Offset 0. As can be seen in the image, 'Object' is shown as the type for its return value, since no specific object type is defined for the 'List entries' from the SQL query. They are 'client objects' with variable structure.

  • A Show alert (Popup) event action is executed in the action part, which defines the static text 'Table fields' as the Title.

  • In the Message the All map keys value resolver returns all field names of the (client) object present as input value. Thereby, the selection of 'String' as Key type is required exceptionally.

  • The concatenated Replace text value resolver was added here only to replace spaces in the String image of the supplied list of field names with a line break.

images/download/attachments/177910371/image-2024-9-10_9-8-4-version-1-modificationdate-1725952083636-api-v2.png images/download/attachments/177910371/image-2024-9-10_9-8-55-version-1-modificationdate-1725952134864-api-v2.png

Runtime example:

images/download/attachments/177910371/image2022-11-22_14-47-49-version-1-modificationdate-1725892531746-api-v2.png

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.