Using Alumio Transformers: A Hassle-Free Way To Modify Data

Table Of Contents

  • Introduction
  • Video
  • Use Cases Of Alumio Transformers
  1. Transforming A Field From String To Integer
  2. Prefixing A Sku
  3. Merger Transformer
  4. Remapping The Field Of Your Data
  5. Moving Your Data Out Of The Product Node
    Closing Thoughts!

Introduction

In eCommerce, the role of transformers is quite important in making data organized and usable for future use in various applications. From enriching data to data filtering to data mapping, transformers do them all. Alumio has made the task of transforming data a cakewalk! Anyone using Alumio can easily transform data by configuring them using the powerful transformer feature it offers. This blog will shed some light on how to use the most commonly used transformers in a step-by-step guide!

Video

Use Cases Of Alumio Transformers

1. Transforming A Field From String To Integer

As you open the Transformers segment in Alumio, there are two observable fields on the top-right corner.

The first field represents the data coming in from a system. On the other hand, the second field helps you to visualize the transformed data, once a specific data transformer has been implemented.

Once a transformer has been applied, one simply needs to click on the Test button to get (or visualize) the modified data.

Let’s take a quick example to understand.

{
    "product": {
        "sku": "123",
        "price": "900",
        "slides": []
    }
}

JavaScript

Let’s assume that we need to transform the above-mentioned data gathered from a source. As you can see, the price variable is assigned a string value (900). However, it should ideally be an integer or float value.

(For starters, a string value is generally assigned to characters while an integer or float value is assigned to numerical figures!)

Notwithstanding the complexity of the demand by data transformations, Alumio Entity Transformers can easily accomplish the same!

Step 1:

Click on the Add Transformers button present under the Transformers section. The Transformers drop-down menu will pop up and you can see a wide range of pre-built transformers.

Step 2:

For this particular example, you need to select “Value Mapper”, and map the value of the data.

Note: If you wish to map the key, you can also select the “Key Mapper”

Step 3:

Next, you have to define the Accessor. The accessor indicated where the data can be found that needs transformation. Select “Pattern Accessor” from the Accessor drop-down menu.

You have to set up the pattern now. In this case, it is the field of price which comes under the product node. So, you can simply type “product.price”.

Step 4:

Subsequently, you need to select the Mapper. To convert the string value to integer, select “Cast: Integer”

Step 5:

Voila! You have successfully applied the transformer. Click on the Test button now to visualize the transformed data.

The transformed data will look something like this!

{
    "product": {
        "sku": "123",
        "price": 900,
        "slides": []
    }
}

JavaScript

The transformer will instantaneously change the string value of the product to an integer value.

2. Prefixing A Sku

In the domain of inventory management, an SKU (Stock Keeping Unit) is a specific item for sale which is tracked, such as a product/service.

Let’s work on the same example again.

{
    "product": {
        "sku": "123",
        "price": "900",
        "slides": []
    }
}

JavaScript

Alumio Transformer can prefix the Sku value easily. Here’s how!

Step 1:

Click on the Add Transformers button present under the Transformers section.

Step 2:

Select “Value Mapper”, and map the value of the data.

Step 3:

Select “Pattern Accessor” from the Accessor drop-down menu.

For the pattern, simply type “product.sku” since you want to transform the sku.

Step 4:

Now, you need to select the Mapper just like the last time. Select “String: Append” in this case.

Step 5:

Add the append you require in the Append field. For example, you can add “TESTX”.

Step 6:

You are done with applying the transformer. Click on the Test button to visualize the transformed data.

It will look something like this.

{
    "product": {
        "sku": "123TESTX",
        "price": "900",
        "slides": []
    }
}

JavaScript

3. Merger Transformer

Complex operations often require pulling data live from certain APIs and merging them together. Alumio Transformer facilitates smooth retrieval and merging of data. Here’s how!

Step 1:

Click on Add Transformers and select “Merger Transformer” from the drop-down list.

Step 2:

Now, you have to select the data that you wish to merge. For example, you can select the HTTP transformer if you are willing to retrieve live data from a web surface.

Step 3:

Subsequently, you need to fill the Request URL section with an https link from where you want to pull the web surface data.

Step 4:

Now, you have to select and set up the HTTP client.

Step 5:

Moving on, there will be a Template box, where you have to specify where the data is going to be saved and merged with. For instance, if you want to save it to the Product “slides”, you just have to mention that!

Step 6:

Well, that’s everything you need to do and the Alumio transformer will do the rest.

You can click on the Test button to visualize the merged data. You will see that the retrieved data from the web surface has been successfully merged with the product slide you had specified in Step 5.

4. Remapping The Field Of Your Data

In some scenarios, you will need to remap the fields of your data and once again, Alumio transformer can be your trusted aide in doing that.

Let’s take the same data once again to make it easier for you to grasp.

{
    "product": {
        "sku": "123",
        "price": "900",
        "slides": []
    }
}

JavaScript

For instance, there is a requirement where you have to replace “sku” with “name” and “price” with “new_price”. In this scenario, you will require a mapper to accomplish that.

Step 1:

Click on the Add Transformers button and select “Key Mapper” from the drop-down list.

Step 2:

Next, select “Key Accessor” from the Accessor drop-down menu.

Step 3:

Now, you have to specify the Root. In this case, all the fields we are looking to modify come under the Product node. Thus, you just need to mention “product” inside the Root box.

Step 4:

Moving on, you have to select the Mapper you want to use. If you want to utilize one transformer for multiple mapping actions, the best option for you is to select the “Dictionary Map”.

Step 5:

Upon selecting “Dictionary Map”, a section of adding maps will appear. You can create as many maps you wish to by clicking on Add Map.

There will be String Fields where you have to mention the current field name in the prevailing data followed by the new field name which replaces the former.

As discussed above, we are looking to replace:

  1. “sku” with “name” and

  2. “price” with “new_price”.

So, there will be two maps where you need to enter the details separately for these two modifications.

Step 6:

Now, there will be a Comparator whose default value is Equals. It functions by checking for keys named “sku” and “price”. For every instance of these two in the data (where the key equals “sku” and “price’'), the transformer will seamlessly modify it to “name” and “new_price” respectively.

{
    "product": {
        "name": "123",
        "new_price": "900",
        "slides": []
    }
}

JavaScript

Step 7:

You have successfully implemented the remapping transformer. By clicking on the Test button, you can visualize the transformed data where the fields have been successfully remapped.

5. Moving Your Data Out Of The Product Node

Last but not the least, there is another interesting use case which is quite often needed.

What if you are required to move the data out of the product node (refer to the data example we have been using) to the root node? It is very much possible to accomplish that as well with just a few clicks!

Step 1:

Click on the Add Transformers button and select “Move Using A Pattern” from the drop-down list. It’s a simple move transformer that Alumio offers.

Step 2:

Next, we have to select a Pattern. You need to type product.* since we are moving out the data from the product node. The symbol * basically denotes a wildcard, which essentially becomes a variable and can be utilized in a replacement pattern.

Step 3:

You will have to fill the replacement box next with “$1”. It indicates the variables we have defined in the product node.

Step 4:

You have successfully moved your data from the product node to the root. By clicking on the Test button, you can visualize the transformed data.

It will look like this.

{
    "product": [],
    "sku": "123",
    "price": "900",
    "slides": []
}

JavaScript

The product node will become empty and all the variables will be moved to the root node.

Closing Thoughts!

The day-to-day operations of enterprises are very much dependent on data. Since data is commonly sourced from multiple sources and formats across an organization, data transformation is required to ensure that data from one application or source is understandable by other applications and databases.

It is a vital aspect for application integration. The central steps of data integration are extraction, transformation, and loading (also known as ETL). Often, data needs to be merged, aggregated, enriched, summarized, or filtered depending on the nature of the integration scenario. Alumio offers the best one-stop solution for data transformation that can seamlessly integrate a myriad range of data. Stay tuned to our other transformer blogs to learn more!