Commit a53adbea authored by pshinde's avatar pshinde

Source code for Itemchanged and validation and post save for Period Table Generation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99977 ce508802-f39f-4f6c-b175-0d175dae99d5
parent af3fc9c2
/********************************************************
Title : BankGauranteeIC [F15DSUN018]
Date : 22/JUL/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.sys.UtilMethods;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.Stateless;
import org.apache.xerces.dom.AttributeMap;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sybase.ejb.cts.TimestampSeqHelper;
@Stateless
public class PrdTableGenIC extends ValidatorEJB implements PrdTableGenICLocal, PrdTableGenICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = null;
ValidatorEJB valEjb = null;
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("Val xmlStrling :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val xmlString2 :: " + xmlString2);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String childNodeName = null;
String errString = "";
String errCode = "";
String userId = "";
String sql = "";
String errorType = "";
String lineNo = "";
String loginEmpCode = "";
String siteCode="",priceListHdr="",priceListGrp="";
int cnt = 0;
int ctr = 0;
int childNodeListLength=0;
int parentNodeListLength = 0;
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();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
int currentFormNo = 0;
int count = 0;
double quantityDbl = 0, rateDbl = 0;
Boolean isNumber = true;
Boolean isOrdType = false;
NodeList parentList = null;
NodeList childList = null;
boolean getValue=false;
boolean getPeriodValue=false;
String prdCode="",cntCode="",frDate="",toDate="",addDate="",chgDate="";
String prdTblNo="",prdClose="";
Timestamp fromDate=null,tooDate=null;
String divisionList="",frmDateList="";
ArrayList divisionLst = new ArrayList();
String retString="",begPart="",endPart="",mainStr="";
try
{
System.out.println("@@@@@@@@ wfvaldata called");
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
// DistCommon distCommon = new DistCommon();
valEjb =new ValidatorEJB();
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch (currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
ArrayList filter = new ArrayList();
filter.add(0, "prd_code");
filter.add(1, "count_code");
filter.add(2, "fr_date");
filter.add(3, "to_date");
filter.add(4, "prd_closed");
for (int fld = 0; fld < filter.size(); fld++)
{
childNodeName = (String) filter.get(fld);
if (childNodeName.equalsIgnoreCase("prd_code"))
{
prdCode = this.genericUtility.getColumnValue("prd_code", dom);
System.out.println("prdCode :"+prdCode);
if(prdCode == null || prdCode.trim().length()==0)
{
System.out.println("Error : period code should not be blank!!!");
errCode = "VTPRD14";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(prdCode != null && prdCode.trim().length() > 0 )
{
sql = "select count(*) from period where code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
if (cnt == 0)
{
errCode = "VMPRD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if (childNodeName.equalsIgnoreCase("count_code"))
{
cntCode = this.genericUtility.getColumnValue("count_code", dom);
System.out.println("count_code :"+cntCode);
if(cntCode == null || cntCode.trim().length()==0)
{
System.out.println("Error : country code should not be blank!!!");
errCode = "VMCOUNTCD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(cntCode != null && cntCode.trim().length() > 0 )
{
sql = "select count(*) from country where count_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,cntCode.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
if (cnt == 0)
{
errCode = "VTCONTCD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if(childNodeName.equalsIgnoreCase("fr_date"))
{
frDate = genericUtility.getColumnValue("fr_date", dom);
toDate = genericUtility.getColumnValue("to_date", dom);
System.out.println(">>>>>>>>>>>frDate===="+frDate);
System.out.println(">>>>>>>>>>>toDate===="+toDate);
if(frDate==null || frDate.trim().length()==0)
{
errCode = "VTFRDTNULL";//**************s
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if((frDate!=null && frDate.trim().length()>0) && (toDate!=null && toDate.trim().length()>0))
{
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(fromDate.compareTo(tooDate)>0)
{
errCode = "VTFRDATE";//**************
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("to_date"))
{
frDate = genericUtility.getColumnValue("fr_date", dom);
toDate = genericUtility.getColumnValue("to_date", dom);
System.out.println(">>>>>>>>>>>frDate===="+frDate);
System.out.println(">>>>>>>>>>>toDate===="+toDate);
if(toDate==null || toDate.trim().length()==0)
{
errCode = "VTTODTNULL";//
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
if((toDate!=null && toDate.trim().length()>0) && (frDate!=null && frDate.trim().length()>0))
{
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
if(tooDate.compareTo(fromDate)<0)
{
errCode = "VTTODATE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength Detail3:::::::::"+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
//}
parentNode = parentNodeList.item(selectedRow);
// parentNode = parentNodeList.item(0);
//if( parentNode != null )
{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}
System.out.println("@@@@@@@@@@@@childNodeListLength["+childNodeListLength+"]");
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName===="+childNodeName);
if("add_date".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
addDate = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
addDate= "";
}
System.out.println("addDate from detail===="+addDate);
}
if("chg_date".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
chgDate = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
chgDate= "";
}
System.out.println("chgDate from detail===="+chgDate);
}
if("fr_date".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
frDate = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
frDate= "";
}
System.out.println("frDate from detail===="+frDate);
}
if("prd_closed".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
prdClose = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
prdClose= "";
}
System.out.println("prdClose from detail===="+prdClose);
}
if("prd_code".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
prdCode = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
prdCode= "";
}
System.out.println("prdCode from detail===="+prdCode);
}
if("prd_tblno".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
prdTblNo = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
prdTblNo= "";
}
System.out.println("prdTblNo from detail===="+prdTblNo);
}
if("to_date".equalsIgnoreCase(childNode.getNodeName()))
{
if( childNodeList.item(ctr).getFirstChild() != null)
{
toDate = childNodeList.item(ctr).getFirstChild().getNodeValue();
}
else
{
toDate= "";
}
System.out.println("toDate from detail===="+toDate);
}
System.out.println("Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@");
System.out.println("Add Date====="+addDate);
if (childNodeName.equalsIgnoreCase("prd_tblno"))
{
getValue= getDetailValues(prdCode, prdTblNo, frDate, toDate, prdClose, conn);
System.out.println("getValue from getDetailValues==== "+getValue);
if(getValue)
{
divisionList=divisionList+" "+prdTblNo+",";
System.out.println("divisionList===="+divisionList);
/*if(!divisionLst.contains(prdTblNo))
{
System.out.println("divisionLst item>>>>>>>"+prdTblNo);
divisionLst.add(prdTblNo.trim());
}*/
errCode = "VTDIVCLOS";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
System.out.println("Validation of From Date####");
getPeriodValue= getPeriod(prdCode, prdTblNo, frDate, toDate, prdClose, addDate, conn);
System.out.println("getValue from getDetailValues==== "+getPeriodValue);
if(getPeriodValue)
{
frmDateList=frmDateList+" "+prdTblNo+",";
System.out.println("frmDateList===="+frmDateList);
errCode = "VTFRMPRV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//added
}
/* if (childNodeName.equalsIgnoreCase("to_date"))
{
System.out.println("Validation of From Date####");
getPeriodValue= getPeriod(prdCode, prdTblNo, frDate, toDate, prdClose, addDate, conn);
System.out.println("getValue from getDetailValues==== "+getPeriodValue);
if(getPeriodValue)
{
frmDateList=frmDateList+" "+prdTblNo+",";
System.out.println("frmDateList===="+frmDateList);
errCode = "VTFRMPRV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}*/
} // end for
}//end of selected row
break; // case 2 end// case 1 end
}
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
System.out.println("@@@@@errListSize["+errListSize+"]");
if (errList != null && errListSize > 0)
{
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString===="+errString);
errorType = errorType(conn, errCode);
System.out.println("errorType===="+errorType);
/*
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
// errString = "";
}
*/
if(errCode.equals("VTDIVCLOS"))
{
/*
retString=errString;
System.out.println("retString===="+retString);
// retString = itmDBAccessEJB.getErrorString("","VTNTCONF","","",conn);
begPart = retString.substring( 0, retString.indexOf("<trace>") + 7 );
System.out.println("begPart===="+begPart);
endPart = retString.substring( retString.indexOf("</trace>"));
System.out.println("endPart===="+endPart);
mainStr = begPart + divisionList + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
errStringXml.append(errString);
System.out.println("errStringXml===="+errStringXml);
errString = "";
*/
if( divisionList != null && divisionList.trim().length() > 0 )
{
divisionList = divisionList.substring(0, divisionList.length()-1);
}
System.out.println("@@@@@@@ divisionList["+divisionList+"]");
retString=errString;
System.out.println("retString===="+retString);
// retString = itmDBAccessEJB.getErrorString("","VTNTCONF","","",conn);
begPart = retString.substring( 0, errString.indexOf("]]></description>") );
System.out.println("begPart===="+begPart);
endPart = retString.substring( errString.indexOf("]]></description>"), errString.length() );
System.out.println("endPart===="+endPart);
mainStr = begPart + divisionList + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
// errStringXml.append(errString);
System.out.println("errStringXml===="+errStringXml);
// errString = "";
}
if(errCode.equals("VTFRMPRV"))
{
/*
retString=errString;
System.out.println("retString===="+retString);
// retString = itmDBAccessEJB.getErrorString("","VTNTCONF","","",conn);
begPart = retString.substring( 0, retString.indexOf("<trace>") + 7 );
System.out.println("begPart===="+begPart);
endPart = retString.substring( retString.indexOf("</trace>"));
System.out.println("endPart===="+endPart);
mainStr = begPart + divisionList + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
errStringXml.append(errString);
System.out.println("errStringXml===="+errStringXml);
errString = "";
*/
if( frmDateList != null && frmDateList.trim().length() > 0 )
{
frmDateList = frmDateList.substring(0, frmDateList.length()-1);
}
System.out.println("@@@@@@@ frmDateList["+frmDateList+"]");
retString=errString;
System.out.println("retString===="+retString);
// retString = itmDBAccessEJB.getErrorString("","VTNTCONF","","",conn);
begPart = retString.substring( 0, errString.indexOf("]]></description>") );
System.out.println("begPart===="+begPart);
endPart = retString.substring( errString.indexOf("]]></description>"), errString.length() );
System.out.println("endPart===="+endPart);
mainStr = begPart + frmDateList + endPart;
errString = mainStr;
System.out.println("mainStr-----"+mainStr);
// errStringXml.append(errString);
System.out.println("errStringXml===="+errStringXml);
// errString = "";
}
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") +
8, errString.indexOf("<trace>"));
System.out.println("bifurErrString>>>>>>>>>>"+bifurErrString);
bifurErrString = bifurErrString +
errString.substring(errString.indexOf("</trace>") +
8, errString.indexOf("</Errors>"));
System.out.println("bifurErrString@@@@@@@@@@@@"+bifurErrString);
errStringXml.append(bifurErrString);
System.out.println("errStringXml@@@@@@@"+errStringXml.toString());
System.out.println("errStringXml$$$$$$$$$$"+errStringXml.toString());
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
} else
{
errStringXml = new StringBuffer("");
}
} catch (Exception e)
{
e.printStackTrace();
errString = e.getMessage();
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 d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
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 = "";
System.out.println("xmlString............." + xmlString);
System.out.println("xmlString1............" + xmlString1);
System.out.println("xmlString2............" + xmlString2);
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} catch (Exception e)
{
System.out.println("Exception : [EcollectionIC][itemChanged( String, String )] :==>\n" + e.getMessage());
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
{
String sql = "", sql1 = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Connection conn = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
E12GenericUtility genericUtility = new E12GenericUtility();
//java.util.Date currDate = new java.util.Date();
ConnDriver connDriver = new ConnDriver();
int currentFormNo = 0, childNodeListLength = 0;
String columnValue = "", userId = "", termId = "";
String pobNo = "", loginSiteCode = "", siteDescr = "", custCode = "", custName = "";
String wfStatus = "", confiemd = "", remarks = "", empCodeAprv = "", addDate = "";
String addUser = "", addTerm = "", chgDate = "", chgUser = "", chgTerm = "", pharmacyOwn = "";
String loginEmpCode = "", confirmed = "";
int pobLineNo = 0;
int parentNodeListLength = 0;
int lineNo = 0;
Timestamp timestamp = null ;
java.util.Date tranDate = null, dlvCfaDt = null, dueDate = null, lastOrdDt = null ;
java.util.Date statusDate = null, confDate = null, addDate1 = null, chgDate1 = null,lastPOBDate=null;
String prdCode="",cntCode="",frDate="",toDate="",prdClose="",siteCode="";
String refCode="",prdTblno="";
String periodCode="",periodTabNo="",fromDate="",tooDate="",periodClose="",countDescr="";
int prdCnt=0,cnt=0;
String currDate="";
Date fromDateVal=null,toDateVal=null;
String periodClosed="";
try
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
timestamp = new Timestamp(System.currentTimeMillis());
currDate = (sdf.format(timestamp).toString()).trim();
System.out.println("Current Date>>>>>>>>>"+currDate);
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("Now the date is :=> " + sysDate);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>");
valueXmlString.append(editFlag).append("</editFlag>\r\n</Header>\r\n");
System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo + "**************");
switch (currentFormNo)
{
case 1:
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("case 1: itm_default called ");
//valueXmlString.append("<Detail1 domID='1' objContext=\"1\" selected=\"N\">\r\n");
//valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append("<Detail1 domID='1' objContext='1'>");
valueXmlString.append("<prd_code>").append("").append("</prd_code>");
valueXmlString.append("<count_code>").append("").append("</count_code>");
valueXmlString.append("<fr_date>").append("").append("</fr_date>");
valueXmlString.append("<to_date>").append("").append("</to_date>");
valueXmlString.append("<prd_closed>").append("<![CDATA[N]]>").append("</prd_closed>");
valueXmlString.append("</Detail1>");
}
else if(currentColumn.trim().equalsIgnoreCase("count_code"))
{
cntCode = checkNull(genericUtility.getColumnValue("count_code",dom));
prdCode = checkNull(genericUtility.getColumnValue("prd_code",dom));
frDate = checkNull(genericUtility.getColumnValue("fr_date",dom));
toDate = checkNull(genericUtility.getColumnValue("to_date",dom));
prdClose = checkNull(genericUtility.getColumnValue("prd_closed",dom));
System.out.println("Country Code====="+cntCode);
System.out.println("Period Code====="+prdCode);
System.out.println("frDate :"+frDate);
System.out.println("toDate :"+toDate);
System.out.println("prdClose :"+prdClose);
if(cntCode!=null && cntCode.trim().length()>0)
{
sql="select descr from country where count_code= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,cntCode);
rs=pstmt.executeQuery();
if(rs.next())
{
countDescr=rs.getString("descr");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Country description====="+countDescr);
valueXmlString.append("<Detail1 domID='1' objContext='1'>");
valueXmlString.append("<count_code>").append("<![CDATA[" + cntCode + "]]>").append("</count_code>\r\n");
valueXmlString.append("<count_descr>").append("<![CDATA[" + countDescr + "]]>").append("</count_descr>\r\n");
valueXmlString.append("<prd_code>").append("<![CDATA["+ prdCode +"]]>").append("</prd_code>");
valueXmlString.append("<fr_date>").append("<![CDATA["+frDate +"]]>").append("</fr_date>");
valueXmlString.append("<to_date>").append("<![CDATA["+ toDate +"]]>").append("</to_date>");
valueXmlString.append("<prd_closed>").append("<![CDATA[N]]>").append("</prd_closed>");
valueXmlString.append("</Detail1>");
}
}
break;
case 2:
if(currentColumn.trim().equals("itm_default"))
{
System.out.println("itm_default called for case 2");
prdCode = checkNull(genericUtility.getColumnValue("prd_code",dom1));
cntCode = checkNull(genericUtility.getColumnValue("count_code",dom1).trim());
frDate = checkNull(genericUtility.getColumnValue("fr_date",dom1));
toDate = checkNull(genericUtility.getColumnValue("to_date",dom1));
prdClose = checkNull(genericUtility.getColumnValue("prd_closed",dom1));
System.out.println("prdCode :"+prdCode);
System.out.println("cntCode :"+cntCode);
System.out.println("frDate :"+frDate);
System.out.println("toDate :"+toDate);
System.out.println("prdClose :"+prdClose);
sql="select site_code,ref_code,prd_tblno from period_appl where ref_code like '%" + cntCode + "%'";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next())
{
prdCnt++;
siteCode=rs.getString("site_code");
refCode=rs.getString("ref_code");
prdTblno=rs.getString("prd_tblno");
System.out.println("siteCode==="+siteCode);
System.out.println("refCode==="+refCode);
System.out.println("siteCode==="+siteCode);
//sql="select prd_code,prd_tblno,fr_date,to_date,prd_closed from period_tbl where prd_code= ? and prd_tblno= ?";
sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, prdCode);
pstmt1.setString(2, refCode);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
cnt = rs1.getInt(1);
System.out.println("CNT==="+cnt);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(cnt==0)
{
System.out.println("Count is 0");
/*valueXmlString.append("<Detail2 dbID='' domID='"+prdCnt+"' objName=\"period_tbl\" objContext=\"2\">");
valueXmlString.append("<attribute pkNames=\"\" selected=\"Y\" updateFlag=\"A\" status=\"O\" />");*/
valueXmlString.append("<Detail2 domID='" + prdCnt + "' objContext=\"2\" selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"A\" status=\"O\" pkNames=\"\" />\r\n");
valueXmlString.append("<prd_code>").append("<![CDATA["+ prdCode +"]]>").append("</prd_code>");
valueXmlString.append("<prd_tblno>").append("<![CDATA["+refCode+"]]>").append("</prd_tblno>");
valueXmlString.append("<fr_date>").append("<![CDATA["+frDate +"]]>").append("</fr_date>");
valueXmlString.append("<to_date>").append("<![CDATA["+ toDate +"]]>").append("</to_date>");
valueXmlString.append("<prd_closed>").append("<![CDATA[N]]>").append("</prd_closed>");
valueXmlString.append("<add_date>").append("<![CDATA["+currDate +"]]>").append("</add_date>");
valueXmlString.append("<chg_date>").append("<![CDATA["+currDate +"]]>").append("</chg_date>");
valueXmlString.append("</Detail2>");
}
else
{
System.out.println("Count greater than 0");
/*valueXmlString.append("<Detail2 dbID='' domID='"+prdCnt+"' objName=\"period_tbl\" objContext=\"2\">");
valueXmlString.append("<attribute pkNames=\"\" selected=\"Y\" updateFlag=\"E\" status=\"O\" />");*/
sql="select fr_date,to_date,prd_closed from period_tbl where prd_code= ? and prd_tblno=?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, prdCode);
pstmt1.setString(2, refCode);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
fromDateVal=rs1.getDate("fr_date");
toDateVal=rs1.getDate("to_date");
periodClosed=rs1.getString("prd_closed");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("periodClosed==="+periodClosed);
System.out.println("fromDateVal==="+fromDateVal);
System.out.println("toDateVal==="+toDateVal);
String fromDateStr = sdf.format(fromDateVal);
String toDateStr = sdf.format(toDateVal);
System.out.println("String format fromDateStr"+fromDateStr);
System.out.println("String format toDateStr"+toDateStr);
valueXmlString.append("<Detail2 domID='" + prdCnt + "' objContext=\"2\" selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n");
valueXmlString.append("<prd_code>").append("<![CDATA["+ prdCode +"]]>").append("</prd_code>");
valueXmlString.append("<prd_tblno>").append("<![CDATA["+refCode+"]]>").append("</prd_tblno>");
valueXmlString.append("<fr_date>").append("<![CDATA["+fromDateStr +"]]>").append("</fr_date>");
valueXmlString.append("<to_date>").append("<![CDATA["+ toDateStr +"]]>").append("</to_date>");
valueXmlString.append("<prd_closed>").append("<![CDATA["+periodClosed+"]]>").append("</prd_closed>");
valueXmlString.append("<add_date>").append("<![CDATA["+currDate +"]]>").append("</add_date>");
valueXmlString.append("<chg_date>").append("<![CDATA["+currDate +"]]>").append("</chg_date>");
valueXmlString.append("</Detail2>");
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("");
}
System.out.println("valueXmlString from case 2 :" + valueXmlString);
break;
}
valueXmlString.append("</Root>");
} catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
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 d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}//end of errorType
private String checkNull( String input )
{
if (input == null )
{
input = "";
}
return input;
}//end of checkNull
public boolean getDetailValues(String prdCode,String prdTblNo,String frDate, String toDate,String prdClose , Connection conn) throws ITMException
{
System.out.println("Enter in getDetailValues ");
ResultSet rs=null;
PreparedStatement pstmt=null;
SimpleDateFormat sdf =null;
Timestamp currDate = null,fromDate=null,tooDate=null;
String sql="",errorString="";
String chgUser="",chgTerm="";
String errString = "";
int cnt=0,updateCount=0,detCnt=0;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean recordExist=false;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
/*chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
*/
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new Timestamp(System.currentTimeMillis());
System.out.println("TimeStamp>>>>>>>>>>"+currDate);
/* fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as fromDate@@@@@@@==="+fromDate);
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as tooDate @@@@@@@==="+tooDate);*/
System.out.println("Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@");
sql="select count(1) from period_tbl where prd_code <> ? and prd_tblno= ? and prd_closed='N' and ?='N'";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, prdTblNo);
pstmt.setString(3, prdClose);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
System.out.println("CNT==="+cnt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt>0)
{
recordExist=true;
//System.out.println(">>The selected division is already close");
//errString = itmDBAccessEJB.getErrorString("","VTDIVCLOS","","",conn);
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println(">>>>>In finally errString:"+errString);
/*if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCONSUCF") > -1)
{
conn.commit();
System.out.println("Commit Completed");
}
else
{
conn.rollback();
}
}*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("recordExist=============="+recordExist);
return recordExist;
}
public boolean getPeriod(String prdCode,String prdTblNo,String frDate, String toDate,String prdClose ,String addDate, Connection conn) throws ITMException
{
System.out.println("Enter in getPeriod ");
ResultSet rs=null;
PreparedStatement pstmt=null;
SimpleDateFormat sdf =null;
Timestamp currDate = null,fromDate=null,tooDate=null,addDat=null;
String sql="",errorString="";
Date fromDt=null,toDateNew=null;
String chgUser="",chgTerm="",prdCodeNew="";
String errString = "";
int cnt=0,updateCount=0,detCnt=0;
UtilMethods utilMethod=new UtilMethods();
ITMDBAccessEJB itmDBAccessEJB = null;
boolean recordExist=false;
boolean periodStaus=false;
Timestamp frmDateSTr=null,toDateTmstmp=null,frmTimeStamp=null;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new Timestamp(System.currentTimeMillis());
System.out.println("TimeStamp>>>>>>>>>>"+currDate);
System.out.println("Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]Add Date["+addDate+"]@@@");
addDat = Timestamp.valueOf(genericUtility.getValidDateString(addDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set asaddDat@@@@@@@==="+addDat);
frmTimeStamp = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set frmTimeStamp@@@@@@@==="+frmTimeStamp);
sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
System.out.println("CNT==="+cnt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("cnt in period_tbl==="+cnt);
if(cnt>0)
{
sql="select fr_date from period_tbl where ? between fr_date and to_date and prd_tblno= ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setTimestamp(1, addDat);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
fromDt = rs.getDate("fr_date");
System.out.println("fromDt==="+fromDt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
Date getDate=utilMethod.RelativeDate(fromDt, -1);
System.out.println("getDate========"+getDate);
String dateFrm = sdf.format(getDate);
System.out.println("Due Date Max======"+dateFrm);
frmDateSTr = Timestamp.valueOf(genericUtility.getValidDateString(dateFrm, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as frmDateSTr@@@@@@@==="+frmDateSTr);
sql="select prd_code from period_tbl where ? between fr_date and to_date and prd_tblno= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setTimestamp(1, frmDateSTr);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
prdCodeNew = rs.getString("prd_code");
System.out.println("prdCodeNew==="+prdCodeNew);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql="select to_date from period_tbl where prd_code=? and prd_tblno= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCodeNew);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
toDateNew = rs.getDate("to_date");
System.out.println("prdCodeNew==="+prdCodeNew);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("toDateNew===="+toDateNew);
String dateTo = sdf.format(toDateNew);
System.out.println("dateTo test====="+dateTo);
toDateTmstmp = Timestamp.valueOf(genericUtility.getValidDateString(dateTo, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as toDateTmstmp@@@@@@@==="+toDateTmstmp);
//toDateTmstmp frmDateSTr
// if(tooDate.compareTo(fromDate)<0)
// if(frmDateSTr.compareTo(toDateTmstmp)<0)
if(frmTimeStamp.before(toDateTmstmp))
{
System.out.println("frmDateSTr.compareTo(toDateTmstmp)<0");
periodStaus=true;
}
else
{
System.out.println("ELSE ++++++++");
}
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println(">>>>>In finally errString:"+errString);
/*if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCONSUCF") > -1)
{
conn.commit();
System.out.println("Commit Completed");
}
else
{
conn.rollback();
}
}*/
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("periodStaus*************=============="+periodStaus);
return periodStaus;
}
}
/********************************************************
Title : BankGauranteeLocal [F15DSUN018]
Date : 22/JUL/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PrdTableGenICLocal extends ValidatorLocal
{
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;
}
/********************************************************
Title : BankGauranteeRemote [F15DSUN018]
Date : 22/JUL/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface PrdTableGenICRemote extends ValidatorRemote
{
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 org.w3c.dom.*;
import ibase.utility.CommonConstants;
import ibase.utility.GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import ibase.webitm.ejb.ITMDBAccessEJB;
import javax.ejb.Stateless;
@Stateless
public class PrdTableGenPostSave extends ValidatorEJB implements PrdTableGenPostSaveLocal,PrdTableGenPostSaveRemote {
//E12GenericUtility genericUtility = new E12GenericUtility();
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
System.out.println("------------ postSave method called-111111111----------------PrdTableGenPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
Document dom = null;
String errString="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception : PrdTableGenPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException
{
System.out.println("in EcollectionPostSave tran_id---->>["+tranId+"]");
ResultSet rs=null;
PreparedStatement pstmt=null;
SimpleDateFormat sdf =null;
Timestamp currDate = null,fromDate=null,tooDate=null;
String sql="",errorString="";
String prdCode="",prdTblNo="",frDate="",toDate="",prdClose="";
String chgUser="",chgTerm="";
String errString = "";
int cnt=0,updateCount=0,detCnt=0;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean value=false;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new Timestamp(System.currentTimeMillis());
System.out.println("TimeStamp>>>>>>>>>>"+currDate);
NodeList hdrDommList = dom.getElementsByTagName("Detail2");
System.out.println("hdrDommList==="+hdrDommList);
System.out.println("len===["+hdrDommList.getLength()+"]");
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
NodeList detail2List= detailListNode.getChildNodes();
// System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]");
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
// System.out.println("@@@@inside detail4----------------");
for (int cntr = 0; cntr < detail2List.getLength(); cntr++)
{
Node detail2Node = detail2List.item(cntr);
if("prd_code".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdCode = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdCode= "";
}
}
if("prd_tblno".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdTblNo = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdTblNo= "";
}
}
if("fr_date".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
frDate = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
frDate= "";
}
}
if("to_date".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
toDate = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
toDate= "";
}
}
if("prd_closed".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdClose = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdClose= "";
}
}
}
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as fromDate@@@@@@@==="+fromDate);
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as tooDate @@@@@@@==="+tooDate);
System.out.println("@@@@ctr["+dtlCtr+"]Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@");
sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
System.out.println("CNT==="+cnt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt==0)
{
System.out.println("New Exist@@@@@@@");
sql="Insert into period_tbl (PRD_CODE,PRD_TBLNO,FR_DATE,TO_DATE,PRD_CLOSED,CHG_DATE,CHG_USER,CHG_TERM) " +
"values (?,?,?,?,?,?,?,?)";
System.out.println("header sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
pstmt.setString(2,prdTblNo);
pstmt.setTimestamp(3,fromDate);
pstmt.setTimestamp(4,tooDate);
pstmt.setString(5,prdClose);
pstmt.setTimestamp(6,currDate);
pstmt.setString(7,chgUser);
pstmt.setString(8,chgTerm);
detCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Insert Count==="+detCnt);
}
else
{
System.out.println("Record Exist@@@@@@@");
sql = "update period_tbl set FR_DATE= ? ,TO_DATE=?, PRD_CLOSED=?,CHG_DATE=?,CHG_USER=?,CHG_TERM=? where prd_code= ? and prd_tblno= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,fromDate);
pstmt.setTimestamp(2,tooDate);
pstmt.setString(3,prdClose);
pstmt.setTimestamp(4,currDate);
pstmt.setString(5,chgUser);
pstmt.setString(6,chgTerm);
pstmt.setString(7,prdCode);
pstmt.setString(8,prdTblNo);
updateCount = pstmt.executeUpdate();
System.out.println("no of row update: "+updateCount);
pstmt.close();
pstmt = null;
}
if(detCnt>0 ||updateCount>0)
{
System.out.println(">>The selected transaction is confirmed");
errString = itmDBAccessEJB.getErrorString("","VTCONSUCF","","",conn);
}
}
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println(">>>>>In finally errString:"+errString);
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCONSUCF") > -1)
{
conn.commit();
System.out.println("Commit Completed");
}
else
{
conn.rollback();
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
return errorString;
}
private String checkNull( String input )
{
if (input == null )
{
input = "";
}
return input;
}//end of
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface PrdTableGenPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote;
@Remote
public interface PrdTableGenPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,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