Commit 60135ef4 authored by kdabholkar's avatar kdabholkar

new componanats of veiw SYNC Statuas screen .

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@185231 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8ff42be2
package ibase.webitm.ejb.gstclient;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
//import ibase.utility.GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
//import javax.ejb.Stateless;
//import oracle.sql.TIMESTAMP;
import org.w3c.dom.Document;
@javax.ejb.Stateless
public class GstDataPrompMsg extends ProcessEJB implements GstDataPrompMsgLocal,GstDataPrompMsgRemote
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
Connection connLocal = null,connGST = null;
StringBuffer errorMessage = new StringBuffer();
public String process() throws RemoteException, ITMException
{
return "";
}
public String process(String xmlString, String xmlString2,String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
System.out.println("windowName [" + windowName + "]");
System.out.println("xtraParams [" + xtraParams + "]");
if (xmlString != null && xmlString.trim().length() != 0)
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception GstDataPrc :process()"+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retString = "",period = "",fromDateStr = "",toDateStr = "";
try
{
connGST = getConnection();
/*period = checkNull(genericUtility.getColumnValue("prd_code", headerDom));
fromDateStr = genericUtility.getColumnValue("from_date",headerDom);
toDateStr = genericUtility.getColumnValue("to_date",headerDom);*/
System.out.println("Inside Prompt");
retString = itmDBAccessEJB.getErrorString("","INVOPRTION","","",connGST);
return retString;
}
catch (Exception e) {
// TODO: handle exception
System.out.println("EXCEPTION WHILE PROMPT"+e);
}
return retString;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessLocal;
import org.w3c.dom.Document;
public interface GstDataPrompMsgLocal extends ProcessLocal{
public String process() throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ProcessRemote;
import org.w3c.dom.Document;
public interface GstDataPrompMsgRemote extends ProcessRemote{
public String process() throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.gstclient;
import ibase.webitm.ejb.*;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
//import ibase.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.w3c.dom.*;
@javax.ejb.Stateless
public class GstViewStatusIC extends ValidatorEJB implements GstViewStatusICRemote, GstViewStatusICLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
//GenericUtility genericUtility = new GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String wfValData() throws RemoteException, ITMException
{
return "";
}
public String wfValData(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = null;
try
{
System.out.println("Inside GstDataIC wfValData");
if(currXmlDataStr != null && currXmlDataStr.trim().length()!=0)
{
currDom = genericUtility.parseString(currXmlDataStr);
}
if(hdrXmlDataStr != null && hdrXmlDataStr.trim().length()!=0)
{
hdrDom = genericUtility.parseString(hdrXmlDataStr);
}
if(allXmlDataStr != null && allXmlDataStr.trim().length()!=0)
{
allDom = genericUtility.parseString(allXmlDataStr);
}
errString = wfValData( currDom, hdrDom, allDom, objContext, editFlag, xtraParams );
}//end of try
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}//end of catch
return errString ;
}//end of wfvalData() of xml string
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
String errString = "",sql = "";
ResultSet rSet = null;
Connection connObject = null;
PreparedStatement pstmt = null;
NodeList parentList = null;
NodeList childList = null;
int noOfChilds = 0;
String childNodeName = "";
Node childNode =null;
boolean isNumber = true;
String columnValue = "";
int currentFormNo = 0,count = 0;
try
{
connObject = getConnection();
/*ConnDriver connDriver = new ConnDriver();
connObject = connDriver.getConnectDB("DriverITM");
connObject.setAutoCommit(false);
connDriver = null;*/
String userID = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "LoginCode" );
if ( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
parentList = currDom.getElementsByTagName("Detail" + currentFormNo );
childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item( ctr );
childNodeName = childNode.getNodeName();
System.out.println("childNodeName"+childNodeName);
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
if ( "prd_code".equalsIgnoreCase( childNodeName ) )
{
if (childNode.getFirstChild()==null)
{
errString = getErrorString("prd_code","VTBLNKPRD",userID);
break;
}
else
{
isNumber = checkNumeric( columnValue );
System.out.println("isNumber =["+isNumber+"]");
if ( !isNumber )
{
errString = getErrorString("prd_code","NOTANUMBR1",userID);
break;
}
sql = "SELECT COUNT(1) AS CNT FROM PERIOD WHERE CODE = ?";
pstmt = connObject.prepareStatement(sql);
pstmt.setString(1, columnValue);
rSet = pstmt.executeQuery();
if(rSet.next())
{
count = rSet.getInt("CNT");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rSet!=null)
{
rSet.close();
rSet = null;
}
if (count == 0)
{
System.out.println("period code not found in period master");
errString = itmDBAccessEJB.getErrorString("","CNDIPRDINV","","",connObject);
return errString;
}
}
}
}
}
catch(Exception e)
{
System.out.println("Exception in GstViewStatusIC wfValData == >"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if( rSet != null )
{
rSet.close();rSet = null;
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
if( connObject != null && ! connObject.isClosed() )
{
connObject.close();connObject = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}//end of catch
} //end of finally
return (errString);
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
System.out.println("Inside GstDataIC itemChanged");
if (xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
}
catch(Exception e)
{
throw new ITMException(e);
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
int currentFormNo = 0 ;
String sql = "",currDateStr = "";
Timestamp monthDate = null;
Calendar calendar = new GregorianCalendar();
String prdCode = "", fromDateStr = "", toDateStr = "";
Date fromDate = null, toDate = null;
try
{
conn = getConnection();
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;*/
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("currentColumn["+currentColumn+"] && currentFormNo["+currentFormNo+"]");
switch(currentFormNo)
{
case 1 :
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
valueXmlString.append("<Detail1>\r\n");
if("itm_default".equalsIgnoreCase(currentColumn))
{
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -1);
currDateStr = sdf.format(calendar.getTime());
monthDate = Timestamp.valueOf(genericUtility.getValidDateString(currDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = "SELECT CODE FROM PERIOD WHERE ? BETWEEN FR_DATE AND TO_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, java.sql.Timestamp.valueOf(genericUtility.getValidDateString(new Date(), genericUtility.getDBDateFormat())+ " 00:00:00.0"));
rs = pstmt.executeQuery();
if(rs.next())
{
prdCode = rs.getString("CODE") == null ? "" : rs.getString("CODE");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<prd_code>").append("<![CDATA["+prdCode+"]]>").append("</prd_code>");
}
valueXmlString.append("</Detail1>");
}
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
System.out.println("Exception inside GSTDataIC===>"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
if(rs != null)
{
rs.close();rs = null;
}
if(conn != null)
{
conn.close();conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private boolean checkNumeric( String noOfLabel ) throws Exception
{
char[] cArray = noOfLabel.toCharArray();
boolean isNumber = true;
for(int i = 0; i < cArray.length;i++)
{
if( !Character.isDigit(cArray[i]) )
{
isNumber = false;
}
}
return isNumber;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface GstViewStatusICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface GstViewStatusICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import javax.ejb.Stateless;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.utility.ITMException;
import org.w3c.dom.Document;
@Stateless
public class viewGstDataStatus extends ProcessEJB implements viewGstDataStatusLocal,viewGstDataStatusRemote
{
E12GenericUtility genericUtility = null;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException, ITMException
{
System.out.println("******* Inside viewGstDataStatus getData**********");
//System.out.println(".....xtraParams["+xtraParams+"]");
Document dom = null, dom1 = null;
String retString = null;
try
{
//System.out.println(">>>>>xmlString:getData"+xmlString+">>>>xmlString2:"+xmlString2);
if (xmlString != null && xmlString.trim().length() != 0)
{
genericUtility= new E12GenericUtility();
dom = genericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
genericUtility= new E12GenericUtility();
dom1 = genericUtility.parseString(xmlString2);
}
retString = getData(dom, dom1, windowName, xtraParams);
} catch (Exception e)
{
System.out.println("Exception : viewGstDataStatus : getData:" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("Returning from getDate :: " + retString);
return retString;
}
public String getData(Document dom, Document dom1, String windowName, String xtraParams) throws RemoteException, ITMException
{
System.out.println("******************* Kaustubh Dabholkar *******************");
System.out.println("----------- Inside viewGstDataStatus -----------");
String prdCode = "",fromDate = "", toDate = "",sql = "",tranType = "", operatingSite = "", dataSyncStatus = "",
noOfRecords= "", xmlRetString = "", errString = "";
int rows = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection() ;
StringBuffer xmlBuff = new StringBuffer("<?xml version = \"1.0\"?>");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
prdCode = genericUtility.getColumnValue("prd_code", dom);
fromDate = genericUtility.getColumnValue("from_date", dom);
toDate = genericUtility.getColumnValue("to_date", dom);
System.out.println("prdCode::"+prdCode+"fromDate::"+fromDate+"toDate::"+toDate);
String one = prdCode.substring(0,4);
String period1=prdCode.substring(4,6)+one;
System.out.println("two::"+period1 );
sql = "select (Select CASE WHEN rec_type=1 THEN 'Sale_Outward_Transactions' " +
"WHEN rec_type=2 THEN 'Purchase_Inward_Transactions' END CASE from dual) Transaction_Type, " +
"site_code Operating_site, " +
"(Select CASE WHEN submit_status='Y' THEN 'Synced Successfully' " +
"WHEN submit_status='P' THEN 'Data Processed Pending To Sync' END CASE from dual) Data_Sync_Status, " +
"count(submit_status ) Number_Of_Records from gst_data_hdr where PRD_CODE= ? " +
"group by rec_type,site_code,submit_status " +
"order by rec_type,site_code " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, period1);
rs = pstmt.executeQuery();
System.out.println(">>>-GetData SQL :: ["+sql+"]");
while(rs.next())
{
tranType = checkNull(rs.getString("Transaction_Type"));
operatingSite = checkNull(rs.getString("Operating_site"));
dataSyncStatus = checkNull(rs.getString("Data_Sync_Status"));
noOfRecords = checkNull(rs.getString("Number_Of_Records"));
xmlBuff.append("<Detail2>");
xmlBuff.append("<tran_type>").append("<![CDATA[" + tranType + "]]>").append("</tran_type>");
xmlBuff.append("<opt_site>").append("<![CDATA[" + operatingSite + "]]>").append("</opt_site>");
xmlBuff.append("<sync_status>").append("<![CDATA[" + dataSyncStatus + "]]>").append("</sync_status>");
xmlBuff.append("<recod_no>").append("<![CDATA[" + noOfRecords + "]]>").append("</recod_no>");
xmlBuff.append("</Detail2>");
xmlBuff.append("\n");
rows ++;
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
xmlBuff.append("</Header0>\r\n");
xmlBuff.append("</group0>\r\n");
xmlBuff.append("</DocumentRoot>\r\n");
xmlRetString=xmlBuff.toString();
System.out.println("number of ROWS ["+rows+"]");
if(rows == 0)
{
errString = itmDBAccessEJB.getErrorString("", "VTNOREC1", "","", conn);
return errString;
}
System.out.println("xmlRetString:["+xmlRetString+"]rows["+rows+"]");
}catch (SQLException se)
{
System.out.println("SQLException :viewGstDataStatus :getData(Document dom, Document dom2, String winName, String xtraParams):" + se.getMessage() + ":");
se.printStackTrace();
throw new ITMException(se);
} catch (Exception e)
{
System.out.println("Exception :viewGstDataStatus :getData(Document dom, Document dom2, String winName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
} finally
{
try
{
if (conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
} catch (Exception e)
{
}
}
return xmlRetString;
}
private String checkNull(String input)
{
if (input == null || "null".equals(input))
{
input = "";
}
return input;
}
}
\ No newline at end of file
package ibase.webitm.ejb.gstclient;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local // added for ejb3
public interface viewGstDataStatusLocal extends ProcessLocal
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.gstclient;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote // added for ejb3
public interface viewGstDataStatusRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
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