On this page you can find an explanation of how to work with the transformation service within wvr.io.

The transformation service allows users to create a 'script' to transform or alter a dataset. A transformation can be done on a single space at the time and works through the Transformation service.


Setting up the transformation service

  • Add a new service
  • Select 'Upload transform script'
  • Go to Config
    • For File, click on the 'Static' switch to say 'File', now select 'File' in the right box
    • For Config put this line in the right box { "wipe": false, "memberKey": "type" }

This are the default setting and can be adjusted if needed. The memberKey as mentioned in the config part above is important and used in almost all of the transformations.


Filestructure & -type

The transformationservice accepts files of the type .yml and .yaml which should have the following structure:

On the first line it file should contain the name of a transformation (with underscores (_)) followed by a semicolon (:).

The next set of lines are the inputs for the transformation. What the content of these should be is shown in chapter below.

In the example below you can see 4 transformations being done based on 3 functions. Generally for each transformation we tend to keep 1 blank line, but more is possible and for each transformation function we keep 2 blank lines.

Example

drop_attributes_for_type:
  helperColumn
  type

  otherColumn
  type


reverse_relation:
  partOf
  consistsOf


change_attribute_keys:
  person_has_age
  age


Available transformations

Transformation nameFunctionParameters
add_relationsAdd a relation between 2 nodes.
  1. Source node id
  2. Relation key
  3. Target node id
add_relations_for_all_membersCreate relations from a group of nodes (a single type) to a single node.
  1. Source type id
  2. Relation key
  3. Target node id
  4. Member key
attributes_to_new_type

Can be used to create a type of nodes which are more frequently used, like classifications of some sort. Attribute mapping is written as:

-attributeNameOfSource:attributeNameOfTarget

for example:

-otlType:naam

  1. Source type id
  2. Target type id (new)
  3. Relation key
  4. Member key
  5. Attribute mapping
change_attribute_into_type

Changes an attribute into a type. This transformation is used when you have a different type of dataset, where for instance you have a bunch of properties listed as Property instead of a Property with a specific name.

With this transformation, the attribute value will become a type.

  1. Source type id
  2. Source attribute key
  3. Member key
  4. Target attribute key
change_attribute_keysChanges an attribute key for all nodes containing this attribute.
  1. Original attribute key
  2. New attribute key
change_identifiersChanges the id of a node.
  1. Original node id
  2. New node id
create_decomposition_by_separator

Creates a decomposition structure between nodes of one type. For instance if you have a structured dataset with nodes having some attribute (level): 01, 01.02, 01.02.03 and 01.02.01 it will create a relation from 01.02.01 to 01.02 and from 01.02.03 to 01.02 and finally from 01.02 to 01.

The Separator (.) and Attribute key (level) mentioned in the parameters are based on the example mentioned above.

  1. Type id
  2. Relation key
  3. Member key
  4. Separator (.)
  5. Attribute key (level)
create_nodesCreates a new node with a specified node id and name attribute.
  1. Node id
  2. Name attribute value
create_relation_based_on_attribute_valueCreates relations based on a specific attribute with a specific value to a specified node.
  1. Member key
  2. Source type id
  3. Attribute key
  4. Attribute value
  5. Relation Key
  6. Target node id
create_relation_from_sparql_resultExecute the sparql query, and for each result link the from node to the to node.

  1. Sparql query
  2. Binding containing from node id
  3. Binding containing to node id
  4. Relation key
create_typed_nodesCreate a new node with a specified node id and name attribute with a specified type
  1. Target type id
  2. New node id
  3. Name
  4. Member key
delete_type_and_membersDeletes a specific type and all of its members.
  1. Type id
  2. Member type
drop_attributes_for_typeRemoves an attribute for all nodes of a specific type
  1. Attribute key
  2. Type id
  3. Member key
relate_nodes_based_on_attr_value

Create relations based on the attribute value of the source node and link them to the targetNode with the same value.

Note: The target attribute can't have duplicate values.

  1. Source type id
  2. Source attribute key
  3. Target type id
  4. Target attribute key
  5. Relation key
  6. Member key
reverse_all_relations_of_keyReverses all relations with a certain key and gives it a new name
  1. Old key
  2. New key
reverse_relationReverse a specific relation between two nodes
  1. Source node id
  2. Target node id
  3. Old relation key
  4. New relation key
reverse_relation_between_typesReverse a specific relation between two types of nodes
  1. Source type id
  2. Target type id
  3. Old relation key
  4. New relation key
  5. Member key
set_namesSet the name of a specific node (sets attribute: name)
  1. Node id
  2. Name
store_queried_value_on_nodeExecute the sparql query, assuming the query has one result. Stores the found value on the node using the attribute key. If the attribute does not exist, create it before assigning the value. If a previous value on the node exists, override.
  1. Sparql query 
  2. Binding containing value
  3. Binding containing the node id 
  4. Attribute key