The classic OGSA-DAI data integration scenario deals with the issue of performing a SQL join operation between tables in two different databases. In this page, you will learn how to join a set of XML documents from an XML database with a relational table.
This page will guide you through the following steps:
Below you will find an example solution. You'll need to use threads in order to start both requests at once (or you could write two programs and pass the parameters manually). Make sure that the request which waits for the data is started first.
String handle = "http://HOST:PORT/wsrf/services/ogsadai/DataService"; String sinkID = "MySQLResource"; String sourceID = "XindiceResource"; DataService sinkService = WSRFServiceFetcher.getInstance().getWSRFDataService(handle, sinkID); DataService sourceService = WSRFServiceFetcher.getInstance().getWSRFDataService(handle, sourceID);
String tableName = "mytable"; String createTable = "create table if not exists " + tableName + " (id INTEGER, name VARCHAR(64), " + "address VARCHAR(128), phone VARCHAR(20))"; SQLUpdate create = new SQLUpdate( createTable ); sinkService.perform( create );
XPathQuery query = new XPathQuery("/entry[@id<50]");
XSLTransform transform = new XSLTransform(); transform.setXMLInput( query.getOutput() );
DeliverFromURL deliver = new DeliverFromURL( url ); transform.setXSLTInput( deliver.getOutput() );
OutputStreamActivity outputStream = new OutputStreamActivity(); outputStream.setInput(transform.getOutput());
ActivityRequest sourceRequest = new ActivityRequest(); sourceRequest.addActivity( deliver ); sourceRequest.addActivity( query ); sourceRequest.addActivity( transform ); sourceRequest.addActivity( outputStream );
sourceService.perform( sourceRequest );
DeliverFromDT deliverFromDT = new DeliverFromDT(); deliverFromDT.setDataTransportURL( sourceService.getURL() ); deliverFromDT.setDataTransportResourceID( sourceService.getResourceID() ); deliverFromDT.setDataTransportStreamID( outputStream.getName() ); deliverFromDT.setDataTransportMode( DataTransportMode.BLOCK ); SQLBulkLoad bulkload = new SQLBulkLoad( deliverFromDT.getOutput(), tableName ); sinkRequest = new ActivityRequest(); sinkRequest.addActivity( deliverFromDT ); sinkRequest.addActivity( bulkload );
Response sinkResponse = sinkService.perform(sinkRequest);
See examples/tutorials/clienttoolkit/DataIntegrationExample.java for the complete code.
Back: Asynchronous Delivery | Up: Using the Client Toolkit | |
© International Business Machines Corporation, 2004. | © The University of Edinburgh, 2004. |