ObjectOriented Software l l l l How does

Object-Oriented Software l l l l How does it differ from procedural? How is it similar to procedural? Why has it become so popular? Does it replace or supplement procedural? What is the point? Why bother? Is it here to stay or gone tomorrow?

An Object-Oriented Program (OOP) l l Is composed of a collection of individual units called objects which package data and functionality together, rather than of lists of instructions which act on external data. Each object is capable of: – – – receiving calls from other objects to run methods, executing its own methods, and sending calls to run methods in other objects.

What is an Object in OOP? l l An object is a software construct that bundles together data (state) and function (behavior) which, taken together, represent an abstraction of a thing, event, service, etc. An object is an instance of a class. A class models a group of things, events, services, etc. ; an object models a particular member of that group.

What is in a Class (or Object)? l l A class contains attributes and methods. Attributes describe state; methods perform actions. Attributes may be Java primitives, or objects (strings, dates, arrays, other objects, etc). Methods may be instance methods, which only work when the class is instantiated as an object, or static methods, which may be used independently of class instantiation.

Objected-Oriented vs. Procedural l l Both types of language use structured programming logic; the logical architecture of a Java method will resemble that of an ILE RPG procedure. The main difference is macro-architecture: – – With OO, logic and data reside together in objects OO design focuses on object relationships and interactions rather than code block relationships

Java Source and Object Files l Compilation Units (. java files) – – l With a main method Without a main method Java Bytecode (. class files) – – Compilation-level class files Nested class files

Glazers Interfaces Package l l l What is a Java package? com. glazers. interfaces package Five compilation units: – – – Get. Open. PO – import open POs Get. Inter. Co – import intercompany transfers Get. Open. CO – import open customer orders Function – class of static methods Log. Maker – class to make log object

Examples of Java Files Function. java Function. class Get. Open. PO. java Get. Open. PO. class Import. Open. PO. class

More Examples of Java Files Log. Maker. java Log. Maker. class Log. Maker$Print. Ending. class Log. Maker$Print. Heading. class Log. Maker$Print. Line. class Log. Maker$Print. Methods. class

Integration ETL Program Structure l Five Basic Steps – – – Open log file and database connections Extract the result set from source system Transform any data items Load the data batch in target system Close log file and database connections

What are the Objects? l l l Log Object Database Connection Objects SQL Statement Objects Result Set Objects Batch. Insert Objects String and Date Objects

The Code Environment package com. glazers. interfaces; import java. io. *; import java. sql. *; import java. util. *; import com. ibm. as 400. access. *; import com. javaranch. common. GDate; import com. javaranch. common. JDate; import com. glazers. interfaces. *;

Get. Open. PO Class and main public class Get. Open. PO { public static void main(String args[]) { // Create an Import. Open. PO object Import. Open. PO imp. Obj = new Import. Open. PO();

Full main method // Create an Import. Open. PO object Import. Open. PO imp. Obj = new Import. Open. PO(); // Call the main. Line and receive its return code System. exit(imp. Obj. main. Line(args[0], args[1], args[2], args[3], args[4], args[5]));

Comments // The main method for class Get. Open. PO takes six parameters: // 1) Log File Directory Path (ex. Home/Java. Apps/Manu) // 2) Oracle Database Name (SCPODEV, SCPOTEST, etc. ) // 3) Oracle User. ID // 4) Oracle Password // 5) AS/400 User. ID // 6) AS/400 Password // After creating an Import. Open. PO object, these parameters are // passed to its main. Line method.

Import. Open. PO Class & main. Line class Import. Open. PO { public int main. Line (String dir. Path, String ora. SID, String ora. User, String ora. Pwd, String as 400 User, String as 400 Pwd) {
![Import. Open. PO Code Structure l l l l l try [outer try/catch block] Import. Open. PO Code Structure l l l l l try [outer try/catch block]](http://slidetodoc.com/presentation_image_h2/9879300416d137b93e31e5795c4e7b34/image-17.jpg)
Import. Open. PO Code Structure l l l l l try [outer try/catch block] [start the log] try [inner try/catch block] open database connections extract result set from source system perform any data transformations load data batch into target system close database connections catch [catch inner exceptions] catch [catch outer exceptions]

Outer try statements try { // Create Log. Maker object and begin logging Log. Maker log = new Log. Maker(dir. Path, "Open. PO. log"); log. print. Heading("Open PO Import Log"); // If run interactively, display running message System. out. println ("Open PO Import is running");

Inner try block job steps l l Open database connections Create Sql statement objects Extract the result set Loop throught the result set: – – – l Check error table for any rejects – l Extract the data items from result set object Perform any data transformation Set the data into the batch. Insert object If any rejects, print rejects to log Close result sets and database connections

Connect to the i. Series // Register the AS 400 JDBC Driver. Manager. register. Driver(new AS 400 JDBCDriver()); // Create a properties object and connect to the database Properties as 400 Prop = Function. get. AS 400 Prop(as 400 User, as 400 Pwd); conn 400 = Driver. Manager. get. Connection ("jdbc: as 400: //GLAZERS", as 400 Prop);

Connect to Oracle // Load the Oracle JDBC driver Class. for. Name("oracle. jdbc. driver. Oracle. Driver"); // Get the Oracle connection string String ora. Conn. Str = Function. get. Ora. Conn. Str(ora. SID, ora. User, ora. Pwd); // Connect to the database server conn. Ora = Driver. Manager. get. Connection(ora. Conn. Str); conn. Ora. set. Auto. Commit(false);

Extracting the Result Set // Get the SQL statement to assign to the stmt 400 sql. Query string String sql. Query = get. SQL(); // Create a Statement object (stmt 400) stmt 400 = conn 400. create. Statement(); // Execute the SQL Select and obtain the Result. Set object (rs) rs = stmt 400. execute. Query(sql. Query);

The Batch Insert Prepared Statement // Construct the Insert Prepared Statement before entering the loop Prepared. Statement sql. Insert = conn. Ora. prepare. Statement( "INSERT INTO INTINS_SCHEDRCPTS " + "(item, loc, scheddate, qty, expdate, ponum, " + "startdate, dateship, masterloadid, " + "integration_stamp, integration_jobid)" + "VALUES (? , ? , ? , ? )");
- Slides: 23