Table of Contents. Tutorial API Deployment Prerequisites... 1

Similar documents
Tutorial 19 - Remotely Debugging Projects

Table of Contents. Tutorial The Basics Prerequisites Concepts... 1 Information... 1 Learning Objectives... 2

Table of Contents. Installation Preface... 1 Prerequisites... 1 Installation Procedure... 1

Table of Contents. Tutorial

Table of Contents. Tutorial Functions and Hash Maps Prerequisites Concepts... 1 Information... 1

NetBeans IDE Java Quick Start Tutorial

SAS Model Manager 2.2. Tutorials

ActiveSpaces Transactions. Quick Start Guide. Software Release Published May 25, 2015

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

Deploying a System Center 2012 R2 Configuration Manager Hierarchy

Achieve Patch Currency for Microsoft SQL Server Clustered Environments Using HP DMA

Adding Existing Source Code in NetBeans CS288, Autumn 2005 Lab 002

BEA WebLogic. Server. MedRec Clustering Tutorial

INF160 IS Development Environments

Standardize Microsoft SQL Server Cluster Provisioning Using HP DMA

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Technical Note: LogicalApps Web Services

Drawing Manager 2.5.1

Implementing a Persistent Identifier Module in MDM Multidomain Edition

Using Knowledge Management Functionality in Web Dynpro Applications

AccessVia Publishing Platform

BEA WebLogic. Adapter for HL7. Installation and Configuration Guide for WebLogic Integration 7.0

SAS Drug Development. SAS Macro API 1.3 User s Guide

Perceptive Connect. Installation and Setup Guide. Beta version: Compatible with ImageNow, versions 6.6.x and 6.7.x

Veritas NetBackup and Oracle Cloud Infrastructure Object Storage ORACLE HOW TO GUIDE FEBRUARY 2018

Quick Start Guide For Ipswitch Failover v9.0.1

SAS 9.2 Foundation Services. Administrator s Guide

WebSphere MQ V7 STEW. JMS Setup Lab. October 2008 V2.3

BEA WebLogic. Adapter for . Installation and Configuration Guide for WebLogic Integration 7.0

Connect Install Guide


SharePoint Portal Server 2003 Advanced Migration Scenarios

1. Go to the URL Click on JDK download option

Installation Guide Worksoft Certify

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Ocean Wizards and Developers Tools in Visual Studio

SAS 9.4 Foundation Services: Administrator s Guide

EMC Documentum Composer

Administering SAS Enterprise Guide 4.2

BEA WebLogic Mobility Server Installation Guide

Hotfix 913CDD03 Visual Data Explorer and SAS Web OLAP Viewer for Java

Schlumberger Private Customer Use

ASSIGNMENT 5 Objects, Files, and More Garage Management

COMP 250 Winter 2011 Reading: Java background January 5, 2011

Content Matrix. Evaluation Guide. February 12,

SAP NetWeaver Identity Management Identity Center. Implementation guide. Version 7.2 Rev 4. - Extension Framework

In this lab, you will build and execute a simple message flow. A message flow is like a program but is developed using a visual paradigm.

OpenClinica: Towards Database Abstraction, Part 1

BEA Liquid Data for. WebLogic. Deploying Liquid Data

Using SQL Reporting Services with isupport

AppDev StudioTM 3.2 SAS. Migration Guide

Using the JSON Iterator

InQuira Analytics Installation Guide

Generic architecture

Installation, Upgrade, and Setup Guide Version: 10.2

Creating Your First Web Dynpro Application

Certified Core Java Developer VS-1036

WebSphere Message Broker. Programming

Publishing and Subscribing to Cloud Applications with Data Integration Hub

Elixir Repertoire Designer

CHANGING IP ADDRESS OF PERSYSTENT SERVER

Data Ingestion Service. SDK Development Guide. Issue 03 Date HUAWEI TECHNOLOGIES CO., LTD.

SAS Model Manager 2.3

Advanced Java Programming

CS506 Web Design & Development Final Term Solved MCQs with Reference

Perceptive TransForm E-Forms Manager

Kinetica 5.1 Kinetica Installation Guide

Sage X3 Intelligence Financial Reporting. Installation and Upgrade Guide

BEAWebLogic. Portal. MobileAware Interaction Server Installation Guide

Creating Domain Templates Using the Domain Template Builder 11g Release 1 (10.3.6)

TIBCO Spotfire Statistics Services Release Notes

Informatica ActiveVOS

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about?

Installing TimeMap User Guide

Installation Instructions for Release 5.1 of the SAS Performance Management Solutions

TIBCO MDM Studio UI Builder Tutorial

Contents Overview... 5 Upgrading Primavera Gateway... 7 Using Gateway Configuration Utilities... 9

Symantec Ghost Solution Suite Web Console - Getting Started Guide

Creating a SQL Service with IBM WebSphere Portlet Factory. Introduction to creating services from a relational database

ASSIGNMENT 5 Objects, Files, and a Music Player

FuegoBPM TM Enterprise Process Orchestration Engine Configuration Instructions for a JVM Engine

BLUEPRINT TEAM REPOSITORY. For Requirements Center & Requirements Center Test Definition

Synerion Direct Installation Guide

Terracotta Installation Guide

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Cloud Attached Storage

Intelligence on Demand. Elixir Report Migration Guide

NETWRIX INACTIVE USER TRACKER

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

TIBCO BusinessEvents Extreme. System Sizing Guide. Software Release Published May 27, 2012

TIBCO Jaspersoft running in AWS accessing a back office Oracle database via JDBC with Progress DataDirect Cloud.

PART 1. Eclipse IDE Tutorial. 1. What is Eclipse? Eclipse Java IDE

Informatica ActiveVOS

Deploying Windows Server 2003 Internet Authentication Service (IAS) with Virtual Local Area Networks (VLANs)

Cookbook for using SQL Server DTS 2000 with.net

Getting Started Tutorial - Eclipse Edition. Sybase Unwired Platform 1.2

Module Road Map. 7. Version Control with Subversion Introduction Terminology

SAP NetWeaver Identity Management Virtual Directory Server. Tutorial. Version 7.0 Rev 4. - Accessing LDAP servers

SAS AppDev Studio TM 3.4 Eclipse Plug-ins. Migration Guide

Transcription:

Copyright Notice All information contained in this document is the property of ETL Solutions Limited. The information contained in this document is subject to change without notice and does not constitute a commitment on the part of ETL Solutions Limited. No part of this document may be reproduced in any manner, including storage in a retrieval system, transmission via electronic means or other reproduction medium or method (electronic, mechanical, photocopying, recording or otherwise) without the prior written permission of ETL Solutions Limited. 2013 ETL Solutions Limited. All rights reserved. All trademarks mentioned herein belong to their respective owners. i

Table of Contents Tutorial 18... 1 API Deployment... 1 Prerequisites... 1 Information... 1 Exercise 1 - Create the Example Projects... 2 Exercise 2 - Build Your Projects... 4 Exercise 3 - Create the File... 5 Exercise 4 - Add the Main Method... 5 Running the Transformation System... 5 Exercise 5 - Initialisation... 6 Exercise 6 - Create the New Transformer... 6 Exercise 7 - Set Up the Source Adapter... 7 Exercise 8 - Set Up the Target Adapter... 9 Exercise 9 - Initialise the data in TMTransformer... 10 Exercise 10 - Run the Transformation Project... 12 Exercise 11 - Database Connections... 14 ii

Tutorial 18 API Deployment This tutorial shows you how to initiate your transformation projects using java code. This mechanism is known as "short lived" mode which mimics the execution of a project in TM Migrator; that is, the project is initiated and runs to completion. You will need Java development skills in order to implement this deployment and, in essence, the tutorial is more an explanation than a set of exercises to complete. By the end of the tutorial you should be familiar with the steps required to implement a transformation project. The example code used in this tutorial is built up step by step in a single java file and is distributed with the tutorial resources in the following directory. [TMHOME]\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Short The tutorial will begin by deploying a project that uses an XML data model for both the source and target. The deployment code will then be modified to use a different project with a database as the target data store. In the exercises where your code is being edited the text in bold represents the code added to your Java file at each step. Prerequisites Before starting this tutorial we recommend that you have completed the following tasks. 1) Transformation Manager has been installed. 2) An appropriate license has been installed. 3) The tutorial resources including data models, samples and source and target data stores have been downloaded and extracted to your Transformation Manager home directory. 4) You have completed tutorials 1, 2, 3, 4 and 6. 5) You should have completed one of the following tutorials, 5, 7, 8, 9, 11, 13 or 16. 6) You may have completed tutorial 14 or 15. Information The starting point for the tutorial is to create two projects in TM Designer that we will use to demonstrate initiating the projects from java code. The first project uses an XML source and and transforms to an XML target. The second project uses the same XML source and transforms to a database target. The projects will be created using the Import... option from the File menu bar. Throughout the exercises you will see the term [TMHOME] used in the java code. You will need to replace this with your own path to [TMHOME]. Tutorial 18 API Deployment 1

Exercise 1 - Create the Example Projects This exercise will import the two example projects into your TM Designer repository which we will use for demonstration purposes in this tutorial. 1) Click on the File menu bar item. 2) Click on the Import... option to open the Import Wizard dialog as shown below. 3) Click the button to open the Select File window. 4) Navigate to the ShortLivedExamples.zip file. This can be found in the following directory. [TMHOME]\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Short 5) Click the button to paste the destination and file name into the Import File field. The window should look like the one below. 6) Click the button to move to the Select Projects pane. 7) Click the button to select both of the projects listed, ShortLivedXML and ShortLivedDB as shown below. Tutorial 18 Exercise 1 - Create the Example Projects 2

8) Click the button to move to the Select Procedures pane. There should be none to select. 9) Click the button to move to the Select Models pane. The required models will be selected automatically. 10) Click the button to move to the Summary pane. Review the information present. It should look like the image below. The items listed in the Summary pane may not be exactly as shown below. This is because the items listed here must not already exist in the currently open repository. You may notice that the Books v1 model is not displayed because this will probably already exist in your repository. 11) Click the button to complete the import process. Our projects are now in the repository and we can start to create the java file. Tutorial 18 Exercise 1 - Create the Example Projects 3

Exercise 2 - Build Your Projects Now we must build our projects so we create the jar files for each of our projects. 1) Move your mouse pointer so that it is over the title of the project ShortLivedXML v1 and use the right mouse or secondary mouse button to display the context menu. 2) Click once on the Build option from the menu. 3) The Output pane will open and show you if there are any errors in your transform code. In this exercise you should not have any error messages and you should see a message stating Build successful. 4) Move your mouse pointer so that it is over the title of the project ShortLivedDB v1 and use the right mouse or secondary mouse button to display the context menu. Tutorial 18 Exercise 2 - Build Your Projects 4

5) Click once on the Build option from the menu. 6) The Output pane will open and show you if there are any errors in your transform code. In this exercise you should not have any error messages and you should see a message stating Build successful. 7) This will have created two jar files called ETL_ShortLivedXML_1_0.jar and ETL_ShortLivedDB_1_0.jar in the [TMHOME]\jar directory. Exercise 3 - Create the File We start with the outline of a java file containing the main building blocks of any application. Begin by defining the package and class for your deployed code. package shortlived; public final class ShortLived public ShortLived() Exercise 4 - Add the Main Method As the entire example will be self-contained in a single file we also add a main method in order to run the application. The main method below contains a single line to create an instance of the ShortLived object. Notice that the constructor has been made private, as we are only calling it from the main method. package shortlived; public final class ShortLived public static void main(string[] args) ShortLived ashortlived = new ShortLived(); private ShortLived() Now these steps are complete, the actual methods to execute the transforms can be considered. Running the Transformation System As running transformations in Short Lived mode is straightforward, we will only require a single method that will run the transforms. Tutorial 18 Exercise 3 - Create the File 5

For the purpose of this example, the source will be taken from an XML file, with the data also being written to a target XML file. Exercise 5 - Initialisation Add the outline of the method runproject and configure the Transformation Manager Licence. package shortlived; import org.apache.log4j.logger; import net.etltm.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); public static void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); The code above uses Log4j to manage logging. The jar file for Log4j is included in the Transformation Manager installation. If Transformation Manager is installed in its default location the jar will be located in C:\Program Files\TM Suite\libs\log4j-1.2.15.jar. This jar must be included in the class path. Along with creating a skeleton method that will contain the code to run the project, the constructor of the ShortLived class has been modified to setup the Transformation Manager licence. Transformation Manager licensing needs to be set before the rest of the deployment API is used. In this tutorial the folder [TMHOME]\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Short will be used to store resources. If you already have Transformation Manager installed and licensed then it is possible to make a copy of the licence. The default location for the etltm.lic file is [TMHOME]\etc\etltm.lic. Once the etltm.lic file has been located copy etltm.lic to the directory. You may also create your own directory elsewhere for this purpose. Exercise 6 - Create the New Transformer This step creates a new Short-lived TMTransformer object. This is the main object used to carry out the transformations that have been created using TM Designer. package shortlived; import org.apache.log4j.logger; import net.etltm.*; public final class ShortLived Tutorial 18 Exercise 5 - Initialisation 6

private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedXML"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); public static void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error("Error detected when running transform", atmexception); A TMTransformer is created using the same factory class that was previously used to set the Transformation Manager licensing. The getnewtmtransformer method takes three arguments. The first argument can be any Java object. The Java object supplied can be accessed from within your project using the built-in SML functions. In this example we are just going to supply the instance of the ShortLived object. The second argument is a String containing the name of the Transformation Manager project that will be run. In this example the project will be ShortLivedXML. Finally the version of the project is given. The getnewtmtransformer method throws TMExceptions so the method call is wrapped with a try catch statement and any errors logged using Log4j. Exercise 7 - Set Up the Source Adapter The next step is to set up the source adapter. The source adapter is used to access the source data store for transformation. package shortlived; import org.apache.log4j.logger; import net.etltm.*; import java.util.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedXML"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); /** Tutorial 18 Exercise 7 - Set Up the Source Adapter 7

* Create Source TMAdapter for supplied TMTransformer * * @param atmtransformer - TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createsourceadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmlsourceadapter = TMBuiltInAdaptorFactory.makeNewReadTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_Short\\ Source\\books.xml"); axmlsourceadapter.setinstanceconnectiondata(param); return axmlsourceadapter; public static void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); //Set Source atmtransformer.setsource(project_name, createsourceadapter(atmtransformer)); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error(null, atmexception); The source for the ShortLivedXML project is an XML data store so we will need to create and configure a TMXMLAdapter. This will be done in a new method called createsourceadapter. The method takes a TMTransformer as an argument and returns a TMAdapter. A TMXMLAdapter source object is created using the makenewreadtmxmladapter method on the TMBuiltInAdaptorFactory factory class. The method has only one argument, which is a TMTransformer object and returns a new TMXMLAdapter object. Now that a TMXMLAdapter has been created for the TMTransformer it needs to be configured. The adapter is configured using the setinstanceconnectiondata method on the adapter object. The method takes a Map that contains the configuration options. For the TMXMLAdapter we only need to specify the XML file that should be used by the adapter. Let's use the source for the tutorial which is in C:\Users\uc\TM\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Short\Source. Now the adapter is configured the final step is to set it as the source adapter on the TMTransformer object. The source adapter is set using the setsource method on the TMTransformer object. The setsource method takes two arguments, project name and the TMAdapter object. Tutorial 18 Exercise 7 - Set Up the Source Adapter 8

Exercise 8 - Set Up the Target Adapter The target adapter is created in a similar fashion to the source adapter. package shortlived; import org.apache.log4j.logger; import net.etltm.*; import java.util.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedXML"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); /** * Create Source TMAdapter for supplied TMTransformer * * @param atmtransformer - TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createsourceadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmlsourceadapter = TMBuiltInAdaptorFactory.makeNewReadTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment _Short\\Source\\books.xml"); axmlsourceadapter.setinstanceconnectiondata(param); return axmlsourceadapter; /** * Create Target TMAdapter for supplied TMTransformer * * @param atmtransformer- TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createtargetadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmltargetadapter = TMBuiltInAdaptorFactory.makeNewWriteTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment _Short\\Target\\target.xml"); axmltargetadapter.setinstanceconnectiondata(param); return axmltargetadapter; public static public void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer Tutorial 18 Exercise 8 - Set Up the Target Adapter 9

TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); //Set Source atmtransformer.setsource(project_name, createsourceadapter(atmtransformer)); // Set Target atmtransformer.settarget(project_name, createtargetadapter(atmtransformer)); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error(null, atmexception); The ShortLivedXML project uses an XML file for the target. Creating and configuring the target adapter will be done in a new method, createtargetadapter. Like the createsourceadapter it takes a TMTransformer object as an argument and returns a TMAdapter. The first difference is that the makenewwritetmxmladapter method is used on the TMBuiltInAdaptorFactory factory class, instead of the makenewreadtmxmladapter used by the createsourceadapter method. The other difference is that the value in the transform used to configure the adapter points to a different file. Now that the target adapter has been created and configured we need to set it as the source adapter on the TMTransformer object. The target adapter is set using the settarget method on the TMTransformer object. The settarget method takes two arguments, project name and the TMAdapter object. Exercise 9 - Initialise the data in TMTransformer Now the Source and Target Adapters have been created and the source and target xml files have been specified to the respective adapters, the TMTransformer object can open the required information. package shortlived; import org.apache.log4j.logger; import net.etltm.*; import java.util.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedXML"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); /** * Create Source TMAdapter for supplied TMTransformer * * @param atmtransformer - TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createsourceadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmlsourceadapter = TMBuiltInAdaptorFactory.makeNewReadTMXMLAdapter(aTMTransformer); Tutorial 18 Exercise 9 - Initialise the data in TMTransformer 10

Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment _Short\\Source\\books.xml"); axmlsourceadapter.setinstanceconnectiondata(param); return axmlsourceadapter; /** * Create Target TMAdapter for supplied TMTransformer * * @param atmtransformer- TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createtargetadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmltargetadapter = TMBuiltInAdaptorFactory.makeNewWriteTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\Source_and_Target\\Tutorial_18_API_Deployment_ Short\\Target\\target.xml"); axmltargetadapter.setinstanceconnectiondata(param); return axmltargetadapter; public static public void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); //Set Source atmtransformer.setsource(project_name, createsourceadapter(atmtransformer)); // Set Target atmtransformer.settarget(project_name, createtargetadapter(atmtransformer)); //Open the project information along with the source //and target adapter information atmtransformer.openprojectandresources(); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error(null, atmexception); This is simply done in a single line that opens the transformation project information and the source and target file information. Tutorial 18 Exercise 9 - Initialise the data in TMTransformer 11

Exercise 10 - Run the Transformation Project The final line to be added executes the project and its transformations taking the data from the source data store and writing it to the target data store following the business logic defined using TM Designer. package shortlived; import org.apache.log4j.logger; import net.etltm.*; import java.util.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedXML"; private ShortLived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); /** * Create Source TMAdapter for supplied TMTransformer * * @param atmtransformer - TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createsourceadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmlsourceadapter = TMBuiltInAdaptorFactory.makeNewReadTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment _Short\\Source\\books.xml"); axmlsourceadapter.setinstanceconnectiondata(param); return axmlsourceadapter; /** * Create Target TMAdapter for supplied TMTransformer * * @param atmtransformer- TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createtargetadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmltargetadapter = TMBuiltInAdaptorFactory.makeNewWriteTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Sh ort\target\\target.xml"); axmltargetadapter.setinstanceconnectiondata(param); return axmltargetadapter; public static public void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Tutorial 18 Exercise 10 - Run the Transformation Project 12

Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); //Set Source atmtransformer.setsource(project_name, createsourceadapter(atmtransformer)); // Set Target atmtransformer.settarget(project_name, createtargetadapter(atmtransformer)); //Open the project information along with the source //and target adapter information atmtransformer.openprojectandresources(); //run the transform atmtransformer.runalltransforms(); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error(null, atmexception); At this point you can now open the target.xml file to see how your project has transformed the data from the books.xml source data store. In order to run the Java file created using the above steps, ensure you have the following in your classpath. ofetsdo.jar tmglobals.jar tmsaxon-2.4.jar tmstats.jar tmutils.jar tmvalues jar log4j jar jackson-annotations-2.0.5.jar jackson-core-2.0.5.jar Tutorial 18 Exercise 10 - Run the Transformation Project 13

jackson-databind-2.0.5.jar jackson-dataformat-smile-2.0.5.jar ETL_ShortLivedXML_1_0.jar (assuming that the project was built in Exercise 2 of this tutorial) Default location [TMHOME]\jar\ETL_ShortLivedXML_1_0.jar Exercise 11 - Database Connections We will now modify the deployment code to use a different project called ShortLivedDB which has a database as the target data store. package shortlived; import org.apache.log4j.logger; import net.etltm.*; import java.util.*; public final class ShortLived private static final String TM_LICENCE_FILE = "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment_ShortDe ployment\\etltm.lic"; private static final String PROJECT_NAME = "ShortLivedDB"; private Shortlived() TMTransformerFactory.setTMLicenseLocation(TM_LICENCE_FILE); /** * Create Source TMAdapter for supplied TMTransformer * * @param atmtransformer - TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createsourceadapter(tmtransformer atmtransformer) throws TMException TMXMLAdapter axmlsourceadapter = TMBuiltInAdaptorFactory.makeNewReadTMXMLAdapter(aTMTransformer); Map param = new HashMap(); param.put(tmxmladapter.name_url, "[TMHOME]\\Tutorials\\Source_and_Target\\Tutorial_18_API_Deployment _Short\\Source\\books.xml"); axmlsourceadapter.setinstanceconnectiondata(param); return axmlsourceadapter; /** * Create Target TMAdapter for supplied TMTransformer * * @param atmtransformer- TMTransformer to use * @return TMAdapter created * @throws TMException */ private TMAdapter createtargetadapter(tmtransformer atmtransformer) throws TMException TMJDBCAdapter atmjdbcadapter = TMBuiltInAdaptorFactory.makeNewWriteTMJDBCAdapter(aTMTransformer); Map param = new HashMap(); Tutorial 18 Exercise 11 - Database Connections 14

param.put(tmjdbcadapter.name_url, "jdbc:derby:[tmhome]\\tutorials\\source_and_target\\tutorial_18_api _Deployment_Short\\Target\\ShortLivedDB\\books"); param.put(tmjdbcadapter.name_driver, "org.apache.derby.jdbc.embeddeddriver"); atmjdbcadapter.setinstanceconnectiondata(param); return atmjdbcadapter; public static public void main(string[] args) ShortLived ashortlived = new ShortLived(); ashortlived.runproject(); private void runproject() Logger.getLogger(ShortLived.class).info("Short Lived Deployment Example"); try //Create Short-lived TM Transformer TMTransformer atmtransformer = TMTransformerFactory.getNewTMTransformer(this, PROJECT_NAME, 1); //Set Source atmtransformer.setsource(project_name, createsourceadapter(atmtransformer)); // Set Target atmtransformer.settarget(project_name, createtargetadapter(atmtransformer)); //Open the project information along with the source //and target adapter information atmtransformer.openprojectandresources(); //run the transform atmtransformer.runalltransforms(); catch (TMException atmexception) Logger.getLogger(ShortLived.class).error(null, atmexception); As the creation and configuration of the target adapter is in its own method the changes to the target adapter are limited to that method. The first difference is that we use the makenewwritetmjdbcadapter method on the TMBuiltInAdaptorFactory factory class. As the other methods we have used on the TMBuiltInAdaptorFactory factory class it takes a TMTransformer object as an argument and returns the adapter object. Since the new target adapter is a database adapter the configuration option needs to be changed. The configuration now contains the JDBC settings required to connect to the database. The database we will use is in the following directory. [TM]\Tutorials\Source_and_Target\Tutorial_18_API_Deployment_Short\Target\Sh ortliveddb\books We also need to change the constant that contains the project name from ShortLivedXML to ShortLivedDB. After you have executed the transform you will be able to see how your data has been transformed between the books.xml source data store and the books target data store which is a Derby database. You can view the database using TM Designer or an external database query tool. Tutorial 18 Exercise 11 - Database Connections 15

In order to run the updated Java file created using the above step the following jars need to be on the class path. ofetsdo.jar tmglobals.jar tmsaxon-2.4.jar tmstats.jar tmutils.jar tmvalues jar log4j jar jackson-annotations-2.0.5.jar jackson-core-2.0.5.jar jackson-databind-2.0.5.jar jackson-dataformat-smile-2.0.5.jar derby-10.4.2.0.jar ETL_ShortLivedDB_1_0.jar (assuming that the project was built in Exercise 2 of this tutorial) Default location [TMHOME]\jar\ETL_ShortLivedDB_1_0.jar Tutorial 18 Exercise 11 - Database Connections 16