new ListDefBuilder(baseTag [, valueType])
Creates an instance of ListDefBuilder
.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
baseTag |
olympe.dc.InstanceTag | Starting instance tag. |
||
valueType |
function |
<optional> |
olympe.dc.CloudObject | Type of the values, must be a sub-class of |
Methods
-
and()
-
Creates an
And
predicate with the previous and next filtering predicate pushed on the internal transformers stack.Example:
list = list.hastTag(tag).and().hasRelated(rel);
Returns:
This
ListDefBuilder
. -
build()
-
Generates a
ListDef
based on the settings of this builder.Returns:
The generated
ListDef
.- Type
- olympe.dc.ListDef
-
contains(property, value [, caseSensitive] [, relations])
-
Adds a filter transformer that checks whether a specific property contains a given string.
Parameters:
Name Type Argument Default Description property
olympe.dc.registry.Property | string The property to filter on.
value
string | olympe.df.OString The string to match the property with.
caseSensitive
olympe.df.POBoolean | boolean <optional>
false true
if the match has to be case sensitive.relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property
Returns:
This
ListDefBuilder
. -
distinct()
-
Filters out duplicate instances.
Returns:
This
ListDefBuilder
. -
dump()
-
Generate a text representation of the ListDef being built. Warning: a call to this method will execute the query and cause the subscription to be retrieved.
Returns:
- Type
- string
-
equalsTo(property, value [, relations])
-
Adds a filter transformer that matches a specific property with a given value.
Parameters:
Name Type Argument Description property
olympe.dc.registry.Property | string The property to filter on.
value
* The value to match the property with.
relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property.
Returns:
This
ListDefBuilder
. -
excludeInstances(instances)
-
Adds a filter transformer that exclude the instances having a the specified tag, or whose tag is in the specified array
Parameters:
Name Type Description instances
Array.<olympe.dc.InstanceTag> The instance(s) to exclude.
Returns:
This
ListDefBuilder
-
filter(predicateFunction)
-
Adds a filter transformer that matches the specified custom predicate. The predicate function given returns a boolean: whether the instance must be part of the list or not.
Parameters:
Name Type Description predicateFunction
olympe.dc.ListDefBuilder.AnonymousPredicate The predicate function.
Returns:
This
ListDefBuilder
. -
follow(relation)
-
Adds a transformer that follows the given relation.
Parameters:
Name Type Description relation
olympe.dc.registry.Relation The relation to follow.
Returns:
This
ListDefBuilder
. -
followEvery(relations)
-
Adds a transformer that follows the given relations in parallel instead of successively.
Parameters:
Name Type Description relations
Array.<olympe.dc.registry.Relation> The relations to follow.
Returns:
This
ListDefBuilder
. -
followRecursive(relation [, minHops] [, maxHops])
-
Adds a transformer that follows a relation recursively. A simple 'follow' will stop after the first relation, while 'followRecursive` will continue to follow the same relation on the next instances, recursively.
For instance if we have the following graph: (A) -[Children]-> (B) -[Children]-> (C) \ -[Children]-> (D) -[Children]-> (F) -[Children]-> (E)
A.follow(Children)
will return B & E whileA.followRecursive(Children)
will return B, C, D, E & F.Parameters:
Name Type Argument Default Description relation
olympe.dc.registry.Relation The relation to follow.
minHops
olympe.dc.transformers.RecursiveRule | number <optional>
olympe.dc.transformers.RecursiveRule.FIRST The minimal number of times the relation is followed.
maxHops
olympe.dc.transformers.RecursiveRule | number <optional>
olympe.dc.transformers.RecursiveRule.INFINITE The maximal number of time the relation can be followed.
Returns:
This
ListDefBuilder
. -
followSuccessive(relations)
-
Adds transformers that successively follow the given set of relations.
Parameters:
Name Type Description relations
Array.<olympe.dc.registry.Relation> The set of relations to follow.
Returns:
This
ListDefBuilder
. -
greaterThan(property, value [, relations])
-
Adds a filter transformer that checks for numerical properties being greater than the given value.
Parameters:
Name Type Argument Description property
olympe.dc.registry.Property | string The numerical property.
value
olympe.df.PONumber | number The value to compare.
relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property.
Returns:
This
ListDefBuilder
. -
hasRelated(relations [, tag])
-
Adds a filter that only accepts instances connected via at least one of the given relations. Optionally, enforce the instance the relation(s) connect(s) to.
Parameters:
Name Type Argument Description relations
Array.<(olympe.dc.registry.Relation|olympe.dc.transformers.RecursiveRelated)> The relation(s) to filter on.
tag
olympe.dc.InstanceTag <optional>
Tag of a related instance. If provided, the tested and related instances must connect through all relations provided above.
Returns:
This
ListDefBuilder
. -
hasTag(tag)
-
Adds a filter that only accepts instances having the given tag.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The tag to filter on.
Returns:
This
ListDefBuilder
. -
instanceOf(models)
-
Add a filter transformer that checks if entries are instances of specific models.
This will filter out any entry that is not an instance of one of the specified models, following recursively model extensions
Parameters:
Name Type Description models
Array.<olympe.dc.InstanceTag> The models to check for.
Returns:
This
ListDefBuilder
. -
instances()
-
Adds a transformer that returns all the instances of a model.
Returns:
This
ListDefBuilder
. -
limit(start, count)
-
Limit the list to the specified range of ranks.
Parameters:
Name Type Description start
olympe.df.PONumber | number Starting rank of the range.
count
olympe.df.PONumber | number Size of the range.
Returns:
This
ListDefBuilder
. -
matchRegex(property, expression [, caseSensitive] [, relations])
-
Adds a filter transformer that checks whether a string property matches a specified regular expression.
Parameters:
Name Type Argument Default Description property
olympe.dc.registry.Property | string The string property.
expression
olympe.df.POString | string The regular expression to match.
caseSensitive
olympe.df.POBoolean | boolean <optional>
true true
if that matching has to be case sensitive.relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property.
Returns:
This
ListDefBuilder
. -
not()
-
Negates the next filtering predicate (.equals(...), .contains(...), ...) pushed on the internal transformers stack.
Example:
list = list.not().hasTag(tag);
Returns:
This
ListDefBuilder
. -
or()
-
Creates an
Or
predicate with the previous and next filtering predicate pushed on the internal transformers stack.Example:
list = list.hastTag(tag).or().hasRelated(rel);
Returns:
This
ListDefBuilder
. -
setValueType(valueType)
-
Sets the type of the values returned by this query.
Parameters:
Name Type Description valueType
function The type of the values, must be a subclass of
olympe.dc.CloudObject
.Returns:
This
ListDefBuilder
. -
smallerThan(property, value [, relations])
-
Adds a filter transformer that checks for numerical properties being smaller than the given value.
Parameters:
Name Type Argument Description property
olympe.dc.registry.Property | string The numerical property.
value
olympe.df.PONumber | number The value to compare.
relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property.
Returns:
This
ListDefBuilder
. -
sort(valueGetter, comparator [, order])
-
Sort by an anonymous comparing function.
Parameters:
Name Type Argument Default Description valueGetter
olympe.dc.ListDefBuilder.AnonymousComparedValueGetter The callback to retrieve the value (of type T) to compare from the instance.
comparator
olympe.dc.ListDefBuilder.AnonymousComparator The function to use to compare 2 values (of type T).
order
olympe.dc.transformers.SortRule <optional>
olympe.dc.transformers.SortRule.ASCENDING Order of the sort (ascending or descending).
Returns:
This
ListDefBuilder
. -
sortBy(property [, order] [, relations])
-
Sort the list by the given primitive property. The property can be of type
String
,Number
orDateTime
.Parameters:
Name Type Argument Default Description property
olympe.dc.registry.Property | string The property to base the sort on.
order
olympe.dc.transformers.SortRule <optional>
olympe.dc.transformers.SortRule.ASCENDING Order of the sort (ascending or descending).
relations
Array.<!olympe.dc.registry.Relation> <optional>
Relations to follow to retrieve the property.
Returns:
This
ListDefBuilder
. -
transform(transformers)
-
Adds transformers to this
ListDefBuilder
.Parameters:
Name Type Description transformers
Array.<olympe.dc.Transformer> The transformers to add.
Throws:
-
If any of the transformers is invalid.
- Type
- ListDefBuilderError
Returns:
This
ListDefBuilder
. -
-
union(listDef)
-
Creates a new
ListDef
which is the union of this one and the specified one.Parameters:
Name Type Description listDef
olympe.dc.ListDef The
ListDef
to merge with this one.Returns:
This
ListDefBuilder
. -
unionWithSingle(tag)
-
Creates a new
ListDef
which is the union of this one and the specified one (containing a single element).Parameters:
Name Type Description tag
olympe.dc.InstanceTag Starting instance tag.
Returns:
This
ListDefBuilder
.
Type Definitions
-
AnonymousComparator(leftValue, rightValue)
-
Definition of the comparator function passed to sort(). It should return:
- -1 if the leftValue should be listed before the rightValue
- +1 if the rightValue should be listed before the leftValue
- 0 if it cannot be decided
WARNING: it's not allowed to return a Proxy!
Parameters:
Name Type Description leftValue
? rightValue
? Returns:
- Type
- number
-
AnonymousComparedValueGetter(instance)
-
Definition of the valueGetter function passed to sort() WARNING: it's not allowed to return a Proxy!
Parameters:
Name Type Description instance
olympe.dc.CloudObject Returns:
- Type
- *
-
AnonymousPredicate(instance)
-
Definition of the function passed to filter()
Parameters:
Name Type Description instance
olympe.dc.CloudObject Returns:
- Type
- olympe.df.POBoolean