Commit a1296efe authored by ngadkari's avatar ngadkari

Request Id - S17KGTP006 Fin entity wise period open/close facility will be made available.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@180978 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 77b85824
This diff is collapsed.
package ibase.webitm.ejb.sys;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
//import ibase.webitm.ejb.wms.WavegenWizPosRemote;
import ibase.webitm.utility.ITMException;
import java.io.File;
import javax.naming.InitialContext;
public class PeriodStatUpdWizBean {
E12GenericUtility genericUtility = new E12GenericUtility();
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public PeriodStatUpdWizBean(String objName) throws ITMException
{
try
{
this.objName = objName;
}
catch (Exception e)
{
throw new ITMException(e);
}
}
public PeriodStatUpdWizBean() {
}
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;
}
}
package ibase.webitm.ejb.sys;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.util.HashMap;
import org.w3c.dom.Document;
@javax.ejb.Local
public interface PeriodStatUpdWizLocal extends ValidatorLocal
{
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;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String handleRequest(HashMap<String, String> reqParamMap);
}
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class PeriodStatUpdWizPos extends ValidatorEJB implements PeriodStatUpdWizPosLocal,PeriodStatUpdWizPosRemote {
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-----------------PeriodStatUpdWizPos : ");
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);
}
System.out.println("errString["+errString+"]");
}
catch(Exception e)
{
System.out.println("Exception : PeriodStatUpdWizPos.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException
{
String retString = "";
String nodeName = "", loginUser = "";
String siteCode = "";
String prdCode = "";
String statAdm = "";
String statFin = "",statSal="",statIc="",statPur="",statMfg="";
String finEntity = "";
String prCodeFrom = "";
String prCodeTo = "";
String updateSql = "";
int updCnt = 0;
boolean isError = false;
ITMDBAccessEJB ITMDBAccessEJB=new ITMDBAccessEJB();
PreparedStatement pstmt = null;
ResultSet rs = null;
int hdelcnt = 0, detdelcnt = 0;
try
{
loginUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
NodeList detail1NodeList = dom.getElementsByTagName("Detail1");
int detail1NodeListLen = detail1NodeList.getLength();
for(int i=0; i<detail1NodeListLen; i++)
{
NodeList eachDetail1NodeList = detail1NodeList.item(0).getChildNodes();
for(int j=0; j<eachDetail1NodeList.getLength();j++)
{
Node eachDetail1Element = eachDetail1NodeList.item(j);
nodeName = eachDetail1Element.getNodeName();
if(!"#text".equalsIgnoreCase(nodeName) && !"attribute".equals(nodeName))
{
if("fin_entity".equalsIgnoreCase(nodeName))
{
if( eachDetail1Element.getFirstChild() != null)
{
finEntity = eachDetail1Element.getFirstChild().getNodeValue();
}
}
else if("prd_code__from".equalsIgnoreCase(nodeName))
{
if( eachDetail1Element.getFirstChild() != null)
{
prCodeFrom = eachDetail1Element.getFirstChild().getNodeValue();
}
}
else if("prd_code__to".equalsIgnoreCase(nodeName))
{
if( eachDetail1Element.getFirstChild() != null)
{
prCodeTo = eachDetail1Element.getFirstChild().getNodeValue();
}
}
}
}
}
System.out.println("finEntity["+finEntity+"]prCodeFrom["+prCodeFrom+"]prCodeTo["+prCodeTo+"]");
NodeList detail2NodeList = dom.getElementsByTagName("Detail2");
int detail2NodeListLen = detail2NodeList.getLength();
System.out.println("detail2NodeListLen["+detail2NodeListLen+"]");
for(int i=0; i<detail2NodeListLen; i++)
{
Node eachDetail2 = detail2NodeList.item(i);
NodeList eachDetail2NodeList = eachDetail2.getChildNodes();
for(int j=0; j<eachDetail2NodeList.getLength();j++)
{
Node eachDetail2Element = eachDetail2NodeList.item(j);
nodeName = eachDetail2Element.getNodeName();
if(!"#text".equalsIgnoreCase(nodeName) && !"attribute".equals(nodeName))
{
if("site_code".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
siteCode = eachDetail2Element.getFirstChild().getNodeValue();
}
}
if("prd_code".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
prdCode = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_adm".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statAdm = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_fin".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statFin = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_sal".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statSal = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_ic".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statIc = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_pur".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statPur = eachDetail2Element.getFirstChild().getNodeValue();
}
}
else if("stat_mfg".equalsIgnoreCase(nodeName))
{
if (eachDetail2Element.getFirstChild() != null)
{
statMfg = eachDetail2Element.getFirstChild().getNodeValue();
}
}
}
}
updateSql = "UPDATE PERIOD_STAT SET STAT_ADM = '"+ statAdm +"', STAT_FIN = '"+ statFin +"',STAT_SAL = '"+ statSal +"', "
+ "STAT_IC = '"+ statIc +"',STAT_PUR = '"+ statPur +"',STAT_MFG ='"+ statMfg +"' WHERE SITE_CODE = '"+ siteCode +"' AND PRD_CODE = "+ prdCode;
pstmt = conn.prepareStatement(updateSql);
updCnt = pstmt.executeUpdate();
System.out.println("updateSql..........."+ updateSql);
System.out.println("No of records updated "+updCnt);
if(updCnt>0)
{
System.out.println(" records updated "+updCnt);
}
else
{
System.out.println("No of records updated "+updCnt);
}
}
}
catch(Exception e)
{
System.out.println("Exception PeriodStatUpdWizPos -->["+e.getMessage()+"]");
throw new ITMException(e);
}
return retString;
}
}
package ibase.webitm.ejb.sys;
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 PeriodStatUpdWizPosLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.sys;
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 PeriodStatUpdWizPosRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import java.util.HashMap;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface PeriodStatUpdWizRemote extends ValidatorRemote
{
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;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String handleRequest(HashMap<String,String> reqParamMap);
}
package ibase.webitm.servlet.sys;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.zip.GZIPOutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ibase.bi.utility.Messages;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.sys.PeriodStatUpdWizRemote;
import ibase.webitm.utility.ITMException;
public class PeriodStatUpdWizServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
InitialContext ctx = null;
public PeriodStatUpdWizServlet() {
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[ PeriodStatUpdWizServlet START]XXXXXXXXXXXXXXXXXXXX");
request.setCharacterEncoding(CommonConstants.ENCODING);
String action = "", responseXML = "", htmlData = "";
PeriodStatUpdWizRemote periodStatUpdWizRemote = null;
try
{
action = request.getParameter("action");
System.out.println("PeriodStatUpdWizServlet 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 PRE_FORM_VAL = request.getParameter("PRE_FORM_VAL");
System.out.println("OBJ_NAME["+objName+"]");
System.out.println("FORMNO["+formNo+"]");
System.out.println("PRE_FORM_VAL["+PRE_FORM_VAL+"]");
String editorId = (String) request.getSession().getAttribute( "WIZARD_BEAN_ID_" + objName );
System.out.println( " PlistgenWizServlet :: editorId["+editorId+"]" );
if ( request.getSession().getAttribute( "WIZARD_BEAN_" + editorId ) != null )
{
System.out.println(" wizard object found....");
request.getSession().removeAttribute( "WIZARD_BEAN_" + objName );
//Added by Santosh on 31/03/2017 to remove editorID from session
request.getSession().removeAttribute( "WIZARD_BEAN_ID_" + objName );
System.out.println("WIZARD_BEAN_ and WIZARD_BEAN_ID_ removed from session");
request.getRequestDispatcher("/webitm/jsp/PeriodStatUpdWiz.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( "WAVEGEN_WIZ_DETAIL",prevHTMLData);
}
else if("DISPLAY_DETAIL_DATA".equalsIgnoreCase(action))
{
String htmlDataErr = (String) request.getSession().getAttribute( "WAVEGEN_WIZ_DETAIL");
request.getSession().removeAttribute( "WAVEGEN_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();
}
}
else
{
ibase.utility.UserInfoBean userInfoBean = ( ibase.utility.UserInfoBean )request.getSession().getAttribute( "USER_INFO" );
String loginCode=userInfoBean.getLoginCode();
HashMap<String,String> requestParamMap = new HashMap<String,String>();
String paramName = "", paramValue = "";
@SuppressWarnings("unchecked")
Enumeration<String> reqParams = request.getParameterNames();
while(reqParams.hasMoreElements())
{
Object paramObj = reqParams.nextElement();
paramName = (String) paramObj;
paramValue = (String)request.getParameter(paramName);
if(!paramValue.equalsIgnoreCase(""))
requestParamMap.put(paramName,paramValue);
}
requestParamMap.put("loginUser", loginCode);
System.out.println("Request Parameter map :"+requestParamMap);
ctx=getInitialContext();
periodStatUpdWizRemote = (ibase.webitm.ejb.sys.PeriodStatUpdWizRemote) ctx.lookup("ibase/PeriodStatUpdWiz/remote");
responseXML = periodStatUpdWizRemote.handleRequest(requestParamMap);
response.setContentType("text/xml");
if(CommonConstants.CONTENT_ENCODING != null && CommonConstants.CONTENT_ENCODING.equalsIgnoreCase("gzip"))
{
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream gzOutStream = new GZIPOutputStream(response.getOutputStream());
gzOutStream.write(responseXML.getBytes());
gzOutStream.flush();
gzOutStream.close();
}
else
{
response.setHeader("Content-Encoding", "");
OutputStream outStream = response.getOutputStream();
outStream.write(responseXML.getBytes());
outStream.flush();
outStream.close();
}
}
}
catch (Exception e)
{
System.out.println("PlistgenWizServlet.doPost():doPost"+e.getMessage());
e.printStackTrace();
}
System.out.println("XXXXXXXXXXXXXXXXXXXXXX[ PeriodStatUpdWizServlet END]XXXXXXXXXXXXXXXXXXXX");
}
protected InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("PeriodStatUpdWizServlet.getInitialContext()");
throw itme;
}
catch(Exception e)
{
System.out.println("PeriodStatUpdWizServlet.getInitialContext()"+e.getMessage());
throw new ITMException(e);
}
return ctx;
}
}
\ No newline at end of file
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