Project Details
We will now look into some of the components in Ab Initio and the
corresponding method to achieve the same functionality in TIBCO BW.
We shall go for some simple process designs in both the tools and
visualize the basic working of these tools from a common perspective.
This is also a small step to familiarize some of the important
components in Ab Initio like the Normalize and Denormalize Sorted.
At the outset let us be clear that the processes discussed here are
quite simple and elementary. This is just to give a feel of the style of
code and approach that we need to follow together with a focus on the
analogy of the processes involved in both the tools.
Let us take the following simple XML structure for the processes that
we are going to design.
Our sole motto is to map the name tag to the city tags. To be more
precise we need to map Harry to the two cities Dallas and Bangalore.
For parsing the XML structure Ab Initio has a component akin to XML
Parser in TIBCO BW known as Read XML.
We assume that the reader is already familiar with the Hashtable
structure in Java wherein there is a concept of a key value pair
relationship. Let us take the following Hashtable kind of structure.
Key
Value
b
c
d
e
A
A
A
B
We note that the same value A is related to more than one key viz. b,
c, d. In Ab Initio such structures can be manifested into a type of data
that is termed as Vectors.
So the Vector structure in Ab Initio for the above Hashtable
representation would be
Value
Key
A
[
b,
c,
2
d ]
Please note that only the bold form is the real Vector structure.
Going by the above rule we can deduce that for our sample XML the
above structure can be put as
name
city
"Harry"
[vector
"Dallas",
"Bangalore"]
Now let us delve a bit deeper into the main component of the above
process viz. Read XML.
The Read XML uses an expat parser as default though we can also use
a xerces parser too. The important part here is to define the out port
DML which has to be imported in accordance with the XML structure
which we have defined.
We select the Record Format Source as Embed and click on the edit
button that will land us on the following screen.
After this we click on the Import XML as shown which we will give us
the following:
The filename is the actual file wherein we have used the XML
structure.
We click on the Import button and doing that would give us the
following which is in fact the actual DML which is imported from the
XML structure.
Record 1:
[record
name "Harry"
city "Dallas"]
Record 2:
[record
name "Harry"
city "Bangalore"]
type element_type =
record
string("\001") city;
end /* Element Type*/;
type denormalization_type =
element_type[3] /* Denorm vector*/;
type temporary_type =
record
decimal(4) count;
end;
Record 1:
[record
name "Harry"
city [vector
[record
city "Dallas"],
[record
city "Bangalore"]]]
10
11
package Denormalize;
import java.util.*;
import java.io.*;
public class DenormalizeJavaCodetoconverttotheHashtable{
protected String name = "";
protected String[] city = null;
protected String HTable = "";
protected int len = 0;
public String getname() {
return name;
}
public void setname(String val) {
name = val;
}
public String[] getcity() {
return city;
}
public void setcity(String[] val) {
city = val;
}
public String getHTable() {
return HTable;
}
public void setHTable(String val) {
HTable = val;
}
public int getlen() {
return len;
}
public void setlen(int val) {
len = val;
}
public DenormalizeJavaCodetoconverttotheHashtable() {
}
public void invoke() throws Exception {
Hashtable city_hash = new Hashtable();
for(int i=0;i<city.length;i++)
{
city_hash.put(city[i],name);
}
setHTable(city_hash.toString());
setlen(city.length);
}
}
12
13
The message type of the JMS Queue Sender will be Object Ref.
14
15
16
package Normalize;
import java.util.*;
import java.io.*;
public class NormalizeJavaCodeUnwraptheHashtable{
protected Object Hashtable = null;
protected String[] city = null;
protected String name = "";
protected int length = 0;
public Object getHashtable() {
return Hashtable;
}
public void setHashtable(Object val) {
Hashtable = val;
}
public String[] getcity() {
return city;
}
public void setcity(String[] val) {
city = val;
}
public String getname() {
return name;
}
public void setname(String val) {
name = val;
}
public int getlength() {
return length;
}
public void setlength(int val) {
length = val;
}
public NormalizeJavaCodeUnwraptheHashtable() {
}
public void invoke() throws Exception {
Hashtable city_hash=new Hashtable();
city_hash=(Hashtable)getHashtable();
Set city_set=city_hash.keySet();
Iterator city_cnt=city_set.iterator();
int count=0;
String name=new String();
17
while(city_cnt.hasNext())
{
city_cnt.next();
count++;
}
String[] city_arr=new String[count];
count=0;
while(city_itr.hasNext())
{
city_arr[count]=(String)city_itr.next();
name=(String)city_hash.get(city_arr[count]);
count++;
}
setlength((count+1));
setcity(city_arr);
setname(name);
}
}
The text content file in the Write file will be the following.
concat($Java-Code--Unwrap-the-Hashtable/javaCodeActivityOutput/name,"
", $Java-Code--Unwrap-the-Hashtable/javaCodeActivityOutput/city[$i])
18
19