Commit 3702642c authored by sghate's avatar sghate

shital : Done changes on WorkLocationMaster.java

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206839 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9ae24189
......@@ -5,13 +5,18 @@
Date : 03-SEP-2014
Developer : CHETNA SHAHU
Purpose : Define the work loactions for employee
********************************************************/
********************************************************/
package ibase.webitm.ejb.adm;
import ibase.system.config.ConnDriver;
//modified by Shital on 09/08/2019 [Start]
//import ibase.system.config.ConnDriver;
//modified by Shital on 09/08/2019 [End]
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
//modified by Shital on 09/08/2019 [Start]
//import ibase.webitm.utility.GenericUtility;
//modified by Shital on 09/08/2019 [End]
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
......@@ -21,20 +26,25 @@ import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.ejb.Stateless;
//modified by Shital on 09/08/2019 [Start]
//import javax.ejb.Stateless;
//modified by Shital on 09/08/2019 [End]
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
//modified by Shital on 09/08/2019 [Start]
//@Stateless
//modified by Shital on 09/08/2019 [End]
public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMasterLocal,WorkLocationMasterRemote {
GenericUtility genericUtility = GenericUtility.getInstance();
public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMasterLocal,WorkLocationMasterRemote
{
//modified by Shital on 09/08/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
//modified by Shital on 09/08/2019 [End]
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
......@@ -43,7 +53,6 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
Document dom2 = null;
try
{
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString);
......@@ -63,13 +72,16 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
catch(Exception e)
{
//modified by Shital on 09/08/2019 [Start]
e.printStackTrace();
//modified by Shital on 09/08/2019 [End]
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document curDom, Document hdrDom, Document allDom, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String userId = "";
String userId = "";
String errorType = "";
String childNodeName = null;
String errCode = "";
......@@ -78,42 +90,45 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
String stateCode = "";
String active = "";
String errString = "";
int currentFormNo = 0;
int childNodeListLength;
int ctr=0;
int ctr = 0;
int count = 0;
boolean flag = false;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
//modified by Shital on 09/08/2019 [Start]
//ConnDriver connDriver = new ConnDriver();
//modified by Shital on 09/08/2019 [End]
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = connDriver.getConnectDB("DriverITM");
//modified by Shital on 09/08/2019 [Start]
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//modified by Shital on 09/08/2019 [End]
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("Current Form No. :- "+currentFormNo);
switch(currentFormNo)
{
case 1 :
......@@ -121,11 +136,12 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("work_loc_code") && editFlag.equalsIgnoreCase("A") )
{
wrkLocCode = checkNull(genericUtility.getColumnValue("work_loc_code", curDom));
......@@ -139,10 +155,23 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
{
keyFlag = rs.getString("KEY_FLAG");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//modified by Shital on 09/08/2019 [Start]
//rs.close();
//rs = null;
//pstmt.close();
//pstmt = null;
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//modified by Shital on 09/08/2019 [End]
if (keyFlag == null || keyFlag.trim().length() == 0 || keyFlag.equalsIgnoreCase("M"))
{
errCode = "VMWRKLOC01";
......@@ -161,10 +190,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
}
} //work_loc_code end
else if(childNodeName.equalsIgnoreCase("descr")) // Work Location for Description
{
descr = checkNull(genericUtility.getColumnValue("descr", curDom));
descr = checkNull(genericUtility.getColumnValue("descr", curDom));
if(descr == null || descr.trim().length() == 0)
{
errCode = "VMWRKLOC03";
......@@ -172,10 +201,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
errFields.add(childNodeName.toLowerCase());
}
} // End of descr
else if(childNodeName.equalsIgnoreCase("city")) // Validation for state_code
{
String city = checkNull(genericUtility.getColumnValue("city", curDom));
if(city == null || city.trim().length() == 0)
{
errCode = "VMWRKLOC05";
......@@ -193,10 +222,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
}
} // End of city
else if(childNodeName.equalsIgnoreCase("state_code")) // Validation for state_code
{
stateCode = checkNull(genericUtility.getColumnValue("state_code", curDom));
if(stateCode == null || stateCode.trim().length() == 0)
{
errCode = "VESTATCD1";
......@@ -214,10 +243,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
}
} // End of state_code
else if(childNodeName.equalsIgnoreCase("active")) // Validation for active
{
active = checkNull(genericUtility.getColumnValue("active", curDom));
if(active == null || active.trim().length() == 0)
{
errCode = "VMWRKLOC04";
......@@ -226,9 +255,9 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
} // End of active
}
break;
break;
}
int errListSize = errList.size();
count = 0;
String errFldName = null;
......@@ -240,19 +269,21 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println("errCode .........." + errCode);
// errString = getErrorString(errFldName, errCode, userId);
//Commented and added by Varsha V on 20-Jul-18 for calling connection method
// errString = getErrorString(errFldName, errCode, userId);
//modified by Shital on 09/08/2019 [Start]
//errString = itmDBAccessEJB.getErrorString(errFldName, errCode, userId);
errString = itmDBAccessEJB.getErrorString(errFldName,errCode,userId,"",conn);
errString = itmDBAccessEJB.getErrorString(errFldName, errCode, userId, "", conn);
//modified by Shital on 09/08/2019 [End]
System.out.println("errString........"+errString);
//Commented and added by Varsha V on 20-Jul-18 for calling connection method
//modified by Shital on 09/08/2019 [Start]
//errString = itmDBAccessEJB.getErrorString("", errCode, userId);
errString = itmDBAccessEJB.getErrorString("",errCode,userId,"",conn);
errString = itmDBAccessEJB.getErrorString("", errCode, userId, "", conn);
//modified by Shital on 09/08/2019 [End]
System.out.println("errString........"+errString);
errorType = errorType(conn , errCode);
return errString;
}
errList.clear();
errList = null;
......@@ -275,7 +306,8 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
{
try
{
if(conn != null)
//modified by Shital on 09/08/2019 [Start]
/*if(conn != null)
{
if(rs != null)
{
......@@ -289,7 +321,24 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
conn.close();
}
conn = null;
conn = null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
//modified by Shital on 09/08/2019 [End]
}
catch(Exception d)
{
......@@ -306,9 +355,9 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
if(xmlString != null && xmlString.trim().length() > 0)
......@@ -331,6 +380,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
catch(Exception e)
{
System.out.println("Exception : [DistributionRoute][itemChanged( String, String )] :==>\n" + e.getMessage());
//modified by Shital on 09/08/2019 [Start]
e.printStackTrace();
throw new ITMException(e);
//modified by Shital on 09/08/2019 [End]
}
return valueXmlString;
}
......@@ -344,9 +397,9 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
String stateCodeDescr = "";
String stateCode = "";
String userId = "";
String tranDate="";
String tranDate = "";
String termId = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
int currentFormNo = 0;
......@@ -358,25 +411,36 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
ConnDriver connDriver = new ConnDriver();
AdmCommon admCommon = new AdmCommon();
//modified by Shital on 09/08/2019 [Start]
//ConnDriver connDriver = new ConnDriver();
//modified by Shital on 09/08/2019 [End]
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital on 09/08/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital on 09/08/2019 [End]
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termId = getValueFromXTRA_PARAMS(xtraParams,"termId");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
conn = connDriver.getConnectDB("DriverITM");
//modified by Shital on 09/08/2019 [Start]
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
conn.setAutoCommit(false);
connDriver=null;
if(objContext != null && objContext.trim().length()>0)
//connDriver=null;
//modified by Shital on 09/08/2019 [End]
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>");
switch(currentFormNo)
{
case 1 :
......@@ -390,18 +454,27 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
}
while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
System.out.println("currentColumn = "+currentColumn);
if(currentColumn.trim().equalsIgnoreCase("itm_default") )
{
tranDate = simpleDateFormat.format(timestamp).toString();
System.out.println("Tran Date 111: "+tranDate.toString());
valueXmlString.append("<active>").append("<![CDATA[Y]]>").append("</active>");
valueXmlString.append("<chg_user>").append("<![CDATA["+userId+"]]>").append("</chg_user>");
valueXmlString.append("<chg_date>").append("<![CDATA[" + tranDate.trim() +"]]>").append("</chg_date>\r\n");
valueXmlString.append("<chg_term>").append("<![CDATA[" + termId +"]]>").append("</chg_term>\r\n");
tranDate = simpleDateFormat.format(timestamp).toString();
System.out.println("Tran Date 111: "+tranDate.toString());
valueXmlString.append("<active>").append("<![CDATA[Y]]>").append("</active>");
valueXmlString.append("<chg_user>").append("<![CDATA["+userId+"]]>").append("</chg_user>");
valueXmlString.append("<chg_date>").append("<![CDATA[" + tranDate.trim() +"]]>").append("</chg_date>\r\n");
valueXmlString.append("<chg_term>").append("<![CDATA[" + termId +"]]>").append("</chg_term>\r\n");
//modified by Shital on 09/08/2019 [Start]
admCommon.setNodeValue(dom, "active", "Y");
admCommon.setNodeValue(dom, "chg_user", userId);
admCommon.setNodeValue(dom, "chg_date", tranDate);
admCommon.setNodeValue(dom, "chg_term", termId);
//modified by Shital on 09/08/2019 [End]
}
else if(currentColumn.trim().equalsIgnoreCase("city")) //Item change for city
{
city = checkNull(genericUtility.getColumnValue("city", dom));
......@@ -416,26 +489,52 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
stateCode = rs.getString(1);
stateCodeDescr = rs.getString(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//modified by Shital on 09/08/2019 [Start]
//rs.close();
//rs = null;
//pstmt.close();
//pstmt = null;
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//modified by Shital on 09/08/2019 [End]
valueXmlString.append("<city>").append("<![CDATA[" + city +"]]>").append("</city>\r\n");
valueXmlString.append("<state_code>").append("<![CDATA[" + stateCode +"]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[" + stateCodeDescr +"]]>").append("</state_descr>\r\n");
//modified by Shital on 09/08/2019 [Start]
admCommon.setNodeValue(dom, "city", city);
admCommon.setNodeValue(dom, "state_code", stateCode);
admCommon.setNodeValue(dom, "state_descr", stateCodeDescr);
//modified by Shital on 09/08/2019 [End]
valueXmlString.append("<city>").append("<![CDATA[" + city +"]]>").append("</city>\r\n");
valueXmlString.append("<state_code>").append("<![CDATA[" + stateCode +"]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[" + stateCodeDescr +"]]>").append("</state_descr>\r\n");
}
else
{
valueXmlString.append("<city>").append("<![CDATA[]]>").append("</city>\r\n");
valueXmlString.append("<state_code>").append("<![CDATA[]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[]]>").append("</state_descr>\r\n");
valueXmlString.append("<city>").append("<![CDATA[]]>").append("</city>\r\n");
valueXmlString.append("<state_code>").append("<![CDATA[]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[]]>").append("</state_descr>\r\n");
//modified by Shital on 09/08/2019 [Start]
admCommon.setNodeValue(dom, "city", "");
admCommon.setNodeValue(dom, "state_code", "");
admCommon.setNodeValue(dom, "state_descr", "");
//modified by Shital on 09/08/2019 [End]
}//end of city
}
else if(currentColumn.trim().equalsIgnoreCase("state_code")) //Item change for state_code
{
stateCode = checkNull(genericUtility.getColumnValue("state_code", dom));
stateCode = checkNull(genericUtility.getColumnValue("state_code", dom));
if(stateCode != null && stateCode.trim().length() > 0)
{
sql = "SELECT STATE.DESCR AS STATE_DESCR FROM STATE WHERE STATE.STATE_CODE = ? ";
......@@ -446,31 +545,48 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
{
stateCodeDescr = rs.getString("STATE_DESCR");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//modified by Shital on 09/08/2019 [Start]
//rs.close();
//rs = null;
//pstmt.close();
//pstmt = null;
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//modified by Shital on 09/08/2019 [End]
valueXmlString.append("<state_code>").append("<![CDATA[" + stateCode +"]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[" + stateCodeDescr +"]]>").append("</state_descr>\r\n");
//modified by Shital on 09/08/2019 [Start]
admCommon.setNodeValue(dom, "state_code", stateCode);
admCommon.setNodeValue(dom, "state_descr", stateCodeDescr);
//modified by Shital on 09/08/2019 [End]
valueXmlString.append("<state_code>").append("<![CDATA[" + stateCode +"]]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[" + stateCodeDescr +"]]>").append("</state_descr>\r\n");
}
else
{
valueXmlString.append("<state_code>").append("<![CDATA[ ]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[ ]>").append("</state_descr>\r\n");
valueXmlString.append("<state_code>").append("<![CDATA[ ]>").append("</state_code>\r\n");
valueXmlString.append("<state_descr>").append("<![CDATA[ ]>").append("</state_descr>\r\n");
//modified by Shital on 09/08/2019 [Start]
admCommon.setNodeValue(dom, "state_code", " ");
admCommon.setNodeValue(dom, "state_descr", " ");
//modified by Shital on 09/08/2019 [End]
}//end of state_code
}
valueXmlString.append("</Detail1>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
......@@ -480,10 +596,10 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
}
finally
{
try
{
if(conn != null)
//modified by Shital on 09/08/2019 [Start]
/*if(conn != null)
{
if(rs != null)
{
......@@ -494,15 +610,34 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
conn = null;*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
//modified by Shital on 09/08/2019 [End]
}
catch(Exception d)
{
d.printStackTrace();
//modified by Shital on 09/08/2019 [Start]
throw new ITMException(d);
//modified by Shital on 09/08/2019 [End]
}
}
return valueXmlString.toString();
......@@ -516,7 +651,7 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
return input;
}
private String errorType(Connection conn , String errorCode)
private String errorType(Connection conn , String errorCode) throws ITMException
{
String msgType = "E";
PreparedStatement pstmt = null ;
......@@ -535,6 +670,9 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
catch(Exception ex)
{
ex.printStackTrace();
//modified by Shital on 09/08/2019 [Start]
throw new ITMException(ex);
//modified by Shital on 09/08/2019 [End]
}
finally
{
......@@ -554,48 +692,46 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
catch(Exception e)
{
e.printStackTrace();
//modified by Shital on 09/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 09/08/2019 [End]
}
}
return msgType;
}
public boolean isRecordExist(Connection conn , String tableName, String condition)
public boolean isRecordExist(Connection conn , String tableName, String condition)throws ITMException
{
PreparedStatement pstmt = null ;
ResultSet rs = null;
String sql="";
boolean isExist=false;
int recCount=0;
String sql = "";
boolean isExist = false;
int recCount = 0;
try
{
sql = " SELECT COUNT(*) FROM "+tableName +" "+condition;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
recCount=rs.getInt(1);
}
if(recCount>0)
if(recCount > 0)
{
isExist=true;
}
else
{
isExist=false;
}
}
catch(Exception ex)
{
ex.printStackTrace();
//modified by Shital on 09/08/2019 [Start]
throw new ITMException(ex);
//modified by Shital on 09/08/2019 [End]
}
finally
{
......@@ -615,12 +751,13 @@ public class WorkLocationMaster extends ValidatorEJB implements WorkLocationMas
catch(Exception e)
{
e.printStackTrace();
//modified by Shital on 09/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 09/08/2019 [End]
}
}
System.out.print("---------Final--isExist-------"+isExist);
return isExist;
}
}
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