Commit a84c44f6 authored by wansari's avatar wansari

F17BBAS001 added GST reconcilation wizard components


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105868 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3ec76937
/*
* Author: Wasim Ansari
* Date: 02-MAY-2016
* Request: F17BBAS001 (GST Wizard)
*/
package ibase.webitm.bean.gst;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
public class GstWizBean
{
E12GenericUtility genericUtility = new E12GenericUtility();
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public GstWizBean(String objName) throws ITMException
{
try
{
this.objName = objName;
}
catch (Exception e)
{
throw new ITMException(e);
}
}
public GstWizBean() {
}
public String previousForm( String formNo, String xmlData ) throws ITMException
{
String retHtmlData = null;
try
{
System.out.println("In Method : [previousForm]");
System.out.println("xmlString : ["+ xmlData +"]");
String xslFileName = getXSLFileName( this.objName + formNo + "_wiz_" + this.user_lang + "_" + this.user_country + "_" + "A" + ".xsl" );
retHtmlData = (genericUtility).transformToString( xslFileName, xmlData, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
}
catch (Exception e)
{
throw new ITMException(e);
}
return retHtmlData;
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD"+ File.separator + "Galaxy");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
}
This diff is collapsed.
/*
* Author: Wasim Ansari
* Date: 02-MAY-2016
* Request: F17BBAS001 (GST Wizard)
*/
package ibase.webitm.ejb.gst;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface GSTRecoWizEJBLocal 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;
}
/*
* Author: Wasim Ansari
* Date: 02-MAY-2016
* Request: F17BBAS001 (GST Wizard)
*/
package ibase.webitm.ejb.gst;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface GSTRecoWizEJBRemote 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;
}
/*
* Author:Wasim Ansari
* Date:03-05-2017
* Request ID:F17BBAS001 (GST Wizard Post Save Component for Reconciliation Trace)
*/
package ibase.webitm.ejb.gst;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sybase.jaguar.management.jdk12utils.Iterator;
@Stateless
public class GSTRecoWizPosEJB extends ValidatorEJB implements GSTRecoWizPosEJBRemote,GSTRecoWizPosEJBLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
/**
* Default constructor.
*/
public GSTRecoWizPosEJB() {
// TODO Auto-generated constructor stub
}
@Override
public String postSave(String xmlStringAll, String tranID, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
String retString="";
try
{
retString = postSave(xmlStringAll, xtraParams, "", conn);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String postSave(String xmlstring, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
System.out.println("Inside GSTWizardPosEJB Post Save ["+xmlstring+"] \n xtraParams ["+xtraParams+"] \n forcedFlag["+forcedFlag+"]");
PreparedStatement pstmt = null,pstmtUpd = null;
ResultSet rs = null;
boolean isError = false,isLocCon = false;
Document dom = null;
String sql = "",retString = "",tranID = "", tranIdGSTN = "";
ArrayList<String> tranIDList = new ArrayList<String>();
String tranIDStr = "",submitStatus = "";
int cnt = 0;
HashSet<String> hs = new HashSet<String>();
try
{
if(conn == null || conn.isClosed())
{
System.out.println("@@Connection is null");
conn = getConnection();
isLocCon = true;
}
else
{
System.out.println("@@Connection is not null");
}
if(xmlstring != null && (xmlstring.indexOf("Detail2") != -1))
{
sql = " INSERT INTO GSTRECO_TRACE (TRAN_ID,TRAN_ID__GSTN) "
+" VALUES ( ? , ?) ";
pstmt = conn.prepareStatement(sql);
sql = " UPDATE GST_DATA_HDR SET RECO_STATUS = ?,SUBMIT_STATUS = ? WHERE TRAN_ID = ? ";
pstmtUpd = conn.prepareStatement(sql);
dom = genericUtility.parseString(xmlstring);
NodeList detail2NodeList =dom.getElementsByTagName("Detail2");
int detail3NodeListlen = detail2NodeList.getLength();
for(int ctrH = 0; ctrH < detail3NodeListlen ; ctrH++)
{
NodeList childNodeList = detail2NodeList.item(ctrH).getChildNodes();
int childNodeListlen = childNodeList.getLength();
for(int ctrD = 0; ctrD < childNodeListlen ; ctrD++)
{
Node childNode = childNodeList.item(ctrD);
if(childNode != null && "tran_id".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
tranID = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
}
else if(childNode != null && "tran_id__gstn".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
tranIdGSTN = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
}
else if(childNode != null && "status".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
submitStatus = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
}
}
System.out.println("TranID ["+tranID+"] GSTN TranID["+tranIdGSTN+"] Submit Status["+submitStatus+"]");
if(tranID.length() > 0 && tranIdGSTN.length() > 0)
{
if (hs.contains(tranID) || hs.contains(tranIdGSTN))
{
System.out.println("Already inserted");
}
else
{
hs.add(tranID);
hs.add(tranIdGSTN);
pstmt.setString(1, tranID);
pstmt.setString(2, tranIdGSTN);
pstmt.addBatch();
pstmt.clearParameters();
tranIDStr = tranIDStr +"'"+ tranID +"','"+ tranIdGSTN +"'," ;
cnt++;
pstmtUpd.setString(1, "M");
pstmtUpd.setString(2, submitStatus);
pstmtUpd.setString(3, tranID);
pstmtUpd.addBatch();
pstmtUpd.clearParameters();
}
}
else
{
System.out.println("Not inserted---->TranID ["+tranID+"] GSTN TranID["+tranIdGSTN+"]");
}
}
System.out.println("Count["+cnt+"]");
if(cnt > 0)
{
int updCount[] = pstmt.executeBatch();
System.out.println("Rows Inserted-->"+updCount);
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
updCount = pstmtUpd.executeBatch();
System.out.println("Rows updated-->"+updCount);
//tranIDStr = tranIDStr.substring(0, tranIDStr.length()-1);
/*sql = " UPDATE GST_DATA_HDR SET RECO_STATUS = 'M' WHERE TRAN_ID IN ("+tranIDStr+") ";
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
if( pstmt != null )
{
pstmt.close();pstmt = null;
}*/
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
if(pstmtUpd != null)
{
pstmtUpd.close();pstmtUpd = null;
}
}//End if Detail2 not found
else
{
System.out.println("Detail2 not found");
retString = itmDBAccessLocal.getErrorString("","VTBLNKDTL","","",conn);
return retString;
}
}
catch(Exception e)
{
System.out.println("Exception GSTWizardPosEJB ==>"+e.getMessage());
isError = true;
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Inside finally GSTWizardPosEJB isError["+isError+"] connStatus["+isLocCon+"]");
if (rs != null )
{
rs.close();rs = null;
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
if(pstmtUpd != null)
{
pstmtUpd.close();pstmtUpd = null;
}
if(isLocCon)
{
if(isError)
{
System.out.println("Inside rollbacking....");
conn.rollback();
}
else
{
System.out.println("Inside committing....");
conn.commit();
}
if (conn != null )
{
conn.close();conn = null;
}
}
}
catch( Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("errString from post save GSTWizardPosEJB =["+retString+"]");
return retString;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
}
/*
* Author:Wasim Ansari
* Date:03-05-2017
* Request ID:S16EBAS006 (GST Wizard)
*/
package ibase.webitm.ejb.gst;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface GSTRecoWizPosEJBLocal extends ValidatorLocal
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
/*
* Author:Wasim Ansari
* Date:03-05-2017
* Request ID:S16EBAS006 (GST Wizard)
*/
package ibase.webitm.ejb.gst;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
@Remote
public interface GSTRecoWizPosEJBRemote extends ValidatorRemote
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
/*
* Author: Wasim Ansari
* Date: 02-MAY-2016
* Request: F17BBAS001 (GST Wizard)
*/
package ibase.webitm.servlet.gst;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mysql.jdbc.Messages;
public class GSTWizUtilServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public GSTWizUtilServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doPost( request, response );
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
System.out.println("XXXXXXXXXXXXXXXXXXXXXX[ GSTWizUtilServlet START]XXXXXXXXXXXXXXXXXXXX");
request.setCharacterEncoding(CommonConstants.ENCODING);
String action = "", htmlData = "";
try
{
action = request.getParameter("action");
System.out.println("GSTWizUtilServlet ACTION ["+action+"]");
if("previous".equalsIgnoreCase(action))
{
ibase.utility.UserInfoBean userInfo = ( ibase.utility.UserInfoBean )request.getSession().getAttribute( "USER_INFO" );
if(userInfo != null)
{
String objName = request.getParameter("OBJ_NAME");
String formNo = request.getParameter("FORM_NO");
String preFormVal = request.getParameter("PRE_FORM_VAL");
String jspName = request.getParameter("JSP_NAME")!=null ? request.getParameter("JSP_NAME").trim() : "";
System.out.println("OBJ_NAME["+objName+"]");
System.out.println("FORM_NO["+formNo+"]");
System.out.println("PRE_FORM_VAL["+preFormVal+"]");
System.out.println("JSP_NAME["+jspName+"]");
String editorId = (String) request.getSession().getAttribute( "WIZARD_BEAN_ID_" + objName );
System.out.println( " GSTWizUtilServlet :: editorId["+editorId+"]" );
if ( request.getSession().getAttribute( "WIZARD_BEAN_" + editorId ) != null )
{
System.out.println("GSTWizUtilServlet Wizard object found....");
request.getSession().removeAttribute( "WIZARD_BEAN_" + objName );
request.getSession().removeAttribute( "WIZARD_BEAN_ID_" + objName );
request.getRequestDispatcher("/webitm/jsp/"+jspName+".jsp").forward(request, response);
}
}
else
{
htmlData = Messages.getString("ITMWizardHandlerServlet_notLoggedIn")+"\n"+Messages.getString("ITMWizardHandlerServlet_pleaseReLogin");
System.out.println("htmlData ["+htmlData+"]");
}
}
else if("SAVE_DETAIL_DATA".equalsIgnoreCase(action))
{
String prevHTMLData = request.getParameter("HTML_DATA");
request.getSession().setAttribute( "GSTRECO_WIZ_DETAIL",prevHTMLData);
}
else if("DISPLAY_DETAIL_DATA".equalsIgnoreCase(action))
{
String htmlDataErr = (String) request.getSession().getAttribute( "GSTRECO_WIZ_DETAIL");
request.getSession().removeAttribute( "GSTRECO_WIZ_DETAIL");
response.setContentType("text/html");
if(CommonConstants.CONTENT_ENCODING != null && CommonConstants.CONTENT_ENCODING.equalsIgnoreCase("gzip"))
{
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gzOutStream = new GZIPOutputStream(response.getOutputStream());
gzOutStream.write(htmlDataErr.getBytes());
gzOutStream.flush();
gzOutStream.close();
}
else
{
response.setHeader("Content-Encoding", CommonConstants.CONTENT_ENCODING);
OutputStream outStream = response.getOutputStream();
outStream.write(htmlDataErr.getBytes());
outStream.flush();
outStream.close();
}
}
}
catch (Exception e)
{
System.out.println("GSTWizUtilServlet.doPost():doPost"+e.getMessage());
e.printStackTrace();
}
System.out.println("XXXXXXXXXXXXXXXXXXXXXX[ GSTWizUtilServlet END]XXXXXXXXXXXXXXXXXXXX");
}
}
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