Commit 299f6533 authored by ssalve's avatar ssalve

Sarita : Added validation to check combination of siteCode , PrdCode,...

Sarita : Added validation to check combination of siteCode , PrdCode, CctrCode, eff_from and ValidUpto on 29 DEC 2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195029 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 48842906
......@@ -6,7 +6,11 @@
package ibase.webitm.ejb.fin;
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 org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
......@@ -54,11 +58,17 @@ public class CostallocPrs extends ValidatorEJB implements CostallocPrsLocal, Cos
NodeList parentNodeList = null;
Node parentNode = null;
String updateFlag="";
int parentNodeListLength=0;
int parentNodeListLength=0 ,cnt =0;
String allocPerc ="",resBasis="";
double allocPercVal = 0.0;
boolean isLocCon = false;
boolean isError = false;
PreparedStatement pstmt = null;
ResultSet rs = null ;
String sql="";
Timestamp fromDateTimestamp = null;
Timestamp validDateTimestamp = null ;
String acctCode = "",cctrCode="",siteCode="",effFrom="",validUpto="";//Added by priyanka on 29DECEMBER2018
try
{
if (conn == null || conn.isClosed())
......@@ -72,6 +82,58 @@ public class CostallocPrs extends ValidatorEJB implements CostallocPrsLocal, Cos
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();*/
//Added by priyanka on 29DECEMBER2018 -- Added validation if account_code , cctr_code, site_code,eff_from and valid_upto existed Combination [START]
parentNodeList = dom.getElementsByTagName("Detail1");
parentNodeListLength = parentNodeList.getLength();
acctCode = checkNullAndTrim(genericUtility.getColumnValue("acct_code",dom));
cctrCode = checkNullAndTrim(genericUtility.getColumnValue("cctr_code__from",dom));
siteCode = checkNullAndTrim(genericUtility.getColumnValue("site_code",dom));
effFrom = checkNullAndTrim(genericUtility.getColumnValue("eff_from",dom));
validUpto = checkNullAndTrim(genericUtility.getColumnValue("valid_upto",dom));
fromDateTimestamp = Timestamp.valueOf(genericUtility.getValidDateTimeString(effFrom, genericUtility.getApplDateFormat(), genericUtility.getDBDateTimeFormat()));
validDateTimestamp = Timestamp.valueOf(genericUtility.getValidDateTimeString(validUpto, genericUtility.getApplDateFormat(), genericUtility.getDBDateTimeFormat()));
System.out.println("Record of header is :"+acctCode +":" +cctrCode +":" +siteCode + ":"+effFrom +":" +validUpto+"Date format "+fromDateTimestamp +":" +validDateTimestamp);
sql = "select count(*) as cnt from costalloc_bas "
+ "where acct_code =? "
+ "and cctr_code__from =? "
+ "and site_code = ? "
+ "and ? >= eff_from and ? <= valid_upto "
+ "and ? >= eff_from and ? <= valid_upto";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctCode);
pstmt.setString(2,cctrCode);
pstmt.setString(3,siteCode);
pstmt.setTimestamp(4,fromDateTimestamp);
pstmt.setTimestamp(5,validDateTimestamp);
pstmt.setTimestamp(6,fromDateTimestamp);
pstmt.setTimestamp(7,validDateTimestamp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt"); System.out.println("Count is ::: ["+cnt+"]");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt > 0)
{
String errMsg = " For \n Site Code :["+siteCode+"] \n Account Code :["+acctCode+"] \n Cctr Code :["+cctrCode+"] \n Effective From :["+effFrom+"] \n Valid Upto :["+validUpto+"]";
errString = getError(errMsg,"VMPMKY",conn);
isError = true;
}
//Added by priyanka on 29DECEMBER2018 -- Added validation if account_code , cctr_code, site_code,eff_from and valid_upto existed Combination [END]
parentNodeList = dom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for(int row = 0; row < parentNodeListLength; row++)
......@@ -226,4 +288,37 @@ public class CostallocPrs extends ValidatorEJB implements CostallocPrsLocal, Cos
}
return AttribValue;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
private String getError(String errMsg, String Code, Connection conn) throws ITMException, Exception
{
String mainStr ="";
try
{
String errString = "";
errString = new ITMDBAccessEJB().getErrorString("",Code,"","",conn);
System.out.println("Origional ErrorString is =====> <"+errString+">");
String begPart = errString.substring(0,errString.indexOf("</description>"));
String endDesc = errString.substring(errString.indexOf("</description>"),errString.length());
System.out.println("begPart ["+begPart+"] \t endDesc ["+endDesc+"]");
mainStr = checkNullAndTrim(begPart) + errMsg + checkNullAndTrim(endDesc);
System.out.println("mainStr:::::::::::::::::: "+mainStr);
//begPart = null;
//mainStr = errString;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
}
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