Commit c3155e29 authored by gahmad's avatar gahmad

Migrated to EJB3 and added changes of EJB2

java-projects-ejb3/ibase/webitm-adm/ibase/webitm/ejb/adm/ShiftProcess.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91209 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 238cd628
......@@ -3,6 +3,12 @@
*/
package ibase.webitm.ejb.adm;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.utility.CommonConstants;
import ibase.system.config.*;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
......@@ -10,14 +16,11 @@ import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.utility.CommonConstants;
import ibase.system.config.*;
public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftProcessRemote //SessionBean
@Stateless
//public class ShiftProcessEJB extends ProcessEJB implements SessionBean //Commented By Gulzar - 15/01/10()
public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftProcessRemote //Added By Gulzar - 15/01/10()
{
/* UPDATED BY NISAR ON 17/12/07 FOR REQUEST ID : AD7SUN0016 */
String sql = null;
......@@ -38,14 +41,19 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
//InvAllocTrace invallocTrace = new InvAllocTrace();
GenericUtility genericUtility = GenericUtility.getInstance();
//GenericUtility genericUtility = new GenericUtility(); //COMMENTED BY ALKA 24/07/07 AS GENERIC UTILITY NOT INITIALIASED PROPERLY.
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//Commented and Changes below by Gulzar- 15/01/10
//ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
ITMDBAccessLocal itmDBAccessLocal = null;
InitialContext ctx = null;
CommonConstants commonConstants = new CommonConstants();
String chgUser = null;
String chgTerm = null;
/*
/*--Commented by Gulzar- 15/01/10 for ejb3
public void ejbCreate() throws RemoteException, CreateException
{
try
......@@ -68,8 +76,9 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
public void ejbPassivate()
{
}*/
}
*/
//End Commented by Gulzar - 15/01/10
public String process() throws RemoteException,ITMException
{
return "";
......@@ -82,6 +91,18 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
Document detailDom = null;
String userId = "";
try
{
if ( itmDBAccessLocal == null )
{
ctx = getInitialContext();
itmDBAccessLocal = (ITMDBAccessLocal)ctx.lookup( "ibase/ITMDBAccessEJB/local" );
}
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
System.out.println("xtraParams :: " + xtraParams);
System.out.println("xmlString2 :: " + xmlString2);
......@@ -111,7 +132,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
catch (Exception e)
{
System.out.println("Exception :ShiftProcessEJB : process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = itmDBAccessEJB.getErrorString("","VTPROUNSUC",userId);
//rtrStr = itmDBAccessEJB.getErrorString("","VTPROUNSUC",userId);//commented by Gulzar for ejb3 - 15/01/10
rtrStr = itmDBAccessLocal.getErrorString("","VTPROUNSUC",userId); //Added by Gulzar for ejb3 - 15/01/10
//throw new ITMException(e);
}
return rtrStr;
......@@ -152,6 +174,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
String resultString = "";
String dayslist1 = "";
String dayslist2 = "";
java.util.Date currDate = null;
java.sql.Date procDate = null;
java.sql.Date startDate = null;
......@@ -190,6 +213,11 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
int shiftIndexTo = 0;//Added by Jaimin on 16/06/2008 (AD89SUN014)
try
{
if ( itmDBAccessLocal == null )
{
ctx = getInitialContext();
itmDBAccessLocal = (ITMDBAccessLocal)ctx.lookup( "ibase/ITMDBAccessEJB/local" );
}
connDriver = new ConnDriver();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
conn = connDriver.getConnectDB("DriverITM");
......@@ -259,6 +287,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
{
siteCodeTo = "ZZ";
}
patternCodeFilt = genericUtility.getColumnValue("pattern_code",headerDom);
fromDate = genericUtility.getColumnValue("date__fr",headerDom);
System.out.println(" From Date [" +fromDate+"]");
......@@ -353,8 +382,13 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pStmt = null;
int noOfEmp = empList.size();
System.out.println("noOfEmp..........::"+noOfEmp);
//while( rsn1.next() )
//Commented and Changes below - Gulzar - 17/09/09 - Date is incremented by using Calendar
//java.sql.Date toSqlDate1 = new java.sql.Date(toSqlDate.getTime()+(24*60*60*1000)); //Gulzar - 06/08/09
java.sql.Date toSqlDate1 = getNextDate( toSqlDate );
//End Changes - Gulzar - 17/09/09
for( int noOfEmpCnt = 0; noOfEmpCnt < noOfEmp; noOfEmpCnt++ )
{
holiTblNo = null;
......@@ -402,6 +436,33 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn1=null;
*/
//end commented by msalam on 170308 as all the information is coming in getdatasql Query
//Added - Gulzar - 05/08/09
/*
if ( transType != null && "W".equalsIgnoreCase(transType.trim()) )
{
java.sql.Date frSqlDateTemp = frSqlDate;
frSqlDate = new java.sql.Date(frSqlDate.getTime()+(24*60*60*1000));
sql = "UPDATE WORK_SHIFT SET TO_DT = ? "+
"WHERE EMP_CODE = '"+emp+"' "+
"AND FROM_DT < ? AND TO_DT > = ? ";
System.out.println("sql :"+sql);
pstmtn2 = conn.prepareStatement(sql);
pstmtn2.setDate(1,frSqlDateTemp);
pstmtn2.setDate(2,frSqlDate);
pstmtn2.setDate(3,frSqlDate);
upd = pstmtn2.executeUpdate();
System.out.println("Update Count ["+upd+"]");
if ( upd > 0 )
{
System.out.println("Update into WORK_SHIFT Successfully ["+upd+"]");
}
pstmtn2.close();
pstmtn2 = null;
}
//End Added - Gulzar - 05/08/09
*/
sql = "DELETE FROM WORK_SHIFT WHERE EMP_CODE = ? "
+"AND FROM_DT BETWEEN ? AND ? "
+"AND TO_DT BETWEEN ? AND ? ";
......@@ -416,9 +477,9 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn2.setDate(4,frSqlDate);
pstmtn2.setDate(5,toSqlDate);
upd = pstmtn2.executeUpdate();
System.out.println("No Of record deleted fromWORK_SHIFT ["+upd+"]");
System.out.println("No Of record deleted from WORK_SHIFT ["+upd+"]");
pstmtn2.close();
pstmtn2=null;
pstmtn2 = null;
//commented by msalam on 170308 as all the information is coming in getdatasql Query
//no need of this as it can be put in outer query
......@@ -472,7 +533,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
" CASE WHEN SHIFT_INDEX__FR IS NULL THEN 0 ELSE SHIFT_INDEX__FR END AS SHIFT_INDEX__FR, "+
" CASE WHEN SHIFT_INDEX__TO IS NULL THEN 0 ELSE SHIFT_INDEX__TO END AS SHIFT_INDEX__TO "+
" FROM EMP_EMPLOY_EVENTS WHERE EMP_CODE = '"+emp+"' "+
"AND EFF_DATE BETWEEN ? AND ? ORDER BY EFF_DATE"; //Sql modify by jaimin on 16/06/2008 (AD89SUN014)
" AND EFF_DATE BETWEEN ? AND ? ORDER BY EFF_DATE"; //Sql modify by jaimin on 16/06/2008 (AD89SUN014)
System.out.print("EMP_EMPLOY_EVENTS[sql] :: " + sql);
System.out.print("Parameters 1:: [" + frSqlDate+"]");
System.out.print("Parameters 2:: [" + toSqlDate+"]");
......@@ -532,7 +593,10 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
lastShiftIndexStr = shiftIndexTo+""; //Added by jaimin on 16/06/2008 (AD89SUN014)
}
}
edShiftDate = new java.sql.Date(edShiftDate.getTime()+(24*60*60*1000));
//Commented and Changes below - Gulzar - 17/09/09 - Date is incremented by using Calendar
//edShiftDate = new java.sql.Date(edShiftDate.getTime()+(24*60*60*1000));
edShiftDate = getNextDate( edShiftDate );
//End Changes Gulzar - 17/09/09
System.out.println("After Adding 1 to edShiftDate ["+edShiftDate+"]");
}
}
......@@ -571,7 +635,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn4=null;
System.out.println("At 420 Pattern Code -lastPatternCodeStr -::"+lastPatternCodeStr);
}
toSqlDate = new java.sql.Date(toSqlDate.getTime()+(24*60*60*1000));
//toSqlDate = new java.sql.Date(toSqlDate.getTime()+(24*60*60*1000)); //Gulzar - 19/06/09
if(lastPatternCodeStr == null || lastPatternCodeStr.trim().length() == 0)
{
lastPatternCodeStr = patternCode;
......@@ -586,7 +650,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
//End Addition - Jaimin - 16/06/2008 - (AD89SUN014)
//errString = insertUpdateWorkShift(empInfo, emp, stShiftDate, toSqlDate, lastPatternCodeStr, lastPatternCodeStr,holiTblNo ,conn);//Commented by jaimin on 16/06/2008 (AD89SUN014)
errString = insertUpdateWorkShift(empInfo, emp, stShiftDate, toSqlDate, lastPatternCodeStr, lastPatternCodeStr,holiTblNo ,Integer.parseInt(lastShiftIndexStr),conn);//Added by jaimin on 16/06/2008 (AD89SUN014)
errString = insertUpdateWorkShift(empInfo, emp, stShiftDate, toSqlDate1, lastPatternCodeStr, lastPatternCodeStr,holiTblNo ,Integer.parseInt(lastShiftIndexStr),conn);//Added by jaimin on 16/06/2008 (AD89SUN014)
if(errString.length() > 0)
{
......@@ -612,7 +676,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
if (cnt == 0)
{
System.out.println("Record not found for process ........");
errString = itmDBAccessEJB.getErrorString("","VTRDNTFD","","",conn);
//errString = itmDBAccessEJB.getErrorString("","VTRDNTFD","","",conn);//commented by Gulzar for ejb3 - 15/01/10
errString = itmDBAccessLocal.getErrorString("","VTRDNTFD","","",conn);//Added by Gulzar for ejb3 - 15/01/10
return errString;
}
else
......@@ -652,11 +717,6 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
{
try
{
if(conn != null)
{
conn.close();
conn = null;
if(pstmtn1!=null)
{
pstmtn1.close();
......@@ -667,6 +727,10 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn3.close();
pstmtn3=null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
......@@ -706,10 +770,17 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
java.util.Date joiningDate = null;
try{
if ( itmDBAccessLocal == null )
{
ctx = getInitialContext();
itmDBAccessLocal = (ITMDBAccessLocal)ctx.lookup( "ibase/ITMDBAccessEJB/local" );
}
stmt = conn.createStatement();
if(frpatternCode == null)
{
errString = itmDBAccessEJB.getErrorString("","VTPATTERNU","");
//errString = itmDBAccessEJB.getErrorString("","VTPATTERNU","");//commented by Gulzar for ejb3 - 15/01/10
errString = itmDBAccessLocal.getErrorString("","VTPATTERNU","");//Added by Gulzar for ejb3 - 15/01/10
return errString ;
}
sql = "SELECT SHIFT_PATTERN,START_DATE,NO_OF_DAYS FROM SHIFT_PATTERN WHERE PATTERN_CODE = '"+frpatternCode+"'";
......@@ -737,7 +808,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
java.sql.Date shiftStDate2 = shiftStDate;
System.out.println("shiftStDate2 : " + shiftStDate2 + " shiftEndDate : " + shiftEndDate);
while( shiftStDate2.compareTo( shiftEndDate ) < 0)
while( shiftStDate2.compareTo( shiftEndDate ) < 0 )
{
shiftOfDate = null;
//Updated by nisar on 21/02/06
......@@ -746,11 +817,12 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
//added by msalam on 25/02/08 for inserting record of Holiday type W
String holidayType = null;
//getHolidayTypeForDate( java.util.Date shiftDate, String holiTblNo, Connection conn)
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
//added by msalam on 25/02/08 for inserting record of Holiday type W
//next line commented and modified line added by msalam on 25/02/08
//while(isHolidayForType(shiftStDate2, 'H', holiTblNo,conn))
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
while( isHolidayForType(shiftStDate2, holidayType, holiTblNo,conn) && shiftStDate2.compareTo( toPrdDate ) <= 0 )
{
//added by nisar on 17/12/07 for requestId : AD7SUN0016
......@@ -764,6 +836,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
System.out.println("shiftStDate2 :: " + shiftStDate2);
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
}
*/
//End Changes by Gulzar - 24/11/09 (AD89SUN117)
if( ! (shiftStDate2.compareTo(shiftEndDate) < 0 ))
{
......@@ -873,8 +947,9 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
stDate = new java.sql.Date( stDate.getTime() + ( 24 * 60 * 60 * 1000 ));
}
*/
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
java.sql.Date previousDate = stDate;
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
while( isHolidayForType( stDate, holidayType, holiTblNo,conn ) && stDate.compareTo( toPrdDate ) <= 0 )
{
System.out.println( "From 839" );
......@@ -884,6 +959,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
System.out.println("stDate :: " + stDate);
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
}
*/
//End Changes - Gulzar - 24/11/09
//end by msalam on 250208
shiftOfDate = stDate;
......@@ -952,9 +1029,10 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
shiftOfDate = new java.sql.Date(shiftOfDate.getTime()+(24*60*60*1000));
}
*/
holidayType = getHolidayTypeForDate( (java.util.Date)shiftOfDate, holiTblNo, conn );
java.util.Date tempShiftOfDate = shiftOfDate;
java.util.Date previousDate = tempShiftOfDate;
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( (java.util.Date)shiftOfDate, holiTblNo, conn );
while( isHolidayForType( tempShiftOfDate, holidayType, holiTblNo,conn ) )
{
System.out.println( "From 917" );
......@@ -966,6 +1044,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
System.out.println( "In isHolidayForType at 912 tempShiftOfDate :: " + tempShiftOfDate );
holidayType = getHolidayTypeForDate( tempShiftOfDate, holiTblNo, conn );
}
*/
//End Changes by Gulzar - 24/11/09 (AD89SUN117)
//end by msalam on 250208
//shiftOfDate = shiftOfDate1;
......@@ -982,7 +1062,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn6.setDate(1, shiftStDate);
//pstmtn6.setDate(2, shiftStDate2);//ADDED EXTRA PARAMETER LINE BY DURGA 02/04/07
System.out.println("Sql At 939 :: " + sql);
System.out.println("Sql At 1018 :: " + sql);
System.out.println("PARAMETER IN UPDATE QUERY FROM_DT "+shiftStDate+"\n");
System.out.println("PARAMETER IN UPDATE QUERY SHIFT "+shift+"\n");
System.out.println("PARAMETER IN UPDATE QUERY EMP_CODE "+empCode+"\n");
......@@ -1053,7 +1133,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
if(stDate != null && stDate.compareTo(shiftStDate) > 0)
{
System.out.println("Pattern is not Valid for the Processing Month........");
errString = itmDBAccessEJB.getErrorString("","VTINVPATRN","","",conn);
//errString = itmDBAccessEJB.getErrorString("","VTINVPATRN","","",conn);//commented by Gulzar for ejb3 - 15/01/10
errString = itmDBAccessLocal.getErrorString("","VTINVPATRN","","",conn);//Added by Gulzar for ejb3 - 15/01/10
conn.rollback();
return errString;
}
......@@ -1112,6 +1193,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
//start - Overload - function added by jaimin on 16/06/2008 (AD89SUN014)
private String insertUpdateWorkShift(EmpInfo empInfo, String empCode, java.sql.Date shiftStDate, java.sql.Date shiftEndDate, String frpatternCode, String topatterenCode, String holiTblNo,int shiftIndexNew, Connection conn) throws Exception
{
System.out.println("insertUpdateWorkShift is called...............");
String insertSql ="",updateSql = "",errString = "";
PreparedStatement pstmtn5 = null,pstmtn6=null,pstmtInsert = null,pstmtUpdate = null;
PreparedStatement pstmtEmp = null;
......@@ -1128,10 +1210,16 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
java.util.Date joiningDate = null;
try{
if ( itmDBAccessLocal == null )
{
ctx = getInitialContext();
itmDBAccessLocal = (ITMDBAccessLocal)ctx.lookup( "ibase/ITMDBAccessEJB/local" );
}
stmt = conn.createStatement();
if(frpatternCode == null)
{
errString = itmDBAccessEJB.getErrorString("","VTPATTERNU","");
//errString = itmDBAccessEJB.getErrorString("","VTPATTERNU","");//commented by Gulzar for ejb3 - 15/01/10
errString = itmDBAccessLocal.getErrorString("","VTPATTERNU","");//Added by Gulzar for ejb3 - 15/01/10
return errString ;
}
sql = "SELECT SHIFT_PATTERN,START_DATE,NO_OF_DAYS FROM SHIFT_PATTERN WHERE PATTERN_CODE = '"+frpatternCode+"'";
......@@ -1159,7 +1247,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
java.sql.Date shiftStDate2 = shiftStDate;
System.out.println("shiftStDate2 : " + shiftStDate2 + " shiftEndDate : " + shiftEndDate);
while( shiftStDate2.compareTo( shiftEndDate ) < 0)
while( shiftStDate2.compareTo( shiftEndDate ) < 0 )
{
shiftOfDate = null;
//Updated by nisar on 21/02/06
......@@ -1168,11 +1256,12 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
//added by msalam on 25/02/08 for inserting record of Holiday type W
String holidayType = null;
//getHolidayTypeForDate( java.util.Date shiftDate, String holiTblNo, Connection conn)
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
//added by msalam on 25/02/08 for inserting record of Holiday type W
//next line commented and modified line added by msalam on 25/02/08
//while(isHolidayForType(shiftStDate2, 'H', holiTblNo,conn))
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
while( isHolidayForType(shiftStDate2, holidayType, holiTblNo,conn) && shiftStDate2.compareTo( toPrdDate ) <= 0 )
{
//added by nisar on 17/12/07 for requestId : AD7SUN0016
......@@ -1182,10 +1271,15 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
insertIntoWorkShiftForHoliday( empCode, shiftStDate, shiftStDate2, holidayType, frpatternCode, conn );
//code ended by nisar on 17/12/07 for requestId : AD7SUN0016
shiftStDate = shiftStDate2;
shiftStDate2 = new java.sql.Date(shiftStDate2.getTime()+(24*60*60*1000));
//Commented and Changes below - Gulzar - 17/09/09 - Date is incremented by using Calendar
//shiftStDate2 = new java.sql.Date(shiftStDate2.getTime()+(24*60*60*1000));
shiftStDate2 = getNextDate( shiftStDate2 );
//End Changes - Gulzar - 17/09/09
System.out.println("shiftStDate2 :: " + shiftStDate2);
holidayType = getHolidayTypeForDate( shiftStDate2, holiTblNo, conn );
}
*/
//End changes - Gulzar - 24/11/09
if( ! (shiftStDate2.compareTo(shiftEndDate) < 0 ))
{
......@@ -1274,7 +1368,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
shift = getActualshift(shiftStDate2,frpatternCode,shiftPattern,stDate,noOfDays);
System.out.println("At 612 Shift:: " + shift);
}
else if(!shiftDateNewString.equalsIgnoreCase("NULLFOUND")&& shiftDateNewString.trim().length()!=0)
else if(!shiftDateNewString.equalsIgnoreCase("NULLFOUND") && shiftDateNewString.trim().length()!=0)
{
System.out.println("At 615 ");
if( shiftOfDate == null )
......@@ -1296,17 +1390,23 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
stDate = new java.sql.Date( stDate.getTime() + ( 24 * 60 * 60 * 1000 ));
}
*/
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
java.sql.Date previousDate = stDate;
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
while( isHolidayForType( stDate, holidayType, holiTblNo,conn ) && stDate.compareTo( toPrdDate ) <= 0 )
{
System.out.println( "From 839" );
insertIntoWorkShiftForHoliday( empCode, previousDate, stDate, holidayType, frpatternCode, conn );
previousDate = stDate;
stDate = new java.sql.Date( stDate.getTime() + ( 24*60*60*1000 ) );
//Commented and Changes below - Gulzar - 17/09/09 - Date is incremented by using Calendar
//stDate = new java.sql.Date( stDate.getTime() + ( 24*60*60*1000 ) );
stDate = getNextDate( stDate );
//End changes Gulzar - 17/09/09
System.out.println("stDate :: " + stDate);
holidayType = getHolidayTypeForDate( stDate, holiTblNo, conn );
}
*/
//End Changes by Gulzar - 24/11/09 (AD89SUN117)
//end by msalam on 250208
shiftOfDate = stDate;
......@@ -1375,20 +1475,28 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
shiftOfDate = new java.sql.Date(shiftOfDate.getTime()+(24*60*60*1000));
}
*/
holidayType = getHolidayTypeForDate( (java.util.Date)shiftOfDate, holiTblNo, conn );
java.util.Date tempShiftOfDate = shiftOfDate;
java.util.Date previousDate = tempShiftOfDate;
/*-- Commented by Gulzar to ignore holiday and considered as normal day - 24/11/09 (AD89SUN117)
holidayType = getHolidayTypeForDate( (java.util.Date)shiftOfDate, holiTblNo, conn );
while( isHolidayForType( tempShiftOfDate, holidayType, holiTblNo,conn ) )
{
System.out.println( "From 917" );
insertIntoWorkShiftForHoliday( empCode, ( new java.sql.Date( previousDate.getTime() ) ),
( new java.sql.Date( tempShiftOfDate.getTime() ) ), holidayType, frpatternCode, conn );
stDate = new java.sql.Date(shiftOfDate.getTime()+(24*60*60*1000));
//Commented and Changes below - Gulzar - 17/09/09 - Date is incremented by using Calendar
//stDate = new java.sql.Date(shiftOfDate.getTime()+(24*60*60*1000));
stDate = getNextDate( new java.sql.Date( shiftOfDate.getTime() ) );
previousDate = tempShiftOfDate;
tempShiftOfDate = new java.sql.Date(tempShiftOfDate.getTime()+(24*60*60*1000));
//tempShiftOfDate = new java.sql.Date(tempShiftOfDate.getTime()+(24*60*60*1000));
java.sql.Date sDate1 = getNextDate( new java.sql.Date( tempShiftOfDate.getTime() ) );
tempShiftOfDate = new java.util.Date( sDate1.getTime() );
//End Changes - Gulzar - 17/09/09
System.out.println( "In isHolidayForType at 912 tempShiftOfDate :: " + tempShiftOfDate );
holidayType = getHolidayTypeForDate( tempShiftOfDate, holiTblNo, conn );
}
*/
//End Changes by Gulzar - 24/11/09 (AD89SUN117)
//end by msalam on 250208
//shiftOfDate = shiftOfDate1;
......@@ -1405,7 +1513,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtn6.setDate(1, shiftStDate);
//pstmtn6.setDate(2, shiftStDate2);//ADDED EXTRA PARAMETER LINE BY DURGA 02/04/07
System.out.println("Sql At 939 :: " + sql);
System.out.println("Sql At 1444 :: " + sql);
System.out.println("PARAMETER IN UPDATE QUERY FROM_DT "+shiftStDate+"\n");
System.out.println("PARAMETER IN UPDATE QUERY SHIFT "+shift+"\n");
System.out.println("PARAMETER IN UPDATE QUERY EMP_CODE "+empCode+"\n");
......@@ -1467,8 +1575,15 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtUpdate=null;
}
shiftStDate2 = new java.sql.Date(shiftStDate2.getTime()+(24*60*60*1000));
System.gc();
//Commented and Changes below - Gulzar - 17/09/09
//shiftStDate2 = new java.sql.Date(shiftStDate2.getTime()+(24*60*60*1000)); //Gulzar - 17/09/09
{
System.out.println("Before Incrementing shiftStDate2 by one day.........::"+shiftStDate2);
shiftStDate2 = getNextDate( shiftStDate2 ); //Gulzar - 17/09/09
System.out.println("After incremented shiftStDate2 by one day....::"+shiftStDate2);
}
//System.gc();
//End Changes Gulzar - 17/09/09
}//end of while
//pstmtn5.close();
......@@ -1476,7 +1591,8 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
if(stDate != null && stDate.compareTo(shiftStDate) > 0)
{
System.out.println("Pattern is not Valid for the Processing Month........");
errString = itmDBAccessEJB.getErrorString("","VTINVPATRN","","",conn);
//errString = itmDBAccessEJB.getErrorString("","VTINVPATRN","","",conn);//commented by Gulzar for ejb3 - 15/01/10
errString = itmDBAccessLocal.getErrorString("","VTINVPATRN","","",conn);//Added by Gulzar for ejb3 - 15/01/10
conn.rollback();
return errString;
}
......@@ -1769,7 +1885,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
PreparedStatement stmt = null;
ResultSet rs = null; int cnt = 0;
System.out.println("Shift date isHoliday :: " + shiftDate);
System.out.println("Hol Tupe in isHoliday :: " + holidayType);
System.out.println("Hol Type in isHoliday :: " + holidayType);
try{
sqlStr = "select count(*) from holiday where Hol_Date = ? and Hol_Type = '" + holidayType + "' and HOL_TBLNO ='"+holiTblNo+"'";
stmt = conn.prepareStatement(sqlStr);
......@@ -1896,6 +2012,15 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtUpdate.close();
pstmtUpdate=null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if(pstmtInsert!=null)
{
pstmtInsert.close();
......@@ -1907,9 +2032,9 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
pstmtUpdate=null;
}
}
catch(Exception e)
catch (Exception e1)
{
e.printStackTrace();
}
}
}//end of insertIntoWorkShiftForHoliday()//added by nisar on 17/12/07
//ADDED BY MSALAM ON 250208 TO GET HOLIDAY DAY TYPE
......@@ -1920,7 +2045,7 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
PreparedStatement stmt = null;
ResultSet rs = null;
String holType = null;
System.out.println("Holiday tyoe for date :: " + shiftDate);
System.out.println("Holiday type for date :: " + shiftDate);
try{
//sqlStr = "select Hol_Type from holiday where Hol_Date = ? and HOL_TBLNO ='" + holiTblNo + "'";//Commentd by jaimin on 17/06/2008 (AD89SUN016)
sqlStr = "select Hol_Type from holiday where Hol_Date = ? and HOL_TBLNO ='" + holiTblNo + "' and HOL_TYPE <> 'W' "; //Added by jaimin on 17/06/2008 (AD89SUN016)
......@@ -1978,4 +2103,47 @@ public class ShiftProcess extends ProcessEJB implements ShiftProcessLocal,ShiftP
public java.util.Date dateJoin = null;
}
//end bean class added by msalam on 170308
//Function added - Gulzar - 17/09/09
private java.sql.Date getNextDate( java.sql.Date currShiftDate )
{
java.util.Date uDate1 = null;
java.sql.Date nextShiftDate = null;
try
{
Calendar calObject = Calendar.getInstance();
calObject.setTime( currShiftDate );
calObject.add( calObject.DATE, 1 );
uDate1 = calObject.getTime();
nextShiftDate = new java.sql.Date( uDate1.getTime() );
calObject = null;
}
catch( Exception e )
{
e.printStackTrace();
}
return nextShiftDate;
}
//End Added - Gulzar - 17/09/09
//Added - Gulzar - 15/01/10
protected InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("ITMException :[SprsItemReorg] :getInitialContext :==>");
throw itme;
}
catch(Exception e)
{
System.out.println("Exception :[SprsItemReorg] :getInitialContext :==>");
throw new ITMException(e);
}
return ctx;
}
//End Added - Gulzar - 15/01/10
}
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