Class: FirstRelated

olympe.dc.transformers. FirstRelated

Transformer that will find the first instance connected via a specific relation. If none is found, it will follow the secondary relation and try again. This is useful when looking for an instance in a chain.

Example:

const res = lst.transform(new olympe.dc.transformers.FirstRelated(rel, olympe.dc.RelationType.MODEL));

This will look for the instances connected via 'rel' to the instances in 'lst', searching the models if not found in the initial instance.


new FirstRelated(primaryRel, secondaryRel [, primaryDirection] [, secondaryRelation])

Creates an instance of the 'FirstRelated' transformer.

Parameters:
Name Type Argument Default Description
primaryRel olympe.dc.InstanceTag

Tag of the relation to the value.

secondaryRel olympe.dc.InstanceTag

Tag of the secondary relation to follow if no value exist on the current instance.

primaryDirection olympe.dc.Direction <optional>
olympe.dc.Direction.DESTINATION

Direction for the primary relation.

secondaryRelation olympe.dc.Direction <optional>
olympe.dc.Direction.DESTINATION

Direction for the secondary relation.

Implements:

Methods


getName()

Gets this Transformer unique name.

Implements:
Returns:

The name.

Type
string

getRelationDirection()

Gets the value relation direction.

Returns:

The relations direction.

Type
olympe.dc.Direction

getRelationTag()

Gets the value relation tag.

Returns:

The relations tag.

Type
string

getSecondaryDirection()

Gets the secondary relation's direction.

Returns:

The secondary relation's direction.

Type
olympe.dc.Direction

getSecondaryTag()

Gets the secondary relation tag.

Returns:

The tag for the secondary relation.

Type
string

getTransform(manager, stateResolver, callback)

Get the transformer's transform function. This is the method that implementations of Transformer must provide and is where the actual transformation will take place.

Parameters:
Name Type Description
manager olympe.dc.Manager

The DC manager.

stateResolver olympe.dc.ranking.StateResolver

The state resolver.

callback olympe.dc.Manager.TransformationCallback

The callback.

Implements:
Returns:

The transform function.

Type
olympe.dc.Manager.TransformationCallback

getValueType()

Gets the transformed item's value type. A null value means that the transformer will not change the type of the values (e.g. a sort transformer).

Implements:
Returns:

Returns the transformed listDef value new type or null if this transformer does not change it

Type
function

serialize(parameters)

Serializes the transformer.

Parameters:
Name Type Description
parameters olympe.dc.query.Parameters

The parameters for the serialization.

Implements:
Throws:

If the transformer is not serializable.

Type
Error
Returns:

The JSON representation.

Type
string

toString()

Gets a string representation of the transformer.

Implements:
Returns:

The representation.

Type
string