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
Andpredicate 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
ListDefbased 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 propertyolympe.dc.registry.Property | string The property to filter on.
valuestring | olympe.df.OString The string to match the property with.
caseSensitiveolympe.df.POBoolean | boolean <optional>
false trueif the match has to be case sensitive.relationsArray.<!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 propertyolympe.dc.registry.Property | string The property to filter on.
value* The value to match the property with.
relationsArray.<!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 instancesArray.<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 predicateFunctionolympe.dc.ListDefBuilder.AnonymousPredicate The predicate function.
Returns:
This
ListDefBuilder. -
follow(relation)
-
Adds a transformer that follows the given relation.
Parameters:
Name Type Description relationolympe.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 relationsArray.<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 relationolympe.dc.registry.Relation The relation to follow.
minHopsolympe.dc.transformers.RecursiveRule | number <optional>
olympe.dc.transformers.RecursiveRule.FIRST The minimal number of times the relation is followed.
maxHopsolympe.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 relationsArray.<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 propertyolympe.dc.registry.Property | string The numerical property.
valueolympe.df.PONumber | number The value to compare.
relationsArray.<!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 relationsArray.<(olympe.dc.registry.Relation|olympe.dc.transformers.RecursiveRelated)> The relation(s) to filter on.
tagolympe.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 tagolympe.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 modelsArray.<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 startolympe.df.PONumber | number Starting rank of the range.
countolympe.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 propertyolympe.dc.registry.Property | string The string property.
expressionolympe.df.POString | string The regular expression to match.
caseSensitiveolympe.df.POBoolean | boolean <optional>
true trueif that matching has to be case sensitive.relationsArray.<!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
Orpredicate 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 valueTypefunction 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 propertyolympe.dc.registry.Property | string The numerical property.
valueolympe.df.PONumber | number The value to compare.
relationsArray.<!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 valueGetterolympe.dc.ListDefBuilder.AnonymousComparedValueGetter The callback to retrieve the value (of type T) to compare from the instance.
comparatorolympe.dc.ListDefBuilder.AnonymousComparator The function to use to compare 2 values (of type T).
orderolympe.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,NumberorDateTime.Parameters:
Name Type Argument Default Description propertyolympe.dc.registry.Property | string The property to base the sort on.
orderolympe.dc.transformers.SortRule <optional>
olympe.dc.transformers.SortRule.ASCENDING Order of the sort (ascending or descending).
relationsArray.<!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 transformersArray.<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
ListDefwhich is the union of this one and the specified one.Parameters:
Name Type Description listDefolympe.dc.ListDef The
ListDefto merge with this one.Returns:
This
ListDefBuilder. -
unionWithSingle(tag)
-
Creates a new
ListDefwhich is the union of this one and the specified one (containing a single element).Parameters:
Name Type Description tagolympe.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 instanceolympe.dc.CloudObject Returns:
- Type
- *
-
AnonymousPredicate(instance)
-
Definition of the function passed to filter()
Parameters:
Name Type Description instanceolympe.dc.CloudObject Returns:
- Type
- olympe.df.POBoolean
Olympe SDK