Commit 50502aac authored by nshinde's avatar nshinde

Added By Manoj dtd 05/11/2012 implement abstract method


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92142 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c68a4ccc
package ibase.webitm.ejb.sys; package ibase.webitm.ejb.sys;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.bean.*; import ibase.webitm.bean.*;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.system.config.*; import ibase.system.config.*;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
import ibase.scheduler.utility.interfaces.Schedule; import ibase.scheduler.utility.interfaces.Schedule;
import java.util.*; import java.util.*;
import java.rmi.*; import java.rmi.*;
import javax.ejb.*; import javax.ejb.*;
import javax.rmi.*; import javax.rmi.*;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.*; import java.io.*;
import java.lang.String; import java.lang.String;
import javax.mail.*; import javax.mail.*;
import javax.mail.internet.*; import javax.mail.internet.*;
import javax.activation.*; import javax.activation.*;
import java.sql.*; import java.sql.*;
import org.apache.log4j.*; import org.apache.log4j.*;
import org.w3c.dom.*; import org.w3c.dom.*;
public class DownloadCSVBatchBean implements Schedule public class DownloadCSVBatchBean implements Schedule
{ {
protected ibase.utility.UserInfoBean userInfo = null; protected ibase.utility.UserInfoBean userInfo = null;
//Added By Manoj dtd 05/11/2012 implement abstract method
public void downloadTransaction( String objName, String downloadLoc, String entityCode, public String schedulePriority( String wrkflwPriority )throws Exception
String entityType, String siteCodeDnld, String custCodeDnld ) throws RemoteException, ITMException {
{ return "";
String templUpld = null; }
String templTypeUpld = null; public void downloadTransaction( String objName, String downloadLoc, String entityCode,
String templDnld = null; String entityType, String siteCodeDnld, String custCodeDnld ) throws RemoteException, ITMException
String templTypeDnld = null; {
String objEximpFmt = null; String templUpld = null;
String templTypeUpld = null;
TranXmlData client = null; String templDnld = null;
String dnldFileNameServer = null; String templTypeDnld = null;
String dnldFileNameEmail = null; String objEximpFmt = null;
String downloadLocEmail = null;
String xmlToCsvStr = null; TranXmlData client = null;
HashMap emailHash = new HashMap(); String dnldFileNameServer = null;
HashMap tranFileMip = new HashMap(); String dnldFileNameEmail = null;
// 11/09/09 manoharan DI89SUN223 String downloadLocEmail = null;
HashMap tranSeqMap = new HashMap(); String xmlToCsvStr = null;
// end 11/09/09 manoharan HashMap emailHash = new HashMap();
HashMap tranFileMip = new HashMap();
String tranId = null; // 11/09/09 manoharan DI89SUN223
String custCode = null; HashMap tranSeqMap = new HashMap();
String siteCode = null; // end 11/09/09 manoharan
String emailAddr = null;
String uniformCode = null; String tranId = null;
String dt = null; String custCode = null;
String dty = null; String siteCode = null;
String trfCycle = null; String emailAddr = null;
String prvCustCode = null; String uniformCode = null;
String previousDay = null; String dt = null;
String trfType = null; String dty = null;
String filePath = null; String trfCycle = null;
String retString = null; String prvCustCode = null;
String subject = null; String previousDay = null;
int recCounter = 0; String trfType = null;
String text = null; String filePath = null;
java.sql.Timestamp fromDate = null; String retString = null;
java.sql.Timestamp toDate = null; String subject = null;
int recCounter = 0;
boolean isTemplateExist = false; String text = null;
java.sql.Timestamp fromDate = null;
siteCodeDnld = ( siteCodeDnld != null && siteCodeDnld.equalsIgnoreCase( "null" ) ) ? java.sql.Timestamp toDate = null;
"" : siteCodeDnld.trim();
custCodeDnld = ( custCodeDnld != null && custCodeDnld.equalsIgnoreCase( "null" ) ) ? boolean isTemplateExist = false;
"" : custCodeDnld.trim();
String sql = null; siteCodeDnld = ( siteCodeDnld != null && siteCodeDnld.equalsIgnoreCase( "null" ) ) ?
"" : siteCodeDnld.trim();
//System.out.println( "downloadLoc:: " + downloadLoc ); custCodeDnld = ( custCodeDnld != null && custCodeDnld.equalsIgnoreCase( "null" ) ) ?
"" : custCodeDnld.trim();
sql = " SELECT OBJ_NAME, TEMPL_UPLD, TEMPL_TYPE_UPLD, TEMPL_DNLD, TEMPL_TYPE_DNLD" String sql = null;
+" FROM OBJECT_EXIM_FMT "
+" WHERE OBJ_NAME = '" + objName + "'" //System.out.println( "downloadLoc:: " + downloadLoc );
+" AND OBJ_CONTEXT = '" + entityType.trim() + "-" + entityCode.trim() + "'";
sql = " SELECT OBJ_NAME, TEMPL_UPLD, TEMPL_TYPE_UPLD, TEMPL_DNLD, TEMPL_TYPE_DNLD"
+" FROM OBJECT_EXIM_FMT "
java.sql.Connection conn = null; +" WHERE OBJ_NAME = '" + objName + "'"
java.sql.PreparedStatement pstmt = null; +" AND OBJ_CONTEXT = '" + entityType.trim() + "-" + entityCode.trim() + "'";
java.sql.ResultSet rs = null;
java.sql.PreparedStatement pstmtSeq = null; java.sql.Connection conn = null;
java.sql.PreparedStatement pstmtSeq2 = null; java.sql.PreparedStatement pstmt = null;
java.sql.ResultSet rsSeq = null; java.sql.ResultSet rs = null;
java.sql.ResultSet rsSeq2 = null;
java.sql.Timestamp tranDate = null; java.sql.PreparedStatement pstmtSeq = null;
java.sql.PreparedStatement pstmtSeq2 = null;
java.sql.ResultSet rsSeq = null;
ConnDriver connDriver = new ConnDriver(); java.sql.ResultSet rsSeq2 = null;
try java.sql.Timestamp tranDate = null;
{
conn = connDriver.getConnectDB( "DriverITM" );
conn.setAutoCommit( false ); ConnDriver connDriver = new ConnDriver();
try
pstmt = conn.prepareStatement( sql ); {
rs = pstmt.executeQuery(); conn = connDriver.getConnectDB( "DriverITM" );
if( rs.next() ) conn.setAutoCommit( false );
{
objName = rs.getString( "OBJ_NAME" ); pstmt = conn.prepareStatement( sql );
templUpld = rs.getString( "TEMPL_UPLD" ); rs = pstmt.executeQuery();
templTypeUpld = rs.getString( "TEMPL_TYPE_UPLD" ); if( rs.next() )
templDnld = rs.getString( "TEMPL_DNLD" ); {
templTypeDnld = rs.getString( "TEMPL_TYPE_DNLD" ); objName = rs.getString( "OBJ_NAME" );
templUpld = rs.getString( "TEMPL_UPLD" );
isTemplateExist = true; templTypeUpld = rs.getString( "TEMPL_TYPE_UPLD" );
} templDnld = rs.getString( "TEMPL_DNLD" );
/*System.out.println( " isTemplateExist :: [" + isTemplateExist + "]" ); templTypeDnld = rs.getString( "TEMPL_TYPE_DNLD" );
System.out.println( " objName :: [" + objName + "]" );
System.out.println( " templUpld :: [" + templUpld + "]" ); isTemplateExist = true;
System.out.println( " templTypeUpld :: [" + templTypeUpld + "]" ); }
System.out.println( " templDnld :: [" + templDnld + "]" ); /*System.out.println( " isTemplateExist :: [" + isTemplateExist + "]" );
System.out.println( " templTypeDnld :: [" + templTypeDnld + "]" ); System.out.println( " objName :: [" + objName + "]" );
*/ System.out.println( " templUpld :: [" + templUpld + "]" );
rs.close(); System.out.println( " templTypeUpld :: [" + templTypeUpld + "]" );
rs = null; System.out.println( " templDnld :: [" + templDnld + "]" );
pstmt.close(); System.out.println( " templTypeDnld :: [" + templTypeDnld + "]" );
pstmt = null; */
}catch( Exception ex ) rs.close();
{ rs = null;
ex.printStackTrace(); pstmt.close();
} pstmt = null;
if( isTemplateExist ) }catch( Exception ex )
{ {
GenericUtility genericUtility = GenericUtility.getInstance(); ex.printStackTrace();
}
//String xlsFileName = null; if( isTemplateExist )
//String csvData = null; {
GenericUtility genericUtility = GenericUtility.getInstance();
try
{ //String xlsFileName = null;
if( templTypeDnld.equalsIgnoreCase( "C" ) ) //String csvData = null;
{
try
{
if( objName.equalsIgnoreCase( "INVOICE" ) ) if( templTypeDnld.equalsIgnoreCase( "C" ) )
{ {
//start - select all the undownloaded invoice, if found,
//then download for each.
sql =" SELECT IV.INVOICE_ID TRAN_ID, IV.CUST_CODE CUST_CODE, " if( objName.equalsIgnoreCase( "INVOICE" ) )
+" IV.SITE_CODE SITE_CODE, CU.EMAIL_ADDR EMAIL_ADDR, " {
+" CU.UNIFORM_CODE UNIFORM_CODE, " //start - select all the undownloaded invoice, if found,
+" TO_CHAR( IV.TRAN_DATE, 'DDMMYYYY' ) DTY, " //then download for each.
+" TO_CHAR( IV.TRAN_DATE, 'DDMM' ) DT, IV.TRAN_DATE TRAN_DATE, " sql =" SELECT IV.INVOICE_ID TRAN_ID, IV.CUST_CODE CUST_CODE, "
+" SC.INV_TRF_TYPE INV_TRF_TYPE, SC.INV_TRF_CYCLE INV_TRF_CYCLE " +" IV.SITE_CODE SITE_CODE, CU.EMAIL_ADDR EMAIL_ADDR, "
+" FROM INVOICE IV, CUSTOMER CU, SITE_CUSTOMER SC " +" CU.UNIFORM_CODE UNIFORM_CODE, "
+" WHERE IV.CUST_CODE__BIL = CU.CUST_CODE " +" TO_CHAR( IV.TRAN_DATE, 'DDMMYYYY' ) DTY, "
+" AND IV.SITE_CODE = SC.SITE_CODE " +" TO_CHAR( IV.TRAN_DATE, 'DDMM' ) DT, IV.TRAN_DATE TRAN_DATE, "
+" AND IV.CUST_CODE__BIL = SC.CUST_CODE " +" SC.INV_TRF_TYPE INV_TRF_TYPE, SC.INV_TRF_CYCLE INV_TRF_CYCLE "
+" AND SC.DOWNLOAD_YN = 'Y' " +" FROM INVOICE IV, CUSTOMER CU, SITE_CUSTOMER SC "
+" AND ( IV.DOWNLOAD_FLAG IS NULL OR IV.DOWNLOAD_FLAG = 'N' ) "; +" WHERE IV.CUST_CODE__BIL = CU.CUST_CODE "
+" AND IV.SITE_CODE = SC.SITE_CODE "
if( siteCodeDnld != null && siteCodeDnld.trim().length() > 0 +" AND IV.CUST_CODE__BIL = SC.CUST_CODE "
&& custCodeDnld != null && custCodeDnld.trim().length() > 0 ) +" AND SC.DOWNLOAD_YN = 'Y' "
{ +" AND ( IV.DOWNLOAD_FLAG IS NULL OR IV.DOWNLOAD_FLAG = 'N' ) ";
sql = sql + " AND IV.SITE_CODE = ? "
+" AND IV.CUST_CODE = ? "; if( siteCodeDnld != null && siteCodeDnld.trim().length() > 0
} && custCodeDnld != null && custCodeDnld.trim().length() > 0 )
sql = sql + " ORDER BY IV.CUST_CODE, IV.TRAN_DATE, IV.INVOICE_ID ASC "; {
sql = sql + " AND IV.SITE_CODE = ? "
pstmt = conn.prepareStatement( sql ); +" AND IV.CUST_CODE = ? ";
if( siteCodeDnld != null && siteCodeDnld.trim().length() > 0 }
&& custCodeDnld != null && custCodeDnld.trim().length() > 0 ) sql = sql + " ORDER BY IV.CUST_CODE, IV.TRAN_DATE, IV.INVOICE_ID ASC ";
{
pstmt.setString(1, siteCodeDnld); pstmt = conn.prepareStatement( sql );
pstmt.setString(2, custCodeDnld); if( siteCodeDnld != null && siteCodeDnld.trim().length() > 0
} && custCodeDnld != null && custCodeDnld.trim().length() > 0 )
rs = pstmt.executeQuery(); {
prvCustCode = null; pstmt.setString(1, siteCodeDnld);
recCounter = 0; pstmt.setString(2, custCodeDnld);
while( rs.next() ) }
{ rs = pstmt.executeQuery();
tranFileMip = new HashMap(); prvCustCode = null;
emailHash = new HashMap(); recCounter = 0;
retString = null; while( rs.next() )
tranId = rs.getString( "TRAN_ID" ); {
custCode = rs.getString( "CUST_CODE" ); tranFileMip = new HashMap();
siteCode = rs.getString( "SITE_CODE" ); emailHash = new HashMap();
emailAddr = rs.getString( "EMAIL_ADDR" ); retString = null;
uniformCode = rs.getString( "UNIFORM_CODE" ); tranId = rs.getString( "TRAN_ID" );
dt = rs.getString( "DT" ); custCode = rs.getString( "CUST_CODE" );
dty = rs.getString( "DTY" ); siteCode = rs.getString( "SITE_CODE" );
tranDate = rs.getTimestamp( "TRAN_DATE" ); emailAddr = rs.getString( "EMAIL_ADDR" );
trfType = rs.getString( "INV_TRF_TYPE" ); uniformCode = rs.getString( "UNIFORM_CODE" );
trfCycle = rs.getString( "INV_TRF_CYCLE" ); dt = rs.getString( "DT" );
dty = rs.getString( "DTY" );
System.out.println("tranDate =="+tranDate); tranDate = rs.getTimestamp( "TRAN_DATE" );
System.out.println("custCode =="+custCode); trfType = rs.getString( "INV_TRF_TYPE" );
System.out.println("prvCustCode =="+prvCustCode); trfCycle = rs.getString( "INV_TRF_CYCLE" );
System.out.println("dt =="+dt);
System.out.println("previousDay =="+previousDay); System.out.println("tranDate =="+tranDate);
System.out.println("custCode =="+custCode);
// 11/09/09 manoharan DI89SUN223 to store the sequence number System.out.println("prvCustCode =="+prvCustCode);
//(file suffix) in invoice table and increment for the same day System.out.println("dt =="+dt);
pstmtSeq2 = conn.prepareStatement("SELECT NVL(MAX(CASE WHEN DOWNLOAD_FILE_SEQ " System.out.println("previousDay =="+previousDay);
+" IS NULL THEN 0 ELSE DOWNLOAD_FILE_SEQ END),0) AS DOWNLOAD_FILE_SEQ "
+" FROM INVOICE WHERE CUST_CODE = ? AND TRAN_DATE = ? " // 11/09/09 manoharan DI89SUN223 to store the sequence number
+" AND DOWNLOAD_FLAG = 'Y'"); //(file suffix) in invoice table and increment for the same day
// end 11/09/09 manoharan to store the sequence number pstmtSeq2 = conn.prepareStatement("SELECT NVL(MAX(CASE WHEN DOWNLOAD_FILE_SEQ "
//(file suffix) in invoice table and increment for the same day +" IS NULL THEN 0 ELSE DOWNLOAD_FILE_SEQ END),0) AS DOWNLOAD_FILE_SEQ "
+" FROM INVOICE WHERE CUST_CODE = ? AND TRAN_DATE = ? "
tranFileMip.put( "tranId", tranId ); +" AND DOWNLOAD_FLAG = 'Y'");
tranFileMip.put( "templDnld", templDnld ); // end 11/09/09 manoharan to store the sequence number
//(file suffix) in invoice table and increment for the same day
// 27/04/10 sachin---to send file in new format as IDDMM<invoice id>.CSV
// for email start tranFileMip.put( "tranId", tranId );
if(!("S".equalsIgnoreCase(trfType))) tranFileMip.put( "templDnld", templDnld );
{
dnldFileNameEmail = "I"+ dt + tranId.trim(); // 27/04/10 sachin---to send file in new format as IDDMM<invoice id>.CSV
tranFileMip.put( "dnldFileName", dnldFileNameEmail ); // for email start
if(!("S".equalsIgnoreCase(trfType)))
downloadLocEmail = CommonConstants.JBOSSHOME + File.separator {
+ "server" + File.separator + "default" + File.separator dnldFileNameEmail = "I"+ dt + tranId.trim();
+ "tmp"; tranFileMip.put( "dnldFileName", dnldFileNameEmail );
filePath = downloadLocEmail + File.separator + dnldFileNameEmail downloadLocEmail = CommonConstants.JBOSSHOME + File.separator
+ ".csv"; + "server" + File.separator + "default" + File.separator
+ "tmp";
System.out.println(filePath);
filePath = downloadLocEmail + File.separator + dnldFileNameEmail
subject = "Invoice in CSV format for Invoice No." +tranId; + ".csv";
text = "Dear Sir/Madam,\n Please find the attached CSV file "
+" for Invoice No. "+tranId; System.out.println(filePath);
if(emailAddr == null && emailAddr.equalsIgnoreCase(" ")) subject = "Invoice in CSV format for Invoice No." +tranId;
{ text = "Dear Sir/Madam,\n Please find the attached CSV file "
emailAddr = ""; +" for Invoice No. "+tranId;
}
if(emailAddr == null && emailAddr.equalsIgnoreCase(" "))
{
emailHash.put("TO_ADDR", emailAddr); emailAddr = "";
emailHash.put("SUBJECT", subject); }
emailHash.put("TEXT", text);
emailHash.put("FILEPATH", filePath);
} emailHash.put("TO_ADDR", emailAddr);
// 27/04/10 sachin---to send file in new format as IDDMM<invoice id>.CSV emailHash.put("SUBJECT", subject);
// for email end emailHash.put("TEXT", text);
emailHash.put("FILEPATH", filePath);
// 06/04/10 SY90SUN012 -sachin to select the peroid against }
//the tran date from period table start // 27/04/10 sachin---to send file in new format as IDDMM<invoice id>.CSV
// for email end
pstmtSeq = conn.prepareStatement( " SELECT FR_DATE, TO_DATE FROM PERIOD "
+" WHERE ? BETWEEN FR_DATE AND TO_DATE "); // 06/04/10 SY90SUN012 -sachin to select the peroid against
//the tran date from period table start
pstmtSeq.setTimestamp(1, tranDate);
rsSeq = pstmtSeq.executeQuery(); pstmtSeq = conn.prepareStatement( " SELECT FR_DATE, TO_DATE FROM PERIOD "
if( rsSeq.next() ) +" WHERE ? BETWEEN FR_DATE AND TO_DATE ");
{
fromDate = rsSeq.getTimestamp( "FR_DATE" ); pstmtSeq.setTimestamp(1, tranDate);
toDate = rsSeq.getTimestamp( "TO_DATE" ); rsSeq = pstmtSeq.executeQuery();
if( rsSeq.next() )
} {
rsSeq.close(); fromDate = rsSeq.getTimestamp( "FR_DATE" );
rsSeq = null; toDate = rsSeq.getTimestamp( "TO_DATE" );
pstmtSeq.close();
pstmtSeq = null; }
rsSeq.close();
// end 06/04/10 SY90SUN012 sachin to select the peroid rsSeq = null;
//against the tran date from period table end pstmtSeq.close();
pstmtSeq = null;
if(trfCycle != null && trfCycle.equalsIgnoreCase( "O" ))
{ // end 06/04/10 SY90SUN012 sachin to select the peroid
pstmtSeq = conn.prepareStatement( " SELECT IV.INV_EXP_DATE " //against the tran date from period table end
+" FROM INVOICE IV, SITE_CUSTOMER SC "
+" WHERE IV.CUST_CODE__BIL = SC.CUST_CODE " if(trfCycle != null && trfCycle.equalsIgnoreCase( "O" ))
+" AND IV.SITE_CODE = SC.SITE_CODE " {
+" AND IV.INV_EXP_DATE IS NOT NULL " pstmtSeq = conn.prepareStatement( " SELECT IV.INV_EXP_DATE "
+" AND IV.TRAN_DATE BETWEEN ? AND ? " +" FROM INVOICE IV, SITE_CUSTOMER SC "
+" AND IV.SITE_CODE = ? " +" WHERE IV.CUST_CODE__BIL = SC.CUST_CODE "
+" AND IV.CUST_CODE = ? " +" AND IV.SITE_CODE = SC.SITE_CODE "
+" AND IV.DOWNLOAD_FLAG = 'Y' " ); +" AND IV.INV_EXP_DATE IS NOT NULL "
+" AND IV.TRAN_DATE BETWEEN ? AND ? "
pstmtSeq.setTimestamp(1, fromDate); +" AND IV.SITE_CODE = ? "
pstmtSeq.setTimestamp(2, toDate); +" AND IV.CUST_CODE = ? "
pstmtSeq.setString(3, siteCode); +" AND IV.DOWNLOAD_FLAG = 'Y' " );
pstmtSeq.setString(4, custCode);
pstmtSeq.setTimestamp(1, fromDate);
rsSeq = pstmtSeq.executeQuery(); pstmtSeq.setTimestamp(2, toDate);
if( rsSeq.next() ) pstmtSeq.setString(3, siteCode);
{ pstmtSeq.setString(4, custCode);
updateFlag(tranId, conn);
System.out.println("Inside Once -- already downloaded "); rsSeq = pstmtSeq.executeQuery();
} if( rsSeq.next() )
else {
{ updateFlag(tranId, conn);
if(!("S".equalsIgnoreCase(trfType))) System.out.println("Inside Once -- already downloaded ");
{ }
download(tranFileMip, downloadLocEmail); else
retString = sendMail(emailHash, conn); {
deleteFile(filePath); if(!("S".equalsIgnoreCase(trfType)))
} {
if(!("E".equalsIgnoreCase(trfType))) download(tranFileMip, downloadLocEmail);
{ retString = sendMail(emailHash, conn);
if( custCode.equalsIgnoreCase( prvCustCode ) && dt.equalsIgnoreCase( previousDay ) ) deleteFile(filePath);
{ }
recCounter++; if(!("E".equalsIgnoreCase(trfType)))
} {
else if( custCode.equalsIgnoreCase( prvCustCode ) && dt.equalsIgnoreCase( previousDay ) )
{ {
// 11/09/09 DI89SUN223 manoharan to store the sequence number recCounter++;
// (file suffix) in invoice table and increment for the same day }
//recCounter = 1; else
{
pstmtSeq2.setString(1,custCode); // 11/09/09 DI89SUN223 manoharan to store the sequence number
pstmtSeq2.setTimestamp(2,tranDate); // (file suffix) in invoice table and increment for the same day
rsSeq2 = pstmtSeq2.executeQuery(); //recCounter = 1;
if( rsSeq2.next() )
{ pstmtSeq2.setString(1,custCode);
recCounter = rsSeq2.getInt("download_file_seq"); pstmtSeq2.setTimestamp(2,tranDate);
rsSeq2 = pstmtSeq2.executeQuery();
System.out.println(recCounter); if( rsSeq2.next() )
} {
rsSeq2.close(); recCounter = rsSeq2.getInt("download_file_seq");
rsSeq2 = null;
System.out.println(recCounter);
recCounter++; }
rsSeq2.close();
// end 11/09/09 manoharan to store the sequence number (file suffix) rsSeq2 = null;
// in invoice table and increment for the same day
} recCounter++;
System.out.println(recCounter); // end 11/09/09 manoharan to store the sequence number (file suffix)
dnldFileNameServer = ( uniformCode == null ? "" : uniformCode.trim() ) // in invoice table and increment for the same day
+ "_" + dty + "_" }
+ ( new java.text.DecimalFormat( "000" ) ).format( recCounter );
prvCustCode = custCode; System.out.println(recCounter);
previousDay = dt; dnldFileNameServer = ( uniformCode == null ? "" : uniformCode.trim() )
+ "_" + dty + "_"
if("B".equalsIgnoreCase(trfType)) + ( new java.text.DecimalFormat( "000" ) ).format( recCounter );
{ prvCustCode = custCode;
tranFileMip.remove("dnldFileName"); previousDay = dt;
}
tranFileMip.put( "dnldFileName", dnldFileNameServer ); if("B".equalsIgnoreCase(trfType))
download(tranFileMip, downloadLoc); {
retString = "updateSeq"; tranFileMip.remove("dnldFileName");
} }
tranFileMip.put( "dnldFileName", dnldFileNameServer );
} download(tranFileMip, downloadLoc);
rsSeq.close(); retString = "updateSeq";
rsSeq = null; }
pstmtSeq.close();
pstmtSeq = null; }
} rsSeq.close();
else if(trfCycle != null && trfCycle.equalsIgnoreCase( "A" )) rsSeq = null;
{ pstmtSeq.close();
if(!("S".equalsIgnoreCase(trfType))) pstmtSeq = null;
{ }
download(tranFileMip, downloadLocEmail); else if(trfCycle != null && trfCycle.equalsIgnoreCase( "A" ))
retString = sendMail(emailHash, conn); {
deleteFile(filePath); if(!("S".equalsIgnoreCase(trfType)))
} {
if(!("E".equalsIgnoreCase(trfType))) download(tranFileMip, downloadLocEmail);
{ retString = sendMail(emailHash, conn);
if( custCode.equalsIgnoreCase( prvCustCode ) && dt.equalsIgnoreCase( previousDay ) ) deleteFile(filePath);
{ }
recCounter++; if(!("E".equalsIgnoreCase(trfType)))
} {
else if( custCode.equalsIgnoreCase( prvCustCode ) && dt.equalsIgnoreCase( previousDay ) )
{ {
// 11/09/09 DI89SUN223 manoharan to store the sequence number recCounter++;
// (file suffix) in invoice table and increment for the same day }
//recCounter = 1; else
{
pstmtSeq2.setString(1,custCode); // 11/09/09 DI89SUN223 manoharan to store the sequence number
pstmtSeq2.setTimestamp(2,tranDate); // (file suffix) in invoice table and increment for the same day
rsSeq2 = pstmtSeq2.executeQuery(); //recCounter = 1;
if( rsSeq2.next() )
{ pstmtSeq2.setString(1,custCode);
recCounter = rsSeq2.getInt("download_file_seq"); pstmtSeq2.setTimestamp(2,tranDate);
rsSeq2 = pstmtSeq2.executeQuery();
System.out.println(recCounter); if( rsSeq2.next() )
} {
rsSeq2.close(); recCounter = rsSeq2.getInt("download_file_seq");
rsSeq2 = null;
System.out.println(recCounter);
recCounter++; }
rsSeq2.close();
// end 11/09/09 manoharan to store the sequence number (file suffix) rsSeq2 = null;
// in invoice table and increment for the same day
} recCounter++;
System.out.println(recCounter); // end 11/09/09 manoharan to store the sequence number (file suffix)
dnldFileNameServer = ( uniformCode == null ? "" : uniformCode.trim() ) // in invoice table and increment for the same day
+ "_" + dty + "_" }
+ ( new java.text.DecimalFormat( "000" ) ).format( recCounter );
prvCustCode = custCode; System.out.println(recCounter);
previousDay = dt; dnldFileNameServer = ( uniformCode == null ? "" : uniformCode.trim() )
+ "_" + dty + "_"
if("B".equalsIgnoreCase(trfType)) + ( new java.text.DecimalFormat( "000" ) ).format( recCounter );
{ prvCustCode = custCode;
tranFileMip.remove("dnldFileName"); previousDay = dt;
}
tranFileMip.put( "dnldFileName", dnldFileNameServer ); if("B".equalsIgnoreCase(trfType))
download(tranFileMip, downloadLoc); {
retString = "updateSeq"; tranFileMip.remove("dnldFileName");
} }
} tranFileMip.put( "dnldFileName", dnldFileNameServer );
//Changed by Sachin [update the Download_flag and INV_EXP_DATE after download(tranFileMip, downloadLoc);
//each invoice files downloading] retString = "updateSeq";
}
if(retString!=null && !retString.equalsIgnoreCase("ERROR")) }
{ //Changed by Sachin [update the Download_flag and INV_EXP_DATE after
sql = "UPDATE INVOICE SET " //each invoice files downloading]
+" DOWNLOAD_FLAG = 'Y', INV_EXP_DATE = SYSDATE ";
if(retString!=null && !retString.equalsIgnoreCase("ERROR"))
if(!("E".equalsIgnoreCase(trfType))) {
{ sql = "UPDATE INVOICE SET "
sql += ", DOWNLOAD_FILE_SEQ = "+recCounter; +" DOWNLOAD_FLAG = 'Y', INV_EXP_DATE = SYSDATE ";
}
if(!("E".equalsIgnoreCase(trfType)))
sql +=" WHERE INVOICE_ID = ? "; {
sql += ", DOWNLOAD_FILE_SEQ = "+recCounter;
pstmtSeq = conn.prepareStatement(sql); }
pstmtSeq.setString( 1, tranId ); sql +=" WHERE INVOICE_ID = ? ";
int rowCnt = pstmtSeq.executeUpdate(); pstmtSeq = conn.prepareStatement(sql);
System.out.println("Successfully updated =="+rowCnt); pstmtSeq.setString( 1, tranId );
if(rowCnt >= 1) int rowCnt = pstmtSeq.executeUpdate();
{
conn.commit(); System.out.println("Successfully updated =="+rowCnt);
}
else if(rowCnt >= 1)
{ {
conn.rollback(); conn.commit();
} }
pstmtSeq.close(); else
pstmtSeq = null; {
} conn.rollback();
}
pstmtSeq2.close(); pstmtSeq.close();
pstmtSeq2 = null; pstmtSeq = null;
} }
//Changed by Sachin [update the Download_flag and INV_EXP_DATE after
//each invoice files downloading].end pstmtSeq2.close();
pstmtSeq2 = null;
//end - select all the undownloaded invoice, if found, then download for each. }
//Changed by Sachin [update the Download_flag and INV_EXP_DATE after
} //each invoice files downloading].end
}
} //end - select all the undownloaded invoice, if found, then download for each.
catch( Exception pte )
{ }
try{ }
conn.rollback(); }
conn.close(); catch( Exception pte )
conn = null; {
}catch( Exception ex ){} try{
pte.printStackTrace(); conn.rollback();
} conn.close();
conn = null;
} }catch( Exception ex ){}
} pte.printStackTrace();
}
public void updateFlag(String tranId, Connection conn)throws RemoteException, ITMException
{ }
java.sql.PreparedStatement pstmtSeq2 = null; }
try
{ public void updateFlag(String tranId, Connection conn)throws RemoteException, ITMException
pstmtSeq2 = conn.prepareStatement( "UPDATE INVOICE SET " {
+" DOWNLOAD_FLAG = 'Y' WHERE INVOICE_ID = ? " ); java.sql.PreparedStatement pstmtSeq2 = null;
try
pstmtSeq2.setString( 1, tranId ); {
int rowCnt = pstmtSeq2.executeUpdate(); pstmtSeq2 = conn.prepareStatement( "UPDATE INVOICE SET "
if(rowCnt >= 1){ +" DOWNLOAD_FLAG = 'Y' WHERE INVOICE_ID = ? " );
conn.commit();
} pstmtSeq2.setString( 1, tranId );
else{ int rowCnt = pstmtSeq2.executeUpdate();
conn.rollback(); if(rowCnt >= 1){
} conn.commit();
pstmtSeq2.close(); }
pstmtSeq2 = null; else{
} conn.rollback();
catch (Exception e) }
{ pstmtSeq2.close();
System.out.println("Unable to updateFlag (" + e.getMessage() + ")"); pstmtSeq2 = null;
} }
} catch (Exception e)
{
System.out.println("Unable to updateFlag (" + e.getMessage() + ")");
}
public void deleteFile( String filePath)throws RemoteException, ITMException }
{
try
{
// Construct a File object for the file to be deleted. public void deleteFile( String filePath)throws RemoteException, ITMException
File target = new File(filePath); {
try
if (!target.exists()) { {
System.err.println("File " + filePath // Construct a File object for the file to be deleted.
+ " not present to begin with!"); File target = new File(filePath);
return;
} if (!target.exists()) {
System.err.println("File " + filePath
// delete tmp file: + " not present to begin with!");
if (target.delete()) return;
System.err.println("** Deleted " + filePath + " **"); }
else
System.err.println("Failed to delete " + filePath); // delete tmp file:
} if (target.delete())
catch (SecurityException e) System.err.println("** Deleted " + filePath + " **");
{ else
System.err.println("Unable to delete " + filePath + "(" System.err.println("Failed to delete " + filePath);
+ e.getMessage() + ")"); }
} catch (SecurityException e)
} {
System.err.println("Unable to delete " + filePath + "("
+ e.getMessage() + ")");
}
public void download( HashMap map, String downloadLoc)throws RemoteException, ITMException }
{
java.sql.Connection conn = null;
java.sql.PreparedStatement pstmt = null;
java.sql.ResultSet rs = null; public void download( HashMap map, String downloadLoc)throws RemoteException, ITMException
String tranId = null; {
String dnldFileName = null; java.sql.Connection conn = null;
String xmlToCsvStr = null; java.sql.PreparedStatement pstmt = null;
String templDnld = null; java.sql.ResultSet rs = null;
String csvData = null; String tranId = null;
TranXmlData client = null; String dnldFileName = null;
String xmlToCsvStr = null;
String templDnld = null;
ibase.webitm.utility.XML2CSVCustomConverter csvConverter = null; String csvData = null;
csvConverter = new ibase.webitm.utility.XML2CSVCustomConverter(); TranXmlData client = null;
ConnDriver connDriver = new ConnDriver();
client = new TranXmlData();
if( map.size() > 0 ) ibase.webitm.utility.XML2CSVCustomConverter csvConverter = null;
{ csvConverter = new ibase.webitm.utility.XML2CSVCustomConverter();
try ConnDriver connDriver = new ConnDriver();
{ client = new TranXmlData();
conn = connDriver.getConnectDB( "DriverITM" ); if( map.size() > 0 )
conn.setAutoCommit( false ); {
connDriver = null; try
{
tranId = ( String )map.get( "tranId" ); conn = connDriver.getConnectDB( "DriverITM" );
dnldFileName = ( String )map.get( "dnldFileName" ); conn.setAutoCommit( false );
templDnld = ( String )map.get( "templDnld" ); connDriver = null;
xmlToCsvStr = client.getTranXml( "invoice", tranId = ( String )map.get( "tranId" );
java.sql.Timestamp.valueOf( "2008-11-01 00:00:00" ), dnldFileName = ( String )map.get( "dnldFileName" );
java.sql.Timestamp.valueOf( "2008-11-01 00:00:00" ), templDnld = ( String )map.get( "templDnld" );
tranId, tranId, conn );
xmlToCsvStr = client.getTranXml( "invoice",
csvData = csvConverter.convert( xmlToCsvStr, java.sql.Timestamp.valueOf( "2008-11-01 00:00:00" ),
CommonConstants.JBOSSHOME + File.separator + "download" java.sql.Timestamp.valueOf( "2008-11-01 00:00:00" ),
+ File.separator + "template" tranId, tranId, conn );
+ File.separator + templDnld + ".xml", null);
FileWriter fw = new FileWriter( downloadLoc + File.separator + dnldFileName + ".csv" ); csvData = csvConverter.convert( xmlToCsvStr,
CommonConstants.JBOSSHOME + File.separator + "download"
fw.write( csvData ); + File.separator + "template"
fw.close(); + File.separator + templDnld + ".xml", null);
fw = null; FileWriter fw = new FileWriter( downloadLoc + File.separator + dnldFileName + ".csv" );
conn.close();
conn = null; fw.write( csvData );
fw.close();
System.out.println("Inside download "); fw = null;
} conn.close();
catch( Exception ex ) conn = null;
{
//ignore this exception as if one file throws exception next file should download. System.out.println("Inside download ");
} }
catch( Exception ex )
} {
} //ignore this exception as if one file throws exception next file should download.
}
public String sendMail(HashMap hMap, Connection conn)throws Exception
{ }
}
String retString = "";
String to = ""; public String sendMail(HashMap hMap, Connection conn)throws Exception
String from = ""; {
String cc = "";
boolean debug = false; String retString = "";
String subject = "",text = ""; String to = "";
String xmlDataFilePath = ""; String from = "";
java.sql.PreparedStatement pstmtSeq = null; String cc = "";
java.sql.ResultSet rsSeq = null; boolean debug = false;
try String subject = "",text = "";
{ String xmlDataFilePath = "";
Properties props = System.getProperties(); java.sql.PreparedStatement pstmtSeq = null;
props.put("mail.smtp.host", CommonConstants.SMTPHOST); java.sql.ResultSet rsSeq = null;
Authenticator auth = null; try
{
Session session= Session.getDefaultInstance(props,auth); Properties props = System.getProperties();
session.setDebug(debug); props.put("mail.smtp.host", CommonConstants.SMTPHOST);
MimeMessage msg = new MimeMessage(session); Authenticator auth = null;
MimeBodyPart mbp1 = new MimeBodyPart();
MimeBodyPart mbp2 = new MimeBodyPart(); Session session= Session.getDefaultInstance(props,auth);
Multipart mp = new MimeMultipart(); session.setDebug(debug);
MimeMessage msg = new MimeMessage(session);
from = CommonConstants.MAILFROM; MimeBodyPart mbp1 = new MimeBodyPart();
to = (String)hMap.get("TO_ADDR"); MimeBodyPart mbp2 = new MimeBodyPart();
Multipart mp = new MimeMultipart();
subject = (String)hMap.get("SUBJECT");
text = (String)hMap.get("TEXT"); from = CommonConstants.MAILFROM;
xmlDataFilePath = (String)hMap.get("FILEPATH"); to = (String)hMap.get("TO_ADDR");
InternetAddress[] address = {new InternetAddress(to)}; subject = (String)hMap.get("SUBJECT");
text = (String)hMap.get("TEXT");
mbp1.setText(text); xmlDataFilePath = (String)hMap.get("FILEPATH");
mp.addBodyPart(mbp1);
InternetAddress[] address = {new InternetAddress(to)};
// 30/03/10 Sachin---this part is added to send file as attachment.
mbp1.setText(text);
if( xmlDataFilePath != null ) mp.addBodyPart(mbp1);
{
File createdFileObj = null; // 30/03/10 Sachin---this part is added to send file as attachment.
createdFileObj = new File(xmlDataFilePath);
mbp2 = new MimeBodyPart(); if( xmlDataFilePath != null )
DataSource source = new FileDataSource(createdFileObj); {
mbp2.setDataHandler(new DataHandler(source)); File createdFileObj = null;
mbp2.setFileName((createdFileObj.toString()).substring((createdFileObj.toString()).lastIndexOf("\\")+1, createdFileObj.toString().length())); createdFileObj = new File(xmlDataFilePath);
} mbp2 = new MimeBodyPart();
// 30/03/10 Sachin---end of part send file as attachment. DataSource source = new FileDataSource(createdFileObj);
mbp2.setDataHandler(new DataHandler(source));
mp.addBodyPart(mbp2); mbp2.setFileName((createdFileObj.toString()).substring((createdFileObj.toString()).lastIndexOf("\\")+1, createdFileObj.toString().length()));
}
msg.setRecipients(Message.RecipientType.TO, address); // 30/03/10 Sachin---end of part send file as attachment.
// 28/04/10 Sachin---Start to check CC address is present mp.addBodyPart(mbp2);
pstmtSeq = conn.prepareStatement( "SELECT VAR_VALUE FROM DISPARM " msg.setRecipients(Message.RecipientType.TO, address);
+" WHERE PRD_CODE='999999' AND VAR_NAME = 'INV_MAIL_CC' " );
// 28/04/10 Sachin---Start to check CC address is present
rsSeq = pstmtSeq.executeQuery();
if( rsSeq.next() ) pstmtSeq = conn.prepareStatement( "SELECT VAR_VALUE FROM DISPARM "
{ +" WHERE PRD_CODE='999999' AND VAR_NAME = 'INV_MAIL_CC' " );
cc = rsSeq.getString( "VAR_VALUE" );
System.out.println("cc =="+ cc); rsSeq = pstmtSeq.executeQuery();
} if( rsSeq.next() )
rsSeq.close(); {
rsSeq = null; cc = rsSeq.getString( "VAR_VALUE" );
pstmtSeq.close(); System.out.println("cc =="+ cc);
pstmtSeq = null; }
rsSeq.close();
if(cc != null && cc.trim().length() > 0){ rsSeq = null;
InternetAddress[] ccAddress = {new InternetAddress(cc)}; pstmtSeq.close();
msg.setRecipients(Message.RecipientType.CC, ccAddress); pstmtSeq = null;
}
if(cc != null && cc.trim().length() > 0){
// 28/04/10 Sachin---End to check CC address is present InternetAddress[] ccAddress = {new InternetAddress(cc)};
msg.setRecipients(Message.RecipientType.CC, ccAddress);
msg.setSubject(subject); }
msg.setFrom(new InternetAddress(from));
msg.setContent(mp); // 28/04/10 Sachin---End to check CC address is present
msg.setSentDate(new java.util.Date());
msg.setSubject(subject);
if(msg.getRecipients(Message.RecipientType.TO) != null ) msg.setFrom(new InternetAddress(from));
{ msg.setContent(mp);
System.out.println("sending mail ..........."); msg.setSentDate(new java.util.Date());
Transport.send(msg);
} if(msg.getRecipients(Message.RecipientType.TO) != null )
} {
catch (MessagingException mex) System.out.println("sending mail ...........");
{ Transport.send(msg);
retString = "ERROR"; }
System.out.println("SendEMail:MessagingException:\n"); }
mex.printStackTrace(); catch (MessagingException mex)
} {
catch (Exception e) retString = "ERROR";
{ System.out.println("SendEMail:MessagingException:\n");
retString = "ERROR"; mex.printStackTrace();
System.out.println("SendEMail:MessagingException:\n"); }
e.printStackTrace(); catch (Exception e)
} {
return retString; retString = "ERROR";
} System.out.println("SendEMail:MessagingException:\n");
e.printStackTrace();
public String schedule( HashMap map )throws RemoteException, ITMException }
{ return retString;
return ""; }
}
public String schedule( String scheduleParamXML )throws RemoteException, ITMException public String schedule( HashMap map )throws RemoteException, ITMException
{ {
String userInfoList = null; return "";
String isIntractive = null; }
String objName = null; public String schedule( String scheduleParamXML )throws RemoteException, ITMException
String downloadLoc = null; {
String userInfoList = null;
ArrayList paramListArr = new ArrayList(); String isIntractive = null;
String objName = null;
try String downloadLoc = null;
{
//APPLICATION_CONTEXT = CommonConstants.UPLOAD_LOC + File.separator ArrayList paramListArr = new ArrayList();
//+ "webapps" + File.separator + "ibase" + File.separator ;
//System.out.println(" scheduleParamXML [" + scheduleParamXML + "]"); try
{
Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML ); //APPLICATION_CONTEXT = CommonConstants.UPLOAD_LOC + File.separator
NodeList paramList = userInfoDom.getElementsByTagName( "ACTUALPARAMETER" ); //+ "webapps" + File.separator + "ibase" + File.separator ;
// //System.out.println(" scheduleParamXML [" + scheduleParamXML + "]");
int noOfParam = paramList.getLength();
for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ ) Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML );
{ NodeList paramList = userInfoDom.getElementsByTagName( "ACTUALPARAMETER" );
paramListArr.add( ( String )( paramList.item( paramCnt ).getFirstChild().getNodeValue() ) ); //
} int noOfParam = paramList.getLength();
for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ )
//for( int i = 0 ; i < paramListArr.size(); i++ ) {
//{ paramListArr.add( ( String )( paramList.item( paramCnt ).getFirstChild().getNodeValue() ) );
// System.out.println( "My param :: " + (String)paramListArr.get( i ) ); }
//}
// //for( int i = 0 ; i < paramListArr.size(); i++ )
//{
/* // System.out.println( "My param :: " + (String)paramListArr.get( i ) );
System.out.println(" RootNode [ " + rootNode+ " ] "); //}
NodeList propNodeList = rootNode.getChildNodes(); //
System.out.println(" propNodeList [ " + propNodeList+ " ] ");
int noOfProps = propNodeList.getLength(); /*
for( int propCtr = 0; propCtr < noOfProps; propCtr++ ) System.out.println(" RootNode [ " + rootNode+ " ] ");
{ NodeList propNodeList = rootNode.getChildNodes();
Node propNode = propNodeList.item( propCtr ); System.out.println(" propNodeList [ " + propNodeList+ " ] ");
System.out.println(" propNode [" +propNode+"]"); int noOfProps = propNodeList.getLength();
if( propNode != null && propNode.getFirstChild() != null ) for( int propCtr = 0; propCtr < noOfProps; propCtr++ )
{ {
String propName = propNode.getNodeName(); Node propNode = propNodeList.item( propCtr );
System.out.println(" propName [" +propName+"]"); System.out.println(" propNode [" +propNode+"]");
if ( "UserInfoStr".equalsIgnoreCase( propName ) ) if( propNode != null && propNode.getFirstChild() != null )
{ {
userInfoList = propNode.getFirstChild().getNodeValue(); String propName = propNode.getNodeName();
System.out.println(" userInfoList [" + userInfoList + "]"); System.out.println(" propName [" +propName+"]");
} if ( "UserInfoStr".equalsIgnoreCase( propName ) )
else if ( "downloadLoc".equalsIgnoreCase( propName ) ) {
{ userInfoList = propNode.getFirstChild().getNodeValue();
downloadLoc = propNode.getFirstChild().getNodeValue(); System.out.println(" userInfoList [" + userInfoList + "]");
System.out.println(" isIntractive [" + isIntractive + "]"); }
} else if ( "downloadLoc".equalsIgnoreCase( propName ) )
else if ( "objName".equalsIgnoreCase( propName ) ) {
{ downloadLoc = propNode.getFirstChild().getNodeValue();
objName = propNode.getFirstChild().getNodeValue(); System.out.println(" isIntractive [" + isIntractive + "]");
System.out.println(" objName [" + objName + "]"); }
} else if ( "objName".equalsIgnoreCase( propName ) )
else if ( "entityCode".equalsIgnoreCase( propName ) ) {
{ objName = propNode.getFirstChild().getNodeValue();
entityCode = propNode.getFirstChild().getNodeValue(); System.out.println(" objName [" + objName + "]");
System.out.println(" entityCode [" + entityCode + "]"); }
} else if ( "entityCode".equalsIgnoreCase( propName ) )
else if ( "entityType".equalsIgnoreCase( propName ) ) {
{ entityCode = propNode.getFirstChild().getNodeValue();
entityType = propNode.getFirstChild().getNodeValue(); System.out.println(" entityCode [" + entityCode + "]");
System.out.println(" entityType [" + entityType + "]"); }
} else if ( "entityType".equalsIgnoreCase( propName ) )
} {
} entityType = propNode.getFirstChild().getNodeValue();
*/ System.out.println(" entityType [" + entityType + "]");
//downloadTransaction( objName, downloadLoc, entityCode, entityType, null ); }
/* }
List and order of arguments : }
1. location, */
2. Entity Code //downloadTransaction( objName, downloadLoc, entityCode, entityType, null );
3. Entity Type /*
4. Stite Code List and order of arguments :
5. Cust code 1. location,
*/ 2. Entity Code
downloadTransaction( (String)paramListArr.get( 0 ), (String)paramListArr.get( 1 ), 3. Entity Type
(String)paramListArr.get( 2 ), (String)paramListArr.get( 3 ), 4. Stite Code
(String)paramListArr.get( 4 ), (String)paramListArr.get( 5 ) ); 5. Cust code
} */
catch(Exception e) downloadTransaction( (String)paramListArr.get( 0 ), (String)paramListArr.get( 1 ),
{ (String)paramListArr.get( 2 ), (String)paramListArr.get( 3 ),
//System.out.println("DownloadCSVBatchEJB :==>Schedule"); (String)paramListArr.get( 4 ), (String)paramListArr.get( 5 ) );
e.printStackTrace(); }
} catch(Exception e)
{
return ""; //System.out.println("DownloadCSVBatchEJB :==>Schedule");
} e.printStackTrace();
}
return "";
}
} }
\ No newline at end of file
/******************************************* /*******************************************
Title ExpiryProcess Title ExpiryProcess
Developed Date 3/9/2009 Developed Date 3/9/2009
Modified By Ashwin on 05-Aug-10 Modified By Ashwin on 05-Aug-10
// For Getting Processing Sites from Schedulers ActualParameter Instead of DISPARM // For Getting Processing Sites from Schedulers ActualParameter Instead of DISPARM
********************************************/ ********************************************/
package ibase.webitm.ejb.sys; package ibase.webitm.ejb.sys;
import java.util.*; import java.util.*;
import java.sql.*; import java.sql.*;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import org.apache.axis.Constants; import org.apache.axis.Constants;
import org.apache.axis.client.Call; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType; import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode; import javax.xml.rpc.ParameterMode;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import java.util.*; import java.util.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.webitm.utility.GenericUtility ; import ibase.webitm.utility.GenericUtility ;
import ibase.scheduler.utility.interfaces.Schedule; import ibase.scheduler.utility.interfaces.Schedule;
import java.util.Date; import java.util.Date;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
//import org.apache.commons.logging.LogFactory; //import org.apache.commons.logging.LogFactory;
public class ExpiryProcess implements Schedule public class ExpiryProcess implements Schedule
{ {
ibase.utility.GenericUtility genericUtility = new ibase.utility.GenericUtility(); ibase.utility.GenericUtility genericUtility = new ibase.utility.GenericUtility();
Object[] aobj = new Object[4]; Object[] aobj = new Object[4];
//Added By Manoj dtd 05/11/2012 implement abstract method
public String schedule( HashMap map )throws RemoteException, ITMException public String schedulePriority( String wrkflwPriority )throws Exception
{ {
return ""; return "";
} }
public String schedule( String scheduleParamXML )throws RemoteException, ITMException public String schedule( HashMap map )throws RemoteException, ITMException
{ {
System.out.println("\n\n\n\n\n ::::::::::::::::::: ExpiryProcess :::::::::::::::::::::::"); return "";
PreparedStatement pstmt = null ; }
ResultSet rs = null ; public String schedule( String scheduleParamXML )throws RemoteException, ITMException
Connection conn=null; {
String sql=""; System.out.println("\n\n\n\n\n ::::::::::::::::::: ExpiryProcess :::::::::::::::::::::::");
String userInfoList = null; PreparedStatement pstmt = null ;
String isIntractive = null; ResultSet rs = null ;
String objName = null; Connection conn=null;
String varValue = "",varvalue2 = "",varvalue1=""; String sql="";
String addlValue =null; String userInfoList = null;
//String addlValue = ""; String isIntractive = null;
Timestamp frDate = null ,currDate=null,addlValueTm =null,currAppTime = null;//addlValue = null; String objName = null;
SimpleDateFormat currAppdate = null; String varValue = "",varvalue2 = "",varvalue1="";
String lsFromdateStr ="",siteCode = "",retString="",xtraParams="",despid = "",drnoteDateStr = ""; String addlValue =null;
Date lsFromdateDt = null,dateValue = null; //String addlValue = "";
String freshDescr=""; Timestamp frDate = null ,currDate=null,addlValueTm =null,currAppTime = null;//addlValue = null;
String locCode="" ,expLoc = "",nearExpLoc = "" ; SimpleDateFormat currAppdate = null;
StringBuffer filterString = new StringBuffer(); String lsFromdateStr ="",siteCode = "",retString="",xtraParams="",despid = "",drnoteDateStr = "";
StringBuffer fltrArg = null; Date lsFromdateDt = null,dateValue = null;
StringTokenizer stringTokenizer = null; String freshDescr="";
String varName = ""; String locCode="" ,expLoc = "",nearExpLoc = "" ;
StringBuffer filterString = new StringBuffer();
double timdifferance = 0.00; StringBuffer fltrArg = null;
try StringTokenizer stringTokenizer = null;
{ String varName = "";
if( conn == null )
{ double timdifferance = 0.00;
ConnDriver connDriver = new ConnDriver(); try
conn = connDriver.getConnectDB("DriverITM"); {
conn.setAutoCommit(false); if( conn == null )
} {
ConnDriver connDriver = new ConnDriver();
System.out.println(" scheduleParamXML [" + scheduleParamXML + "]"); conn = connDriver.getConnectDB("DriverITM");
Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML ); conn.setAutoCommit(false);
NodeList paramList = userInfoDom.getElementsByTagName( "SCHEDULE" ); }
Node currDetail = null ;
int noOfParam = paramList.getLength(); System.out.println(" scheduleParamXML [" + scheduleParamXML + "]");
for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ ) Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML );
{ NodeList paramList = userInfoDom.getElementsByTagName( "SCHEDULE" );
currDetail = paramList.item(paramCnt); Node currDetail = null ;
siteCode = currDetail.getAttributes().getNamedItem("id").getNodeValue(); int noOfParam = paramList.getLength();
} for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ )
//----- Changes Start By Ashwin On 05-Aug-10 - Begin {
NodeList parentNodeList = null,childNodeList = null; currDetail = paramList.item(paramCnt);
Node parentNode = null,childNode = null; siteCode = currDetail.getAttributes().getNamedItem("id").getNodeValue();
String DisparmSites = ""; }
int childNodeListLength = 0; //----- Changes Start By Ashwin On 05-Aug-10 - Begin
String childNodeName = null; NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
parentNodeList = userInfoDom.getElementsByTagName("ACTUALPARAMETERS"); String DisparmSites = "";
int childNodeListLength = 0;
parentNode = parentNodeList.item(0); String childNodeName = null;
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); parentNodeList = userInfoDom.getElementsByTagName("ACTUALPARAMETERS");
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{ parentNode = parentNodeList.item(0);
childNode = childNodeList.item(ctr); childNodeList = parentNode.getChildNodes();
childNodeName = childNode.getNodeName(); childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName)) {
{ childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(ctr==0)
{ if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
DisparmSites=childNode.getFirstChild().getNodeValue(); {
}
} if(ctr==0)
} {
System.out.println("\n\n :::: Disparm Sites["+DisparmSites+"]"); DisparmSites=childNode.getFirstChild().getNodeValue();
}
//----- Changes End By Ashwin On 05-Aug-10 - End }
}
// code to be migrate System.out.println("\n\n :::: Disparm Sites["+DisparmSites+"]");
java.sql.Timestamp drnoteDate = new java.sql.Timestamp( System.currentTimeMillis() );
drnoteDateStr = genericUtility.getValidDateString(drnoteDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); //----- Changes End By Ashwin On 05-Aug-10 - End
sql="select var_value,descr " // code to be migrate
+"from disparm " java.sql.Timestamp drnoteDate = new java.sql.Timestamp( System.currentTimeMillis() );
+ "where prd_code = '999999' " drnoteDateStr = genericUtility.getValidDateString(drnoteDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
+ "and var_name = 'ALLOC_FGLOC' " ;
pstmt = conn.prepareStatement( sql ); sql="select var_value,descr "
rs = pstmt.executeQuery(); +"from disparm "
if( rs.next() ) + "where prd_code = '999999' "
{ + "and var_name = 'ALLOC_FGLOC' " ;
locCode = rs.getString("var_value") == null?"":rs.getString("var_value"); pstmt = conn.prepareStatement( sql );
freshDescr = rs.getString("descr") == null?"":rs.getString("descr") ; rs = pstmt.executeQuery();
} if( rs.next() )
rs.close(); {
pstmt.close(); locCode = rs.getString("var_value") == null?"":rs.getString("var_value");
rs=null; freshDescr = rs.getString("descr") == null?"":rs.getString("descr") ;
pstmt = null; }
sql="select var_value " rs.close();
+"from disparm " pstmt.close();
+ "where prd_code = '999999' " rs=null;
+ "and var_name = 'NEAREXP_LOC' " ; pstmt = null;
pstmt = conn.prepareStatement( sql ); sql="select var_value "
rs = pstmt.executeQuery(); +"from disparm "
if( rs.next() ) + "where prd_code = '999999' "
{ + "and var_name = 'NEAREXP_LOC' " ;
nearExpLoc = rs.getString("var_value")==null?"":rs.getString("var_value"); pstmt = conn.prepareStatement( sql );
} rs = pstmt.executeQuery();
rs.close(); if( rs.next() )
pstmt.close(); {
rs=null; nearExpLoc = rs.getString("var_value")==null?"":rs.getString("var_value");
pstmt = null; }
rs.close();
sql="select var_value " pstmt.close();
+"from disparm " rs=null;
+ "where prd_code = '999999' " pstmt = null;
+ "and var_name = 'EXP_LOC' " ;
pstmt = conn.prepareStatement( sql ); sql="select var_value "
rs = pstmt.executeQuery(); +"from disparm "
if( rs.next() ) + "where prd_code = '999999' "
{ + "and var_name = 'EXP_LOC' " ;
expLoc = rs.getString("var_value")==null?"":rs.getString("var_value"); pstmt = conn.prepareStatement( sql );
} rs = pstmt.executeQuery();
rs.close(); if( rs.next() )
pstmt.close(); {
rs=null; expLoc = rs.getString("var_value")==null?"":rs.getString("var_value");
pstmt = null; }
// end of code rs.close();
//sql = "select site_code from site " ; pstmt.close();
rs=null;
//-- Commented By Ashwin On 05-Aug-10 - Begin pstmt = null;
// So as to get Sites from scheduler ActualParameter Instead of DISPLARM // end of code
/*sql = " SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE='999999' AND VAR_NAME = 'AUTONEARCHARGESITE' " ; //sql = "select site_code from site " ;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); //-- Commented By Ashwin On 05-Aug-10 - Begin
if(rs.next()) // So as to get Sites from scheduler ActualParameter Instead of DISPLARM
{ /*sql = " SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE='999999' AND VAR_NAME = 'AUTONEARCHARGESITE' " ;
varName = rs.getString("var_value"); pstmt = conn.prepareStatement(sql);
} rs = pstmt.executeQuery();
rs.close(); if(rs.next())
pstmt.close(); {
rs=null; varName = rs.getString("var_value");
pstmt = null; }
stringTokenizer = new StringTokenizer(varName ,","); rs.close();
*/ pstmt.close();
//Changes Done by Ashwin On 05-Aug-10 - End rs=null;
pstmt = null;
stringTokenizer = new StringTokenizer(DisparmSites ,","); stringTokenizer = new StringTokenizer(varName ,",");
while(stringTokenizer.hasMoreElements()) */
{ //Changes Done by Ashwin On 05-Aug-10 - End
filterString.append(stringTokenizer.nextToken()).append("\t");
filterString.append(drnoteDateStr).append("\t"); stringTokenizer = new StringTokenizer(DisparmSites ,",");
filterString.append("00").append("\t"); while(stringTokenizer.hasMoreElements())
filterString.append("ZZ").append("\t"); {
//filterString.append("").append("\t");// changes for nearexpiry and expiry filterString.append(stringTokenizer.nextToken()).append("\t");
fltrArg = new StringBuffer( filterString.toString() ); filterString.append(drnoteDateStr).append("\t");
fltrArg.append(nearExpLoc).append("\t"); // nearexpiery to nearexppiery filterString.append("00").append("\t");
fltrArg.append(nearExpLoc).append("\t"); filterString.append("ZZ").append("\t");
fltrArg.append("E").append("\t"); //filterString.append("").append("\t");// changes for nearexpiry and expiry
fltrArg.append("\n"); fltrArg = new StringBuffer( filterString.toString() );
retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn ); fltrArg.append(nearExpLoc).append("\t"); // nearexpiery to nearexppiery
fltrArg = new StringBuffer( filterString.toString() ); fltrArg.append(nearExpLoc).append("\t");
fltrArg.append(locCode).append("\t"); //fresh to fresh using nearExpieryLocation fltrArg.append("E").append("\t");
fltrArg.append(locCode).append("\t"); fltrArg.append("\n");
fltrArg.append("N").append("\t"); retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn );
fltrArg.append("\n"); fltrArg = new StringBuffer( filterString.toString() );
retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn ); fltrArg.append(locCode).append("\t"); //fresh to fresh using nearExpieryLocation
fltrArg = new StringBuffer( filterString.toString() ); fltrArg.append(locCode).append("\t");
fltrArg.append(locCode).append("\t"); //fresh to fresh using ExpieryLocaltion fltrArg.append("N").append("\t");
fltrArg.append(locCode).append("\t"); fltrArg.append("\n");
fltrArg.append("E").append("\t"); retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn );
fltrArg.append("\n"); fltrArg = new StringBuffer( filterString.toString() );
retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn ); fltrArg.append(locCode).append("\t"); //fresh to fresh using ExpieryLocaltion
filterString.setLength(0); fltrArg.append(locCode).append("\t");
} fltrArg.append("E").append("\t");
} fltrArg.append("\n");
catch(Exception e) retString = callNvo( fltrArg.toString(), "near_expiry", "pr_default_1", conn );
{ filterString.setLength(0);
e.printStackTrace(); }
} }
return ""; catch(Exception e)
} // end of schedule {
public String callNvo( String filterData, String objName, String serviceCode, Connection conn ) throws ITMException e.printStackTrace();
{ }
String methodName = ""; return "";
String retString = ""; } // end of schedule
String serviceURI = ""; public String callNvo( String filterData, String objName, String serviceCode, Connection conn ) throws ITMException
String actionURI = ""; {
String selectSql = "" , selectSqlSec = "" ; String methodName = "";
String businessObj = "",xtraParams = ""; String retString = "";
Statement stmt = null; String serviceURI = "";
PreparedStatement pstmt = null; String actionURI = "";
ResultSet rs = null; String selectSql = "" , selectSqlSec = "" ;
try String businessObj = "",xtraParams = "";
{ Statement stmt = null;
PreparedStatement pstmt = null;
//businessObj = "nvo_bo_finance_charge_calc"; ResultSet rs = null;
selectSql = "SELECT comp_name FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND service_code = ? "; try
System.out.println("\nselectSql :: "+selectSql); {
pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1,objName); //businessObj = "nvo_bo_finance_charge_calc";
pstmt.setString(2,serviceCode); selectSql = "SELECT comp_name FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND service_code = ? ";
rs = pstmt.executeQuery(); System.out.println("\nselectSql :: "+selectSql);
//stmt = conn.createStatement(); pstmt = conn.prepareStatement(selectSql);
//rs = stmt.executeQuery(selectSql); pstmt.setString(1,objName);
if ( rs.next() ) pstmt.setString(2,serviceCode);
{ rs = pstmt.executeQuery();
businessObj = rs.getString( "comp_name" ); //stmt = conn.createStatement();
} //rs = stmt.executeQuery(selectSql);
System.out.println("businessObj :: "+businessObj); if ( rs.next() )
rs.close(); {
pstmt.close(); businessObj = rs.getString( "comp_name" );
rs = null; }
pstmt = null; System.out.println("businessObj :: "+businessObj);
selectSqlSec = "SELECT SERVICE_URI, METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; rs.close();
System.out.println("\nselectSql :: "+selectSqlSec); pstmt.close();
pstmt = conn.prepareStatement(selectSqlSec); rs = null;
pstmt.setString(1,serviceCode); pstmt = null;
rs = pstmt.executeQuery(); selectSqlSec = "SELECT SERVICE_URI, METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
//rs = stmt.executeQuery(selectSql); System.out.println("\nselectSql :: "+selectSqlSec);
if ( rs.next() ) pstmt = conn.prepareStatement(selectSqlSec);
{ pstmt.setString(1,serviceCode);
serviceURI = rs.getString( "SERVICE_URI" ); rs = pstmt.executeQuery();
methodName = rs.getString( "METHOD_NAME" ); //rs = stmt.executeQuery(selectSql);
} if ( rs.next() )
actionURI = "http://NvoServiceurl.org/"+methodName; {
System.out.println("\n actionURI :: "+actionURI); serviceURI = rs.getString( "SERVICE_URI" );
Service service = new Service(); methodName = rs.getString( "METHOD_NAME" );
Call call = ( Call )service.createCall(); }
call.setTargetEndpointAddress(new java.net.URL(serviceURI)); actionURI = "http://NvoServiceurl.org/"+methodName;
System.out.println("\n actionURI :: "+actionURI);
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) ); Service service = new Service();
call.setUseSOAPAction(true); Call call = ( Call )service.createCall();
call.setSOAPActionURI(actionURI); call.setTargetEndpointAddress(new java.net.URL(serviceURI));
Object[] aobj = new Object[4];
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN); call.setUseSOAPAction(true);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN); call.setSOAPActionURI(actionURI);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN); Object[] aobj = new Object[4];
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(businessObj); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[1] = new String(filterData); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[2] = new String( "" ); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[3] = new String( xtraParams );// passed blank as It can not be created from scheduler
aobj[0] = new String(businessObj);
call.setReturnType(XMLType.XSD_STRING); aobj[1] = new String(filterData);
retString = (String)call.invoke( aobj ); aobj[2] = new String( "" );
System.out.println("Return value [" + retString +"]"); aobj[3] = new String( xtraParams );// passed blank as It can not be created from scheduler
}
catch(Exception e) call.setReturnType(XMLType.XSD_STRING);
{ retString = (String)call.invoke( aobj );
e.printStackTrace(); System.out.println("Return value [" + retString +"]");
throw new ITMException(e); }
} catch(Exception e)
finally {
{ e.printStackTrace();
try throw new ITMException(e);
{ }
if(rs!=null) finally
{ {
rs.close(); try
rs=null; {
} if(rs!=null)
if (pstmt != null ) {
{ rs.close();
pstmt.close(); rs=null;
pstmt = null; }
} if (pstmt != null )
} {
catch(Exception e) pstmt.close();
{ e.printStackTrace();} pstmt = null;
} }
return retString ; }
} catch(Exception e)
{ e.printStackTrace();}
}
return retString ;
}
} }
\ No newline at end of file
/******************************************* /*******************************************
Developed Date 3/9/2009 Developed Date 3/9/2009
Modified By Ashwin on 05-Aug-10 Modified By Ashwin on 05-Aug-10
// For Getting Processing Sites from Scheduler's ActualParameter Instead of FINPARM // For Getting Processing Sites from Scheduler's ActualParameter Instead of FINPARM
********************************************/ ********************************************/
package ibase.webitm.ejb.sys; package ibase.webitm.ejb.sys;
import java.util.*; import java.util.*;
import java.sql.*; import java.sql.*;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import org.apache.axis.Constants; import org.apache.axis.Constants;
import org.apache.axis.client.Call; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType; import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode; import javax.xml.rpc.ParameterMode;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import java.util.*; import java.util.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.webitm.utility.GenericUtility ; import ibase.webitm.utility.GenericUtility ;
import ibase.scheduler.utility.interfaces.Schedule; import ibase.scheduler.utility.interfaces.Schedule;
import java.util.Date; import java.util.Date;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
//import org.apache.commons.logging.LogFactory; //import org.apache.commons.logging.LogFactory;
public class FinChargeCalcPrc implements Schedule public class FinChargeCalcPrc implements Schedule
{ {
ibase.utility.GenericUtility genericUtility = new ibase.utility.GenericUtility(); ibase.utility.GenericUtility genericUtility = new ibase.utility.GenericUtility();
public String schedule( HashMap map )throws RemoteException, ITMException //Added By Manoj dtd 05/11/2012 implement abstract method
{ public String schedulePriority( String wrkflwPriority )throws Exception
{
return ""; return "";
} }
public String schedule( String scheduleParamXML )throws RemoteException, ITMException public String schedule( HashMap map )throws RemoteException, ITMException
{ {
System.out.println("\n\n::::: FinChargeCalcPrc ::::::::: ");
System.out.println("\n\n::::: INside scheduleParamXML [" + scheduleParamXML + "]"); return "";
PreparedStatement pstmt = null ; }
ResultSet rs = null ; public String schedule( String scheduleParamXML )throws RemoteException, ITMException
Connection conn=null; {
String sql=""; System.out.println("\n\n::::: FinChargeCalcPrc ::::::::: ");
String userInfoList = null; System.out.println("\n\n::::: INside scheduleParamXML [" + scheduleParamXML + "]");
String isIntractive = null; PreparedStatement pstmt = null ;
String objName = null; ResultSet rs = null ;
String downloadLoc = null; Connection conn=null;
String varValue = "",varvalue2 = "",varvalue1="",drnoteDateStr = ""; String sql="";
//String addlValue =null; String userInfoList = null;
//String addlValue = ""; String isIntractive = null;
Timestamp frDate = null ,currDate=null,addlValueTm =null;//addlValue = null; String objName = null;
SimpleDateFormat currAppdate = null; String downloadLoc = null;
String lsFromdateStr ="",siteCode = "",retString="",despid = "",addlValueMinFin="",varValueMinFin="",addlValueStr="",frDateStr = ""; String varValue = "",varvalue2 = "",varvalue1="",drnoteDateStr = "";
Timestamp lsFromdateDt = null,dateValue = null,addlValue=null; //String addlValue =null;
ArrayList paramListArr = new ArrayList(); //String addlValue = "";
double timdifferance = 0.00; Timestamp frDate = null ,currDate=null,addlValueTm =null;//addlValue = null;
StringBuffer filterString = null; SimpleDateFormat currAppdate = null;
filterString = new StringBuffer(); String lsFromdateStr ="",siteCode = "",retString="",despid = "",addlValueMinFin="",varValueMinFin="",addlValueStr="",frDateStr = "";
StringTokenizer stringTokenizer = null; Timestamp lsFromdateDt = null,dateValue = null,addlValue=null;
String varName = ""; ArrayList paramListArr = new ArrayList();
String chgUse = ""; double timdifferance = 0.00;
try StringBuffer filterString = null;
{ filterString = new StringBuffer();
if( conn == null ) StringTokenizer stringTokenizer = null;
{ String varName = "";
ConnDriver connDriver = new ConnDriver(); String chgUse = "";
conn = connDriver.getConnectDB("DriverITM"); try
conn.setAutoCommit(false); {
} if( conn == null )
System.out.println(" scheduleParamXML [" + scheduleParamXML + "]"); {
Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML ); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
//----- Changes Start By Ashwin 31/07/10 - Begin conn.setAutoCommit(false);
NodeList parentNodeList = null,childNodeList = null; }
Node parentNode = null,childNode = null; System.out.println(" scheduleParamXML [" + scheduleParamXML + "]");
String finSites = ""; Document userInfoDom = new ibase.utility.GenericUtility().parseString( scheduleParamXML );
int childNodeListLength = 0;
String childNodeName = null; //----- Changes Start By Ashwin 31/07/10 - Begin
NodeList parentNodeList = null,childNodeList = null;
parentNodeList = userInfoDom.getElementsByTagName("ACTUALPARAMETERS"); Node parentNode = null,childNode = null;
String finSites = "";
parentNode = parentNodeList.item(0); int childNodeListLength = 0;
childNodeList = parentNode.getChildNodes(); String childNodeName = null;
childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++) parentNodeList = userInfoDom.getElementsByTagName("ACTUALPARAMETERS");
{
childNode = childNodeList.item(ctr); parentNode = parentNodeList.item(0);
childNodeName = childNode.getNodeName(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName)) for(int ctr = 0; ctr < childNodeListLength; ctr++)
{ {
childNode = childNodeList.item(ctr);
if(ctr==0) childNodeName = childNode.getNodeName();
{
finSites=childNode.getFirstChild().getNodeValue(); if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
} {
}
} if(ctr==0)
System.out.println("\n\n :::: finSites["+finSites+"]"); {
finSites=childNode.getFirstChild().getNodeValue();
//----- Changes End By Ashwin 31/07/10 - End }
}
NodeList paramList = userInfoDom.getElementsByTagName( "SCHEDULE" ); }
Node currDetail = null ; System.out.println("\n\n :::: finSites["+finSites+"]");
int noOfParam = paramList.getLength();
//System.out.println("noOfParam>>>>>"+noOfParam); //----- Changes End By Ashwin 31/07/10 - End
for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ )
{ NodeList paramList = userInfoDom.getElementsByTagName( "SCHEDULE" );
currDetail = paramList.item(paramCnt); Node currDetail = null ;
siteCode = currDetail.getAttributes().getNamedItem("id").getNodeValue(); int noOfParam = paramList.getLength();
} //System.out.println("noOfParam>>>>>"+noOfParam);
//start code 08/10/09 for( int paramCnt = 0; paramCnt < noOfParam ; paramCnt++ )
{
chgUse = userInfoDom.getElementsByTagName( "loginCode" ).item(0).getFirstChild().getNodeValue(); currDetail = paramList.item(paramCnt);
siteCode = currDetail.getAttributes().getNamedItem("id").getNodeValue();
//System.out.println("loginCodeBase>>>"+loginCodeBase); }
//end code 08/10/09 //start code 08/10/09
// code to be migrate for itmdefault chgUse = userInfoDom.getElementsByTagName( "loginCode" ).item(0).getFirstChild().getNodeValue();
java.sql.Timestamp drnoteDate = new java.sql.Timestamp( System.currentTimeMillis() );
drnoteDateStr = genericUtility.getValidDateString(drnoteDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); //System.out.println("loginCodeBase>>>"+loginCodeBase);
//System.out.println("drnoteDate>>>"+drnoteDate); //end code 08/10/09
sql="select var_value, addl_value "
+" from finparm " // code to be migrate for itmdefault
+" where var_name='FIN_CHARGE_DATE' " java.sql.Timestamp drnoteDate = new java.sql.Timestamp( System.currentTimeMillis() );
+" and prd_code='999999' " ; drnoteDateStr = genericUtility.getValidDateString(drnoteDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
pstmt = conn.prepareStatement( sql ); //System.out.println("drnoteDate>>>"+drnoteDate);
rs = pstmt.executeQuery(); sql="select var_value, addl_value "
if( rs.next() ) +" from finparm "
{ +" where var_name='FIN_CHARGE_DATE' "
varValue = rs.getString("var_value")==null?"":rs.getString("var_value"); +" and prd_code='999999' " ;
addlValueStr = rs.getString("addl_value") ; pstmt = conn.prepareStatement( sql );
} rs = pstmt.executeQuery();
System.out.println(">>>>>>>>>>>>value>>>>>>>" + varValue); if( rs.next() )
System.out.println(">>>>>>>>>>>>addlValue>>>>>>>" + addlValueStr); {
rs.close(); varValue = rs.getString("var_value")==null?"":rs.getString("var_value");
rs=null; addlValueStr = rs.getString("addl_value") ;
pstmt.close(); }
pstmt = null; System.out.println(">>>>>>>>>>>>value>>>>>>>" + varValue);
System.out.println(">>>>>>>>>>>>addlValue>>>>>>>" + addlValueStr);
if(varValue==null || varValue.trim().length()==0) rs.close();
{ rs=null;
varValue = "P"; pstmt.close();
} pstmt = null;
if( "P".equalsIgnoreCase( varValue ) && addlValueStr != null )
{ if(varValue==null || varValue.trim().length()==0)
{
// 12/09/09 manoharan first change to db date format varValue = "P";
//addlValueStr = genericUtility.getValidDateString(addlValue.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); }
frDateStr = addlValueStr ; //genericUtility.getValidDateString(addlValueStr.toString(), genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); if( "P".equalsIgnoreCase( varValue ) && addlValueStr != null )
// end 12/09/09 manoharan first change to db date format {
//frDate = java.sql.Timestamp.valueOf(frDateStr + " 00:00:00");
System.out.println("frDateStr>>>>>>>>"+frDateStr); // 12/09/09 manoharan first change to db date format
}else if( "U".equalsIgnoreCase( varValue ) ) //addlValueStr = genericUtility.getValidDateString(addlValue.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
{ frDateStr = addlValueStr ; //genericUtility.getValidDateString(addlValueStr.toString(), genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
frDate =null; // end 12/09/09 manoharan first change to db date format
} //frDate = java.sql.Timestamp.valueOf(frDateStr + " 00:00:00");
else if( "F".equalsIgnoreCase( varValue ) ) System.out.println("frDateStr>>>>>>>>"+frDateStr);
{ }else if( "U".equalsIgnoreCase( varValue ) )
sql=" select fr_date from acctprd where code = ( select acct_prd from parameter )" ; {
pstmt = conn.prepareStatement(sql); frDate =null;
rs = pstmt.executeQuery(); }
if( rs.next() ) else if( "F".equalsIgnoreCase( varValue ) )
{ {
frDate = rs.getTimestamp("fr_date"); sql=" select fr_date from acctprd where code = ( select acct_prd from parameter )" ;
} pstmt = conn.prepareStatement(sql);
//System.out.println("frDate>>>>>>>>"+frDate); rs = pstmt.executeQuery();
frDateStr = genericUtility.getValidDateString(frDate.toString(),genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()); if( rs.next() )
//System.out.println("frDateStr>>>>>>>>"+frDateStr); {
rs.close(); frDate = rs.getTimestamp("fr_date");
rs=null; }
pstmt.close(); //System.out.println("frDate>>>>>>>>"+frDate);
pstmt=null; frDateStr = genericUtility.getValidDateString(frDate.toString(),genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
sql="select var_value, addl_value from finparm " //System.out.println("frDateStr>>>>>>>>"+frDateStr);
+" where prd_code = '999999' and var_name ='FINCHG_START_DATE' " ; rs.close();
pstmt = conn.prepareStatement(sql); rs=null;
rs = pstmt.executeQuery(); pstmt.close();
if( rs.next() ) pstmt=null;
{ sql="select var_value, addl_value from finparm "
varvalue1 = rs.getString("var_value"); +" where prd_code = '999999' and var_name ='FINCHG_START_DATE' " ;
varvalue2 = rs.getString("addl_value"); pstmt = conn.prepareStatement(sql);
} rs = pstmt.executeQuery();
//System.out.println("varvalue1>>>>>>>>"+varvalue1); if( rs.next() )
//System.out.println("varvalue2>>>>>>>>"+varvalue2); {
rs.close(); varvalue1 = rs.getString("var_value");
rs=null; varvalue2 = rs.getString("addl_value");
pstmt.close(); }
pstmt=null; //System.out.println("varvalue1>>>>>>>>"+varvalue1);
/*if(varvalue2 == null || varvalue2.trim().length()== 0 ) //System.out.println("varvalue2>>>>>>>>"+varvalue2);
{ rs.close();
lsFromdateStr = varvalue1 ; rs=null;
} pstmt.close();
else pstmt=null;
{ /*if(varvalue2 == null || varvalue2.trim().length()== 0 )
lsFromdateStr = varvalue1 + varvalue2 ; {
}*/ lsFromdateStr = varvalue1 ;
//lsFromdateStr = genericUtility.getValidDateString(lsFromdateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); }
//lsFromdateDt = java.sql.Timestamp.valueOf(lsFromdateStr + " 00:00:00"); else
/*if ( !"NULLFOUND".equalsIgnoreCase( lsFromdateStr ) && (lsFromdateStr.trim().length() > 0)) {
{ lsFromdateStr = varvalue1 + varvalue2 ;
frDateStr = genericUtility.getValidDateString(frDate.toString(),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()); }*/
//frDate = java.sql.Timestamp.valueOf(frDateStr + " 00:00:00"); //lsFromdateStr = genericUtility.getValidDateString(lsFromdateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
timdifferance = genericUtility.timeDiff(frDate,lsFromdateDt); //lsFromdateDt = java.sql.Timestamp.valueOf(lsFromdateStr + " 00:00:00");
if(timdifferance <0) /*if ( !"NULLFOUND".equalsIgnoreCase( lsFromdateStr ) && (lsFromdateStr.trim().length() > 0))
{ {
frDateStr = lsFromdateStr ; frDateStr = genericUtility.getValidDateString(frDate.toString(),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
} //frDate = java.sql.Timestamp.valueOf(frDateStr + " 00:00:00");
}*/ timdifferance = genericUtility.timeDiff(frDate,lsFromdateDt);
if ( varvalue2 !=null &&(varvalue2.trim().length() > 0) ) if(timdifferance <0)
{ {
//System.out.println("varvalue2.toString()>>>>>>>>"+varvalue2.toString()); frDateStr = lsFromdateStr ;
java.sql.Timestamp lsFromdateDate = Timestamp.valueOf(genericUtility.getValidDateString(varvalue2, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); }
}*/
java.sql.Timestamp frDatedate = Timestamp.valueOf(genericUtility.getValidDateString(frDateStr.toString(), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); if ( varvalue2 !=null &&(varvalue2.trim().length() > 0) )
{
if(frDatedate.compareTo (lsFromdateDate) < 0 ) //System.out.println("varvalue2.toString()>>>>>>>>"+varvalue2.toString());
{ java.sql.Timestamp lsFromdateDate = Timestamp.valueOf(genericUtility.getValidDateString(varvalue2, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
frDateStr = lsFromdateStr ;
frDateStr = genericUtility.getValidDateString(frDateStr.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); java.sql.Timestamp frDatedate = Timestamp.valueOf(genericUtility.getValidDateString(frDateStr.toString(), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("frDateStr>>>>>>>>"+frDateStr);
} if(frDatedate.compareTo (lsFromdateDate) < 0 )
} {
} frDateStr = lsFromdateStr ;
sql=" select var_value " frDateStr = genericUtility.getValidDateString(frDateStr.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
+ "from finparm " System.out.println("frDateStr>>>>>>>>"+frDateStr);
+ " where var_name='TRANTYPE_FINCHRGCALC' " }
+" and prd_code='999999' " ; }
pstmt = conn.prepareStatement(sql); }
rs = pstmt.executeQuery(); sql=" select var_value "
if( rs.next() ) + "from finparm "
{ + " where var_name='TRANTYPE_FINCHRGCALC' "
varValue = rs.getString("var_value")==null?"":rs.getString("var_value").trim(); +" and prd_code='999999' " ;
} pstmt = conn.prepareStatement(sql);
rs.close(); rs = pstmt.executeQuery();
rs=null; if( rs.next() )
pstmt.close(); {
pstmt = null; varValue = rs.getString("var_value")==null?"":rs.getString("var_value").trim();
}
sql=" select var_value,addl_value " rs.close();
+ "from finparm " rs=null;
+ " where var_name='MIN_FINCHG_AR' " pstmt.close();
+" and prd_code='999999' " ; pstmt = null;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); sql=" select var_value,addl_value "
if( rs.next() ) + "from finparm "
{ + " where var_name='MIN_FINCHG_AR' "
varValueMinFin = rs.getString("var_value")==null?"":rs.getString("var_value").trim(); +" and prd_code='999999' " ;
addlValueMinFin = rs.getString("addl_value")==null?"":rs.getString("addl_value").trim(); pstmt = conn.prepareStatement(sql);
} rs = pstmt.executeQuery();
//System.out.println("varValueMinFin>>>>>>>>"+varValueMinFin); if( rs.next() )
//System.out.println("addlValueMinFin>>>>>>>>"+addlValueMinFin); {
rs.close(); varValueMinFin = rs.getString("var_value")==null?"":rs.getString("var_value").trim();
rs=null; addlValueMinFin = rs.getString("addl_value")==null?"":rs.getString("addl_value").trim();
pstmt.close(); }
pstmt = null; //System.out.println("varValueMinFin>>>>>>>>"+varValueMinFin);
sql=" select var_value ,addl_value " //System.out.println("addlValueMinFin>>>>>>>>"+addlValueMinFin);
+ "from finparm " rs.close();
+ " where var_name='ACCT_AR_FINCHG_AR' " rs=null;
+" and prd_code='999999' " ; pstmt.close();
pstmt = conn.prepareStatement(sql); pstmt = null;
rs = pstmt.executeQuery(); sql=" select var_value ,addl_value "
if( rs.next() ) + "from finparm "
{ + " where var_name='ACCT_AR_FINCHG_AR' "
varvalue1 = rs.getString("var_value")==null?"":rs.getString("var_value").trim(); +" and prd_code='999999' " ;
varvalue2 = rs.getString("addl_value")==null?"":rs.getString("addl_value").trim(); pstmt = conn.prepareStatement(sql);
} rs = pstmt.executeQuery();
//System.out.println("varvalue1>>>>>>>>"+varvalue1); if( rs.next() )
//System.out.println("varvalue2>>>>>>>>"+varvalue2); {
rs.close(); varvalue1 = rs.getString("var_value")==null?"":rs.getString("var_value").trim();
rs=null; varvalue2 = rs.getString("addl_value")==null?"":rs.getString("addl_value").trim();
pstmt.close(); }
pstmt = null; //System.out.println("varvalue1>>>>>>>>"+varvalue1);
// end of code //System.out.println("varvalue2>>>>>>>>"+varvalue2);
//sql = "select site_code from site " ; rs.close();
//sql= "select * from disAUTONEARCHARGESITE rs=null;
String xtraParams = getXtraParams( userInfoDom , siteCode , conn ); pstmt.close();
System.out.println("xtraParams...\n"+xtraParams); pstmt = null;
/*Changes Done By ashwin on 31/07/10 - Begin // end of code
sql = " SELECT VAR_VALUE FROM FINPARM WHERE PRD_CODE='999999' AND VAR_NAME='AUTOFINCHARGESITE' " ; //sql = "select site_code from site " ;
pstmt = conn.prepareStatement(sql); //sql= "select * from disAUTONEARCHARGESITE
rs = pstmt.executeQuery(); String xtraParams = getXtraParams( userInfoDom , siteCode , conn );
if(rs.next()) System.out.println("xtraParams...\n"+xtraParams);
{ /*Changes Done By ashwin on 31/07/10 - Begin
varName = rs.getString("var_value"); sql = " SELECT VAR_VALUE FROM FINPARM WHERE PRD_CODE='999999' AND VAR_NAME='AUTOFINCHARGESITE' " ;
} pstmt = conn.prepareStatement(sql);
rs.close(); rs = pstmt.executeQuery();
pstmt.close(); if(rs.next())
rs=null; {
pstmt = null; varName = rs.getString("var_value");
stringTokenizer = new StringTokenizer(varName ,",");*/ }
rs.close();
//Changes Done By ashwin on31/07/10 - End pstmt.close();
//So as to get Sites from scheduler ActualParameter Instead of FINPARM rs=null;
stringTokenizer = new StringTokenizer(finSites ,","); pstmt = null;
//Changes Done By ashwin on 7/31/2010 stringTokenizer = new StringTokenizer(varName ,",");*/
while(stringTokenizer.hasMoreElements())
{ //Changes Done By ashwin on31/07/10 - End
filterString.append(stringTokenizer.nextToken()).append("\t"); //So as to get Sites from scheduler ActualParameter Instead of FINPARM
filterString.append(frDateStr).append("\t"); stringTokenizer = new StringTokenizer(finSites ,",");
filterString.append(drnoteDateStr).append("\t"); //Changes Done By ashwin on 7/31/2010
filterString.append(varValueMinFin + addlValueMinFin).append("\t"); while(stringTokenizer.hasMoreElements())
filterString.append(drnoteDate).append("\t"); {
filterString.append(varvalue1).append("\t"); filterString.append(stringTokenizer.nextToken()).append("\t");
filterString.append(varvalue1).append("\t"); filterString.append(frDateStr).append("\t");
filterString.append("0").append("\t"); filterString.append(drnoteDateStr).append("\t");
filterString.append("Z").append("\t"); filterString.append(varValueMinFin + addlValueMinFin).append("\t");
filterString.append("Y").append("\t"); filterString.append(drnoteDate).append("\t");
filterString.append("Y").append("\t"); filterString.append(varvalue1).append("\t");
filterString.append(varValue ).append("\t"); filterString.append(varvalue1).append("\t");
filterString.append("0").append("\t"); filterString.append("0").append("\t");
filterString.append("\n"); filterString.append("Z").append("\t");
System.out.println("frDateStr>>>2>>>>>"+frDateStr); filterString.append("Y").append("\t");
System.out.println("Data sent ["+filterString.toString() + "]"); filterString.append("Y").append("\t");
// added chgUse in callNvo() on 08/10/09 for xtrapram filterString.append(varValue ).append("\t");
retString = callNvo( filterString.toString(), "finance_charge_calc", "pr_default_1",xtraParams, conn ); filterString.append("0").append("\t");
// end filterString.append("\n");
filterString.setLength(0); System.out.println("frDateStr>>>2>>>>>"+frDateStr);
} System.out.println("Data sent ["+filterString.toString() + "]");
} // added chgUse in callNvo() on 08/10/09 for xtrapram
catch(Exception e) retString = callNvo( filterString.toString(), "finance_charge_calc", "pr_default_1",xtraParams, conn );
{ // end
e.printStackTrace(); filterString.setLength(0);
} }
return ""; }
} // end of schedule catch(Exception e)
public String callNvo( String filterData, String objName, String serviceCode,String xtraParams , Connection conn ) throws ITMException {
{ e.printStackTrace();
String methodName = ""; }
String retString = ""; return "";
String serviceURI = ""; } // end of schedule
String actionURI = ""; public String callNvo( String filterData, String objName, String serviceCode,String xtraParams , Connection conn ) throws ITMException
String selectSql = ""; {
String businessObj = ""; String methodName = "";
PreparedStatement pStmt = null; String retString = "";
ResultSet rs = null; String serviceURI = "";
try String actionURI = "";
{ String selectSql = "";
//businessObj = "nvo_bo_finance_charge_calc"; String businessObj = "";
selectSql = "SELECT comp_name FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND service_code = ? "; PreparedStatement pStmt = null;
//System.out.println("\nselectSql :: "+selectSql); ResultSet rs = null;
pStmt = conn.prepareStatement(selectSql); try
pStmt.setString(1,objName); {
pStmt.setString(2,serviceCode); //businessObj = "nvo_bo_finance_charge_calc";
rs = pStmt.executeQuery(); selectSql = "SELECT comp_name FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND service_code = ? ";
if ( rs.next() ) //System.out.println("\nselectSql :: "+selectSql);
{ pStmt = conn.prepareStatement(selectSql);
businessObj = rs.getString( "comp_name" ); pStmt.setString(1,objName);
} pStmt.setString(2,serviceCode);
System.out.println("\n businessObj :: ["+businessObj+"]"); rs = pStmt.executeQuery();
rs.close(); if ( rs.next() )
rs=null; {
pStmt.close(); businessObj = rs.getString( "comp_name" );
pStmt = null; }
selectSql = "SELECT SERVICE_URI, METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? "; System.out.println("\n businessObj :: ["+businessObj+"]");
System.out.println("\nselectSql :: "+selectSql); rs.close();
pStmt = conn.prepareStatement(selectSql); rs=null;
pStmt.setString(1,serviceCode); pStmt.close();
rs = pStmt.executeQuery(); pStmt = null;
if ( rs.next() ) selectSql = "SELECT SERVICE_URI, METHOD_NAME FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
{ System.out.println("\nselectSql :: "+selectSql);
serviceURI = rs.getString( "SERVICE_URI" ); pStmt = conn.prepareStatement(selectSql);
methodName = rs.getString( "METHOD_NAME" ); pStmt.setString(1,serviceCode);
} rs = pStmt.executeQuery();
rs.close(); if ( rs.next() )
rs=null; {
pStmt.close(); serviceURI = rs.getString( "SERVICE_URI" );
pStmt = null; methodName = rs.getString( "METHOD_NAME" );
System.out.println("\n serviceURI :: ["+serviceURI+"]"); }
System.out.println("\n methodName :: ["+methodName+"]"); rs.close();
actionURI = "http://NvoServiceurl.org/"+methodName; rs=null;
System.out.println("\n actionURI :: ["+actionURI+"]"); pStmt.close();
Service service = new Service(); pStmt = null;
Call call = ( Call )service.createCall(); System.out.println("\n serviceURI :: ["+serviceURI+"]");
call.setTargetEndpointAddress(new java.net.URL(serviceURI)); System.out.println("\n methodName :: ["+methodName+"]");
actionURI = "http://NvoServiceurl.org/"+methodName;
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) ); System.out.println("\n actionURI :: ["+actionURI+"]");
call.setUseSOAPAction(true); Service service = new Service();
call.setSOAPActionURI(actionURI); Call call = ( Call )service.createCall();
Object[] aobj = new Object[4]; call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN); call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN); call.setUseSOAPAction(true);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN); call.setSOAPActionURI(actionURI);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN); Object[] aobj = new Object[4];
aobj[0] = new String(businessObj); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[1] = new String(filterData); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[2] = new String( "" ); call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[3] = new String( xtraParams );// passed blank as It can not be created from scheduler call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING); aobj[0] = new String(businessObj);
retString = (String)call.invoke( aobj ); aobj[1] = new String(filterData);
System.out.println("Return value [" + retString +"]"); // leave this aobj[2] = new String( "" );
} aobj[3] = new String( xtraParams );// passed blank as It can not be created from scheduler
catch(Exception e)
{ call.setReturnType(XMLType.XSD_STRING);
e.printStackTrace(); retString = (String)call.invoke( aobj );
throw new ITMException(e); System.out.println("Return value [" + retString +"]"); // leave this
} }
finally catch(Exception e)
{ {
try e.printStackTrace();
{ throw new ITMException(e);
if(pStmt != null ) }
{ finally
pStmt.close(); {
pStmt = null; try
} {
} if(pStmt != null )
catch(Exception e) {
{e.printStackTrace();} pStmt.close();
} pStmt = null;
return retString ; }
}
} catch(Exception e)
private Timestamp getCurrdateAppFormat() {e.printStackTrace();}
{ }
String s = ""; return retString ;
Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance(); }
try private Timestamp getCurrdateAppFormat()
{ {
java.util.Date date = null; String s = "";
timestamp = new Timestamp(System.currentTimeMillis()); Timestamp timestamp = null;
//System.out.println(genericUtility.getDBDateFormat()); GenericUtility genericUtility = GenericUtility.getInstance();
try
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat()); {
date = simpledateformat.parse(timestamp.toString()); java.util.Date date = null;
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0"); timestamp = new Timestamp(System.currentTimeMillis());
//System.out.println("timestamp is ==>"+timestamp); //System.out.println(genericUtility.getDBDateFormat());
}
catch(Exception exception) SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
{ date = simpledateformat.parse(timestamp.toString());
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage()); timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
} //System.out.println("timestamp is ==>"+timestamp);
return timestamp; }
} catch(Exception exception)
private String getXtraParams(Document userInfoDom ,String siteCode , Connection conn )throws Exception {
{ System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
StringBuffer xtraParamsBuff = new StringBuffer(); }
PreparedStatement pstmt =null; return timestamp;
ResultSet rs = null; }
String XTRA_PARAMS_SEPARATOR = "~~"; private String getXtraParams(Document userInfoDom ,String siteCode , Connection conn )throws Exception
String loginCode="",loginEmpCode="",loginSiteCode="",entityCode="",profileId="",userType=""; {
String runMode="",chgTerm="",chgUser="",remoteHost="",sql="", charEnc=""; StringBuffer xtraParamsBuff = new StringBuffer();
PreparedStatement pstmt =null;
loginCode = userInfoDom.getElementsByTagName( "loginCode" ).item(0).getFirstChild().getNodeValue(); ResultSet rs = null;
charEnc = userInfoDom.getElementsByTagName( "charEnc" ).item(0).getFirstChild().getNodeValue(); String XTRA_PARAMS_SEPARATOR = "~~";
remoteHost = userInfoDom.getElementsByTagName( "remoteHost" ).item(0).getFirstChild().getNodeValue(); String loginCode="",loginEmpCode="",loginSiteCode="",entityCode="",profileId="",userType="";
String runMode="",chgTerm="",chgUser="",remoteHost="",sql="", charEnc="";
sql="select emp_code,entity_code,profile_id,user_type,chg_term,chg_user from users where code = ? ";
pstmt=conn.prepareStatement(sql); loginCode = userInfoDom.getElementsByTagName( "loginCode" ).item(0).getFirstChild().getNodeValue();
pstmt.setString(1,loginCode); charEnc = userInfoDom.getElementsByTagName( "charEnc" ).item(0).getFirstChild().getNodeValue();
//pstmt.setString(2,siteCode); remoteHost = userInfoDom.getElementsByTagName( "remoteHost" ).item(0).getFirstChild().getNodeValue();
//pstmt.setString(3,itemCode);
rs = pstmt.executeQuery(); sql="select emp_code,entity_code,profile_id,user_type,chg_term,chg_user from users where code = ? ";
if(rs.next()) pstmt=conn.prepareStatement(sql);
{ pstmt.setString(1,loginCode);
loginEmpCode = rs.getString("emp_code")==null?"":rs.getString("emp_code"); //pstmt.setString(2,siteCode);
entityCode = rs.getString("entity_code")==null?"":rs.getString("entity_code"); //pstmt.setString(3,itemCode);
profileId = rs.getString("PROFILE_ID")==null?"":rs.getString("PROFILE_ID"); rs = pstmt.executeQuery();
userType = rs.getString("USER_TYPE")==null?"":rs.getString("USER_TYPE"); if(rs.next())
chgTerm = rs.getString("CHG_TERM")==null?"":rs.getString("CHG_TERM"); {
chgUser = rs.getString("CHG_USER")==null?"":rs.getString("CHG_USER"); loginEmpCode = rs.getString("emp_code")==null?"":rs.getString("emp_code");
} entityCode = rs.getString("entity_code")==null?"":rs.getString("entity_code");
pstmt.close(); profileId = rs.getString("PROFILE_ID")==null?"":rs.getString("PROFILE_ID");
pstmt=null; userType = rs.getString("USER_TYPE")==null?"":rs.getString("USER_TYPE");
rs.close(); chgTerm = rs.getString("CHG_TERM")==null?"":rs.getString("CHG_TERM");
rs=null; chgUser = rs.getString("CHG_USER")==null?"":rs.getString("CHG_USER");
xtraParamsBuff.append("loginCode=" + loginCode); }
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginEmpCode=" + loginEmpCode); pstmt.close();
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginSiteCode=" + siteCode); pstmt=null;
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("entityCode=" + entityCode); rs.close();
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("profileId=" + profileId); rs=null;
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("userType=" + userType); xtraParamsBuff.append("loginCode=" + loginCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("runMode=I"); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginEmpCode=" + loginEmpCode);
//xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_lang=" + this.user_lang); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("loginSiteCode=" + siteCode);
//xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_country=" + this.user_country); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("entityCode=" + entityCode);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("charEnc=" +charEnc ); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("profileId=" + profileId);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("userType=" + userType);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("termId="+remoteHost); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("runMode=I");
// changes by madhup 10/02/07 //xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_lang=" + this.user_lang);
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("chgTerm=" + chgTerm); //xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("user_country=" + this.user_country);
return xtraParamsBuff.toString(); xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("charEnc=" +charEnc );
}
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("termId="+remoteHost);
// changes by madhup 10/02/07
xtraParamsBuff.append(XTRA_PARAMS_SEPARATOR).append("chgTerm=" + chgTerm);
return xtraParamsBuff.toString();
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment