How to use Execute entity transformers

Introduction

There are two types of transformers in Alumio, they are:

  • Entity transformers, for example:
    • Data, transform data using mappers and conditions
    • Node, transform nodes
    • Filter previously stored entities
    • Get branches from a pattern
    • etc.
  • Data Transformers
    • Value setter
    • Copy using a pattern
    • Value mapper
    • Conditional Transformer
    • etc.

When you are inside an entity transformer like “Data, transform data using mappers and conditions” or “Node, transform nodes”, you didn’t use to be able to use entity transformers. Now, you are able to use “Execute entity transformers” to do so.

Transformer “Execute entity transformers” is a transformer that allows you to execute configurations and prototypes in the entity transformer level in the Data Transformer level.

NOTE: Please keep in mind that the transformer expects exactly one entity returned after all entity transformers inside it are executed. Therefore, you will not be able to use data filter to filter out the entity that is currently being processed, as it would end up with 0 entities returned. You will also not be able to separate the entities using the “Get branches from a pattern” as it would end up with you having more than one entity.

Use cases

Loop into an array to do complex transformation within each object

Inside the “Data, transform data using mappers and conditions”, you can now use entity transformers like “Node, transform nodes” to loop into an array and do complex transformation to each object in the array.

It usually happens when you are creating/modifying an entity transformer. You already set the root of the entity transformer to “Data, transform data using mappers and conditions” and you already have a lot of data transformers inside it. However, you now need to loop into an array within the same entity transformer to do HTTP call using HTTP transformer within each object of the array. In this case, you can use “Execute entity transformers” to do so.

Reuse entity transformer configurations you’ve created

Let’s say you have a set of transformers that are frequently used in several routes of your integrations. For example, reducing inventory of a product you cached in a storage, fetching product data from a storage or web service, getting a time difference between two timestamps, etc. In Alumio, you can create a single entity transformer configurations and make it a reusable, just like when you code and you build your own function.

For instance, you have created an entity transformer that adds 10 to an integer value of property num. It simply does the below transformation.

Now, you want to reuse it in some parts of your integration. You can use it inside “Data, transform data using mappers and conditions” or inside “Node, transform nodes”, such as below.