Table of Contents

Search

  1. Preface
  2. Introduction to Informatica Edge Data Streaming
  3. Licenses
  4. Using Informatica Administrator
  5. Creating and Managing the Edge Data Streaming Service
  6. Edge Data Streaming Entity Types
  7. Edge Data Streaming Nodes
  8. Data Connections
  9. Working With Data Flows
  10. Managing the Edge Data Streaming Components
  11. Security
  12. High Availability
  13. Disaster Recovery
  14. Monitoring Edge Data Streaming Entities
  15. Appendix A: Troubleshooting
  16. Appendix B: Frequently Asked Questions
  17. Appendix C: Regular Expressions
  18. Appendix D: Command Line Program
  19. Appendix E: Configuring Edge Data Streaming to Work With a ZooKeeper Observer
  20. Appendix F: Glossary

User Guide

User Guide

JavaScript Transformation Type

JavaScript Transformation Type

Use a JavaScript transformation to transform records and insert delimiters. To create a JavaScript transformation, add the JavaScript transformation type to a link.
In the JavaScript transformation, you specify a JavaScript function that applies the transformations that you want. You can include methods to check whether input records match a particular condition, and you can either drop or forward records on the basis of the results. If the JavaScript function is not valid, the transformation logs an error message and the data flow ceases.
The JavaScript function uses the Rhino 1.7R1 JavaScript engine. For more information about the Rhino 1.7R1 JavaScript engine, see https://javadoc.io/doc/rhino/js/latest/index-all.html.

JavaScript Transformation Properties

You can configure the following properties for the JavaScript transformation type:
Entity Name
Name of the JavaScript transformation. Maximum length is 32 characters.
Description
Description of the JavaScript transformation. Maximum length is 256 characters.
JavaScript Functions
JavaScript transformation program to transform records and insert delimiters. The program must include the filter function that applies the transformations. Maximum length is 4000 characters.

The JavaScript Transformation Function

The JavaScript transformation is associated with an input stream, from which it reads data, and an output stream, to which it writes data. Input data consists of records in byte array form. The output is a
ByteArrayOutputStream
object.
To transform the input data and write the transformed data to the output stream, in the Administrator tool, create a JavaScript program. You can use the default
transform
function. From the body of the
transform
function, call the methods that you require.
Use the
transform
function to perform the following tasks:
  • Read operations from the input and write operations to the output without an intermediate byte array-to-string conversion. Use simple read and write operations if you want to only append or prepend strings to the input.
  • Read the byte array from the input as a string and write the string to the output as a byte array. Use read and write operations that convert from and to a byte array form if you want to transform the data.
  • Transform the record.
The
transform
function has the following signature:
function transform(input, output, utility){ //TODO:Add your function code here }
The
transform
function accepts the following arguments:
input
Input data stream in byte array form.
output
ByteArrayOutputStream
object to which you write transformed data as a byte array.
utility
Built-in utility class that includes methods for the read and write operations that you require to transform data and methods to append LF and CRLF delimiters.
The
utility
class includes the following Java methods:
  • getBytes(String str)
    . Convert a text string to a byte array.
  • getString(byte[] bytes)
    . Convert a byte array to a text string.
  • getBytesForLF()
    . Get the raw byte sequence of the line feed delimiter.
  • getBytesForCRLF()
    . Get the raw byte sequence of the carriage return line feed delimiter.
You can also use your own methods instead of the methods in the
utility
class. For example, you can add a method if you want to add delimiters other than the line feed and carriage return line feed delimiters. Define your own methods in the
transform
function, and then call the methods from the
transform
function, as shown in the following example:
function transform(input, output, utility) { //funtion body // Call to custom function MyFunction1 myFunction1(); // Call to custom function MyFunction2 myFunction2(); // Definition of custom function myFunction1 function myFunction1(a,b){ // myFunction1 body } // Definition of custom function myFunction2 function myFunction2(c,d){ // myFunction2 body } }
Apply Transformation On
Select the source service, target service, or aggregator on which you want to apply the transformation.
Statistics
You can collect and monitor the following statistics:
  • Events Received
  • Bytes Received
  • Events Generated
  • Bytes Sent
  • Time Taken for Transformation (Milliseconds)
If you want to validate the JavaScript program, you must use a third-party tool.
EDS
does not validate the JavaScript program. The JavaScript transformation does not support the
print
,
let
and,
of
functions.

Sample Function to Append Line Feed Delimiter

The following JavaScript function appends the line feed delimiter to each record:
function transform(input, output, utility) { //Write the input to the output for(j = 0; j< input.length; j++){ output.write(input[j]); } //Add a line feed delimiter output.write(utility.getBytesForLF()); }

Sample Function to Append String

The following JavaScript function appends a string
myString
to the input byte array:
function transform(input, output, utility) { var string = utility.getString(input); var textToAdd = "myString "; var newString = textToAdd.concat(string); output.write(utility.getBytes(newString)); }

0 COMMENTS

We’d like to hear from you!