Commit b476dc38 authored by manohar's avatar manohar

This commit was generated by cvs2svn to compensate for changes in r22, which

included commits to RCS files with non-trunk default branches.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91087 ce508802-f39f-4f6c-b175-0d175dae99d5
parent dd2feda3
package ibase.webitm.ejb.sys;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import ibase.webitm.utility.*;
import java.util.StringTokenizer;
import ibase.webitm.utility.*;
import ibase.utility.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.util.ArrayList;
import java.text.*;
import ibase.webitm.ejb.dis.*;
import java.sql.*;
import java.io.*;
public class CreateRCPXML
{
private String winName = null;
private String tranIdCol = null;
private String tranId = null;
private String filePath = null;
private PreparedStatement pstmt = null;
private ResultSet rs = null;
private String winSqls[];
//private String formNos[];
private ArrayList formNos = new ArrayList();
public CreateRCPXML(){}
public CreateRCPXML( String winName, String tranIdCol )
{
this.winName = winName;
this.tranIdCol = tranIdCol;
//to change as per the db name
filePath = CommonConstants.JBOSSHOME + File.separator + "SQL" + File.separator + CommonConstants.DB_NAME + File.separator;
}
public String getTranXML( String tranId, Connection conn ) throws Exception
{
String sql = "select form_no from obj_forms where win_name = '" + this.winName + "'";
this.tranId = tranId;
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
while( rs.next() )
{
formNos.add( rs.getString( "form_no" ) );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
int noOfForms = formNos.size();
winSqls = new String[ noOfForms ];
for( int formIdx = 0; formIdx < noOfForms ; formIdx++ )
{
sql = getFormSQL( ( String )formNos.get( formIdx ) );
winSqls[ formIdx ] = sql;
}
return prepareXML( winSqls, conn );
}
private String getFormSQL( String formNo ) throws Exception
{
StringBuffer dataBuff = new StringBuffer();
String lineStr = null;
String fileName = winName.substring( 2 ) + ( formNo.equalsIgnoreCase( "1" ) ? "21" : "1" + formNo );
BufferedReader br = new BufferedReader( new FileReader( filePath + fileName + ".sql" ) );
while( ( lineStr = br.readLine() ) != null )
{
dataBuff.append( lineStr );
}
return dataBuff.toString();
}
private String prepareXML( String []formSQLs, Connection conn ) throws Exception
{
StringBuffer tranXmlBuff = new StringBuffer( " <DocumentRoot> "
+" <description>Datawindow Root</description> "
+" <group0><description>Group0 description</description> "
+" <Header0><description>Header0 members</description> "
+" <DocumentRoot><description>Datawindow Root</description> "
+" <group0><description>Group0 description</description> "
+" <Header0><description>Header0 members</description> "
);
String colName = null;
String colVal = null;
String colXml = null;
String detTag = null;
String detEndTag = null;
for( int formSqlIdx = 0; formSqlIdx < formSQLs.length ; formSqlIdx++ )
{
pstmt = conn.prepareStatement( formSQLs[ formSqlIdx ] );
pstmt.setString( 1, this.tranId );
rs = pstmt.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
detTag = "<Detail" + ( formSqlIdx + 1 ) + ">";
detEndTag = "</Detail" + ( formSqlIdx + 1 ) + ">";
while( rs.next() )
{
tranXmlBuff.append( "\n\t" + detTag );
for( int rsIdx = 1; rsIdx < numberOfColumns ; rsIdx++ )
{
colName = rsmd.getColumnName( rsIdx );
colVal = rs.getString( colName );
colXml = "\n\t\t<" + colName.toLowerCase() + ">"
+ ( colVal == null || colVal.trim().length() == 0 || colVal.equalsIgnoreCase( "null" ) ? "" : colVal )
+ "</" + colName.toLowerCase() + ">";
tranXmlBuff.append( colXml );
}
tranXmlBuff.append( "\t" + detEndTag );
}
rsmd = null;
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
tranXmlBuff.append( " </Header0> "
+" </group0> "
+" </DocumentRoot> "
+" </Header0> "
+" </group0> "
+"</DocumentRoot> " );
return tranXmlBuff.toString();
}
}
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import java.util.*;
import java.lang.String;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.sys.NFCreateEdiMultiLogic;
import javax.ejb.Stateless;// added for ejb3
@Stateless // added for ejb3
public class GenerateEDI extends ActionHandlerEJB implements GenerateEDILocal , GenerateEDIRemote //SessionBean //commented for ejb3
{
ibase.webitm.utility.GenericUtility genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String genEDI() throws RemoteException,ITMException
{
return "";
}
public String genEDI( String winName, String editFlag, String xmlString, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
System.out.println("Generate Edi called");
Document dom = null;
String retString = null;
//Connection conn = null;
try
{
if( xmlString != null && xmlString.trim().length() > 0 )
{
System.out.println("XML String :" + xmlString );
dom = genericUtility.parseString( xmlString );
}
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
//connDriver = null;
NFCreateEdiMultiLogic createEdi = new NFCreateEdiMultiLogic();
retString = createEdi.nfCreateEdiMultiLogic( dom, winName, xtraParams, conn );
}
catch(Exception e)
{
System.out.println("Exception :GenerateEDIEJB :" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
/*
if( retString != null || retString.trim().length() > 0 )
{
conn.rollback();
}
else
{
conn.commit();
}
if( conn != null )
{
conn.close();
}
conn = null;
*/
}catch( Exception ex )
{
ex.printStackTrace();
}
}
return retString;
}
//generate edi for transaction id provided
public String genEDI( String winName, String tranId, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
Document dom = null;
String xmlString = null;
String retString = null;
try
{
CreateRCPXML tranXmlObj = new CreateRCPXML( winName, "" );
xmlString = tranXmlObj.getTranXML( tranId, conn );
//System.out.println( "EDI String :: " + xmlString );
if( xmlString != null && xmlString.trim().length() > 0 )
{
dom = genericUtility.parseString( xmlString );
}
NFCreateEdiMultiLogic createEdi = new NFCreateEdiMultiLogic();
retString = createEdi.nfCreateEdiMultiLogic( dom, winName, xtraParams, conn );
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
/*
if( retString != null || retString.trim().length() > 0 )
{
conn.rollback();
}
else
{
conn.commit();
}
if( conn != null )
{
conn.close();
}
conn = null;
*/
}catch( Exception ex )
{
ex.printStackTrace();
}
}
return retString;
}
//
}
\ No newline at end of file
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;//commented for ejb3
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import java.sql.Connection;
import javax.ejb.Local;// added for ejb3
@Local // added for ejb3
public interface GenerateEDILocal extends ActionHandlerLocal //,EJBObject //commented for ejb3
{
public String genEDI() throws RemoteException,ITMException;
public String genEDI( String winName, String tranId, String xtraParams, Connection conn ) throws RemoteException,ITMException;
public String genEDI( String winName, String editFlag, String xmlString, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;//commented for ejb3
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import java.sql.Connection;
import javax.ejb.Remote;// added for ejb3
@Remote // added for ejb3
public interface GenerateEDIRemote extends ActionHandlerRemote //,EJBObject//commented for ejb3
{
public String genEDI() throws RemoteException,ITMException;
public String genEDI( String winName, String tranId, String xtraParams, Connection conn ) throws RemoteException,ITMException;
public String genEDI( String winName, String editFlag, String xmlString, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.sys;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import ibase.webitm.utility.*;
import java.util.StringTokenizer;
import ibase.webitm.utility.*;
import ibase.utility.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.util.ArrayList;
import java.text.*;
import ibase.webitm.ejb.dis.*;
import java.sql.*;
import java.io.*;
public class NFCreateEdiMultiLogic
{
String termid = null;
int liLineNo, liFldNoS, liObjSlD, liFldNoD, liFormno, liEntform, liFormnoA, liSubPos, liRet;
int liPos, liPos1, liPos2, liVal, liPos3, liPos4, liCtr;
int liPreformno;
String lsEntity, lsEntitySource, lsEntitySourceRef, lsWinNameLoad, lsFindVal;
String lsEdiAddr, lsErrbuf, lsErrcode = null, lsEntityCode, lsType, lsBatchno;
String lsFlddata, lsConstantVal, lsVal, lsFldval, lsFunc, lsTotFunc, lsRetCode;
String lsKeystr, lsThiswin, lsSubjectInfo[], lsSubjectStr, lsSubject, lsTaxdata;
String lsEntityAddnl, lsEntityNext, lsTranidSer, lsKeystrSl, lsMailoption, lsStatOption;
String lsLineNo;
String lsFldNameDest = null;
Timestamp ldToday = null;
int llRowcount, llRow, llTotRows, ret, llCount, llTotfld;
boolean lbLoop = true , lbSendconfirm = true, lbEdidetdefined = false;
boolean lbFirstcolumn = true;
String lsMailServer, lsMailBox, lsMailId, lsFilename, lsMailApplication;
String lsMailNo, lsMailName;
String lsNull = null;
String lsTranser, lsTranidcol, lsXfrtax;
String lsEdimedium, lsColumnsep, lsNullInter;
String lsTable, lsTranid[], lsTran, lsTable1, lsTable2, lsTable3, lsSql;
String lsTranId, lsWhere, lsTranValue[], lsFileName, lsFilepath, lsFileNameOld, lsFile[], lspathonly;
int liBound, liRow, liMaxcol, liMaxrow, i, j, liCnt;
int llFound;
String lsDateFormat, lsSuffix, lsPrefix, lsAlignment, lsColumn, lsFilepathOld, lsVarValue, lsFilepath1;
ArrayList lsStrg, lsTemp;
int aiMaxobj = 0;
String lsString = null, lsStr = null;
int liFileNum, liFilewrite, liFileclose, liColWidth, liFileobjOld, liFileobj;
String userid = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
EdiControlBean ediRow = null;
ArrayList ediRowsList = null;
ArrayList ediControlDetArr = null;
Queue ediControlFileQue = null;
EdiControlFileBean ediCtrlFile = null;
HashMap fldTypeMap = null;
ArrayList lnvoData = null;
EdiControlDet ediControlDet = null;
EdiControlBean ediRows = null;
String tranIdFile = null;
ibase.webitm.utility.GenericUtility genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
String asWinname = null;
String gsRunMode = null;
PreparedStatement ediFilePStmt = null;
ResultSet ediFileRS = null;
StringBuffer outPutStrBuff = new StringBuffer();
PreparedStatement batchLoadPstmt = null;
PreparedStatement batchLoadDetPstmt = null;
String insBatchLoad = "insert into batchload( batch_id, tran_sl, win_name, load_stat, edi_addr, chg_date, chg_user, chg_term, load_mode ) "
+" values( ?, 1, ?, 'N', ?, ?, ?, ?, ? )";
String insBatchLoadDet = "insert into batchloaddet (batch_id,tran_sl,obj_sl, obj_ssl,fld_no, fld_data, fld_tax,col_name) "
+" values ( ?, ?, ?, ?, ?, ?, ?, ? ) ";
String gsDatabase = CommonConstants.DB_NAME;
public String nfCreateEdiMultiLogic( Document dom, String Winname, String xtraParams, Connection conn ) throws Exception, ITMException
{
liPreformno = 0;
lbFirstcolumn = false;
asWinname = Winname;
//System.out.println( "nfCreateEdiMultiLogic called !!!!!" );
termid = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "termid" );
if( "B".equalsIgnoreCase( gsRunMode ) )
{
return "";
}
try
{
batchLoadPstmt = conn.prepareStatement( insBatchLoad );
batchLoadDetPstmt = conn.prepareStatement( insBatchLoadDet );
sql = "select tran_id_col, mail_option from transetup where upper(tran_window) = upper( ? )";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
rs = pstmt.executeQuery();
if( rs.next() )
{
lsTranidcol = rs.getString( "tran_id_col" );
lsMailoption = rs.getString( "mail_option" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex ){
lsErrcode = "VTTRSET1";
ex.printStackTrace();
throw new ITMException( ex );
}
try
{
lsThiswin = "I-BL";
sql = "select key_string from transetup "
+" where upper(tran_window) = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, lsThiswin );
rs = pstmt.executeQuery();
if( rs.next() )
{
lsKeystr = rs.getString( "key_string" );
}
else
{
if( rs != null )
{
rs.close();
}
rs = null;
if( pstmt != null )
{
pstmt.close();
}
sql = "select key_string from transetup where tran_window = 'GENERAL' ";
System.out.println( "transetup :: " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
lsKeystr = rs.getString( "key_string" );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex )
{
ex.printStackTrace();
throw new ITMException( ex );
}
try
{
ediRowsList = new ArrayList();
//sql = "select line_no, entity, entity_source, entity_source_ref, "
// +" win_name__load, subject_str, entity_addnl, ref_ser, xfr_tax, stat_option, "
// +" edi_medium,column_seprator,interpret_null "
// +" from edi_control where win_name = '" + asWinname + "'"
// +" and (edi_event is null or win_name = edi_event) ";
sql = "select line_no, entity, entity_source, entity_source_ref, "
+" win_name__load, subject_str, entity_addnl, ref_ser, xfr_tax, stat_option, "
+" edi_medium,column_seprator,interpret_null "
+" from edi_control where win_name = ? "
+" and (edi_event is null or win_name = edi_event) ";
//System.out.println( "Preparing edi control sql :: " + sql );
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
rs = pstmt.executeQuery();
while( rs.next() )
{
ediRows = new EdiControlBean();
ediRows.lineNo = rs.getInt( "line_no" );
ediRows.entity = rs.getString( "entity" );
ediRows.entitySource = rs.getString( "entity_source" );
ediRows.entitySourceRef = rs.getString( "entity_source_ref" );
ediRows.winNameLoad = rs.getString( "win_name__load" );
ediRows.xfrTax = rs.getString( "xfr_tax" );
ediRows.refSer = rs.getString( "ref_ser" );
ediRows.subjectStr = rs.getString( "subject_str" );
ediRows.entityAddnl = rs.getString( "entity_addnl" );
ediRows.statOption = rs.getString( "stat_option" );
ediRows.ediMedium = rs.getString( "edi_medium" );
ediRows.columnSeprator = rs.getString( "column_seprator" );
ediRows.interpretNull = rs.getString( "interpret_null" );
ediRowsList.add( ediRows );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex )
{
lsErrcode = "VTOPENCUR";
throw new ITMException( ex );
}
int noOfEdiRows = 0;
noOfEdiRows = ediRowsList.size();
//System.out.println( "noOfEdiRows::" + noOfEdiRows );
for ( int cnt = 0; cnt < noOfEdiRows ; cnt++ )
{
ediRows = ( EdiControlBean )ediRowsList.get( cnt );
liLineNo = ediRows.lineNo;
lsEntity = ediRows.entity;
lsEntitySource = ediRows.entitySource;
lsEntitySourceRef = ediRows.entitySourceRef;
lsWinNameLoad = ediRows.winNameLoad;
lsXfrtax = ediRows.xfrTax;
lsTranser = ediRows.refSer;
lsSubjectStr = ediRows.subjectStr;
lsEntityAddnl = ediRows.entityAddnl;
lsStatOption = ediRows.statOption;
lsEdimedium = ediRows.ediMedium;
lsColumnsep = ediRows.columnSeprator;
lsNullInter = ediRows.interpretNull;
liPreformno = 0;
if( !efCheckCondition( asWinname, liLineNo, dom, conn ) )
{
continue;
}
String transetupSql = null;
//transetupSql = "SELECT transetup.table_name, "
// +" transetup.table_name_det1, "
// +" transetup.table_name_det2, "
// +" transetup.table_name_det3, "
// +" transetup.tran_id_col "
// +" FROM transetup "
// +" WHERE transetup.tran_window = '" + asWinname + "'" ;
transetupSql = "SELECT transetup.table_name, "
+" transetup.table_name_det1, "
+" transetup.table_name_det2, "
+" transetup.table_name_det3, "
+" transetup.tran_id_col "
+" FROM transetup "
+" WHERE transetup.tran_window = ? ";
//System.out.println( "Getting transetup transetupSql :: " + transetupSql );
try
{
pstmt = conn.prepareStatement( transetupSql );
pstmt.setString( 1, asWinname );
rs = pstmt.executeQuery();
if( rs.next() )
{
lsTable = rs.getString( "table_name" );
lsTable1 = rs.getString( "table_name_det1" );
lsTable2 = rs.getString( "table_name_det2" );
lsTable3 = rs.getString( "table_name_det3" );
lsTranId = rs.getString( "tran_id_col" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex )
{
ex.printStackTrace();
throw new ITMException( ex );
}
finally
{
try{
if( rs != null )
rs.close();
rs = null;
if( pstmt != null )
pstmt.close();
pstmt = null;
}catch( Exception e ){
throw new ITMException( e );
}
}
lsTranid = fGetTokens( lsTranId, "," );
if( "2".equalsIgnoreCase( lsEdimedium ) )
{
String ediFileSql = null;
ediFileSql = " SELECT edi_control_file.file_object, "
+" edi_control_file.file_name, "
+" edi_control_file.file_path "
+" FROM edi_control_file "
+" WHERE ( edi_control_file.win_name = ? ) "
+" order by file_object ";
ediFilePStmt = conn.prepareStatement( ediFileSql );
ediFilePStmt.setString( 1, asWinname );
ediFileRS = ediFilePStmt.executeQuery();
ediControlFileQue = new Queue();
while( ediFileRS.next() )
{
ediCtrlFile = new EdiControlFileBean();
ediCtrlFile.liFileobj = ediFileRS.getInt( "file_object" );
ediCtrlFile.lsFileName = ediFileRS.getString( "file_name" );
ediCtrlFile.lsFilepath = ediFileRS.getString( "file_path" );
lspathonly = ediCtrlFile.lsFilepath;
File mkd = new File(lspathonly);
if(!mkd.exists())
{
mkd.mkdirs();
}
mkd = null;
ediControlFileQue.offer( ediCtrlFile );
}
ediFileRS.close();
ediFileRS = null;
ediFilePStmt.close();
ediFilePStmt = null;
ediCtrlFile = ( EdiControlFileBean )ediControlFileQue.poll();
if( ediCtrlFile != null )
{
liFileobj = ediCtrlFile.liFileobj;
lsFileName = ediCtrlFile.lsFileName;
lsFilepath = ediCtrlFile.lsFilepath;
}
else
{
lsErrcode = "VEDIFLENF";
return lsErrcode;
}
liFileobjOld = liFileobj;
lsFileNameOld = lsFileName;
lsFilepathOld = lsFilepath;
liCnt = 1;
lsFile = fGetTokens( lsFileName, "|" );
liCnt = lsFile.length;
}
lsEntitySourceRef = ( lsEntitySourceRef != null && lsEntitySourceRef.trim().length() > 0 ) ? lsEntitySourceRef.trim() : null;
if( "P".equalsIgnoreCase( lsEntitySource ) )
{
lsEntityCode = lsEntitySourceRef;
}
else if( lsEntitySource.charAt( 0 ) >= '0' && lsEntitySource.charAt( 0 ) <= '6' )
{
liEntform = Integer.parseInt( lsEntitySource ) + 1;
lsEntityCode = getColumnValueForLine( lsEntitySourceRef, dom, Integer.toString( liEntform ), 1 );
}
else
{
lsErrcode = "VEDIERR3";
return lsErrcode;
}
//System.out.println( "lsEntityCode :: " + lsEntityCode );
if( lsEntityCode == null || lsEntityCode.trim().length() == 0 )
{
continue;
}
else
{
//System.out.println( "lsEntity :: " + lsEntity + "lsEntityCode :: " + lsEntityCode );
lsEdiAddr = nfGetEdiAddress( lsEntity.charAt( 0 ), lsEntityCode, conn );
if( lsEdiAddr == null || lsEdiAddr.trim().length() == 0 )
{
lsErrcode = "VEDIERR4";
return lsErrcode;
}
}
String loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
lsBatchno = generateTranId( "I-BL", loginSiteCode, conn );
ldToday = new java.sql.Timestamp( System.currentTimeMillis() ); //datetime(today(),now())
if( lsWinNameLoad == null || lsWinNameLoad.trim().length() == 0 )
{
lsWinNameLoad = asWinname;
}
if( lsEdimedium == null
|| lsEdimedium.trim().length() == 0
|| lsEdimedium.trim().equalsIgnoreCase( "1" ) )
{
batchLoadPstmt.setString( 1, lsBatchno );
batchLoadPstmt.setString( 2, lsWinNameLoad );
batchLoadPstmt.setString( 3, lsEdiAddr );
batchLoadPstmt.setTimestamp( 4, new java.sql.Timestamp( System.currentTimeMillis() ) );
batchLoadPstmt.setString( 5, userid );
batchLoadPstmt.setString( 6, termid );
String asEditopt = null;
batchLoadPstmt.setString( 7, asEditopt );
batchLoadPstmt.executeUpdate();
}
sql = "select count( * ) cnt from obj_forms where win_name = ? ";//'" + asWinname + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
rs = pstmt.executeQuery();
if( rs.next() )
{
aiMaxobj = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
for( liFormno = 1; liFormno <= aiMaxobj ; liFormno++ )
{
liFormnoA = liFormno - 1;
long llDetcount = 0;
sql = "select count(1) cnt from edi_control_det "
+" where win_name = ? " //'" + asWinname + "'"
+" and line_no = ? "; // + liLineNo;
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
pstmt.setInt( 2, liLineNo );
rs = pstmt.executeQuery();
if( rs.next() )
{
llDetcount = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( llDetcount > 0 )
{
lbEdidetdefined = true;
sql = "select count(1) from edi_control_det "
+" where win_name = ? " //'" + asWinname + "'"
+" and line_no = ? " //+ liLineNo
+" and obj_sl__source = ? "; // + liFormnoA;
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
pstmt.setInt( 2, liLineNo );
pstmt.setInt( 3, liFormnoA );
rs = pstmt.executeQuery( );
if( rs.next() )
{
llDetcount = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( llDetcount > 0 )
{
}
else
{
continue;
}
}
else
{
lbEdidetdefined = false;
}
sql = " select fld_no__source, constant_val, obj_sl__dest, fld_no__dest, subject_pos, "
+" col_width, date_format, suffix, prefix, alignment, FLD_NAME__SOURCE "
+" from edi_control_det "
+" where win_name = ? " // '" + asWinname + "' "
+" and line_no = ? " //+ liLineNo
+" and obj_sl__source = ? "// + liFormnoA
+" order by fld_no__dest ";
ediControlDetArr = new ArrayList();
try
{
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asWinname );
pstmt.setInt( 2, liLineNo );
pstmt.setInt( 3, liFormnoA );
rs = pstmt.executeQuery();
while( rs.next() )
{
ediControlDet = new EdiControlDet();
ediControlDet.fldNameSource = rs.getString( "FLD_NAME__SOURCE" );
ediControlDet.fldNoSource = rs.getInt( "fld_no__source" );
ediControlDet.constantVal = rs.getString( "constant_val" );
ediControlDet.objSlDest = rs.getInt( "obj_sl__dest" );
ediControlDet.fldNoDest = rs.getInt( "fld_no__dest" );
ediControlDet.subjectPos = rs.getInt( "subject_pos" );
ediControlDet.colWidth = rs.getInt( "col_width" );
ediControlDet.dateFormat = rs.getString( "date_format" );
ediControlDet.suffix = rs.getString( "suffix" );
ediControlDet.prefix = rs.getString( "prefix" );
ediControlDet.alignment = rs.getString( "alignment" );
ediControlDetArr.add( ediControlDet );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex )
{
lsErrcode = "VTOPENCUR";
ex.printStackTrace();
throw new ITMException( ex );
}
if( ediControlDetArr.size() > 0 )
{
lbEdidetdefined = true;
int noOfEdiDetRows = 0;
noOfEdiDetRows = ediControlDetArr.size();
llRowcount = getRowCount( dom, liFormno );
if( liFormno == 1 && llRowcount == 0 )
{
lsErrcode = "VSNOHDR";
return lsErrcode;
}
if( liFormno > 1 )
{
if( liPreformno != liFormno )
{
lbFirstcolumn = true;
liPreformno = liFormno;
}
else
{
lbFirstcolumn = false;
}
}
else
{
lbFirstcolumn = false;
}
fldTypeMap = setMetaData( asWinname, Integer.toString( liFormno ) );
for( llRow = 0; llRow < llRowcount; llRow++ )
{
for( int ediDetLine = 0; ediDetLine < noOfEdiDetRows ; ediDetLine++ )
{
ediControlDet = ( EdiControlDet )ediControlDetArr.get( ediDetLine );
liFldNoS = ediControlDet.fldNoSource;
lsConstantVal = ediControlDet.constantVal;
liObjSlD = ediControlDet.objSlDest;
liFldNoD = ediControlDet.fldNoDest;
liSubPos = ediControlDet.subjectPos;
liColWidth = ediControlDet.colWidth;
lsDateFormat = ediControlDet.dateFormat;
lsSuffix = ediControlDet.suffix;
lsPrefix = ediControlDet.prefix;
lsAlignment = ediControlDet.alignment;
lsStrg = lsTemp;
lsFlddata = "";
lsConstantVal = ediControlDet.constantVal;
if( lsConstantVal == null || lsConstantVal.trim().length() == 0 )
{
lsType = ( String )fldTypeMap.get( ediControlDet.fldNameSource );
lsFlddata = getColumnValueForLine( ediControlDet.fldNameSource, dom, Integer.toString( liFormno ), llRow );
}
else
{
if( ediControlDet.fldNameSource != null && ediControlDet.fldNameSource.trim().length() > 0 )
{
lsFlddata = getColumnValueForLine( ediControlDet.fldNameSource, dom, Integer.toString( liFormno ), llRow );
}
else
{
lsFlddata = lsConstantVal;
}
if( left( lsConstantVal, 4 ).equalsIgnoreCase( "FN_" ) )
{
liPos = lsConstantVal.indexOf( "(" );
liPos1 = lsConstantVal.indexOf( "," );
liPos4 = liPos1;
lsFindVal = "";
lsFldval = "";
liPos2 = lsConstantVal.indexOf( ")" );
lsFunc = left( lsConstantVal, liPos + 1 );
lbLoop = true;
while( lbLoop )
{
if( liPos > 0 && liPos2 > 0 )
{
if( liPos1 == 0 )
{
if( liPos4 > 0 )
{
liPos = liPos3;
}
liPos1 = liPos2;
lbLoop = false;
}
else
{
liPos3 = liPos1;
}
lsVal = mid( lsConstantVal, liPos + 1, liPos + liPos1 - liPos );
if( fldTypeMap.containsKey( lsVal.toUpperCase() ) )
{
lsType = ( String )fldTypeMap.get( lsVal.toUpperCase() );
lsFlddata = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
lsFldval = lsFlddata;
if( left(lsType, 5).equalsIgnoreCase( "char" ) )
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}
else
if( left( lsType, 5 ).equalsIgnoreCase( "nume" )
|| left( lsType, 5 ).equalsIgnoreCase( "long" )
|| left( lsType, 5 ).equalsIgnoreCase( "inte" )
|| left( lsType, 5 ).equalsIgnoreCase( "real" )
|| left( lsType, 5 ).equalsIgnoreCase( "deci" ) )
{
lsFldval = getColumnValueForLine( ediControlDet.fldNameSource, dom, Integer.toString( liFormno ), llRow );
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + "," + lsFldval;
}
else
{
lsFindVal = lsFindVal + lsFldval;
}
}
else
if( left( lsType, 9 ).equalsIgnoreCase( "datetime" ) )
{
lsFldval = getColumnValueForLine( ediControlDet.fldNameSource, dom, Integer.toString( liFormno ), llRow );
if( lsDateFormat != null && lsDateFormat.trim().length() > 0 )
{
lsFldval = getDateInFormat( lsFldval, lsDateFormat );
}
else
{
lsFldval = getDateInFormat( lsFldval, "yyyy-mm-dd" );
}
}
else
if( left( lsType, 5 ).equalsIgnoreCase( "date" ) )
{
lsFldval = getColumnValueForLine( ediControlDet.fldNameSource, dom, Integer.toString( liFormno ), llRow );
if ( lsDateFormat != null && lsDateFormat.trim().length() > 0 )
{
lsFldval = getDateInFormat( lsFldval, lsDateFormat );
}
else
{
lsFldval = getDateInFormat( lsFldval, "yyyy-mm-dd" );
}
}
else
{
lsErrcode = "VEDIERR5";
return lsErrcode;
}
}
else
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", " + lsVal;
}
else
{
lsFindVal = lsFindVal + lsVal;
}
}//if isnumber(ls_val)
liPos = liPos1;
liPos1 = pos( lsConstantVal, ",", liPos1 + 1 );
}//if li_pos > 0 and li_pos2 > 0
}
String funcSql = null;
funcSql = " select " + lsFunc + "( " + lsFindVal + " ) from dual";
PreparedStatement funcPStmt = null;
ResultSet funcRS = null;
try
{
funcPStmt = conn.prepareStatement( funcSql );
funcRS = funcPStmt.executeQuery( );
if( funcRS.next() )
{
lsRetCode = funcRS.getString( 1 );
}
funcRS.close();
funcRS = null;
funcPStmt.close();
funcPStmt = null;
}catch( Exception ex )
{
ex.printStackTrace();
}finally{
try{
if( funcRS != null )
funcRS.close();
funcRS = null;
if( funcPStmt != null )
funcPStmt.close();
funcPStmt = null;
}catch( Exception e ){
e.printStackTrace();
}
}
if( lsRetCode != null && lsRetCode.trim().length() > 0 && left( ( lsRetCode ).trim(), 5 ).equalsIgnoreCase( "ERROR" ) )
{
lsErrcode = "VTFUNCERR";
return lsErrcode;
}
else
{
lsFlddata = lsRetCode == null ? "" : lsRetCode;
}
}
else
{
if( pos( lsConstantVal, "(" ) > 0 )
{
liPos = pos( lsConstantVal, "(" );
liPos1 = pos( lsConstantVal, ",");
liPos4 = liPos1;
lsFindVal = "";
lsFldval = "";
liPos2 = pos( lsConstantVal, ")" );
lsFunc = left( lsConstantVal, liPos );
lbLoop = true;
while( lbLoop )
{
if( liPos > 0 && liPos2 > 0 )
{
if( liPos1 == 0 ) // only one argument
{
if( liPos4 > 0 )
{
liPos = liPos3;
}
liPos1 = liPos2;
lbLoop = false;
}
else
{
liPos3 = liPos1;
}
lsVal = mid( lsConstantVal, liPos + 1, liPos1 - liPos - 1 );
if( isnumber( lsVal ) )
{
liVal = Integer.parseInt( lsVal );
lsType = ( String )fldTypeMap.get( lsVal.toUpperCase() );
lsFlddata = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
lsFldval = lsFlddata;
if( left( lsType, 4 ).equalsIgnoreCase( "char" ) )
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}
else if( left( lsType, 4 ).equalsIgnoreCase( "nume" )
|| left( lsType, 4 ).equalsIgnoreCase( "long" )
|| left( lsType, 4 ).equalsIgnoreCase( "inte" )
|| left( lsType, 4 ).equalsIgnoreCase( "real" )
|| left(lsType,4).equalsIgnoreCase( "deci" ) )
{
if ( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ',' + lsFldval;
}
else
{
lsFindVal = lsFindVal + lsFldval;
}
}
else if( left( lsType, 8 ).equalsIgnoreCase( "datetime" ) )
{
if ( gsDatabase.equalsIgnoreCase( "oracle" ) )
{
lsFldval = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
}
else
{
lsFldval = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
}
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}
else if( left( lsType, 4 ).equalsIgnoreCase( "date" ) )
{
if( gsDatabase.equalsIgnoreCase( "oracle" ) )
{
lsFldval = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
}
else
{
lsFldval = getColumnValueForLine( lsVal, dom, Integer.toString( liFormno ), llRow );
}
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}
}
else
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", " + lsVal;
}
else
{
lsFindVal = lsFindVal + lsVal;
}
}
liPos = liPos1;
liPos1 = pos( lsConstantVal, ",", liPos1 + 1);
}
}
lsTotFunc = lsFunc + lsFindVal + ")";
lsTotFunc = "select " + lsTotFunc + " from dual";
PreparedStatement funcPStmt = null;
ResultSet funcRS = null;
try
{
funcPStmt = conn.prepareStatement( lsTotFunc );
funcRS = funcPStmt.executeQuery( );
if( funcRS.next() )
{
lsRetCode = funcRS.getString( 1 );
}
funcRS.close();
funcRS = null;
funcPStmt.close();
funcPStmt = null;
}catch( Exception ex )
{
ex.printStackTrace();
throw new ITMException( ex );
}finally
{
try{
if( funcRS != null )
funcRS.close();
funcRS = null;
if( funcPStmt != null )
funcPStmt.close();
funcPStmt = null;
}catch( Exception e ){
e.printStackTrace();
}
}
lsFlddata = lsRetCode.trim();
}
else
{
lsFlddata = lsConstantVal;
}
}
if( left( lsConstantVal, 8 ).equalsIgnoreCase( "ef_fill" ) )
{
String noOfFill = null;
int noOfBlank = 0;
noOfFill = lsConstantVal.substring( lsConstantVal.indexOf( "(" ) + 1, lsConstantVal.indexOf( ")" ) );
if( noOfFill == null || noOfFill.trim().length() == 0 )
{
noOfFill = "0";
}
try
{
noOfBlank = Integer.parseInt( noOfFill.trim() );
}
catch( Exception ex )
{
lsErrcode = "VTFILLERR";
ex.printStackTrace();
return lsErrcode;
}
lsFlddata = space( noOfBlank );
}
}
//end missing logic-3 to be incorporated
if( lsFlddata == null || lsFlddata.trim().length() == 0 || lsFlddata.equalsIgnoreCase( "null" ) )
{
lsFlddata = "";
}
lsFlddata = nfEdiMapping( asWinname, liLineNo, liFormnoA, liFldNoS, lsFlddata, conn );
//msalam on 040309
if ( lbFirstcolumn && lsXfrtax != null && lsXfrtax.equalsIgnoreCase( "Y" ) )
{
if( lsTranser == null || lsTranser.trim().length() == 0 )
{
lsErrcode = "VTNOTRNSER";
return lsErrcode;
}
if( lsTranidcol == null || lsTranidcol.trim().length() == 0 )
{
lsErrcode = "VTNOTRNID";
}
lsLineNo = getColumnValueForLine( "line_no", dom, Integer.toString( liFormno ), llRow );
//lsType = ld_dataobj[li_formno].describe("line_no.Coltype")
//if left(ls_type,4) = "char" then
// ls_line_no = ld_dataobj[li_formno].getitemstring(ll_row,"line_no")
//elseif left(ls_type,4) = "nume" or left(ls_type,4) = "long" or left(ls_type,4) = "inte" or left(ls_type,4) = "real" or left(ls_type,4) = "numb" then
// ls_line_no = string(ld_dataobj[li_formno].getitemnumber(ll_row,"line_no"))
//elseif left(ls_type,4) = "deci" then
// ls_line_no = string(ld_dataobj[li_formno].getitemdecimal(ll_row,"line_no"))
//else
//what to do for this else line msalam on 100309
// ls_line_no = string(ll_row)
//end if
String tranIdVal = getColumnValueForLine( lsTranidcol, dom, Integer.toString( 1 ), 1 );
lsTaxdata = gfBatchTaxData( lsTranser, tranIdVal, dom, Integer.parseInt( lsLineNo ), liFormnoA + 1, conn );
}
else
{
lsTaxdata = "";
}
if ( lsEdimedium == null
|| lsEdimedium.trim().length() == 0
|| lsEdimedium.equalsIgnoreCase( "1" ) )
{
try
{
//pstmt = conn.prepareStatement( insBatchLoadDet );
batchLoadDetPstmt.setString( 1, lsBatchno );
batchLoadDetPstmt.setInt( 2, 1 );
batchLoadDetPstmt.setInt( 3, liObjSlD );
batchLoadDetPstmt.setInt( 4, llRow );
batchLoadDetPstmt.setInt( 5, liFldNoD );
batchLoadDetPstmt.setString( 6, lsFlddata );
batchLoadDetPstmt.setString( 7, lsTaxdata );
lsFldNameDest = ediControlDet.fldNameSource;
batchLoadDetPstmt.setString( 8, lsFldNameDest );
batchLoadDetPstmt.executeUpdate();
}catch( Exception e )
{
e.printStackTrace();
throw new ITMException( e );
}
}
if( liSubPos > 0 ) //and not isnull(li_sub_pos) then
{
lsSubjectInfo[ liSubPos ] = lsFlddata;
}
//end msalam on 040309
if( lsEdimedium.trim().equalsIgnoreCase( "2" ) )
{
lsStr = new String( lsFlddata );
for( liCnt = 0; liCnt < lsFile.length ; liCnt++ )
{
if( lsFile[ liCnt ].equalsIgnoreCase( Integer.toString( liFldNoS ) ) )
{
lsFile[ liCnt ] = lsStr.trim();
}
}
if( liColWidth > 0 )
{
//lsAlignment = ediControlDet.alignment;
if( lsStr.length() < liColWidth )
{
if( lsAlignment != null && lsAlignment.equalsIgnoreCase( "R" ) )
{
lsStr = space( liColWidth - ( lsStr ).length() ) + lsStr;
}
else
{
lsStr = lsStr + space( liColWidth - ( lsStr ).length() );
}
}
else
{
if( lsAlignment != null && lsAlignment.equalsIgnoreCase( "R" ) )
{
lsStr = mid( lsStr, (lsStr).length() - liColWidth, liColWidth );
}
else
{
lsStr = mid( lsStr, 0, liColWidth );
}
}
}
if( lsSuffix != null && lsSuffix.trim().length() > 0 )
{
lsStr = lsStr + lsSuffix;
}
else if( lsPrefix != null && lsPrefix.length() > 0 )
{
lsStr = lsPrefix + lsStr;
}
//if( lsStrg == null )
//{
// lsStrg = new ArrayList();
//}
//lsStrg.add( lsStr );
}
outPutStrBuff.append( lsStr );
}//end of edi_control_det for loop
outPutStrBuff.append( "\n" );
if( lsErrcode != null && lsErrcode.trim().length() > 0 )
{
return lsErrcode;
}
}
}
//else added by msalam on 060309
else
{
//System.out.println( "In else 1125!!!!!" );
lbEdidetdefined = false;
//llRowcount = ld_dataobj[li_formno].rowcount()
if( dom == null )
{
//System.out.println( "In else 1125!!!!!" );
return "DOMNULL";
}
llRowcount = getRowCount( dom, liFormno );
if( liFormno == 1 && llRowcount == 0 )
{
lsErrcode = "VSNOHDR";
return lsErrcode;
}
//System.out.println( "llRowcount::" + llRowcount );
for( int llRow = 1; llRow < llRowcount ; llRow++ )
{
//not needed.
//llTotfld = getRowCount( dom, liFormno );
//System.out.println( "In site lopp 1143!!!!!" );
if ( lsXfrtax != null && lsXfrtax.equalsIgnoreCase( "Y" ) )
{
if( lsTranser == null || lsTranser.trim().length() == 0 )
{
lsErrcode = "VTNOTRNSER";
return lsErrcode;
}
if( lsTranidcol == null || lsTranidcol.trim().length() == 0 )
{
lsErrcode = "VTNOTRNID";
return lsErrcode;
}
//System.out.println( "llRow :: " + llRow + " : liFormno :: " + liFormno );
lsLineNo = getColumnValueForLine( "line_no", dom, Integer.toString( liFormno ), llRow );
String tranId = getColumnValueForLine( lsTranidcol, dom, Integer.toString( 1 ), 1 );
lsTaxdata = gfBatchTaxData(lsTranser, tranId, dom, Integer.parseInt( lsLineNo ), liFormnoA + 1, conn);
}
else
{
lsTaxdata = "";
}
HashMap colValMap = getColumnValueMap( dom, llRow, Integer.toString( liFormno ) );
//printMap( colValMap );
java.util.Iterator iteratorColVal = null;
java.util.Map.Entry meColVal =null;
java.util.Set setColVal = null;
setColVal = colValMap.entrySet();
iteratorColVal = setColVal.iterator();
liFldNoS = 1;
while( iteratorColVal.hasNext() )
{
meColVal = (java.util.Map.Entry) iteratorColVal.next();
String lsColName = null;
String value = null;
lsColName = ( String )meColVal.getKey();
lsFlddata = ( String ) meColVal.getValue();
liFldNoS++;
lsFlddata = nfEdiMapping( asWinname, liLineNo, liFormnoA, liFldNoS, lsFlddata, conn );
if ( liFldNoS != 1 )
{
lsTaxdata = "";
}
if( lsEdimedium == null || lsEdimedium.trim().length() == 0 || "null".equalsIgnoreCase( lsEdimedium ) || "1".equalsIgnoreCase( lsEdimedium ) )
{
batchLoadDetPstmt.setString( 1, lsBatchno );
batchLoadDetPstmt.setInt( 2, 1 );
batchLoadDetPstmt.setInt( 3, liObjSlD );
batchLoadDetPstmt.setInt( 4, llRow );
batchLoadDetPstmt.setInt( 5, liFldNoS );
batchLoadDetPstmt.setString( 6, lsFlddata );
batchLoadDetPstmt.setString( 7, lsTaxdata );
batchLoadDetPstmt.setString( 8, lsColName );
batchLoadDetPstmt.executeUpdate();
}
if( lsEdimedium != null && lsEdimedium.trim().equalsIgnoreCase( "2" ) )
{
lsStr = lsFlddata;
int fileListLen = lsFile.length;
for( int liCnt = 0; liCnt < fileListLen; liCnt++ )
{
if( lsFile[ liCnt ].equalsIgnoreCase( Integer.toString( liFldNoS ) ) )
{
lsFile[ liCnt ] = lsStr.trim();
}
}
if( liColWidth > 0)
{
if( lsStr.length() < liColWidth )
{
if( "R".equalsIgnoreCase( lsAlignment ) )
{
lsStr = space( liColWidth - lsStr.length() ) + lsStr;
}
else
{
lsStr = lsStr + space( liColWidth - lsStr.length() );
}
}
else
{
if( "R".equalsIgnoreCase( lsAlignment ) )
{
lsStr = mid( lsStr, lsStr.length() - liColWidth, liColWidth );
}
else
{
lsStr = mid( lsStr, 1, liColWidth );
}
}
}
if( lsSuffix != null && lsSuffix.trim().length() > 0 )
{
lsStr = lsStr + lsSuffix;
}
else if( lsPrefix != null && lsPrefix.trim().length() > 0 )
{
lsStr = lsPrefix + lsStr;
}
System.out.println( "lsStr::" + lsStr );
lsStrg.add( lsStr );
}
if( liSubPos > 0 )
{
outPutStrBuff.append( lsFlddata );
}
}
}
liObjSlD++;
}
//end else added by msalam on 060309
/*
if( lsErrcode != null && lsErrcode.trim().length() > 0 )
{
return lsErrcode;
}
if( lsEdimedium.trim().equalsIgnoreCase( "2" ) )
{
PreparedStatement disParmPStmt = null;
ResultSet disParmRS = null;
String disParmSql = null;
disParmSql = "SELECT DISPARM.VAR_VALUE "
+" FROM DISPARM "
+" WHERE ( DISPARM.VAR_NAME = 'FILE_BACKUP' ) AND "
+" ( DISPARM.PRD_CODE = '999999' ) " ;
try
{
//System.out.println( "disParmSql [" + disParmSql + "]" );
disParmPStmt = conn.prepareStatement( disParmSql );
disParmRS = disParmPStmt.executeQuery();
if( disParmRS.next() )
{
lsVarValue = disParmRS.getString( "VAR_VALUE" );
}
disParmRS.close();
disParmRS = null;
disParmPStmt.close();
disParmPStmt = null;
}catch( Exception ex )
{
ex.printStackTrace();
}finally{
try{
if( disParmRS != null )
disParmRS.close();
disParmRS = null;
if( disParmPStmt != null )
disParmPStmt.close();
disParmPStmt = null;
}catch( Exception e ){
}
}
for( liCnt = 1 ; liCnt < lsFile.length; liCnt++ )
{
lsFileName = lsFileName + lsFile[ liCnt ];
}
if( lsFilepath.length() != 0 )
{
if( lsVarValue.trim().length() > 0 )
{
//lsFilepath1 = lsVarValue + lsFileName + ".txt";
lsFilepath1 = lsVarValue + tranIdFile + ".txt";
}
//lsFilepath = lsFilepath + lsFileName + ".txt";
lsFilepath = lsFilepath + tranIdFile + ".txt";
if( liFormno == 1 )
{
//if( fileexists(lsFilepath) )
//{
// filedelete(lsFilepath);
//}
}
}
//System.out.println( "lbEdidetdefined=" + lbEdidetdefined );
if ( !lbEdidetdefined )
{
//System.out.println( "lsStrg.size()" + ( lsStrg == null ? "NO lsStrg" : lsStrg.size() ) );
llRowcount = lsStrg.size(); //upperbound( ls_strg )
if( llRowcount > 0 )
{
//for( llRow = 1; llRow < llRowcount ; llRow++ )
for( llRow = 0; llRow < llRowcount ; llRow++ )
{
if( lsStrg.get( llRow ) != null && ( ( String )lsStrg.get( llRow ) ).length() > 0 )
{
//to do something about this by msalam**
//ArrayList tempArr = null;
//S
String tempArr = (String)lsStrg.get( llRow );
lsString = lsString + tempArr;//( String )(( ).get(0));
}
}
}
if( lsString != null && lsString.trim().length() > 0 )
{
//lsErrcode = nfFileOpen( lsFilepath, lsString );
if( lsVarValue.length() > 0 )
{
//lsErrcode = nfFileOpen( lsFilepath1, lsString );
}
if( lsErrcode != null && lsErrcode.trim().length() > 0 )
{
//goto errfound
return lsErrcode;
}
}
lsString = "";
}
else
{
int llDatarow, llDatacol;
//System.out.println( "In else lnvoData.size() [" + ( lnvoData != null ? lnvoData.size() : "NULL" ) + "]" );
if( lnvoData != null && lnvoData.size() > 0 )
{
int noOfData = 0;
noOfData = ( (ArrayList)lnvoData.get( 0 ) ).size();
//System.out.println( "noOfData [" + noOfData + "]" );
for( llDatarow = 0; llDatarow < noOfData; llDatarow++ )//to upperbound(lnvo_data[1].data[])
{
lsString = "";
for( llDatacol = 0; llDatacol < lnvoData.size(); llDatacol++ ) // to upperbound(lnvo_data[])
{
//if not isnull(lnvo_data[ll_datacol].data[ll_datarow]) and len(lnvo_data[ll_datacol].data[ll_datarow]) > 0 then
// ls_string = ls_string + lnvo_data[ll_datacol].data[ll_datarow]
//end if
String str = null;
str = (String)( (ArrayList)lnvoData.get( llDatacol ) ).get( llDatarow );
//System.out.println( "str [" + str + "]" );
lsString = lsString + str;
}
if( lsString != null && lsString.length() > 0 )
{
//lsErrcode = nfFileOpen( lsFilepath, lsString ); //nf_fileopen(ls_filepath,ls_string)
if ( lsVarValue.length() > 0 )
{
//nfFileOpen( lsFilepath1, lsString );
}
if( lsErrcode != null && lsErrcode.trim().length() > 0 )
{
return lsErrcode;
}
}
}
lnvoData = null;
lsStrg = null;
}
}
}
lsStrg = lsTemp;
lsFileNameOld = lsFileName;
lsString = "";
ediCtrlFile = ( EdiControlFileBean )ediControlFileQue.poll();
if( ediCtrlFile != null )
{
liFileobj = ediCtrlFile.liFileobj;
lsFileName = ediCtrlFile.lsFileName;
lsFilepath = ediCtrlFile.lsFilepath;
}
else
{
liFileobj = liFileobjOld;
lsFileName = lsFileNameOld;
lsFilepath = lsFilepathOld;
}
liCnt = 1;
lsFile = fGetTokens( lsFileName, "|" );
liCnt = lsFile.length;
lsFileName = "";
liColWidth = 0;
lsDateFormat = "";
lsSuffix = "";
lsPrefix= "";
lsAlignment = "";
*/
}
}//end for ( int cnt = 0; cnt < noOfEdiRows ; cnt++ )
//lsErrcode = nfFileOpen( lsFilepath + tranIdFile + ".txt", outPutStrBuff.toString() );
return ( lsErrcode != null && lsErrcode.trim().length() > 0 ? lsErrcode : "SUCCESS" ) ;
}
private class EdiControlBean
{
String winName = null;
int lineNo;
String entity;
String entitySource = null;
String entitySourceRef = null;
String winNameLoad = null;
String chgUser = null;
Timestamp chgDate = null;
String chgTerm = null;
String xfrTax = null;
String refSer = null;
String subjectStr = null;
String entityAddnl = null;
String statOption = null;
String ediMedium = null;
String columnSeprator = null;
String interpretNull = null;
String transferMode = null;
String ediEvent = null;
String ediEventRef = null;
}
private class EdiControlDet
{
int fldNoSource;
String constantVal = null;
int objSlDest;
int fldNoDest;
int subjectPos;
int colWidth;
String dateFormat = null;
String suffix = null;
String prefix = null;
String alignment;
String fldNameSource = null;
}
private String generateTranId( String winName, String xsiteCode, Connection conn ) throws Exception
{
PreparedStatement lstmt = null;
ResultSet lrs = null;
String keyStringQuery = null;
String tranId = null;
String tranDate = null;
String tranSer = "";
String keyString = "";
String keyCol = "";
try
{
//just for test by msalam on 160309
sql = "select key_string, TRAN_ID_COL, REF_SER from transetup "
+" where upper(tran_window) = 'I-BL' ";
//System.out.println( "transetup :: " + sql );
lstmt = conn.prepareStatement( sql );
lrs = lstmt.executeQuery();
if( lrs.next() )
{
keyString = lrs.getString( "key_string" );
keyCol = lrs.getString( "TRAN_ID_COL" );
tranSer = lrs.getString( "REF_SER" );
}
else
{
if( lrs != null )
{
lrs.close();
}
lrs = null;
if( lstmt != null )
{
lstmt.close();
}
sql = "select key_string, TRAN_ID_COL, REF_SER from transetup where tran_window = 'GENERAL' ";
//System.out.println( "transetup :: " + sql );
lstmt = conn.prepareStatement( sql );
lrs = lstmt.executeQuery();
if( lrs.next() )
{
keyString = lrs.getString( "key_string" );
keyCol = lrs.getString( "TRAN_ID_COL" );
tranSer = lrs.getString( "REF_SER" );
}
}
lrs.close();
lrs = null;
lstmt.close();
lstmt = null;
/*
keyStringQuery = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE upper(TRAN_WINDOW) = upper('"+ winName +"')";
lstmt = conn.createStatement();
lrs = lstmt.executeQuery(keyStringQuery);
if (lrs.next())
{
keyString = lrs.getString( 1 );
keyCol = lrs.getString( 2 );
tranSer = lrs.getString( 3 );
}
*/
tranDate = getCurrdateAppFormat();
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<site_code>" + xsiteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>"+ tranDate + "</tran_date>";
xmlValues = xmlValues +"</Detail1></Root>";
TransIDGenerator tg = new TransIDGenerator(xmlValues, userid, CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID( tranSer, keyCol, keyString, conn );
}
catch(SQLException se)
{
//System.out.println("SQLException :Generating id[failed] : " + "\n" +se.getMessage());
se.printStackTrace();
}
catch(Exception ex)
{
//System.out.println("Exception8:Generating id [failed]:" + "\n" +ex.getMessage());
ex.printStackTrace();
}
finally
{
if (lstmt != null )
{
lstmt.close();
lstmt = null;
}
}
return tranId;
}//trnId
private HashMap setMetaData( String winName, String objContext )
{
Document dom = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int parentNodeListLength = 0;
int childNodeListLength = 0;
String tagName = null;
String tagValue = null;
String colName = "";
String colType = "";
String childNodeName = "";
String fldType="";
String ObjName ="";
String filename ="";
//String winName = "w_tax_process";
//String objContext ="2";
HashMap colTypeMap = null;
try
{
colTypeMap = new HashMap();
ObjName =winName.substring( 2, winName.length() )+ "1" + objContext;
//System.out.println("ObjName :: "+ObjName);
filename = CommonConstants.JBOSSHOME + java.io.File.separator + "bin" + java.io.File.separator + "metadata" + java.io.File.separator + ObjName.trim() + ".xml";
//System.out.println("filename :: "+filename);
java.io.File file = new java.io.File(filename);
DocumentBuilder parser1 = DocumentBuilderFactory.newInstance().newDocumentBuilder();
dom = parser1.parse(file);
NodeList columnsNodeList = dom.getElementsByTagName("table_column");
int tableColLength = columnsNodeList.getLength();
//System.out.println("tableColLength :: "+tableColLength);
for( int i = 0;i < tableColLength; i++ )
{
NodeList columnNodeList = columnsNodeList.item(i).getChildNodes();
int tableColChildLength = columnNodeList.getLength();
for( int j = 0; j < tableColChildLength; j++ )
{
Node colNode = columnNodeList.item(j) ;
tagName = colNode.getNodeName() ;
if ( tagName.equals( "type" ) )
{
colType = colNode.getFirstChild().getNodeValue();
}
if (tagName.equals("name"))
{
colName = colNode.getFirstChild().getNodeValue();
}
}
//this.colTypeList.add(colType.trim().toUpperCase());
//this.colNameList.add(colName.trim().toUpperCase());
colTypeMap.put( colName.trim().toUpperCase(), colType.trim().toUpperCase() );
}
}
catch(java.io.FileNotFoundException fileNotFound)
{
//System.out.println("Exception ::constructor :==>");
fileNotFound.printStackTrace();
}
catch(Exception e )
{
e.printStackTrace();
}
return colTypeMap;
}
private String mid( String lsStr, int start, int liColWidth )
{
//to implement it later by msalam
//System.out.println( "liColWidth[" + liColWidth );
//System.out.println( "start [" + start );
//System.out.println( "lsStr [" + lsStr);
//System.out.println( "lsStr.subString( start, liColWidth ) [" + lsStr.substring( start + 1, start + 1 + liColWidth ) + "][" + lsStr + "]" );
//return lsStr.substring( start + 1, start + 1 + liColWidth );
return lsStr.substring( start, liColWidth );
}
private String left( String src, int size )
{
if( src.length() < size - 1 )
return "";
return src.substring( 0, size - 1 );
}
private String[] fGetTokens( String str, String seperator )
{
String val = null;
ArrayList sArr = new ArrayList();
StringTokenizer st = new StringTokenizer( str, seperator );
while (st.hasMoreTokens()) {
val = st.nextToken();
sArr.add( val );
}
st = null;
String str1[];
int lenArr = 0;
lenArr = sArr.size();
str1 = new String[ lenArr ];
for( int cnt = 0; cnt < lenArr ; cnt++ )
str1[ cnt ] = ( String ) sArr.get( cnt );
return str1;
}
private String nfFileOpen( String asFilepath, String asString )
{
String lsErrcode = null, lsWrite, lsVarValue;
int liFileNum, liLen, liFilewrite, liFileclose;
java.io.File ediFile = null;
java.io.FileWriter ediFileWtr = null;
try
{
ediFileWtr = new java.io.FileWriter( asFilepath, true );
System.out.println( "asString::" + asString );
liLen = asString.length();
if( ediFile == null )
{
lsErrcode = "VBFILEOPEN";
}
lsWrite = asString;
char writeCharArr[] = new char[ lsWrite.length() ];
lsWrite.getChars( 0, lsWrite.length(), writeCharArr, 0 );
ediFileWtr.write( writeCharArr );
}catch( Exception ex )
{
lsErrcode = "VFLEIOERR";
ex.printStackTrace();
}
finally{
try{
ediFileWtr.close();
ediFileWtr = null;
ediFile = null;
}catch( Exception e ){
lsErrcode = "VEFCLERR";
e.printStackTrace();
}
}
return lsErrcode;
}
private String nfEdiMapping( String asWinname, int aiLineNo, int aiFormnoA, int aiFldNoS, String asFlddata, Connection conn )
{
String lsValueDest = null;
String lsDestValueType = null;
String lsOrigData = null;
lsOrigData = asFlddata;
asFlddata = asFlddata.trim();
String sql = null;
PreparedStatement mappingPStmt = null;
ResultSet mappingRS = null;
// if edi Mapping is defined then only coll for detail start
sql = "select count( * ) cnt from edi_mapping "
+" where win_name = ? "; //'" + asWinname + "'";
int countEdiMapping = 0;
try
{
mappingPStmt = conn.prepareStatement( sql );
mappingPStmt.setString( 1, asWinname );
mappingRS = mappingPStmt.executeQuery();
if( mappingRS.next() )
{
countEdiMapping = mappingRS.getInt( "cnt" );
}
mappingRS.close();
mappingRS = null;
mappingPStmt.close();
mappingPStmt = null;
}catch( Exception e )
{
e.printStackTrace();
return lsOrigData;
}
finally{
try{
if( mappingRS != null )
mappingRS.close();
mappingRS = null;
if( mappingPStmt != null )
mappingPStmt.close();
mappingPStmt = null;
}catch( Exception ex ){}
}
if( countEdiMapping == 0 )
{
return asFlddata;
}
// if edi Mapping is defined then only coll for detail end
sql = "select value__dest, dest_value_type from edi_mapping "
+" where win_name = ? "//'" + asWinname + "' and "
+" line_no = ? " // + aiLineNo + " and "
+" obj_sl__source = ? " // + aiFormnoA + " and "
+" fld_no__source = ? " // + aiFldNoS + " and "
+" value__source = ? "; //'" + asFlddata + "'";
try
{
mappingPStmt = conn.prepareStatement( sql );
mappingPStmt.setString( 1, asWinname );
mappingPStmt.setInt( 2, aiLineNo );
mappingPStmt.setInt( 3, aiFormnoA );
mappingPStmt.setInt( 4, aiFldNoS );
mappingPStmt.setString( 5, asFlddata );
mappingRS = mappingPStmt.executeQuery();
if( mappingRS.next() )
{
lsValueDest = mappingRS.getString( "value__dest" );
lsDestValueType = mappingRS.getString( "dest_value_type" );
}
else
{
return lsOrigData;
}
mappingRS.close();
mappingRS = null;
mappingPStmt.close();
mappingPStmt = null;
}catch( Exception e )
{
e.printStackTrace();
return lsOrigData;
}
finally{
try{
if( mappingRS != null )
mappingRS.close();
mappingRS = null;
if( mappingPStmt != null )
mappingPStmt.close();
mappingPStmt = null;
}catch( Exception ex ){}
}
if( lsDestValueType.equalsIgnoreCase( "F" ) )
{
return lsValueDest;
}
else
{
return lsOrigData;
}
}
private boolean efCheckCondition( String asWinname, int liLineNo, Document dom, Connection conn )
{
int llColNo, llCount;
String lsCompValue = null;
String lsOper = null;
String lsEdiMethod = null;
String lsTotFunc = null;
String lsRetCode = null;
String mcoltype = null;
String lsColOperator = null;
boolean lbFlag = true;
String lxChkValue = null;
String lxCompValue = null;
int liPos, liPos1, liPos2, liPos3, liPos4, liVal;
int liSeperator, liStart, liLength;
String lsConstantVal, lsFindVal, lsFldval, lsFunc, lsVal, lsType;
boolean lbLoop;
EdiValuesBean ediVal = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
/*
sql = " select col_no, comp_operator, comp_value, edi_method, col_operator "
+" from edi_control_values "
+" where win_name = '" + asWinName + "'"
+" and line_no = " + alLineNo;
try{
pstmt = conn.prepareStatemet( sql );
rs = pstmt.executeQuery();
while( rs.next() )
{
ediVal = new EdiValuesBean();
ediVal.colNo = rs.getInt( "col_no" );
ediVal.compOperator = rs.getString( "comp_operator" );
ediVal.compValue = rs.getString( "comp_value" );
ediVal.ediMethod = rs.getString( "edi_method" );
ediVal.colOperator = rs.getString( "col_operator" );
ediValArr.add( ediVal );
}
if( ediValArr.size() == 0 )
{
lb_flag = true;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}catch( Exception ex )
{
lbFlag = false;
ex.printStackTrace();
}
finally{
if( rs != null )
rs.close();
rs = null;
if( pstmt != null )
pstmt.close();
pstmt = null;
}
int ediValArrSize = 0;
ediValArrSize = ediValArr.size();
for( int ediCtrlValCnt = 0; ediCtrlValCnt < ediValArrSize ; ediCtrlValCnt++ )
{
ediVal = ediValArr.get( ediCtrlValCnt );
llColNo = ediVal.colNo;
lsOper = ediVal.compOperator;
lsCompValue = ediVal.compValue;
lsEdiMethod = ediVal.ediMethod;
lsColOperator = ediVal.colOperator;
lsOper = lsOper.trim();
lsCompValue = lsCompValue.trim();
if( lsEdiMethod == null || lsEdiMethod.trim().length() == 0 )
{
mcoltype = ads_dataobj.Describe('#' + trim(string(ll_col_no))+".Coltype")
if lower(left(mcoltype,4)) = "char" then
lx_chk_value = trim(ads_dataobj.getitemstring(1,ll_col_no))
lx_comp_value = ls_comp_value
elseif lower(left(mcoltype,4)) = "deci" then
lx_chk_value = ads_dataobj.GetItemDecimal(1,ll_col_no)
lx_comp_value = dec(ls_comp_value)
elseif lower(left(mcoltype,4)) = "numb" then
lx_chk_value = ads_dataobj.GetItemNumber(1,ll_col_no)
lx_comp_value = long(ls_comp_value)
elseif lower(left(mcoltype,8)) = "datetime" then
lx_chk_value = ads_dataobj.GetItemDatetime(1,ll_col_no)
lx_comp_value = datetime(ls_comp_value)
elseif lower(left(mcoltype,4)) = "date" then
lx_chk_value = ads_dataobj.GetItemDate(1,ll_col_no)
lx_comp_value = date(ls_comp_value)
End if
}
else
{
lxCompValue = lsCompValue;
if( left( lsEdiMethod, 3 ).equalsIgnoreCase( "FN_" ) )
{
if( pos( ls_edi_method, "(" ) > 0 )
{
lsConstantVal = lsEdiMethod;
liPos = pos( lsConstantVal, "(" );
liPos1 = pos( lsConstantVal, "," );
liPos4 = liPos1;
lsFindVal = "";
lsFldval = "";
liPos2 = pos( lsConstantVal, ")" );
lsFunc = left( lsConstantVal, liPos );
lbLoop = true;
while( lbLoop )
{
if( liPos > 0 && liPos2 > 0 )
{
if( liPos1 = 0 ) // only one argument
{
if( liPos4 > 0 )
{
liPos = liPos3;
}
liPos1 = liPos2;
lbLoop = false;
}
else
{
liPos3 = liPos1;
}
lsVal = mid( lsConstantVal, liPos + 1, liPos1 - liPos - 1 );
if( isnumber(ls_val) )
{
liVal = Integer.parseInt( lsVal );
ls_type = ads_dataobj.describe("#"+string(ls_val)+".Coltype")
if( left( lsType, 4 ).equalsIgnoreCase( "char" ) )
{
lsFldval = ads_dataobj.getitemstring(1,li_val)
if( len(trim(ls_find_val)) > 0 )
{
ls_find_val = ls_find_val + ', "' + ls_fldval + '"';
}
else
{
ls_find_val = ls_find_val + '"' + ls_fldval + '"';
}
}
else if( left( lsType, 4 ).equalsIgnoreCase( "nume" )
|| left( lsType, 4 ).equalsIgnoreCase( "long" )
|| left( lsType, 4 ).equalsIgnoreCase( "inte" )
|| left( lsType, 4 ).equalsIgnoreCase( "real" )
|| left( lsType, 4 ).equalsIgnoreCase( "deci" ) )
{
lsFldval = string(ads_dataobj.getitemnumber(1,li_val))
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + "," + lsFldval;
}
else
{
lsFindVal = lsFindVal + lsFldval;
}
}
else if( left( ls_type,8) = "datetime" )
{
ls_fldval = string(ads_dataobj.getitemdatetime(1,li_val),'yyyy-mm-dd')
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", \"" + lsFldval + "\"";
}
else
{
lsFindVal = lsFindVal + "\"" + lsFldval + "\"";
}
}else if( left( lsType, 4 ).equalsIgnoreCase( "date" ) )
{
lsFldval = string(ads_dataobj.getitemdate(1,li_val),'yyyy-mm-dd')
if ( ls_find_val != null && ls_find_val.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", \"" + lsFldval + "\"";
}
else
{
lsFindVal = lsFindVal + "\"" + lsFldval + "\"";
}
}
}
else
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", " + lsVal;
}
else
{
lsFindVal = lsFindVal + lsVal;
}
}//if isnumber(ls_val)
liPos = liPos1;
liPos1 = pos( lsConstantVal, ",", liPos1 + 1 );
}//li_pos > 0 and li_pos2 > 0
}
lsTotFunc = lsFunc + lsFindVal + ")";
}
else
{
lxChkValue = trim(ads_dataobj.getitemstring(1,ll_col_no))
lsTotFunc = lsEdiMethod + "(\"" + lxChkValue + "\")"
}
// end 28-03-2006 manoharan
String funcSql = null;
funcSql = " select " + lsFunc + lsFindVal + ") from dual";
PreparedStatement funcPStmt = null;
ResultSet funcRS = null;
funcPStmt = conn.prepareStatement( funcSql );
funcRS = funcPStmt.executeQuery( );
if( funcRS.next() )
{
lsRetCode = funcRS.getString( 1 );
}
funcRS.close();
funcRS = null;
funcPStmt.close();
funcPStmt = null;
if( lsRetCode.equalsIgnoreCase( "N" ) )
{
lbFlag = false;
goto cursorend
}
else
{
lxChkValue = lsRetCode.trim();
}
}
else
{
if( pos( lsEdiMethod, "(" ) > 0 )
{
lsConstantVal = lsEdiMethod;
liPos = pos( lsConstantVal, "(" );
liPos1 = pos( lsConstantVal, "," );
liPos4 = liPos1;
lsFindVal = "";
lsFldval = "";
liPos2 = pos( lsConstantVal, ")" );
lsFunc = left( lsConstantVal, liPos );
lbLoop = true;
while( lbLoop )
{
if( liPos > 0 && liPos2 > 0 ) // if ( ) are there
{
if( liPos1 == 0 ) // only one argument
{
if( liPos4 > 0 )
{
liPos = liPos3;
}
liPos1 = liPos2;
lbLoop = false;
}
else
{
liPos3 = liPos1;
}
lsVal = mid( lsConstantVal, liPos + 1, liPos1 - liPos - 1 );
if( isnumber(lsVal) )
{
liVal = Integer.parseInt( lsVal );
lsType = ads_dataobj.describe("#"+string(ls_val)+".Coltype")
if( left( lsType, 4 ).equalsIgnoreCase( "char" )
{
lsFldval = ads_dataobj.getitemstring(1,li_val)
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}else if( left( lsType, 4 ).equalsIgnoreCase( "nume" )
|| left( lsType, 4 ).equalsIgnoreCase( "long" )
|| left( lsType, 4 ).equalsIgnoreCase( "inte" )
|| left( lsType, 4 ).equalsIgnoreCase( "real" )
|| left( lsType, 4 ).equalsIgnoreCase( "deci" ) )
{
ls_fldval = string(ads_dataobj.getitemnumber(1,li_val))
if( len(trim(lsFindVal)) > 0 )
{
lsFindVal = lsFindVal + "," + lsFldval;
}
else
{
lsFindVal = lsFindVal + lsFldval;
}
}else if( left( lsType, 8 ).equalsIgnoreCase( "datetime" ) )
{
if( gs_database = "oracle" )
{
lsFldval = string(ads_dataobj.getitemdatetime(1,li_val),'dd-mmm-yyyy');
}
else
{
lsFldval = string(ads_dataobj.getitemdatetime(1,li_val),'yyyy-mm-dd') ;
}
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}else if( left( lsType, 4 ).equalsIgnoreCase( "date" ) )
{
if( gs_database = "oracle" )
{
lsFldval = string(ads_dataobj.getitemdate(1,li_val),'dd-mmm-yyyy');
}
else
{
lsFldval = string(ads_dataobj.getitemdate(1,li_val),'yyyy-mm-dd');
}
if( ls_find_val != null && ls_find_val.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", '" + lsFldval + "'";
}
else
{
lsFindVal = lsFindVal + "'" + lsFldval + "'";
}
}
}
else
{
if( lsFindVal != null && lsFindVal.trim().length() > 0 )
{
lsFindVal = lsFindVal + ", " + lsVal;
}
else
{
lsFindVal = lsFindVal + lsVal;
}
}//if isnumber(ls_val)
liPos = liPos1;
liPos1 = pos( lsConstantVal, ",", liPos1 + 1 );
} //li_pos > 0 and li_pos2 > 0
}
lsTotFunc = lsFunc + lsFindVal + ")";
}
else
{
lxChkValue = trim(ads_dataobj.getitemstring(1,ll_col_no ) );
lsTotFunc = lsEdiMethod + "(\"" +lxChkValue + "\")";
}
// end 28-03-2006 manoharan
lsTotFunc = "select " + ls_tot_func + " from dual";
PreparedStatement fuctCallPStmt = null;
ResultSet functCallRs = null;
try{
fuctCallPStmt = conn.preparedStatement( lsTolFunc );
functCallRs = fuctCallPStmt.executeQuery();
if( functCallRs.next() )
{
lsRetCode = functCallRs.getString( 1 );
}
functCallRs.close();
functCallRs = null;
fuctCallPStmt.close();
fuctCallPStmt = null;
}catch( Exception ex )
{
ex.printStackTrace( );
}finally{
try
{
if( functCallRs != null )
functCallRs.close();
functCallRs = null;
if( fuctCallPStmt != null )
fuctCallPStmt.close();
fuctCallPStmt = null;
}catch( Exception ex ){}
}
if( lsRetCode == null )
{
lsRetCode = "N";
}
lxChkValue = lsRetCode.trim();
}
}
if( lsColOperator.length() > 0 )
{
if( mid( lsColOperator, 1, 7 ).equalsIgnoreCase( "SUBSTR(" ) )
{
liPos = pos( lsColOperator, ")" );
liSeperator = pos( lsColOperator, "," );
liStart = integer( mid( lsColOperator, 8, liSeperator - 8 ) );
liLength = Integer.parseInt( mid ( lsColOperator, liSeperator + 1 ,liPos - liSeperator - 1 ) );
lxChkValue = mid( lxChkValue, liStart, liLength );
}
}
lxChkValue = lxChkValue
if ( lsOper.equalsIgnoreCase( "=" ) )
{
if( lxCompValue.equalsIgnoreCase( lxChkValue )
{
lbFlag = true;
}
else
{
lbFlag = false
goto cursorend
}
}else if( lsOper.equalsIgnoreCase( ">" ) )
{
if( lxCompValue.comparTo( lxChkValue ) < 0 )
{
lbFlag = true;
//return true
}
else
{
lbFlag = false;
goto cursorend
}
}else if( lsOper.equalsIgnoreCase( "<" )
{
if( lxCompValue.compareTo( lxChkValue ) > 0 )
{
lbFlag = true
//return true
}
else
{
lbFlag = false
goto cursorend
//return false
}
}else if( lsOper.equalsIgnoreCase( "in" ) )
{
if( pos( lxCompValue, Integer.parseInt( lxChkValue) ) > 0 )
{
lbFlag = true
//return true
}else
{
lbFlag = false
goto cursorend
//return false
}
}
else if( lsOper.equalsIgnoreCase( "not in" ) )
{
if( pos( lxCompValue, Integer.parseInt( lxChkValue ) ) = 0 )
{
lbFlag = true;
//return true
}
else
{
lbFlag = false;
goto cursorend
//return false
}
}else if ( lsOper.equalsIgnoreCase( "<>" ) )
{
if( !( lxCompValue.equalsIgnoreCase( lx_chk_value ) ) )
{
lbflag = true;
//return true
}else
{
lbFlag = false;
goto cursorend
//return false
}
}
}
*/
return lbFlag;
}
private class EdiValuesBean
{
String winName = null;
int lineNo;
int colNo;
String compOperator = null;
String compValue = null;
String ediMethod = null;
int lineNoVal;
String colOperator;
}
private int pos( String str, String searchChar )
{
return str.indexOf( searchChar );
}
private int pos( String str, String searchChar, int position )
{
//System.out.println( "str.indexOf( searchChar, position ) :: " + " " + str.length() + " " + str + " " + position );
return ( str.indexOf( searchChar, position ) == -1 ? 0 : str.indexOf( searchChar, position ) );
}
private String space( int noOfSpaces )
{
String blankStr = null;
blankStr = "";
for( int cnt = 0; cnt < noOfSpaces ; cnt++ )
{
blankStr = blankStr + " ";
}
return blankStr;
}
private int getRowCount( Document dom, int formNo )
{
int rowCount = 0;
NodeList detailList = null;
String detail = null;
detail = "Detail" + formNo;
//System.out.println( "detail::" + detail );
if( dom == null )
{
//System.out.println( "dom == null " );
return -1;
}
detailList = dom.getElementsByTagName( detail );
rowCount = detailList.getLength();
return rowCount;
}
private class EdiControlFileBean
{
int liFileobj;
String lsFileName = null;
String lsFilepath = null;
}
private boolean isnumber( String str )
{
int val;
try
{
val = Integer.parseInt( str );
}catch( NumberFormatException nex )
{
return false;
}catch( Exception ex )
{
return false;
}
//System.out.println( "return from is number is true" );
return true;
}
public String getColumnValueForLine(String colName, Document dom, String formNo, int lineNo ) throws ITMException
{
Node elementName = null, parentNode = null;
NodeList elementList = null;
NodeList detailList = null;
Element elementAttr = null;
String columnName = "";
String columnValue = null;
boolean continueLoop = true;
boolean isFormNo = false;
ibase.utility.GenericUtility genUtility = ibase.utility.GenericUtility.getInstance();
int ctr;
try
{
//System.out.println( "(colName, formNo, lineNo ) :: ( " + colName + ", " + formNo + ", " + lineNo + " )" );
detailList = dom.getElementsByTagName( "Detail" + Integer.parseInt(formNo) );
columnValue = genUtility.getColumnValueFromNode( colName, detailList.item( lineNo - 1 ) );
}
catch(Exception e)
{
//System.out.println("Exception : [GenericUtility][getColumnValue(2)] :==>\n"+e.getMessage());
throw new ITMException(e);
}
return columnValue;
}
private String getCurrdateAppFormat(java.sql.Timestamp ts)
{
String dateAf ="";
//System.out.println("Comming Date[In DB Format] :::"+ts.toString());
try
{
Object date = null;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(ts.toString());
dateAf = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(date).toString();
}
catch(Exception e)
{
e.printStackTrace();
}
//System.out.println("Retturning Date :::"+dateAf);
return (dateAf);
}
private String getCurrdateAppFormat()
{
String currAppdate ="";
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate =new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
}
catch(Exception e)
{
e.printStackTrace();
//System.out.println("Exception in :::calcFrsBal"+e.getMessage());
}
return (currAppdate);
}
private class Queue
{
ArrayList data = new ArrayList();
int pos = 0;
public void offer( Object dat )
{
data.add( dat );
}
public Object poll()
{
//System.out.println( "data.size() : " + data.size() + " pos : " + pos );
if( data.size() == 0 || data.size() < pos )
{
return null;
}
int t = pos;
t = ( t==data.size()?pos-1:t);
pos++;
//System.out.println( "t=" + t );
return data.get( t );
}
}
private void printArray( String [] lsFile )
{
for( int cnt =0 ; cnt < lsFile.length ; cnt++ )
System.out.println( lsFile[ cnt ] );
}
/*
private void printMap( HashMap fldTypeMap )
{
java.util.Iterator iteratorSup = null;
java.util.Map.Entry meSup =null;
java.util.Set setSup = null;
setSup = fldTypeMap.entrySet();
iteratorSup = setSup.iterator();
while( iteratorSup.hasNext() )
{
meSup=(java.util.Map.Entry) iteratorSup.next();
String tKey = null;
String value = null;
tKey = ( String )meSup.getKey();
value = ( String ) meSup.getValue();
System.out.println( tKey + " : " + value );
}
}
*/
private String getDateInFormat( String date, String format )
{
String currDate = null;
//Object dateObj = null;
java.util.Date dt = null;
SimpleDateFormat sdf = null;
try
{
sdf = new SimpleDateFormat( "dd/MM/yyyy" );
dt = sdf.parse( date );
sdf = new SimpleDateFormat( format );
currDate = sdf.format( dt ).toString();
System.out.println(currDate);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in getCurrdateWoTimeInDBFormat :::"+e.getMessage());
}
return (currDate);
}
private String nfGetEdiAddress( char asEntity, String asEntityCode, Connection conn ) throws Exception
{
String sql = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String lsEdiAddr = null;
switch( asEntity )
{
case '0' :
case 'O' :
sql = "select edi_addr from site where site_code = ? ";
break;
case 'C' :
sql = "select edi_addr from customer where cust_code = ? ";
break;
case 'S' :
sql = "select edi_addr from supplier where supp_code = ? ";
break;
case 'L' :
sql = "select edi_addr from loanparty where party_code = ? ";
break;
}
//sql = sql + asEntityCode + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asEntityCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
lsEdiAddr = rs.getString( "edi_addr" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
return lsEdiAddr;
}
private String gfBatchTaxData( String asRefser, String asTranId,
Document dom,
int asLineno, int aiFormNo,
Connection conn ) throws Exception
{
String lsTaxstr = null, lsErrcode = null, lsTaxform = null, lsAcct = null, lsChgStat = null, lsPaytax = null;
long llLen = 0;
double lcTaxperc = 0.0, lcTaxableAmt = 0.0, lcTaxAmt = 0.0;
java.sql.Timestamp ldtTfdate = null;
String lsTaxCode = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
if( aiFormNo == 0 )
{
return "";
}
String sql = null;
sql = " select tax_perc,taxable_amt,tax_amt, chg_stat,tax_form,tax_form_date,acct_code,pay_tax,tax_code "
+" from taxtran "
+" where tran_code = ? " //'" + asRefser + "'"
+" and tran_id = ? " //'" + asTranId + "'"
+" and line_no = ? "//" + asLineno
+" order by tran_code, tran_id, line_no, line_no__tax ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, asRefser );
pstmt.setString( 2, asTranId );
pstmt.setInt( 3, asLineno );
rs = pstmt.executeQuery();
while( rs.next() )
{
lcTaxperc = rs.getDouble( "tax_perc" );
lcTaxableAmt = rs.getDouble( "taxable_amt" );
lcTaxAmt = rs.getDouble( "tax_amt" );
lsChgStat = rs.getString( "chg_stat" );
lsTaxform = rs.getString( "tax_form" );
ldtTfdate = rs.getTimestamp( "tax_form_date" );
lsAcct = rs.getString( "acct_code" );
lsPaytax = rs.getString( "pay_tax" );
lsTaxCode = rs.getString( "tax_code" );
//if( lcTaxperc == null || lcTaxperc.trim().length() == 0 )
//{
// lcTaxperc = 0;
//}
if( lsAcct == null || lsAcct.trim().length() == 0 )
{
lsAcct = "";
}
if( lsChgStat == null || lsChgStat.trim().length() == 0 )
{
lsChgStat = "";
}
if( ldtTfdate == null )
{
ldtTfdate = new java.sql.Timestamp( System.currentTimeMillis() );
}
if( lsPaytax == null || lsPaytax.trim().length() == 0 )
{
lsPaytax = "N";
}
lsTaxstr = lsTaxstr + lsTaxCode + "\t" + Double.toString( lcTaxperc )+ "\t" +
Double.toString( lcTaxableAmt) + "\t"
+ Double.toString( lcTaxAmt ) + "\t" + lsChgStat + "\t" +
lsTaxform + "\t" + ldtTfdate.toString() + "\t" +lsAcct + "\t";
}
//System.out.println( "lsTaxstr :: " + lsTaxstr );
llLen = lsTaxstr != null ? lsTaxstr.length() : 0;
if( lsTaxstr != null && lsTaxstr.trim().length() > 0 )
{
lsTaxstr = lsTaxstr.substring( 0, (int)llLen - 1 ) + "|";
}
else
{
lsTaxstr = "";
}
return lsTaxstr;
}
private HashMap getColumnValueMap( Document dom, int lineNo, String formNo )
{
NodeList detailList = null;
HashMap detailMap = new HashMap();
NodeList detNodeList = null;
try
{
detailList = dom.getElementsByTagName( "Detail" + formNo );
if( "1".equalsIgnoreCase( formNo ) )
{
detNodeList = detNodeList = detailList.item( 0 ).getChildNodes();
}else
{
detNodeList = detailList.item( lineNo - 1 ).getChildNodes();
}
for( int colIdx = 0, noOfColumns = detNodeList.getLength();
colIdx < noOfColumns;
colIdx++ )
{
Node colNode = detNodeList.item( colIdx );
if( colNode.getNodeType() == Node.ELEMENT_NODE )
{
String colName = colNode.getNodeName();
String colVal = ( colNode.getFirstChild() != null ? colNode.getFirstChild().getNodeValue() : "null" );
detailMap.put( colName, ( colVal != null && colVal.trim().length() > 0 ? colVal : "null" ) );
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return detailMap;
}
private void printMap( HashMap hmap )
{
java.util.Iterator iteratorMap = null;
java.util.Set setMap = null;
java.util.Map.Entry entry = null;
setMap = hmap.entrySet();
iteratorMap = setMap.iterator();
while( iteratorMap.hasNext() )
{
entry = ( java.util.Map.Entry )iteratorMap.next();
String tKey = null;
String supplierCode = null;
tKey = (String)entry.getKey();
//System.out.println(" mapType : ( tKey, value ) :: ( " + tKey + ", " + ( String )entry.getValue() + " )" );
}
}
}
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