How to generate a star pattern using Informatica with a Java Transformation

This post is in continuation to my earlier post where I described how to generate a star pattern without using a Java transformation. In this post I will describe the method to generate this pattern using Java transformation.

Just for the benefit of readers who have not read my previous post, below is the description of the problem which we will solve using a Java transformation this time.

Question:- To generate a star pattern using Informatica depending on the number of rows in the input file

Suppose there are 7 rows in the source file (any type of data),  the target should have 7 rows of stars in the following pattern:-



Solving this problem using java transformation is easier than the solution i presented without java transformation in my previous post here.

In this mapping also we will have one pipeline to get the row count of the file using aggregator and set it into a mapping variable.

Second pipeline will use a java transformation and some java code magic to generate the required pattern.

Below is the complete mapping screenshot


Mapping explanation:-

Pipeline 1:- To get the row count in the file. We will use an aggregator to get the count of the rows in the file and an expression to set this count into a mapping variable. Below are the screenshots of the aggregator and the expression used



Pipeline 2:- Here we use the row count, generate a row sequence in and expression and then pass these two values to the java transformation.


Use Java transformation in Passive mode and create following input and output ports


Use below code to generate the star pattern and connect the finalPattern port to target.


The code snippet used above is pasted below:-

starpattern = "";
spacepattern = "";

for (int i =0; i < sequence ; i++){

starpattern = starpattern + “*”;


for (int j =0; j< rowcount – sequence; j++){

spacepattern = spacepattern + ” “;


for (int i =1; i < sequence ; i++){

starpattern = starpattern + “*”;


finalPattern = spacepattern + starpattern;

Well that is all about solving this problem using a java transformation.

let me know in comments if you need any clarifications.

Leave a comment

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