Page History
Panel | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||
EACHThis function determines Determines whether all instances of a specified entity meet a certain criteria. Syntax
Inputs
Return type
Examples Suppose the following data model.
|
...
bgColor | white |
---|
ALL
Use this function to create a collection of all instances of a specified entity.
Syntax
Code Block |
---|
ALL entity |
...
- entity - Entity of which to collect all its instances.
Return type
- collection of entity instances
Examples
Suppose the following data model. The Parent
and Child
entities both have Person
as base entity.
...
Back to top |
---|
...
bgColor | white |
---|
COLLECT FROM [WHERE]
Use this function to create a collection of entity or attribute instances (meeting certain criteria).
Syntax
Code Block |
---|
COLLECT entity | attribute FROM collection [ WHERE ( expression ) ] |
...
- entity or attribute - Entity or attribute to collect.
- collection - A collection of entity instances.
- expression - Boolean expression that represents the criterion the instance has to meet.
Return type
- collection of entity instances
- collection of attribute values
UI Text Box | ||
---|---|---|
| ||
A collections contains no duplicates. Intermediary |
Examples
Suppose the following model. Entity Teacher
has a multivalued relation with entity Child
via the relation Teacher.teaches_Children
.
...
COLLECT Child.name FROM ALL Child
WHERE ( Child.hobbies = "Reading" )
...
Back to top |
---|
...
bgColor | white |
---|
COLLECT FROM NAMED [WHERE]
Use this version of the COLLECT FROM [WHERE] function for complex nested selections in which it is necessary to use an alias.
Syntax
Code Block |
---|
COLLECT entity | attribute FROM collection NAMED alias [ WHERE ( expression ) ] |
...
- entity or attribute - Entity or attribute to collect. This should contain the alias, e.g. alias.Name.
- collection - A collection of entity instances.
- alias - A name for the collection.
- expression - Boolean expression that represents the criterion the instance has to meet.
Return type
- collection of entity instances
- collection of attribute values
UI Text Box | ||
---|---|---|
| ||
A collections contains no duplicates. Intermediary |
Examples
Suppose the following model with only instances of entity Person
. Person.hasChildren
is a relation from Person to Person.
...
To retrieve all the parent names, we use this expression:
Code Block |
---|
COLLECT Parent.name
FROM
COLLECT Person
FROM ALL Person
WHERE ( Person.hasChildren != ? ) NAMED Parent |
This expression results in “Rick”, “Julia” and “Joan”.
To retrieve all children names, we use this expression:
Code Block |
---|
COLLECT Child
FROM (
COLLECT Person.hasChildren
FROM ALL Person
WHERE ( Person.hasChildren != ? ) ) NAMED Child |
This expression results in a collection of three instances of Person
(i.e Person_1
, Person_3
and Person_5
, with names Kim, Bob and Sam).
To retrieve all children younger than 15, we use this expression:
Code Block |
---|
COLLECT Child
FROM (
COLLECT Person.hasChildren
FROM ALL Person
WHERE ( Person.hasChildren != ? ) ) NAMED Child
WHERE ( Child.Age < 15 ) |
This expression results in a collection of two instances of Person
(i.e Person_3
and Person_5
, with names Bob and Sam).
To retrieve the children’s names with a parent older than 40 years:
Code Block |
---|
COLLECT Child.Name
FROM (
COLLECT Person.hasChildren
FROM ALL Person
WHERE ( Person.hasChildren != ? AND Person.Age > 40 ) ) NAMED Child |
This expression results in a collection with only the name “Kim”.
You can make it as complex as you like, for example:
Code Block |
---|
COLLECT Child.Name
FROM (
COLLECT Parent.hasChildren
FROM (
COLLECT Person
FROM ALL Person
WHERE ( Person.hasChildren != ? ) ) NAMED Parent
WHERE ( Parent.Age > 40 )
) NAMED Child
WHERE ( Child.Age < 18 ) |
This expression results also in a collection with only the name “Kim”.
UI Text Box | ||
---|---|---|
| ||
In some occasions, a local variable could be a good alternative for using an alias. E.g. if you want a collection of all persons except the person that is currently active, this would be simple and transparent:
|
Back to top |
---|
...
bgColor | white |
---|
UNPACK
Use this function to extract the value from a single valued collection or list. It is the inverse of the LIST function.
Syntax
Code Block |
---|
UNPACK ( collection/list ) |
...
- collection/list - A collection or list of one entity or attribute instance.
Return type
- entity instance
- attribute value of any type
Examples
Suppose the following data model.
...
UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) )
= “Ron”- In case a second entry "Ron","490" exists, the expression
UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) )
will fail, because theUNPACK
cannot resolve a list with two elements. To solve this theUNIQUE
function has to be used:UNPACK ( UNIQUE ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MIN ( COLLECT Person.SequenceNumber FROM ALL Person ) ) ) )
= "Ron". UNPACK ( COLLECT Person.name FROM ALL Person WHERE ( Person.SequenceNumber = MAX ( COLLECT Person.SequenceNumber FROM ALL Person ) ) )
= “Jenny”
Back to top |
---|
...
bgColor | white |
---|
LIST
Use this function to create a list based on a value. It is the inverse of the UNPACK function.
Syntax
Code Block |
---|
LIST ( attribute/collection ) |
...
- attribute - An attribute of any data type.
- collection/list - A collection or list of values.
Return type
- a multivalued list with entries of any type
Examples
...
Suppose the following data model.
...
LIST ( COLLECT Person.name FROM ALL Person ) = [ "Bob" , "Jane" , "Mary" , "Rick" , "Ron" , "Jenny" ]
- In this example the
LIST
function adds no value, as the result of theCOLLECT
is already a list.
- In this example the
LIST ( COLLECT Person.SequenceNumber FROM ALL Person ) = []
- As Jenny has an unknown sequence number, the result of the
COLLECT
expression is?
. TheLIST
function creates an empty list in case the parameter has?
value.
- As Jenny has an unknown sequence number, the result of the
Back to top |
---|
...
bgColor | white |
---|
...
This function determines the size of a collection.
Syntax
Code Block |
---|
SIZE ( collection ) |
...
- collection - A collection of attribute or entity instances. This can be an expression or a relation attribute for instance.
Return type
- integer
Example
Suppose you have a Parent
and a Child
entity, where Parent
has a multivalued relation with Child
via the relation Parent.has_Children
. With this model the following instances are created:
...
Then:
...
UI Text Box | ||
---|---|---|
| ||
SIZE and COUNT are similar except for ?: SIZE ( ? ) results in 0, while COUNT ( ? ) results in ? |
Back to top |
---|
...
bgColor | white |
---|
UNIQUE
...
|
...
Syntax
Code Block |
---|
UNIQUE ( collection ) |
- collection - A collection of attribute or entity instances.
Return type
- collection
Examples
Suppose the following model.
...
Back to top |
---|
...
bgColor | white |
---|
SUBSET OF
...
|
...
Syntax
Code Block |
---|
collection1 SUBSET OF collection2 |
...
- collection1 - The collection that is tested to be a subset of the second collection.
- collection2 - The collection that is tested to hold all the items in the first collection.
Return type
- Boolean
Venn diagram
Examples
...
|
...
1 SUBSET OF Address.Numbers
Given Adress.Numbers = ?
...
UI Text Box | ||
---|---|---|
| ||
Values between single quotes are considered value list items. For backwards compatibility reasons, a comma separated sequence of value list items is treated as a collection. That's why there is no need to enclose the values between square brackets. In fact if you do add the square brackets you create a matrix rather than a list. |
Back to top |
---|
...
bgColor | white |
---|
UNION
Adds two collections of the same base type to a new collection.
Syntax
Code Block |
---|
UNION ( collection1 , collection2 ) |
...
- collection1 - First collection to be added to the new collection.
- collection2 - Second collection to be added to the new collection.
Return type
- collection
Venn diagram
Examples
Suppose you have a Parent
and a Child
entity, where Parent
has a multivalued relation with Child
via the relation Parent.has_Children
. With this model the following instances are created:
...
Back to top |
---|
...
bgColor | white |
---|
INTERSECTION
This function determines the intersection of two collections. It returns a collection containing the items that are present in both specified collections.
Syntax
Code Block |
---|
INTERSECTION ( collection1 , collection2 ) |
...
- collection1, collection2 - Collections to be intersected. These collections must be of the same base type.
Return type
- collection
Venn diagram
Examples
Suppose the following model. Entity Teacher
has a multivalued relation with entity Child
via the relation Teacher.teaches_Children
.
...
Back to top |
---|
bgColor | white |
---|
DIFFERENCE
This function returns a collection containing all the items from collection1 that are not present in collection2.
Syntax
Code Block |
---|
DIFFERENCE ( collection1 , collection2 ) |
- collection1, collection2 - Collections to be compared. These collections must be of the same base type.
Return type
- collection
Venn diagram
Examples
Back to top |
---|
bgColor | white |
---|
SYMMETRIC_DIFFERENCE
This function determines the symmetric difference between two collections. It returns a collection with the elements of the provided collections which are in either one of the collections, but not in both.
Syntax
Code Block |
---|
SYMMETRIC_DIFFERENCE ( collection1 , collection2 ) |
- collection1, collection2 - Collections to be compared. These collections must be of the same base type.
Return type
- collection
Venn diagram
Examples
Back to top |
---|
Panel | |||
---|---|---|---|
| |||
A note on collections and duplicatesAn expression resulting in a collection does not contain duplicates. Please be aware however, that intermediary results of a This is best illustrated with the following examples. | |||
Person instance | Person.Name | Person.Age | |
Person_1 | Kim | 24 | |
Person_2 | Rick | 25 | |
Person_3 | Bob | 25 | |
Expression | Result | Type | Note | COLLECT Person.Age FROM ALL Person | [ 24 , 25 ] | String (multivalued) |
SIZE ( COLLECT Person.Age FROM ALL Person ) | 3 | Integer | The intermediary collection is [ 24, 25, 25 ] |
TSL: The ages present are: [[[ COLLECT Person.Age FROM ALL Person ]]]. | The ages present are: 24, 25, 25. | String | The intermediary collection is [ 24, 25, 25 ] |
SIZE ( UNIQUE ( COLLECT Person.Age FROM ALL Person ) ) | 2 | Integer | The duplicates in the intermediary collection are filtered by the UNIQUE function |
Person instance | Person.Name | Person.Age | |
Person_2 | Rick | 25 | |
Person_3 | Bob | 25 | |
Expression | Result | Type | Note | COLLECT Person.Age FROM ALL Person | [ 25 ] | Integer (multivalued) | UNPACK ( COLLECT Person.Age FROM ALL Person ) | Error | The collection contains 2 elements [ 25 , 25 ] | UNPACK ( UNIQUE ( COLLECT Person.Age FROM ALL Person ) ) | 25 |
UI Text Box | |||
|
. |
Back to top |
---|