Boomi

Remove Emojis From The Payload

Remove emojis from the given file

In this blog we will remove the emojis from the payload, sample input and output documents are given below:

Input:

Expected Output:

Now go to the Boomi Atomsphere Platform to start the integration.

Step 1: Go to platform.boomi.com

Use Email Address and Password to log into the Boomi platform

Step 2: Click on Integration

Step 3: Click on Create New

Step 4: Create a Process Component

Step 5: Choose Start shape as “Connector” type and choose connector as “Disk V2”

Step 6: Click on the ‘+’ icon in the Connection to configure the connection

Step 7: Give the connection name ‘Disk’, in the directory text field give the directory path from where you want to read the file and click “Test Connection”. At last click ‘Save and Close’

Step 8: Select the action as “Get” and Click on the “+” icon in Operation to configure the operation

Step 9: Give the operation name “Read file” and click on “import” and “Save and Close”

Step 10: Click on Parameters, then click on the “+” button

Step 11: Select Input as ID, Type as “Static”, give the file name(test.json) in static value, and hit on “OK”

Step 12: Search “Data Process” in the Shape palette and attach it to the disk v2

Step 13: Open the “Data Process” shape and select Processing Stape as “Custom Scripting”, Language as Groovy 1.5 and click on “Edit Script”

Step 14: We need to write a script to remove the emojis

Here is a small demonstration of the above scripting:

// Import the necessary libraries

import java.util.Properties;

import java.io.InputStream;

for ( int i = 0; i < dataContext.getDataCount(); i++ ) {

InputStream is = dataContext.getStream(i);

Properties props = dataContext.getProperties(i);

// text is a keyword that needs to read the full data produced by the previous shape

def data_in = is.text;

// This is a regular expiration that helps to identify all the emojis

String regex = “[^\\p{L}\\p{N}\\p{P}\\p{Z}\\p{Sm}\\p{Sc}\\p{Sk}\\p{M}\\r\\n]”;

// replaceAll is a function that will help to replace the emojis with the blank string

String result = data_in.replaceAll(regex, “”);

String data_out = result;

// Here we are changing the output data to Byte code

is = new ByteArrayInputStream(data_out.toString().getBytes())

dataContext.storeStream(is, props);

}

Step 15: We need to stop shape at the end to stop the Integration

Step 16: Now we need to go to the Atom Management page because we need to change the default character encoding style

Step 17: We need to search our Atom and go to “Startup Properties”. Here we can see the Default Character Encoding is windows-1252

Step 18: We need to change the Default Character Encoding from windows-1252 to UTF-8 (Unicode Transformation Format) for that we need to go to “Properties”, write UTF-8 in the File Encoding text field, and hit Save

Step 19: After that, we need to Restart our atom so the changes can reflect, for that, we need to go to “Atom Information” and click on Restart Atom

Step 20: After a successful restart we need to go to “Startup Properties” and check the Default Character Encoding style, it will be UTF-8

Step 21: Now we need to go to the “Built” page, click on the “Test” button and then select our Atom, and hit ok to test

Step 22: After a successful run we need to click on the stop shape and see the shape source data

Step 23: In the Document Viewer we can see all the emojis are removed from the payload

Thank You

Author

Sourav karmakar

Leave a comment

Your email address will not be published. Required fields are marked *