ODI - Integrating more social data

Carrying on from the earlier post on integrating social data from Facebook Graph API, the functions you need to integrate JSON are here for download. I have wrapped into 2 functions, there is a readme in the zip describing what you need to do;

  1. JSON_to_XML
  2. Zipped_JSON_to_XML

After you have imported the ODI user functions you can then easily call them from your code; in ODI procedures for example. For example I have a procedure with a Groovy task that simply calls the function as;

  • JSON_to_XML("http://graph.facebook.com/search?q=exadata&type=post", "D:\\output\\fb_exadata.xml", "", "facebook");

The first parameter is a URI (not a regular filesystem path) representing the input data to be processed, and the second parameter is a filesystem path representing the generated file. The 3rd and 4th parameters are for configuring the XML generated, the unnamed element and root node names.

Here is an example of a zipped input taken from the filesystem;

  • Zipped_JSON_to_XML("file:///D:/input/fb_exadata.zip", "D:\\output\\fb_exadata.xml", "", "facebook");

The download is on the ODI user function samples download on the Java.net site. Its a community area, so try it out, make changes, and let me know how it goes. There are a few challenges in the process with names from JSON to XML, so the code has some support for that but could be better.

The 3rd and 4th parameters let us handle JSON with arrays of unnamed elements;

  • [{"id":"345", "name":"bob"},{"id":"123", "name":"jim"}]

so we can generate the following XML passing company as the 3rd parameter for the array name and emp as the unnamed element parameter, most commonly only the 4th parameter needs a value;

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <company>
  3. <emp><id>345</id><name>bob</name></emp>
  4. <emp><id>123</id><name>jim</name></emp>
  5. </company>

There's a few other posts I will share when I get a moment, including using named pipes and an expert for specific technologies (such as XML). I did this post for fast model creation which is very useful for relational oriented systems, but for XML we can have a much more specific one incorporating much of the sensible defaults and an option for using a system other than in-memory.

Comments:

Hi David,

I am unable to download the zip file. If I click on the link , I am getting redirected to https://home.java.net/

Let me know where to find this.
Thanks

Posted by Bhabani on August 07, 2013 at 07:39 AM PDT #

Hi Bhabani

If you create a java.net account it will download OK. There are other artifacts worth checking out in the ODI shared area on java.net from others and the PM team.

Cheers
David

Posted by David on August 07, 2013 at 08:00 AM PDT #

Yes I am logged in. But no lock yet. Also I am getting some kind of error when I click on my name " welcome bhabaniranjan" on top right corner.

You are not allowed to do that (read, or write, or update, or delete downloads)

Posted by Bhabani on August 07, 2013 at 08:53 AM PDT #

Hi Bhabani

You should be able to login and navigate to the OracleDI project, you can use the link below, this will take you to the User Functions section where you should see the JSON XML download;

https://java.net/projects/oracledi/downloads/directory/ODI/User%20Functions

Cheers
David

Posted by David on August 07, 2013 at 08:58 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Learn the latest trends, use cases, product updates, and customer success examples for Oracle's data integration products-- including Oracle Data Integrator, Oracle GoldenGate and Oracle Enterprise Data Quality

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
4
5
6
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today