Commit 23241126 authored by kmandhre's avatar kmandhre

source added for commission master


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92735 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d19cf56d
This diff is collapsed.
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
//public interface SOrderForm extends ValidatorLocal,EJBObject
@Local // added for ejb3
public interface CommissiondetICLocal
{
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(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
//public interface SOrderForm extends ValidatorLocal,EJBObject
@Remote // added for ejb3
public interface CommissiondetICRemote
{
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(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
//import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@javax.ejb.Stateless
public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosLocal, CommissiondetPosRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
//public String postSave(String domString, String tranId, String objContext, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
String errString = "";
Document dom = null;
PreparedStatement pstmt = null,pstmt1= null,pstmt2= null;
ResultSet rs = null,rs1 = null,rs2 = null;
String sql = "",sql1="",sql2="";
String itemCode = "";
System.out.println(" Tran id = "+tranId);
System.out.println("dom Strig = "+domString);
int noOfParent = 0,i = 0;
boolean found = false,isError = false;
java.sql.Timestamp effDate = null,effDateLast = null;
java.sql.Timestamp validUpto = null, validUptoLast=null;
SimpleDateFormat sdf1 = null;
String effDateStr="",itemSer="",validUptostr="",commTable="",retString="",lineNo="",lineNoLast="";
String customError = "",mainStr = "", begPart = "" ,endPart = "";
int cnt=0;
//ConnDriver connDriver = null;
//Connection conn=null;
System.out.println("Connection = "+conn);
try
{
conn.setAutoCommit(false);
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
dom = genericUtility.parseString(domString);
NodeList detail3List = dom.getElementsByTagName("Detail2");
NodeList detail1List = dom.getElementsByTagName("Detail1");
System.out.println("@@@@@ postSave called");
System.out.println("@@@@@@@@ detail3List [[[[[[[["+detail3List.toString()+"]]]]]]]]]]]]]");
System.out.println("@@@@@@@@ detail1List [[[[[[[["+detail1List.toString()+"]]]]]]]]]]]]]");
if(detail3List != null && detail3List.getLength() > 0)
{
commTable = genericUtility.getColumnValueFromNode("comm_table", dom.getElementsByTagName("Detail2").item(0));
//effDateStr = genericUtility.getColumnValueFromNode("eff_date", dom.getElementsByTagName("Detail2").item(0));
//validUptostr = genericUtility.getColumnValueFromNode("valid_upto", dom.getElementsByTagName("Detail2").item(0));
//lineNo = genericUtility.getColumnValueFromNode("line_no", dom.getElementsByTagName("Detail2").item(0));
//itemCode = genericUtility.getColumnValueFromNode("item_code", dom.getElementsByTagName("Detail2").item(0));
//itemSer = genericUtility.getColumnValueFromNode("item_ser", dom.getElementsByTagName("Detail2").item(0));
noOfParent = detail3List.getLength();
sql2 = " select distinct item_code, item_ser from comm_det where comm_table= ? ";
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1,commTable);
rs2 = pstmt2.executeQuery();
while(rs2.next())
{
itemCode = rs2.getString("item_code");
itemSer= rs2.getString("item_ser");
validUptoLast = null;
lineNoLast = null;
sql = " select line_no,eff_date,valid_upto FROM comm_det where comm_table = ? and item_code=? and item_ser= ? order by eff_date asc " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,commTable);
pstmt.setString(2,itemCode);
pstmt.setString(3,itemSer);
rs = pstmt.executeQuery();
while(rs.next())
{
// int cnt = rs.getInt(1);
lineNo = rs.getString("line_no");
effDate = rs.getTimestamp("eff_date");
validUpto = rs.getTimestamp("valid_upto");
if( validUptoLast != null && ( lineNoLast != null ) )
{
System.out.println("EffDate = "+effDate +" valid up last = "+validUptoLast+" valid Upto="+validUpto);
if(! (validUpto.after(validUptoLast)) )
{
conn.rollback();
customError = "Invalid Effective Date and Valid Upto Date for Line No = "+lineNo+" .";
retString = itmDBAccessEJB.getErrorString("","INVLDT01","","",conn);
begPart = retString.substring( 0, retString.indexOf("<trace>") + 7 );
endPart = retString.substring( retString.indexOf("</trace>"));
mainStr = begPart + customError + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
return errString;
}
if( effDate.before(validUptoLast) || ((int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24))) == 0 )
{
Calendar c = Calendar.getInstance();
c.setTime((effDate));
c.add(Calendar.DATE, -1);
validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new : ["+validUptoLast+"]");
// System.out.println("@@@@@updating:::.["+commTable+"]...["+lineNo+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully.");
sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast);
pstmt1.setString(2,commTable);
pstmt1.setString(3,lineNoLast);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
if ( cnt > 0 )
{
System.out.println("@@@@@@update sucess:::.["+commTable+"]...["+lineNoLast+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully.");
}
}
if(effDate.after(validUptoLast))
{
int diffInDays = (int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24) );
System.out.println("Diff Days="+diffInDays);
if(diffInDays > 1)
{
Calendar c = Calendar.getInstance();
c.setTime((validUptoLast));
c.add(Calendar.DATE, (diffInDays - 1));
validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new 2: ["+validUptoLast+"]");
sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast);
pstmt1.setString(2,commTable);
pstmt1.setString(3,lineNoLast);
cnt = pstmt1.executeUpdate();
pstmt1.close();
pstmt1 = null;
if ( cnt > 0 )
{
System.out.println("@@@@@@update sucess2::record update successfully.");
}
}
}
}
validUptoLast = validUpto;
effDateLast = effDate;//added by kunal on 22/02/13
lineNoLast = lineNo;
System.out.println("@@@@ validUptoLast"+validUptoLast+"::::lineNoLast"+lineNoLast);
} // inside querry
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} // outside querry
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
}
}
catch(Exception e)
{
try
{
isError = true;
if(conn != null)
{
conn.rollback();
}
System.out.println("Exception.. "+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
catch (Exception e1)
{
e1.printStackTrace();
throw new ITMException(e1);
}
}
finally
{
try
{
if(isError)
{
conn.rollback();
System.out.println("Transaction rollback... ");
}
else
{
conn.commit();
System.out.println("@@@@ Transaction commit... ");
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
}
/* This file is Cteated it incorporate the Pre Save logic from Window
* Gulzar 08/09/06
*/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local; // added for ejb3
//public interface SReturnPrs extends ValidatorLocal, EJBObject
@Local // added for ejb3
public interface CommissiondetPosLocal extends ValidatorLocal
{
//public String preSaveRec()throws RemoteException,ITMException;
//public String preSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
public String postSave()throws RemoteException,ITMException;
//public String postSave( String domString,String tranId, String objContext, String editFlag, String xtraParams ) throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
/* This file is Cteated it incorporate the Pre Save logic from Window
* Gulzar 08/09/06
*/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote; // added for ejb3
//public interface SReturnPrs extends ValidatorRemote, EJBObject
@Remote // added for ejb3
public interface CommissiondetPosRemote extends ValidatorRemote
{
//public String preSaveRec()throws RemoteException,ITMException;
//public String preSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
public String postSave()throws RemoteException,ITMException;
//public String postSave( String domString,String tranId, String objContext, String editFlag, String xtraParams ) throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) 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