1 Oracle EBS 12.1.3: Integrate OA Framework BC4J components within Java Concurrent program. Concurrent processing has been one of the rewarding aspect of Oracle EBS. This allows us to process millions of transactions behind the scene without any user intervention. Oracle has provided multiple avenues to design a concurrent program. One stands out of all “Java concurrent program” which uses “Java — one language, endless possibilities”. Most of background processes performs some kind of database operation. When comes to Java concurrent program, JDBC API is in practice to execute SQL operation. Oracle Application Framework (OAF) is available since many years now to help us to reduce some of the application development complexities. OAF insulates JDBC connection pool complexity within AOL/J integration code. OAF is built on MVC deign patterns where MVC stands for model-view and controller. Model-View relationship separates business/back-end logic with graphical user interface logic. This represent how do we control operation on server level object like “table inserts”. OAF provides all the bare minimal code which developer needs to write additionally to fire SELECT/INSERT/UPDATE statement. This way development team is more focus on actual task in hand which in this tutorial “ Read a XML file”. In this tutorial, I am going to demonstrate “How to use OA Framework BC4J components in Java concurrent program” to perform complex background operations like loading a data file. We are going to build a custom Java concurrent program which will read the XML file, parse it and load it into the database table. Sample XML file being used for this tutorial is provided as below.
55
Embed
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concurrent program.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Oracle EBS 12.1.3: Integrate OA Framework BC4J components within Java Concurrent program.
Concurrent processing has been one of the rewarding aspect of Oracle EBS. This allows us to process
millions of transactions behind the scene without any user intervention. Oracle has provided multiple
avenues to design a concurrent program. One stands out of all “Java concurrent program” which uses
“Java — one language, endless possibilities”.
Most of background processes performs some kind of database operation. When comes to Java
concurrent program, JDBC API is in practice to execute SQL operation. Oracle Application Framework
(OAF) is available since many years now to help us to reduce some of the application development
complexities. OAF insulates JDBC connection pool complexity within AOL/J integration code.
OAF is built on MVC deign patterns where MVC stands for model-view and controller. Model-View
relationship separates business/back-end logic with graphical user interface logic. This represent how do
we control operation on server level object like “table inserts”. OAF provides all the bare minimal code
which developer needs to write additionally to fire SELECT/INSERT/UPDATE statement. This way
development team is more focus on actual task in hand which in this tutorial “Read a XML file”.
In this tutorial, I am going to demonstrate “How to use OA Framework BC4J components in Java
concurrent program” to perform complex background operations like loading a data file.
We are going to build a custom Java concurrent program which will read the XML file, parse it and load it
into the database table. Sample XML file being used for this tutorial is provided as below.
2
System Configuration used in this demonstration.
JDeveloper 10g on Window7 4GB RAM.
Oracle Database 11.2.0.4
Oracle EBS 12.1.3 on Linux.
JDeveloper is being primarily tool used for OAF development. Before we proceed, we will have to find
out what JDeveloper version works with Oracle EBS release installed in the development environment.
Oracle has generously published this information in Metalink note#416708.1 to help us find exact
JDeveloper patch required.
I built this example on Release 12.1.3 with patch 15880118 applied which corresponds to JDeveloper
Patch# 9879989 as per below matrix available in note#416708.1.
OA Framework - How to Find the Correct Version of JDeveloper for OA Extensions to Use with
E-Business Suite 11i or Release 12.x (Doc ID 416708.1)
JDeveloper doesn’t comes with installer. Once you have downloaded the patch, you just need to
extract/unzip file at your preferred location.
As an example, I used C:\Amit\Jdev_12_1_3\ as a location to unzip\extract the patch.
3
Setup Your Development Environment
It’s important we follow all the instructions provided under section “Setting Up Your Development
Environment” in Oracle Application Framework Developer's Guide. This can save us from nuisances.
Step1: Create an environment variable “JDEV_USER_HOME” in local machine.
Step2: Add below responsibilities to your EBS user account.
Step3: Define JDeveloper Database Connection
Step3.a: You can switch to Connection tab, right click on Databases and select “New Database
Connection”.
Responsibility:
OA Framework ToolBox OA Framework ToolBox Tutorial Labs
4
Step3.b: Ignore the First/Splash screen.
Step3.c: Choose connection name.
Step3.d: Provide DB schema name as Username and corresponding password.
5
Step3.e: Provide Database hostname, DB Port and SID.
Step3.f: Test the connection.
6
Step3.g: Expand the connection to review an object / table.
Your DB connection is ready to use. JDeveloper will need DB connection to create Entity Object, View
object etc. for you.
Step4: Run the examples comes with JDeveloper patch
Running examples comes with patch is great way to find out if you are going to get into any trouble with
AOL/J integration. All the examples can be loaded by single WORKSPACE selection “toolbox.jws”. They
are normally available under <LOCAL_ DIR >\JDevHome\jdev\myprojects.
public class LoadData implements JavaConcurrentProgram{
public LoadData()
{}
public void runProgram(CpContext ctx)
{}
}
public void runProgram(CpContext ctx) { System.out.println(" Running Custom Job Parse and Load XML data into Contact Info table."); String attribute; String line = null; // Concurrent Request execution status ReqCompletion rStatus = ctx.getReqCompletion(); rOutFile = ctx.getOutFile(); // get OutFile object from CpContext rLogFile = ctx.getLogFile();// get LogFile object from CpContext ParameterList pList = ctx.getParameterList(); Hashtable mAttributes = new Hashtable();
23
Code continue...
Object obj = null; // Retrive the list of parameters provided to concurrent request. if(pList.hasMoreElements()) { rLogFile.writeln( "--------------------", rLogFile.STATEMENT); String attribute_name; String attribute_value; for(; pList.hasMoreElements(); ) { NameValueType namevaluetype = pList.nextParameter(); attribute_name = namevaluetype.getName(); attribute_value = namevaluetype.getValue(); if(attribute_value != null) { if(attribute_name.equalsIgnoreCase("P_FILE_NAME")) mFileName = attribute_value; } } } BufferedReader br; try { br = new BufferedReader(new FileReader(mFileName)); while ((line = br.readLine()) != null) { rLogFile.writeln(line,rLogFile.STATEMENT); } } catch (FileNotFoundException e) {rLogFile.writeln(e.getMessage(),rLogFile.STATEMENT);} catch (java.io.IOException e1) {rLogFile.writeln (e1.getMessage(),rLogFile.STATEMENT) ;} rStatus.setCompletion(mXmlErrorCode, mXmlErrorMsg); rLogFile.writeln ("Load XML Data using OA Business Component job Completed",rLogFile.STATEMENT);
}
24
Step10: Test the basic functionality.
Step10.a: Create directories at middle tier which represent BC4J package
“custom.oracle.apps.custmodule.conc.server”.
Connect to APPS tier (I got Linux) as an instance owner, run below commands to create your directory
structure.
Step10.b: Upload all the class files from local machine to middle tier.
Step10.c: Define concurrent program and executable.
public void startElement(String namespaceURI, String sName, // simple name String qName, Attributes attrs) throws SAXException { getElementText(); attrlist=attrs; if (qName.equalsIgnoreCase("vendor")
recordData=true; if (recordData) { if (qName.equalsIgnoreCase("name")) Set_Attributes(attrlist, sName,qName,getElementText()); if (qName.equalsIgnoreCase("address")) Set_Attributes(attrlist, sName,qName,getElementText()); if (qName.equalsIgnoreCase("city")) Set_Attributes(attrlist, sName,qName,getElementText()); if (qName.equalsIgnoreCase("state")) Set_Attributes(attrlist, sName,qName,getElementText()); if (qName.equalsIgnoreCase("zip")) Set_Attributes(attrlist, sName,qName,getElementText()); } } public void Set_Attributes(Attributes mAttribute, String localName, String qualifiedName,
String tagValue ) { if (recordData) { //System.out.println("Set_Attributes ->"+localName+" :"+qualifiedName+ ":"+ tagValue); if (qualifiedName.equalsIgnoreCase("name")) lName = tagValue; if (qualifiedName.equalsIgnoreCase("Address")) lAddress = tagValue; if (qualifiedName.equalsIgnoreCase("city")) lCity = tagValue; if (qualifiedName.equalsIgnoreCase("state")) lState = tagValue; if (qualifiedName.equalsIgnoreCase("zip")) lZip = tagValue; } }
31
public void characters(char[] buf, int offset, int len) throws SAXException { String s = new String(buf, offset, len); if (textBuffer == null) textBuffer = new StringBuffer(s); else textBuffer.append(s); } public String getElementText() throws SAXException { if (textBuffer == null) return null ; String s = ""+textBuffer; textBuffer = null; return s; } public void endElement(String namespaceURI, String sName, String qName ) throws SAXException { Set_Attributes(attrlist, sName,qName,getElementText()); if (qName.equalsIgnoreCase("vendor")) { recordData=false; System.out.println(" name->"+lName); System.out.println(" mAddress->"+lAddress); System.out.println(" city->"+lCity); System.out.println(" state->"+lState); System.out.println(" zip->"+lZip); } } public static void main(String[] args) { String fileName="C:\\Amit\\Jdev_12_1_3\\Jdev\\jdevhome\\jdev\\contactInfo.xml"; ReadXML xmltobeRead = new ReadXML(); xmltobeRead.readFile(fileName); }
}
32
Step12: Integrate BC4J functionality with Java concurrent program.
Step12.a: Define variable and create standalone Application module in LoadXML class.
Step12.b: Add a get method to access AM instance in ReadXML class.
Step12.c: Instantiate the xml parser in LoadXML.
Step12.d: Create a method which will insert row into View Object in ReadXML class.
This method will be called evert time we hit the </vendor> tag which represent end-of-record.
ReadXML xmlConsumer = new ReadXML(); xmlConsumer.readFile(mFileName);
Finally query the table to confirm data was truly loaded.
35
As you can see, I was able to insert data into table without writing a single
INSERT statement. This is the simplification BC4J component offers to us.
This completes the demonstration “Integrate OA Framework BC4J components within Java concurrent
program”. All the class source code is available in Appendix section.
Summary
Define entity object for table.
Define view object for entity object.
Define application module for view object.
Define “LoadXML” class which implements Java concurrent program methods.
Define “ReadXML” class which implement SAX Parser API’s.
Create a root level Application Module in LoadXML class using Context passed as
parameter.
Instantiate ReadXML within LoadXML class.
Create an SAX Parser instance using SAXParserFactory and pass the XML file as
parameter to parse method.
Parsing will generate event in below sequence for XML elements.
-> StartElement()
->Characters()
->EndElement()
Inside method “EndElement()” , If xml element is “VENDOR” , call
CreateContactInfoRow()” which create a new row in view object.
At the end of “CreateContactInfoRow()” method call commitContactInfo() which is defined
in application module to post the changes at database table.
For all the XML element “VENDOR” , CreateContactInfoRow() will be called which will
create eventually all the rows in table.
After XML parsing event complete, set the request set completion status as 0 in LoadData
class.
36
Appendix A: Application module java class.
package custom.oracle.apps.custmodule.conc.server; import oracle.apps.fnd.framework.OAException; import oracle.apps.fnd.framework.server.OAApplicationModuleImpl; import oracle.apps.fnd.framework.server.OADBTransaction; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class contactinfoAMImpl extends OAApplicationModuleImpl { /**This is the default constructor (do not remove) */ public contactinfoAMImpl() { } /**Container's getter for contactInfoVO1 */ public contactInfoVOImpl getcontactInfoVO1() { return (contactInfoVOImpl)findViewObject("contactInfoVO1"); } public void commitContactInfo() { Throwable athrowable[] = null; OADBTransaction oadbtransaction = getOADBTransaction(); contactInfoVOImpl ccNewContact = getcontactInfoVO1(); oadbtransaction.postChanges(); oadbtransaction.commit(); ccNewContact.closeRowSet(); oadbtransaction.clearEntityCache("custom.oracle.apps.custmodule.conc.server.contactInfoEO"); if(athrowable != null && athrowable.length > 0) throw OAException.getBundledOAException(athrowable); else return; } /**Sample main for debugging Business Components code using the tester. */ public static void main(String[] args) { launchTester("custom.oracle.apps.custmodule.conc.server", /* package name */ "contactinfoAMLocal" /* Configuration Name */); } }
37
Appendix B: Entity Object Java class file.
package custom.oracle.apps.custmodule.conc.server; import oracle.apps.fnd.framework.server.OAEntityDefImpl; import oracle.apps.fnd.framework.server.OAEntityImpl; import oracle.jbo.domain.Date; import oracle.jbo.domain.Number; import oracle.jbo.domain.RowID; import oracle.jbo.server.AttributeDefImpl; import oracle.jbo.server.EntityDefImpl; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class contactInfoEOImpl extends OAEntityImpl { public static final int NAME = 0; public static final int ADDRESS = 1; public static final int CITY = 2; public static final int STATE = 3; public static final int ZIP = 4; public static final int CREATIONDATE = 5; public static final int CREATEDBY = 6; public static final int LASTUPDATEDATE = 7; public static final int LASTUPDATEDBY = 8; public static final int ROWID = 9; public static final int LASTUPDATELOGIN = 10; private static OAEntityDefImpl mDefinitionObject; /**This is the default constructor (do not remove) */ public contactInfoEOImpl() { } /**Retrieves the definition object for this instance class. */ public static synchronized EntityDefImpl getDefinitionObject() { if (mDefinitionObject == null) { mDefinitionObject = (OAEntityDefImpl)EntityDefImpl.findDefObject("custom.oracle.apps.custmodule.conc.server.contactInfoEO"); } return mDefinitionObject; }
38
/**Gets the attribute value for Name, using the alias name Name */ public String getName() { return (String)getAttributeInternal(NAME); } /**Sets <code>value</code> as the attribute value for Name */ public void setName(String value) { setAttributeInternal(NAME, value); } /**Gets the attribute value for Address, using the alias name Address */ public String getAddress() { return (String)getAttributeInternal(ADDRESS); } /**Sets <code>value</code> as the attribute value for Address */ public void setAddress(String value) { setAttributeInternal(ADDRESS, value); } /**Gets the attribute value for City, using the alias name City */ public String getCity() { return (String)getAttributeInternal(CITY); } /**Sets <code>value</code> as the attribute value for City */ public void setCity(String value) { setAttributeInternal(CITY, value); } /**Gets the attribute value for State, using the alias name State */ public String getState() { return (String)getAttributeInternal(STATE); } /**Sets <code>value</code> as the attribute value for State */ public void setState(String value) { setAttributeInternal(STATE, value); }
39
/**Gets the attribute value for Zip, using the alias name Zip */ public String getZip() { return (String)getAttributeInternal(ZIP); } /**Sets <code>value</code> as the attribute value for Zip */ public void setZip(String value) { setAttributeInternal(ZIP, value); } /**Gets the attribute value for CreationDate, using the alias name CreationDate */ public Date getCreationDate() { return (Date)getAttributeInternal(CREATIONDATE); } /**Sets <code>value</code> as the attribute value for CreationDate */ public void setCreationDate(Date value) { setAttributeInternal(CREATIONDATE, value); } /**Gets the attribute value for CreatedBy, using the alias name CreatedBy */ public Number getCreatedBy() { return (Number)getAttributeInternal(CREATEDBY); } /**Sets <code>value</code> as the attribute value for CreatedBy */ public void setCreatedBy(Number value) { setAttributeInternal(CREATEDBY, value); } /**Gets the attribute value for LastUpdateDate, using the alias name LastUpdateDate */ public Date getLastUpdateDate() { return (Date)getAttributeInternal(LASTUPDATEDATE); } /**Sets <code>value</code> as the attribute value for LastUpdateDate */ public void setLastUpdateDate(Date value) { setAttributeInternal(LASTUPDATEDATE, value); } /**Gets the attribute value for LastUpdatedBy, using the alias name LastUpdatedBy*/
40
public Number getLastUpdatedBy() { return (Number)getAttributeInternal(LASTUPDATEDBY); } /**Sets <code>value</code> as the attribute value for LastUpdatedBy */ public void setLastUpdatedBy(Number value) { setAttributeInternal(LASTUPDATEDBY, value); } /**Gets the attribute value for RowID, using the alias name RowID */ public RowID getRowID() { return (RowID)getAttributeInternal(ROWID); } /**getAttrInvokeAccessor: generated method. Do not modify. */ protected Object getAttrInvokeAccessor(int index, AttributeDefImpl attrDef) throws Exception { switch (index) { case NAME: return getName(); case ADDRESS: return getAddress(); case CITY: return getCity(); case STATE: return getState(); case ZIP: return getZip(); case CREATIONDATE: return getCreationDate(); case CREATEDBY: return getCreatedBy(); case LASTUPDATEDATE: return getLastUpdateDate(); case LASTUPDATEDBY: return getLastUpdatedBy(); case ROWID: return getRowID(); case LASTUPDATELOGIN: return getLastUpdateLogin(); default: return super.getAttrInvokeAccessor(index, attrDef); } }
41
protected void setAttrInvokeAccessor(int index, Object value, AttributeDefImpl attrDef) throws Exception { switch (index) { case NAME: setName((String)value); return; case ADDRESS: setAddress((String)value); return; case CITY: setCity((String)value); return; case STATE: setState((String)value); return; case ZIP: setZip((String)value); return; case CREATIONDATE: setCreationDate((Date)value); return; case CREATEDBY: setCreatedBy((Number)value); return; case LASTUPDATEDATE: setLastUpdateDate((Date)value); return; case LASTUPDATEDBY: setLastUpdatedBy((Number)value); return; case LASTUPDATELOGIN: setLastUpdateLogin((Number)value); return; default: super.setAttrInvokeAccessor(index, value, attrDef); return; } } public Number getLastUpdateLogin() { return (Number)getAttributeInternal(LASTUPDATELOGIN); } public void setLastUpdateLogin(Number value) { setAttributeInternal(LASTUPDATELOGIN, value); } }
42
Appendix C: View Object Java class file.
package custom.oracle.apps.custmodule.conc.server; import oracle.apps.fnd.framework.server.OAViewRowImpl; import oracle.jbo.domain.Date; import oracle.jbo.domain.Number; import oracle.jbo.domain.RowID; import oracle.jbo.server.AttributeDefImpl; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class contactInfoVORowImpl extends OAViewRowImpl { public static final int NAME = 0; public static final int ADDRESS = 1; public static final int CITY = 2; public static final int STATE = 3; public static final int ZIP = 4; public static final int CREATIONDATE = 5; public static final int CREATEDBY = 6; public static final int LASTUPDATEDATE = 7; public static final int LASTUPDATEDBY = 8; public static final int ROWID = 9; public static final int LASTUPDATELOGIN = 10; /**This is the default constructor (do not remove) */ public contactInfoVORowImpl() { } /**Gets contactInfoEO entity object. */ public contactInfoEOImpl getcontactInfoEO() { return (contactInfoEOImpl)getEntity(0); } /**Gets the attribute value for NAME using the alias name Name */ public String getName() { return (String) getAttributeInternal(NAME); } /**Sets <code>value</code> as attribute value for NAME using the alias name Name */
43
public void setName(String value) { setAttributeInternal(NAME, value); } /**Gets the attribute value for ADDRESS using the alias name Address */ public String getAddress() { return (String) getAttributeInternal(ADDRESS); } /**Sets <code>value</code> as attribute value for ADDRESS using the alias name Address */ public void setAddress(String value) { setAttributeInternal(ADDRESS, value); } /**Gets the attribute value for CITY using the alias name City */ public String getCity() { return (String) getAttributeInternal(CITY); } /**Sets <code>value</code> as attribute value for CITY using the alias name City */ public void setCity(String value) { setAttributeInternal(CITY, value); } /**Gets the attribute value for STATE using the alias name State */ public String getState() { return (String) getAttributeInternal(STATE); } /**Sets <code>value</code> as attribute value for STATE using the alias name State */ public void setState(String value) { setAttributeInternal(STATE, value); } /**Gets the attribute value for ZIP using the alias name Zip */ public String getZip() { return (String) getAttributeInternal(ZIP); } /**Sets <code>value</code> as attribute value for ZIP using the alias name Zip
44
*/ public void setZip(String value) { setAttributeInternal(ZIP, value); } /**Gets the attribute value for CREATION_DATE using the alias name CreationDate */ public Date getCreationDate() { return (Date) getAttributeInternal(CREATIONDATE); } /**Sets <code>value</code> as attribute value for CREATION_DATE using the alias name CreationDate */ public void setCreationDate(Date value) { setAttributeInternal(CREATIONDATE, value); } /**Gets the attribute value for CREATED_BY using the alias name CreatedBy */ public Number getCreatedBy() { return (Number) getAttributeInternal(CREATEDBY); } /**Sets <code>value</code> as attribute value for CREATED_BY using the alias name CreatedBy */ public void setCreatedBy(Number value) { setAttributeInternal(CREATEDBY, value); } /**Gets the attribute value for LAST_UPDATE_DATE using the alias name LastUpdateDate */ public Date getLastUpdateDate() { return (Date) getAttributeInternal(LASTUPDATEDATE); } /**Sets <code>value</code> as attribute value for LAST_UPDATE_DATE using the alias name LastUpdateDate */ public void setLastUpdateDate(Date value) { setAttributeInternal(LASTUPDATEDATE, value); } public Number getLastUpdatedBy() { return (Number) getAttributeInternal(LASTUPDATEDBY); }
45
/**Sets <code>value</code> as attribute value for LAST_UPDATED_BY using the alias name LastUpdatedBy */ public void setLastUpdatedBy(Number value) { setAttributeInternal(LASTUPDATEDBY, value); } /**Gets the attribute value for ROWID using the alias name RowID */ public RowID getRowID() { return (RowID) getAttributeInternal(ROWID); } /**getAttrInvokeAccessor: generated method. Do not modify. */ protected Object getAttrInvokeAccessor(int index, AttributeDefImpl attrDef) throws Exception { switch (index) { case NAME: return getName(); case ADDRESS: return getAddress(); case CITY: return getCity(); case STATE: return getState(); case ZIP: return getZip(); case CREATIONDATE: return getCreationDate(); case CREATEDBY: return getCreatedBy(); case LASTUPDATEDATE: return getLastUpdateDate(); case LASTUPDATEDBY: return getLastUpdatedBy(); case ROWID: return getRowID(); case LASTUPDATELOGIN: return getLastUpdateLogin(); default: return super.getAttrInvokeAccessor(index, attrDef); } } /**setAttrInvokeAccessor: generated method. Do not modify. */
46
*/
protected void setAttrInvokeAccessor(int index, Object value, AttributeDefImpl attrDef) throws Exception { switch (index) { case NAME: setName((String)value); return; case ADDRESS: setAddress((String)value); return; case CITY: setCity((String)value); return; case STATE: setState((String)value); return; case ZIP: setZip((String)value); return; case CREATIONDATE: setCreationDate((Date)value); return; case CREATEDBY: setCreatedBy((Number)value); return; case LASTUPDATEDATE: setLastUpdateDate((Date)value); return; case LASTUPDATEDBY: setLastUpdatedBy((Number)value); return; case LASTUPDATELOGIN: setLastUpdateLogin((Number)value); return; default: super.setAttrInvokeAccessor(index, value, attrDef); return; } } /**Gets the attribute value for LAST_UPDATE_LOGIN using the alias name LastUpdateLogin */ public Number getLastUpdateLogin() { return (Number) getAttributeInternal(LASTUPDATELOGIN); } /**Sets <code>value</code> as attribute value for LAST_UPDATE_LOGIN using the alias name LastUpdateLogin
47
public void setLastUpdateLogin(Number value) { setAttributeInternal(LASTUPDATELOGIN, value); } } package custom.oracle.apps.custmodule.conc.server; import oracle.apps.fnd.framework.server.OAViewObjectImpl; // --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class contactInfoVOImpl extends OAViewObjectImpl { /**This is the default constructor (do not remove) */ public contactInfoVOImpl() { } }
public static String getFileName() { return mFileName; } public void runProgram(CpContext ctx) { System.out.println(" Running Custom Job Parse and Load XML data into Contact Info table."); String attribute; String line = null; // Concurrent Request execution status ReqCompletion rStatus = ctx.getReqCompletion(); // properties will be used to store the all values in hash table with particular name Properties rProperties = new Properties(); rProperties.put("APPS_CONTEXT", ctx); String mAmDefName = "custom.oracle.apps.custmodule.conc.server.contactinfoAM"; ljobAM = OAApplicationModuleFactory.createRootOAApplicationModule(ctx, mAmDefName); rOutFile = ctx.getOutFile(); // get OutFile object from CpContext rLogFile = ctx.getLogFile();// get LogFile object from CpContext //LogFile mLog = cpcontext.getLogFile(); //cpcontext.getReqDetails() ParameterList pList = ctx.getParameterList(); Hashtable mAttributes = new Hashtable(); Object obj = null; // Retrive the list of parameters provided to concurrent request. if(pList.hasMoreElements()) { rLogFile.writeln( "--------------------", rLogFile.STATEMENT); String attribute_name; String attribute_value; for(; pList.hasMoreElements(); ) { NameValueType namevaluetype = pList.nextParameter(); attribute_name = namevaluetype.getName(); attribute_value = namevaluetype.getValue(); if(attribute_value != null) { if(attribute_name.equalsIgnoreCase("P_FILE_NAME"))
50
mFileName = attribute_value; } } } Message message = new Message("FND", "CONC-ARGUMENTS"); rLogFile.writeln(message, rLogFile.STATEMENT); rLogFile.writeln( "--------------------", rLogFile.STATEMENT); rLogFile.writeln("File Name: "+mFileName,rLogFile.STATEMENT ); BufferedReader br; try { br = new BufferedReader(new FileReader(mFileName)); while ((line = br.readLine()) != null) { rLogFile.writeln(line,rLogFile.STATEMENT); } } catch (FileNotFoundException e) {rLogFile.writeln(e.getMessage(),rLogFile.STATEMENT);} catch (java.io.IOException e1) {rLogFile.writeln(e1.getMessage(),rLogFile.STATEMENT);} //Call the XML Parser ReadXML xmlConsumer = new ReadXML(); xmlConsumer.readFile(mFileName); rStatus.setCompletion(mXmlErrorCode, mXmlErrorMsg); rLogFile.writeln("Load XML Data using OA Business Component job Completed",rLogFile.STATEMENT); } }