Commit 8f500e42 authored by ssalve's avatar ssalve

changes in generateTranId method, added new method getTimeStamp and...

changes in generateTranId method, added new method getTimeStamp and getGstStateCode , changes of access modifiers private to public on 3AUG2017


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106476 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 66fdc1d1
...@@ -11,7 +11,12 @@ import java.sql.Connection; ...@@ -11,7 +11,12 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
...@@ -24,7 +29,7 @@ import ibase.webitm.utility.TransIDGenerator; ...@@ -24,7 +29,7 @@ import ibase.webitm.utility.TransIDGenerator;
public class GSTCommonUtil extends ValidatorEJB public class GSTCommonUtil extends ValidatorEJB
{ {
E12GenericUtility genericUtility = new E12GenericUtility();
public String getImagePath(String tranWindow, String tranId, String altColVal, String folderName, Connection conn) throws ITMException public String getImagePath(String tranWindow, String tranId, String altColVal, String folderName, Connection conn) throws ITMException
{ {
System.out.println("Common utility to get image path"); System.out.println("Common utility to get image path");
...@@ -196,7 +201,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -196,7 +201,7 @@ public class GSTCommonUtil extends ValidatorEJB
} }
return bi; return bi;
} }
private String dynamicMenuImage(String objDescr) public String dynamicMenuImage(String objDescr)
{ {
StringBuffer mnIconBuffer = new StringBuffer(); StringBuffer mnIconBuffer = new StringBuffer();
String[] refSr = null; String[] refSr = null;
...@@ -338,7 +343,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -338,7 +343,7 @@ public class GSTCommonUtil extends ValidatorEJB
conn = getConnection(); conn = getConnection();
isLocalConnection = true; isLocalConnection = true;
} }
tranId = generateTranId("w_gst_api_call", "", "", conn); tranId = generateTranId("w_gst_api_call", "", conn);
insertSql = " INSERT INTO API_CALL_LOG (TRAN_ID, PRD_CODE, CALL_DATE, SITE_CODE, USER_ID, CALL_TYPE, REC_TYPE, NO_OF_RECORDS, CALL_STATUS, RESPONSE_ID, RESPONSE_INFO, CHG_USER, CHG_DATE, CHG_TERM)" insertSql = " INSERT INTO API_CALL_LOG (TRAN_ID, PRD_CODE, CALL_DATE, SITE_CODE, USER_ID, CALL_TYPE, REC_TYPE, NO_OF_RECORDS, CALL_STATUS, RESPONSE_ID, RESPONSE_INFO, CHG_USER, CHG_DATE, CHG_TERM)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
...@@ -415,7 +420,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -415,7 +420,7 @@ public class GSTCommonUtil extends ValidatorEJB
return insertCnt; return insertCnt;
} }
private String generateTranId( String windowName, String siteCode, String tranDateStr, Connection conn )throws ITMException,Exception public String generateTranId( String windowName, String siteCode, Connection conn )throws ITMException,Exception
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
...@@ -425,9 +430,16 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -425,9 +430,16 @@ public class GSTCommonUtil extends ValidatorEJB
String keyString = ""; String keyString = "";
String keyCol = ""; String keyCol = "";
String xmlValues = ""; String xmlValues = "";
java.sql.Timestamp currDate = null;
java.sql.Date effDate = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try try
{ {
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
String currDateStr = sdfAppl.format(currDate);
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? "; selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql); pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName ); pstmt.setString( 1, windowName );
...@@ -449,7 +461,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -449,7 +461,7 @@ public class GSTCommonUtil extends ValidatorEJB
xmlValues = xmlValues + "<Detail1>"; xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>"; xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>"; xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>"; xmlValues = xmlValues + "<tran_date>" + currDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>"; xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]"); System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME); TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
...@@ -512,7 +524,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -512,7 +524,7 @@ public class GSTCommonUtil extends ValidatorEJB
return dateFormat; return dateFormat;
} }
private static String checkNull(String input) public String checkNull(String input)
{ {
if (input==null) if (input==null)
{ {
...@@ -520,7 +532,7 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -520,7 +532,7 @@ public class GSTCommonUtil extends ValidatorEJB
} }
return input; return input;
} }
private static String checkNullAndTrim(String input) public String checkNullAndTrim(String input)
{ {
if (input==null) if (input==null)
{ {
...@@ -528,5 +540,144 @@ public class GSTCommonUtil extends ValidatorEJB ...@@ -528,5 +540,144 @@ public class GSTCommonUtil extends ValidatorEJB
} }
return input.trim(); return input.trim();
} }
public double getDouble(String amount)
{
double result = 0.0;
result = Double.parseDouble((amount==null||amount.equals("")) ? "0" : amount);
return result;
}
public int getNumOfNonDelDetail(Document dom2,int detailNo)
{
Node childNode = null;
NodeList updateList;
String childNodeName = "";
String updateFlag="";
int cntr=0;
System.out.println("Inside getXmlDocument method!!!!!!!!!!!!!!");
try
{
System.out.println("detailString value is =="+genericUtility.serializeDom(dom2));
NodeList detailNoteList = dom2.getElementsByTagName("Detail"+detailNo);
for(int cnt = 0;cnt<detailNoteList.getLength();cnt++)
{
Node pNode=detailNoteList.item(cnt);
/*NodeList cNodeList=pNode.getChildNodes();
childNodeListLength = cNodeList.getLength();*/
childNodeName = pNode.getNodeName();
//System.out.println("pNode::["+pNode+"]"+"cNodeList::["+cNodeList+"]");
updateFlag = getAttributeVal(pNode,"updateFlag");
System.out.println("updateFlag [" + updateFlag + "]");
if(!updateFlag.equalsIgnoreCase("D"))
{
cntr++;
}
System.out.println("Counter is ==="+cntr);
}
}
catch(Exception e)
{
System.out.println("Exception : : getNumOfNonDelDetail :"+e);
e.printStackTrace();
}
return cntr;
}
public String getAttributeVal(Node dom, String attribName )throws ITMException
{
String AttribValue = null;
try
{
NodeList detailList = dom.getChildNodes();
int detListLength = detailList.getLength();
for(int ctr = 0; ctr < detListLength; ctr++)
{
Node curDetail = detailList.item(ctr);
if(curDetail.getNodeName().equals("attribute"))
{
AttribValue = curDetail.getAttributes().getNamedItem(attribName).getNodeValue();
break;
}
else
{
continue;
}
}
}
catch (Exception e)
{
System.out.println("Exception : : searchNode :"+e);
throw new ITMException(e);
}
return AttribValue;
}
public String getGstStateCode(String siteCode , Connection conn) throws ITMException
{
String pos ="";
String sSQL ="";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sSQL = "SELECT ST.GST_CODE FROM TARODEV.SITE S,TARODEV.STATE ST WHERE S.STATE_CODE = ST.STATE_CODE AND S.SITE_CODE = ?";
pstmt = conn.prepareStatement(sSQL);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
pos = rs.getString("GST_CODE");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (rs != null )
{
rs.close();rs = null;
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
}
catch( Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return pos;
}
public Timestamp getTimeStamp(String dateStr) throws ITMException, Exception
{
String dbDateStr = "";
if(dateStr != null && !dateStr.equals(""))
{
dbDateStr =(new E12GenericUtility()).getValidDateTimeString(dateStr, (new E12GenericUtility()).getApplDateTimeFormat(), (new E12GenericUtility()).getDBDateTimeFormat());
return java.sql.Timestamp.valueOf(dbDateStr);
}
else
{
return null;
}
}
} }
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