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
package ibase.webitm.ejb.sys;
import java.io.StringWriter;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.naming.InitialContext;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
@javax.ejb.Stateless
public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLocal, PeriodStatUpdWizRemote
{
public String globalXtraParams = "";
@Override
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 retString = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
globalXtraParams = xtraParams;
if (xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
}
catch (Exception e)
{
System.out.println ( "Exception :PeriodStatUpdWiz :itemChanged(String,String):" + e.getMessage() + ":" );
retString = genericUtility.createErrorString(e);
}
System.out.println ( "Return String from PeriodStatUpdWiz ["+retString+"]" );
return retString;
}
@Override
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
E12GenericUtility e12genericUtility = new E12GenericUtility();
StringBuffer valueXmlString = new StringBuffer();
String loginUser="";
int currentFormNo = 0;
String siteCode = "", currDate = "", retString ="", dateFormat = "";
boolean selectFlag=false,offerSelect=false;
InitialContext ctx = null;
ResultSet rs=null;
PreparedStatement pstmt=null;
Connection conn = null;
try
{
System.out.println("itemChanged called for PeriodStatUpdWiz");
conn = getConnection();
siteCode = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginUser=e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
dateFormat = e12genericUtility.getApplDateFormat();
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
SimpleDateFormat sdf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
SimpleDateFormat adf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
currDate = sdf.format(new java.util.Date());
System.out.println("currDate"+currDate);
System.out.println("currentColumn["+currentColumn+"] currentFormNo["+currentFormNo+"]" );
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?><Root><Header><editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag></Header>" );
switch(currentFormNo)
{
case 1:
{
System.out.println(" -------- Inside itemchange case 1111111 ------------ ");
int existCnt=0;
Timestamp effFrom=null,validUpto=null;
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
System.out.println("loginUser"+loginUser);
valueXmlString.append("<Detail1 domID='1'>");
valueXmlString.append("<fin_entity><![CDATA[").append("").append( "]]></fin_entity>");
valueXmlString.append("<prd_code__from><![CDATA[" ).append("").append( "]]></prd_code__from>");
valueXmlString.append("<prd_code__to><![CDATA[").append("").append( "]]></prd_code__to>");
valueXmlString.append("</Detail1>" );
}
break;
}
case 2:
{
System.out.println(" -------- Inside itemchange case 222222 ------------ ");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
String finEntity="",prdCodeFrm="",prdCodeTo="";
String nodeName = "";
String errCode ="";
String effFrom1=null,validUpto1=null,remarks=null,prdCode=null;
int domID = 0, detDomId = 0,previousCnt=0;
finEntity=checkNull(e12genericUtility.getColumnValue("fin_entity",dom1));
prdCodeFrm=checkNull(e12genericUtility.getColumnValue("prd_code__from",dom1));
prdCodeTo=checkNull(e12genericUtility.getColumnValue("prd_code__to",dom1));
valueXmlString.append("<Detail1 domID='1'>");
valueXmlString.append("<fin_entity><![CDATA[").append(finEntity).append( "]]></fin_entity>");
valueXmlString.append("<prd_code__from><![CDATA[" ).append(prdCodeFrm).append( "]]></prd_code__from>");
valueXmlString.append("<prd_code__to><![CDATA[").append(prdCodeTo).append( "]]></prd_code__to>");
valueXmlString.append("</Detail1>" );
String getDataSql= "SELECT A.SITE_CODE,B.DESCR,A.PRD_CODE,A.STAT_ADM,A.STAT_FIN,A.STAT_SAL,A.STAT_IC,A.STAT_PUR,A.STAT_MFG "
+" FROM PERIOD_STAT A, SITE B WHERE A.SITE_CODE = B.SITE_CODE AND A. PRD_CODE> = '"+prdCodeFrm+"' "
+"AND A.PRD_CODE <='"+prdCodeTo+"' AND B.FIN_ENTITY = '"+finEntity+"'";
pstmt = conn.prepareStatement(getDataSql);
System.out.println("The getDataSql becomes .................:"+getDataSql);
rs = pstmt.executeQuery();
while (rs.next())
{
valueXmlString.append("<Detail2 domID='"+(++detDomId)+"'>");
valueXmlString.append("<site_code>").append("<![CDATA[" + rs.getString(1) +"]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + rs.getString(2) +"]]>").append("</descr>");
valueXmlString.append("<prd_code>").append("<![CDATA[" + rs.getString(3) +"]]>").append("</prd_code>");
valueXmlString.append("<stat_adm>").append("<![CDATA[" + rs.getString(4) +"]]>").append("</stat_adm>");
valueXmlString.append("<stat_fin>").append("<![CDATA[" + rs.getString(5) +"]]>").append("</stat_fin>");
valueXmlString.append("<stat_sal>").append("<![CDATA[" + rs.getString(6) +"]]>").append("</stat_sal>");
valueXmlString.append("<stat_ic>").append("<![CDATA[" + rs.getString(7) +"]]>").append("</stat_ic>");
valueXmlString.append("<stat_pur>").append("<![CDATA[" + rs.getString(8) +"]]>").append("</stat_pur>");
valueXmlString.append("<stat_mfg>").append("<![CDATA[" + rs.getString(9) +"]]>").append("</stat_mfg>");
valueXmlString.append("</Detail2>");
valueXmlString.append("\n");
}
}
}
}
valueXmlString.append( "</Root>" );
}
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.itemChanged():catchBlock"+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if(!conn.isClosed() && conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.itemChanged():finally block");
e.printStackTrace();
}
}
return valueXmlString.toString();
}
@Override
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;
System.out.println("PricelistGenEJB.wfValData()");
System.out.println("xmlString :"+xmlString);
System.out.println("xmlString1 :"+xmlString1);
System.out.println("xmlString2 :"+xmlString2);
System.out.println("objContext :"+objContext);
System.out.println("editFlag :"+editFlag);
System.out.println("xtraParams :"+xtraParams);
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);
}
System.out.println("Before calling function wfvalData****");
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println("After calling method wfVAlData Error String===="+errString);
}
catch (Exception e)
{
System.out.println("Exception : [PeriodStatUpdWiz][wfValData( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}
return (errString);
}
@Override
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException
{ String finEntity="",prdCodeFrm="",prdCodeTo="";
String errString = "";
int currentFormNo = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
String childNodeName = null;
Node parentNode = null;
int childNodeListLength;
Node childNode = null;
String errCode=null,errorType=null,productCode=null,userId=null,grpCode=null;
int ctr=0,count=0,cnt=0;
E12GenericUtility e12genericUtility = new E12GenericUtility();
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
ResultSet rs=null;
PreparedStatement pstmt=null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
Connection conn = null;
try
{
conn=getConnection();
userId = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo ["+currentFormNo+"]");
}
switch (currentFormNo)
{
case 1:
{
parentNodeList = currFormDataDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("Child name --->> "+childNodeName);
if(childNodeName.equalsIgnoreCase("fin_entity"))
{
finEntity=e12genericUtility.getColumnValue("fin_entity", currFormDataDom);
String sql="Select count(*) from site where fin_entity= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, finEntity);
rs=pstmt.executeQuery();
if(rs.next())
{
count=rs.getInt(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if(count==0)
{
errCode="VMFENTY1";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
if(childNodeName.equalsIgnoreCase("prd_code__from"))
{
prdCodeFrm=e12genericUtility.getColumnValue("prd_code__from", currFormDataDom);
if (prdCodeFrm!=null)
{
if(!"0".equalsIgnoreCase(prdCodeFrm.trim()))
{
String sql1="Select count(*) FROM period_stat WHERE PRD_CODE= ?";
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, prdCodeFrm);
rs=pstmt.executeQuery();
if(rs.next())
{
count=rs.getInt(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if(count==0)
{
errCode="CNDIPRDINV";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
}
if(childNodeName.equalsIgnoreCase("prd_code__to"))
{
prdCodeTo=e12genericUtility.getColumnValue("prd_code__to", currFormDataDom);
String sql1="Select count(*) FROM period_stat WHERE PRD_CODE= ?";
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, prdCodeTo);
rs=pstmt.executeQuery();
if(rs.next())
{
count=rs.getInt(1);
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if(count==0)
{
errCode="CNDIPRDINV";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
System.out.println("errString["+errString+"]");
break;
}
case 2:
{
System.out.println("errString["+errString+"]");
break;
}
}
int errListSize = errList.size();
cnt =0;
String errFldName = null;
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 );
errorType = errorType( conn, errCode );
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);
System.out.println("errStringXml .........."+errStringXml);
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)
{
System.out.println("PeriodStatUpdWiz.wfValData()");
e.printStackTrace();
}
return errStringXml.toString();
}
@Override
public String handleRequest(HashMap<String, String> reqParamMap)
{
String action = "", retXMLStr = "";
try
{
action = (String)reqParamMap.get("action");
if("ITEM_CHANGE".equalsIgnoreCase(action))
{
String currXmlDataStr = "", hdrXmlDataStr = "", allXmlDataStr = "", currentColumn = "", objContext = "", editFlag = "";
currXmlDataStr = (String)reqParamMap.get("CUR_XML_STR");
hdrXmlDataStr = (String)reqParamMap.get("HDR_XML_STR");
allXmlDataStr = (String)reqParamMap.get("ALL_XML_STR");
currentColumn = (String)reqParamMap.get("CUR_COLUMN");
objContext = (String)reqParamMap.get("OBJ_CONTEXT");
editFlag = (String)reqParamMap.get("EDIT_FLAG");
retXMLStr = itemChanged(currXmlDataStr, hdrXmlDataStr, allXmlDataStr, objContext, currentColumn, editFlag, globalXtraParams);
System.out.println("retXMLStr["+retXMLStr+"] for action ["+action+"]");
}
else if("DELETE".equalsIgnoreCase(action))
{
}
}
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.handleRequest()"+e.getMessage());
e.printStackTrace();
}
return retXMLStr;
}
private static String checkNull(String input)
{
if (input==null)
{
input="";
}
return input;
}
public InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("PeriodStatUpdWiz.getInitialContext()");
throw itme;
}
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.getInitialContext()"+e.getMessage());
throw new ITMException(e);
}
return ctx;
}
public String getValue(String lineItemStr, String column) throws ITMException
{
String retValue = "";
Document lineDom = null;
try
{
lineDom =new E12GenericUtility().parseString("<detail>"+lineItemStr+"</detail>");
retValue = lineDom.getElementsByTagName(column).item(0).getTextContent();
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return retValue;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
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, checkNull(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;
}
}
\ No newline at end of file
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