Wednesday, March 18, 2009

XREF Utilities

SOA suite provides a cross-reference infrastructure that can be used in integration solutions to maintain cross-references of business objects that are exchanged between various applications in the enterprise.

A set of xref tools are available to access and perform admin functions with the xref tables. The tools are – xreftool, xrefimport and xrefexport

Xreftool: The xreftool is a command line admin tool to help configure the cross-references virtual table.
Xrefimport & Xrefexport: The xrefimport and xrefexport tools can be used to help in initial data loads.

Where to find?
The tools can be located at /integration/esb/bin folder.

What are the pre-requisites?
Set OC4J_USERNAME and OC4J_PASSWORD as environment variables before using the xreftool.
Set DB_URL, DB_USER, DB_PASSWORD, OC4J_USERNAME and OC4J_PASSWORD as environment variables before using xrefimport and xrefexport.

How to execute xreftool?
Navigate to /integration/esb/bin folder.
Set OC4J_USERNAME and OC4J_PASSWORD to the login credentials of oc4j administrator.
Execute the following command: xreftool
Valid commands and arguments are:
· listColumns {tableName}
· deleteTable {tableName}
· deleteColumn {tableName columnName}
· addColumns {tableName columnName1,columnName2...}
· listTables {}
· version {}
· createTable {tableName}
· help {}

Ex: To list all the tables in the xref database:-
set OC4J_USER=oc4jadmin
set OC4J_PASSWORD=oc4jadmin
xreftool listTables

The output looks like this:
Total number of xref tables: "2"
No. TableName
--- ---------
1. ITEM95ITEMID
2. CHANGE95CHANGEID

How to execute xrefexport?
Navigate to /integration/esb/bin folder.
Set DB_URL, DB_USER and DB_PASSWORD to the xref datasource URL and xref database login credentials respectively.
Set OC4J_USERNAME and OC4J_PASSWORD to the login credentials of oc4j administrator.
Execute the following command:
xrefexport -file -table

Ex: To export rows in the Item xref table:-
set DB_URL=jdbc:oracle:thin:@atg-aiaagile:1521:ORCL
set DB_USER=aia
set DB_PASSWORD=aia
set OC4J_USER=oc4jadmin
set OC4J_PASSWORD=oc4jadmin
xrefexport –file d:\temp\Item.xml –table ITEM_ITEMID

The exported XML looks as shown below:

How to execute xrefimport?
Navigate to /integration/esb/bin folder.
Set DB_URL, DB_USER and DB_PASSWORD to the xref datasource URL and xref database login credentials respectively.
Set OC4J_USERNAME and OC4J_PASSWORD to the login credentials of oc4j administrator.
Execute the following command:
xrefimport -file [-mode ] [-generate ]

mode argument specifies the preferred way of handling the existing data in case of conflicts. "ignore" would keep the existing data and "overwrite" would overwrite the existing data with the new data. Please note that the mode will kick in only in the case of conflicts. Default is "ignore".
generate argument specifies the column name which has to be created automatically.

Ex: To import rows into the Item xref table, create an input XML in the same format as exported above and then execute the following commands:-

set DB_URL=jdbc:oracle:thin:@atg-aiaagile:1521:ORCL
set DB_USER=aia
set DB_PASSWORD=aia
set OC4J_USER=oc4jadmin
set OC4J_PASSWORD=oc4jadmin
xrefexport –file d:\temp\Item.xml

1 comment:

  1. I have tried using mode = overwrite due to a conflict but I got a unique identifier error. Is there any way to change the value of one of the columns using this tool. Take the example above, I just need to change the value of Ebiz and leave the rest as is
    Thanks

    ReplyDelete