Commit d80145b8 authored by msingh's avatar msingh

Change by Manish on 28/11/16 for Attribute Details Wizard.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104053 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d8738afb
/*
* Author:Nasruddin Khan
* Date:19-OCT-2016
* Request ID: (ItemAttribWizBean Wizard)
*/
package ibase.webitm.bean.wms;
import java.io.File;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.wms.ItemTypeWizEJBLocal;
import ibase.webitm.utility.ITMException;
import javax.naming.InitialContext;
import javax.servlet.http.HttpSession;
public class ItemTypeWizBean
{
E12GenericUtility genericUtility = new E12GenericUtility();
private ibase.utility.UserInfoBean userInfo = null;
private HttpSession sessionCtx = null;
private String objName = "";
private String user_lang = "en";
private String user_country = "US";
public ItemTypeWizBean( String objName, HttpSession sessionCtx) throws ITMException
{
try
{
this.objName = objName;
this.sessionCtx = sessionCtx;
this.userInfo = ( ibase.utility.UserInfoBean ) this.sessionCtx.getAttribute("USER_INFO");
}
catch (Exception e)
{
throw new ITMException(e);
}
}
public ItemTypeWizBean()
{
}
public String getList( String loginCode, String field, String[] values ) throws ITMException
{
System.out.println("loginCode in getList =["+loginCode+"]");
String itemTypeList = "";
ItemTypeWizEJBLocal attribWizEJBLocal = null;
try
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
attribWizEJBLocal = (ItemTypeWizEJBLocal)ctx.lookup("ibase/ItemTypeWizEJB/local");
itemTypeList = attribWizEJBLocal.getList(loginCode, field, values);
String xslFileName = getXSLFileName( "item_type_List_wiz_" + this.user_lang + "_" + this.user_country + ".xsl" );
itemTypeList = (genericUtility).transformToString( xslFileName, itemTypeList, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
}
catch (Exception e)
{
throw new ITMException(e);
}
finally
{
if ( attribWizEJBLocal != null )
{
attribWizEJBLocal = null;
}
}
return itemTypeList;
}
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;
}
public String previousForm( String formNo, String xmlData ) throws ITMException
{
String retHtmlData = null;
try
{
System.out.println("In Method : [previousForm]"+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);
}
finally
{
}
return retHtmlData;
}
}
/**
* PURPOSE : ItemAttribWizEJB component
* AUTHOR : Nasruddin Khan
* DATE : 19-10-16
*/
package ibase.webitm.ejb.wms;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.ArrayList;
import org.w3c.dom.*;
@javax.ejb.Stateless
public class ItemTypeWizEJB extends ValidatorEJB implements ItemTypeWizEJBLocal,ItemTypeWizEJBRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
CommonConstants commonConstants = new CommonConstants();
String globalXtraParams = null;
public String wfValData() throws RemoteException, ITMException
{
return "";
}
@Override
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
try
{
System.out.println( "xmlString ::" + xmlString);
System.out.println( "xmlString1 ::" + xmlString1);
System.out.println( "xmlString2 ::" + xmlString2);
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);
}
errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println( "ErrString: " + errString);
}
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return (errString);
}
@Override
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
/*NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String userId = "", errorType = "", errCode = "", errString = "", childNodeName = "";
int currentFormNo = 0, cnt = 0, childNodeListLength = 0, ctr = 0;
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String> errFields = new ArrayList <String> ();
try
{
conn = getConnection();
System.out.println("xtraParam----->>["+xtraParams+"]");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch ( currentFormNo )
{
case 1:
System.out.println("------in detail1 validation----------------");
parentNodeList = dom.getElementsByTagName("Detail1");
System.out.println("===INSIDE HERE");
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("value of child node name ["+childNodeName + "]");
if("category_code".equalsIgnoreCase(childNodeName))
{
}
}
break;
case 2:
{
System.out.println("CASE 2 CALL");
}
break;
}//End of switch statement
System.out.println("eND SWITCH");
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( "" );
}
System.out.println("return xml [" + errStringXml + "]");
errString = errStringXml.toString();
}
catch ( Exception e )
{
System.out.println ( "Exception: ItemAttribWizEJB: wfValData( Document currFormDataDom ): " + e.getMessage() + ":" );
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println( "Exception : ItemAttribWizEJB:wfValData : " + e.getMessage() );
throw new ITMException(e);
}
}
System.out.println( "errString>>>>>>>::" + errString );*/
return "";
}
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, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
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;
}
@Override
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
@Override
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document currFormDataDom = null;
Document hdrDataDom = null;
Document allFormDataDom = null;
String errString = null;
System.out.println("xmlString in itemChanged ["+xmlString+"]");
System.out.println("xmlString1 in itemChanged ["+xmlString1+"]");
System.out.println("xmlString2 in itemChanged ["+xmlString2+"]");
try
{
if (xmlString != null && xmlString.trim().length()!=0)
{
currFormDataDom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
hdrDataDom = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
allFormDataDom = genericUtility.parseString(xmlString2);
}
System.out.println ( "Calling itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams )");
errString = itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch (Exception e)
{
System.out.println ( "Exception : ItemAttribWizEJB:itemChanged(String,String):" + e.getMessage() + ":" );
throw new ITMException(e);
}
System.out.println ( "returning from ItemAttribWizEJB itemChanged \n[" + errString + "]" );
return errString;
}
@Override
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
Connection conn = null;
int currentFormNo = 0;
StringBuffer valueXmlString;
String sql = "", loginSiteCode = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
globalXtraParams = xtraParams;
System.out.println("xtraParams=["+xtraParams+"] globalXtraParams["+globalXtraParams+"]");
System.out.println("ItemAttribWizEJB itemChanged Called........................... : ["+currentColumn+"]");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>").append(editFlag);
try
{
System.out.println("<<========= Inside itemChanged ===========>>"); // remove
System.out.println("hdrDataDom------->>["+genericUtility.serializeDom(dom)+"]");
System.out.println("currFormDataDom------>>["+genericUtility.serializeDom(dom1)+"]");
System.out.println("allFormDataDom------>>["+genericUtility.serializeDom(dom2)+"]");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
conn = getConnection();
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("current form no["+currentFormNo+"]");
valueXmlString.append("</editFlag>\r\n</Header>\r\n");
switch ( currentFormNo )
{
case 1:
{
System.out.println("<<------------------- Inside case1 itemChanged ItemAttribWizEjb -------------------->>");
valueXmlString.append("<Detail1 domID='1' selected = 'N'>\r\n");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
// valueXmlString.append("<site_code>").append("<![CDATA["+loginSiteCode+"]]>").append("</site_code>\r\n");
valueXmlString.append("<item_type>").append("<![CDATA[]]>").append("</item_type>\r\n");
valueXmlString.append("<phy_attrib_2>").append("<![CDATA[]]>").append("</phy_attrib_2>\r\n");
valueXmlString.append("<phy_attrib_1>").append("<![CDATA[]]>").append("</phy_attrib_1>\r\n");
valueXmlString.append("<phy_attrib_3>").append("<![CDATA[]]>").append("</phy_attrib_3>\r\n");
valueXmlString.append("<phy_attrib_8>").append("<![CDATA[]]>").append("</phy_attrib_8>\r\n");
valueXmlString.append("<phy_attrib_9>").append("<![CDATA[]]>").append("</phy_attrib_9>\r\n");
}
valueXmlString.append("</Detail1>\r\n");
} //Case 1. End
break;
case 2:
{
// String siteCode = checkNullAndTrim(genericUtility.getColumnValue("site_code", dom1));
String itemType = checkNullAndTrim(genericUtility.getColumnValue("item_type", dom1));
String size = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_1", dom1));
String color = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_2", dom1));
String dimension = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_3", dom1));
String fabric = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_8", dom1));
String sleeve = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_9", dom1));
int domID = 0;
valueXmlString.append("<Detail2 domID = '"+domID+"' selected = 'N'>\r\n");
// valueXmlString.append("<site_code>").append("<![CDATA["+siteCode+"]]>").append("</site_code>\r\n");
valueXmlString.append("<item_type>").append("<![CDATA["+itemType+"]]>").append("</item_type>\r\n");
valueXmlString.append("<phy_attrib_2>").append("<![CDATA["+color+"]]>").append("</phy_attrib_2>\r\n");
valueXmlString.append("<phy_attrib_1>").append("<![CDATA["+size+"]]>").append("</phy_attrib_1>\r\n");
valueXmlString.append("<phy_attrib_3>").append("<![CDATA["+dimension+"]]>").append("</phy_attrib_3>\r\n");
valueXmlString.append("<phy_attrib_8>").append("<![CDATA["+fabric+"]]>").append("</phy_attrib_8>\r\n");
valueXmlString.append("<phy_attrib_9>").append("<![CDATA["+sleeve+"]]>").append("</phy_attrib_9>\r\n");
valueXmlString.append("</Detail2>\r\n");
String attribId = "", descr = "", shDescr = "", active = "", sortOrd = "";
System.out.println("<<------------------- Inside case2 itemChanged ItemAttribWizEjb-------------------->>");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
sql = "SELECT A.ATTRIB_ID, A.DESCR, A.SH_DESCR, A.ACTIVE_YN, A.SORT_ORDER FROM ITM_ATTRIB_VAL A, ITEM_TYPE B " +
" WHERE UPPER(A.ATTRIB_CODE) = UPPER(B.PHY_ATTRIB_2) AND UPPER(A.ATTRIB_CODE) = UPPER(?) AND UPPER(B.ITEM_TYPE) = UPPER(?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,color);
pstmt.setString(2,itemType);
rs = pstmt.executeQuery();
while(rs.next())
{
domID++;
attribId = checkNullAndTrim(rs.getString("ATTRIB_ID"));
descr = rs.getString("DESCR");
shDescr = rs.getString("SH_DESCR");
active = checkNullAndTrim(rs.getString("ACTIVE_YN"));
sortOrd = checkNullAndTrim(rs.getString("SORT_ORDER"));
valueXmlString.append("<Detail2 domID = '"+domID+"' selected = 'N'>\r\n");
valueXmlString.append("<attrib_id>").append("<![CDATA["+ attribId +"]]>").append("</attrib_id>\r\n");
valueXmlString.append("<descr>").append("<![CDATA["+ descr +"]]>").append("</descr>\r\n");
valueXmlString.append("<sh_descr>").append("<![CDATA["+ shDescr +"]]>").append("</sh_descr>\r\n");
valueXmlString.append("<active_yn>").append("<![CDATA["+ active +"]]>").append("</active_yn>\r\n");
valueXmlString.append("<sort_order>").append("<![CDATA["+ sortOrd +"]]>").append("</sort_order>\r\n");
valueXmlString.append("</Detail2>\r\n");
}
}
} //Case 2. End
break;
case 3:
{
String itemType = checkNullAndTrim(genericUtility.getColumnValue("item_type", dom1));
String size = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_1", dom1));
String color = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_2", dom1));
String dimension = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_3", dom1));
String fabric = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_8", dom1));
String sleeve = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_9", dom1));
int domID = 0;
valueXmlString.append("<Detail3 domID = '"+domID+"' selected = 'N'>\r\n");
valueXmlString.append("<item_type>").append("<![CDATA["+itemType+"]]>").append("</item_type>\r\n");
valueXmlString.append("<phy_attrib_2>").append("<![CDATA["+color+"]]>").append("</phy_attrib_2>\r\n");
valueXmlString.append("<phy_attrib_1>").append("<![CDATA["+size+"]]>").append("</phy_attrib_1>\r\n");
valueXmlString.append("<phy_attrib_3>").append("<![CDATA["+dimension+"]]>").append("</phy_attrib_3>\r\n");
valueXmlString.append("<phy_attrib_8>").append("<![CDATA["+fabric+"]]>").append("</phy_attrib_8>\r\n");
valueXmlString.append("<phy_attrib_9>").append("<![CDATA["+sleeve+"]]>").append("</phy_attrib_9>\r\n");
valueXmlString.append("</Detail3>\r\n");
String attribId = "", descr = "", shDescr = "", active = "", sortOrd = "";
System.out.println("<<------------------- Inside case3 itemChanged ItemAttribWizEjb-------------------->>");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
sql = "SELECT A.ATTRIB_ID, A.DESCR, A.SH_DESCR, A.ACTIVE_YN, A.SORT_ORDER FROM ITM_ATTRIB_VAL A, ITEM_TYPE B " +
" WHERE UPPER(A.ATTRIB_CODE) = UPPER(B.PHY_ATTRIB_1) AND UPPER(A.ATTRIB_CODE) = UPPER(?) AND UPPER(B.ITEM_TYPE) = UPPER(?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,size);
pstmt.setString(2,itemType);
rs = pstmt.executeQuery();
while(rs.next())
{
domID++;
attribId = checkNullAndTrim(rs.getString("ATTRIB_ID"));
descr = rs.getString("DESCR");
shDescr = rs.getString("SH_DESCR");
active = checkNullAndTrim(rs.getString("ACTIVE_YN"));
sortOrd = checkNullAndTrim(rs.getString("SORT_ORDER"));
valueXmlString.append("<Detail3 domID = '"+domID+"' selected = 'N'>\r\n");
valueXmlString.append("<attrib_id>").append("<![CDATA["+ attribId +"]]>").append("</attrib_id>\r\n");
valueXmlString.append("<descr>").append("<![CDATA["+ descr +"]]>").append("</descr>\r\n");
valueXmlString.append("<sh_descr>").append("<![CDATA["+ shDescr +"]]>").append("</sh_descr>\r\n");
valueXmlString.append("<active_yn>").append("<![CDATA["+ active +"]]>").append("</active_yn>\r\n");
valueXmlString.append("<sort_order>").append("<![CDATA["+ sortOrd +"]]>").append("</sort_order>\r\n");
valueXmlString.append("</Detail3>\r\n");
}
}
} //Case 3. End
break;
case 4:
{
String itemType = checkNullAndTrim(genericUtility.getColumnValue("item_type", dom1));
String size = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_1", dom1));
String color = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_2", dom1));
String dimension = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_3", dom1));
String fabric = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_8", dom1));
String sleeve = checkNullAndTrim(genericUtility.getColumnValue("phy_attrib_9", dom1));
int domID = 0;
valueXmlString.append("<Detail4 domID = '"+domID+"' selected = 'N'>\r\n");
valueXmlString.append("<item_type>").append("<![CDATA["+itemType+"]]>").append("</item_type>\r\n");
valueXmlString.append("<phy_attrib_2>").append("<![CDATA["+color+"]]>").append("</phy_attrib_2>\r\n");
valueXmlString.append("<phy_attrib_1>").append("<![CDATA["+size+"]]>").append("</phy_attrib_1>\r\n");
valueXmlString.append("<phy_attrib_3>").append("<![CDATA["+dimension+"]]>").append("</phy_attrib_3>\r\n");
valueXmlString.append("<phy_attrib_8>").append("<![CDATA["+fabric+"]]>").append("</phy_attrib_8>\r\n");
valueXmlString.append("<phy_attrib_9>").append("<![CDATA["+sleeve+"]]>").append("</phy_attrib_9>\r\n");
valueXmlString.append("</Detail4>\r\n");
String attribId = "", descr = "", shDescr = "", active = "", sortOrd = "";
System.out.println("<<------------------- Inside case4 itemChanged ItemAttribWizEjb-------------------->>");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
sql = "SELECT A.ATTRIB_ID, A.DESCR, A.SH_DESCR, A.ACTIVE_YN, A.SORT_ORDER FROM ITM_ATTRIB_VAL A, ITEM_TYPE B " +
" WHERE UPPER(A.ATTRIB_CODE) = UPPER(B.PHY_ATTRIB_3) AND UPPER(A.ATTRIB_CODE) = UPPER(?) AND UPPER(B.ITEM_TYPE) = UPPER(?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,dimension);
pstmt.setString(2,itemType);
rs = pstmt.executeQuery();
while(rs.next())
{
domID++;
attribId = checkNullAndTrim(rs.getString("ATTRIB_ID"));
descr = rs.getString("DESCR");
shDescr = rs.getString("SH_DESCR");
active = checkNullAndTrim(rs.getString("ACTIVE_YN"));
sortOrd = checkNullAndTrim(rs.getString("SORT_ORDER"));
valueXmlString.append("<Detail4 domID = '"+domID+"' selected = 'N'>\r\n");
valueXmlString.append("<attrib_id>").append("<![CDATA["+ attribId +"]]>").append("</attrib_id>\r\n");
valueXmlString.append("<descr>").append("<![CDATA["+ descr +"]]>").append("</descr>\r\n");
valueXmlString.append("<sh_descr>").append("<![CDATA["+ shDescr +"]]>").append("</sh_descr>\r\n");
valueXmlString.append("<active_yn>").append("<![CDATA["+ active +"]]>").append("</active_yn>\r\n");
valueXmlString.append("<sort_order>").append("<![CDATA["+ sortOrd +"]]>").append("</sort_order>\r\n");
valueXmlString.append("</Detail4>\r\n");
}
}
} //Case 3. End
break;
}//End of switch block
valueXmlString.append( "</Root>\r\n" );
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if ( conn != null )
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println( "valueXmlString.toString()>>>>>>>::"+valueXmlString.toString());
return valueXmlString.toString();
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input.trim();
}
public String getList(String loginCode, String field, String[] values) throws RemoteException, ITMException
{
String sql = "";
StringBuffer valueXmlString = new StringBuffer("<?xml version = \"1.0\" encoding = \"UTF-8\"?> \r\n <Root>\r\n");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("Inside getList---->loginCode["+loginCode+"]FIeld["+field+"]Values["+values+"]");
if (field.equals("item_type"))
{
sql="SELECT ITEM_TYPE, DESCR FROM ITEM_TYPE ";
}
conn = getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int num = 1;
while (rs.next())
{
String fieldId = checkNull(rs.getString(1));
String fieldValue = checkNull(rs.getString(2));
String otherField = "";
valueXmlString.append("<PROD_TYPE domID='" + num + "' selected = '" + useLoop(values, fieldId) + "'>\r\n");
valueXmlString.append("<fieldId><![CDATA[").append(fieldId).append("]]></fieldId>\r\n");
valueXmlString.append("<fieldValue><![CDATA[").append(fieldValue).append("]]></fieldValue>\r\n");
valueXmlString.append("<otherField><![CDATA[").append(otherField).append("]]></otherField>\r\n");
valueXmlString.append("</PROD_TYPE>\r\n");
num++;
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("ItemTypeWizEJB.getList()["+ e.getMessage() +"]");
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (conn != null && !conn.isClosed())
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("Exception :ITMWizardStatefulEJB :getProdTypeList(String) :==>\n"+ e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
System.out.println("\n****ValueXmlString :" + valueXmlString.toString() + ":********");
return valueXmlString.toString();
}
public static String useLoop(String[] arr, String targetValue)
{
for(String s: arr)
{
String str = s == null?"":s.trim();
if(str.equals(targetValue))
return "Y";
}
return "N";
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
public String insertItmattVal( String attCode, String attId,String desc,String shDesc,String active,String sortOrder,String editFlag)throws RemoteException,ITMException
{
String sql = "",errString = "",userId = "",chgTerm = "";
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
Timestamp currDate = null;
boolean isErrorInsert = false;
Connection tempConn = getConnection();
int count = 0;
int insertCnt = 0;
try
{
userId = genericUtility.getValueFromXTRA_PARAMS( globalXtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( globalXtraParams, "chgTerm" );
currDate = getCurrtDate();
System.out.println("ATTRIB_CODE["+attCode+"] ATTRIB_ID["+attId+"]");
sql = " SELECT COUNT(1) FROM ITM_ATTRIB_VAL WHERE ATTRIB_CODE = ? AND ATTRIB_ID = ? " ;
pstmt1 = tempConn.prepareStatement(sql);
pstmt1.setString(1,attCode);
pstmt1.setString(2,attId);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
count = rs1.getInt(1);
}
if(rs1 != null)
{
rs1.close();rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close();pstmt1 = null;
}
System.out.println("editFlag["+editFlag+"]");
if("A".equalsIgnoreCase(editFlag))
{
if(count>0)
{
System.out.println("===RECORD ALREADY EXIST========");
errString = "0";
}
else
{
sql = " INSERT INTO ITM_ATTRIB_VAL (ATTRIB_CODE,ATTRIB_ID,DESCR,SH_DESCR,ACTIVE_YN,SORT_ORDER,CHG_USER,CHG_DATE,CHG_TERM ) "
+ " VALUES (?,?,?,?,?,?,?,?,?) ";
pstmt = tempConn.prepareStatement(sql);
pstmt.setString(1,attCode);
pstmt.setString(2,attId);
pstmt.setString(3,desc);
pstmt.setString(4,shDesc);
pstmt.setString(5,active);
pstmt.setString(6,sortOrder);
pstmt.setString(7,userId);
pstmt.setTimestamp(8,currDate);
pstmt.setString(9,chgTerm);
insertCnt = pstmt.executeUpdate();
System.out.println("number of insert in porder : "+insertCnt);
errString = "1";
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
}
else
{
sql = " UPDATE ITM_ATTRIB_VAL SET DESCR = ?,SH_DESCR = ?,ACTIVE_YN = ?,SORT_ORDER = ? WHERE ATTRIB_CODE = ? AND ATTRIB_ID = ? " ;
pstmt1 = tempConn.prepareStatement(sql);
pstmt1.setString(1,desc);
pstmt1.setString(2,shDesc);
pstmt1.setString(3,active);
pstmt1.setString(4,sortOrder);
pstmt1.setString(5,attCode);
pstmt1.setString(6,attId);
insertCnt = pstmt1.executeUpdate();
System.out.println("number of insert in porder : "+insertCnt);
errString = "1";
}
}
catch(Exception e)
{
System.out.println("error in insert data");
isErrorInsert = true;
e.printStackTrace();
}
finally
{
try
{
if(isErrorInsert)
{
tempConn.rollback();
}
else
{
tempConn.commit();
}
if(tempConn != null)
{
tempConn.close();tempConn = null;
}
if(pstmt != null)
{
pstmt.close();pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return errString;
}
private java.sql.Timestamp getCurrtDate() throws RemoteException,ITMException
{
String currAppdate = "";
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString()+ " 00:00:00.0");
}
catch (Exception e)
{
throw new ITMException(e);
}
return (currDate);
}
public String getAttribute(String itemType) throws RemoteException,ITMException
{
String sql = "", att1 = "", att2 = "", att3 = "", att4 = "", att5 = "", attribute = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection tempConn = getConnection();
try
{
sql = "SELECT PHY_ATTRIB_1, PHY_ATTRIB_2, PHY_ATTRIB_3, PHY_ATTRIB_8, PHY_ATTRIB_9 FROM ITEM_TYPE WHERE ITEM_TYPE = ? " ;
pstmt = tempConn.prepareStatement(sql);
pstmt.setString(1,itemType);
rs = pstmt.executeQuery();
if(rs.next())
{
att1 = checkNull(rs.getString("PHY_ATTRIB_2"));
att2 = checkNull(rs.getString("PHY_ATTRIB_1"));
att3 = checkNull(rs.getString("PHY_ATTRIB_3"));
att4 = checkNull(rs.getString("PHY_ATTRIB_8"));
att5 = checkNull(rs.getString("PHY_ATTRIB_9"));
}
rs.close(); rs =null;
pstmt.close(); pstmt = null;
tempConn.close(); tempConn = null;
attribute = att1+":"+att2+":"+att3+":"+att4+":"+att5;
}
catch(Exception e)
{
e.printStackTrace();
}
return attribute;
}
}
/**
* PURPOSE : Local Interface for ItemAttribWizEJB component
* AUTHOR : Nasruddin Khan
* DATE : 19-10-16
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import org.w3c.dom.*;
@javax.ejb.Local
public interface ItemTypeWizEJBLocal extends ValidatorLocal
{
public String wfValData() 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 itemChanged() 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 currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException, ITMException;
public String getList(String loginCode, String field, String[] values) throws RemoteException,ITMException;
public String insertItmattVal( String attCode, String attId,String desc,String shDesc,String active,String sortOrder,String editFlag)throws RemoteException,ITMException;
public String getAttribute(String itemType) throws RemoteException,ITMException;
}
/**
* PURPOSE : Remote Interface for ItemAttribWizEJB component
* AUTHOR : Nasruddin Khan
* DATE : 19-10-16
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface ItemTypeWizEJBRemote extends ValidatorRemote
{
public String wfValData() 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 itemChanged() 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 currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException, ITMException;
public String getList(String loginCode, String field, String[] values) throws RemoteException,ITMException;
public String insertItmattVal( String attCode, String attId,String desc,String shDesc,String active,String sortOrder,String editFlag)throws RemoteException,ITMException;
public String getAttribute(String itemType) throws RemoteException,ITMException;
}
/*
* Author:Nasruddin
* Date:21-10-2016
*/
package ibase.webitm.ejb.wms;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Session Bean implementation class EtaWizardPosEJB
*/
@Stateless
public class ItemTypeWizPosEJB extends ValidatorEJB implements ItemTypeWizPosEJBRemote,ItemTypeWizPosEJBLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
MasterStatefulLocal masterStatefulLocal = null;
DistCommon distComm = new DistCommon();
/**
* Default constructor.
*/
public ItemTypeWizPosEJB() {
// 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 conn1) throws RemoteException,ITMException
{
System.out.println("Inside ItemAttribPosEJB Post Save");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "",retString = "";
boolean isError = false;
Document dom = null;
String attribCode = "",attribId = "",active = "", descr = "", shDescr = "",
chgTerm = "",loginSiteCode = "" , groupType = "";
Timestamp currDate = null;
Connection conn = null;
int sortOrder = 0;
try
{
if(xmlstring != null && (xmlstring.indexOf("Detail2") != -1))
{
dom = genericUtility.parseString(xmlstring);
System.out.println("hdrDataDom inside post save>>["+genericUtility.serializeDom(dom)+"]");
currDate = getCurrtDate();
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
NodeList detail2NodeList = dom.getElementsByTagName("Detail2");
int detail2NodeListlen = detail2NodeList.getLength();
for(int ctrH = 0; ctrH < detail2NodeListlen ; 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 || childNode.getNodeType() != Node.ELEMENT_NODE)
{
continue;
}
if(childNode != null && "attrib_code".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
attribCode = childNode.getFirstChild().getNodeValue();
}
else if(childNode != null && "attrib_id".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
attribId = childNode.getFirstChild().getNodeValue();
}
else if(childNode != null && "descr".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
descr = childNode.getFirstChild().getNodeValue();
}
else if(childNode != null && "sh_descr".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
shDescr = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
}
else if(childNode != null && "active_yn".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
active = childNode.getFirstChild().getNodeValue();
}
else if(childNode != null && "sort_order".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
sortOrder = Integer.parseInt(childNode.getFirstChild().getNodeValue());
}
else if(childNode != null && "group_type".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
groupType = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
}
}
}
System.out.println("attribCode ["+attribCode+"]\n sortOrder ["+ sortOrder + "]\n ");
System.out.println(" current date ["+ currDate+"]\n change Term \n["+ chgTerm +"] groupType ["+ groupType);
sql = "INSERT INTO ITM_ATTRIB_VAL (ATTRIB_CODE, ATTRIB_ID, DESCR, SH_DESCR, ACTIVE_YN, SORT_ORDER, CHG_USER, CHG_DATE, CHG_TERM) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if(conn == null)
{
System.out.println("Connection is null");
conn = getConnection();
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, attribCode);
pstmt.setString(2, attribId);
pstmt.setString(3, descr);
pstmt.setString(4, shDescr);
pstmt.setString(5, active);
pstmt.setInt(6, sortOrder);
pstmt.setString(7, loginSiteCode);
pstmt.setTimestamp(8, currDate);
pstmt.setString(9, chgTerm);
int record = pstmt.executeUpdate();
System.out.println("record ["+ record + "]");
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( groupType.length() > 0)
{
String[] groupList = groupType.split(",");
for(String attributeCode : groupList)
{
System.out.println("attributeCode["+attributeCode+"]");
sql = "INSERT INTO ITM_ATTRIB_VAL (ATTRIB_CODE, ATTRIB_ID, DESCR, SH_DESCR, ACTIVE_YN, SORT_ORDER, CHG_USER, CHG_DATE, CHG_TERM) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, attributeCode.trim());
pstmt.setString(2, attribId);
pstmt.setString(3, descr);
pstmt.setString(4, shDescr);
pstmt.setString(5, active);
pstmt.setInt(6, sortOrder);
pstmt.setString(7, loginSiteCode);
pstmt.setTimestamp(8, currDate);
pstmt.setString(9, chgTerm);
record = pstmt.executeUpdate();
System.out.println("record groupType ["+ record + "]");
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
}
}
catch(Exception e)
{
isError = true;
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(isError)
{
conn.rollback();
}
else
{
System.out.println("Inside committing....");
conn.commit();
}
if ( rs != null )
{
rs.close();rs = null;
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
}
catch( Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("ItemAttribPosEJB.postSave() ["+retString);
return retString;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
private java.sql.Timestamp getCurrtDate() throws RemoteException,ITMException
{
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString()+ " 00:00:00.0");
}
catch (Exception e)
{
throw new ITMException(e);
}
return (currDate);
}
}
/*
* Author:Nasruddin
* Date:21-10-2016
*/
package ibase.webitm.ejb.wms;
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 ItemTypeWizPosEJBLocal extends ValidatorLocal
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
/*
* Author:Nasruddin khan
* Date:21-10-2016
*
*/
package ibase.webitm.ejb.wms;
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 ItemTypeWizPosEJBRemote extends ValidatorRemote
{
public String postSave(String xmlStringAll, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.servlet.wms;
import ibase.system.config.AppConnectParm;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.wms.ItemTypeWizEJB;
import ibase.webitm.ejb.wms.ItemTypeWizEJBRemote;
import ibase.webitm.servlet.Messages;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
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;
public class ItemTypeWizServlet extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = 1L;
InitialContext ctx = null;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doPost( request, response );
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
try
{
System.out.println("XXXXXXXXXXXXXXXXXXXXXX[ ItemTypeWizServlet ]XXXXXXXXXXXXXXXXXXXX");
request.setCharacterEncoding(CommonConstants.ENCODING);
ItemTypeWizEJBRemote itemTypeWizEJBRemote = null;
String htmlData = ""; //$NON-NLS-1$
String retStr = "";
String actionPrint = request.getParameter("ACTION");
System.out.println("ItemTypeWizServlet ACTION ["+actionPrint+"]");
ctx = getInitialContext();
itemTypeWizEJBRemote = (ibase.webitm.ejb.wms.ItemTypeWizEJBRemote) ctx.lookup("ibase/ItemTypeWizEJB/remote");
if("SAVE".equalsIgnoreCase(actionPrint))
{
String attCode = checkNullAndTrim(request.getParameter("attrib_code"));
String attId = checkNullAndTrim(request.getParameter("attrib_id"));
String desc = checkNullAndTrim(request.getParameter("descr"));
String shDesc = checkNullAndTrim(request.getParameter("sh_descr"));
String active = checkNullAndTrim(request.getParameter("active_yn"));
String sortOrder = checkNullAndTrim(request.getParameter("sort_order"));
String editFlag = checkNullAndTrim(request.getParameter("editflag"));
retStr = itemTypeWizEJBRemote.insertItmattVal(attCode,attId,desc,shDesc,active,sortOrder,editFlag);
System.out.println("retStr ====>> ["+retStr+"]");
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(retStr.toString().getBytes());
gzOutStream.flush();
gzOutStream.close();
}
else
{
response.setHeader("Content-Encoding", "");
OutputStream outStream = response.getOutputStream();
outStream.write(retStr.toString().getBytes());
outStream.flush();
outStream.close();
}
}
else if("ITEMCHANGE".equalsIgnoreCase(actionPrint))
{
String itemType = checkNullAndTrim(request.getParameter("ITEM_TYPE"));
retStr = itemTypeWizEJBRemote.getAttribute(itemType);
System.out.println("retStr ====>> ["+retStr+"]");
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(retStr.toString().getBytes());
gzOutStream.flush();
gzOutStream.close();
}
else
{
response.setHeader("Content-Encoding", "");
OutputStream outStream = response.getOutputStream();
outStream.write(retStr.toString().getBytes());
outStream.flush();
outStream.close();
}
}
else
{
ibase.utility.UserInfoBean userInfo = ( ibase.utility.UserInfoBean )request.getSession().getAttribute( "USER_INFO" ); //$NON-NLS-1$
if(userInfo != null)
{
String objName = request.getParameter("OBJ_NAME");//Storing ObjectName //$NON-NLS-1$
String formNo = request.getParameter("FORM_NO");//Storing Current FormNo //$NON-NLS-1$
String action = request.getParameter("action");//Which actions is performed e.g. 'Next','Previous','Finish' //$NON-NLS-1$
String preFormVal = request.getParameter("PRE_FORM_VAL");
System.out.println("preFormVal==========["+preFormVal+"]");
String editorId = (String) request.getSession().getAttribute( "WIZARD_BEAN_ID_" + objName );
System.out.println(" ITMWizardHandlerServlet :: editorId["+editorId+"]" );
if (request.getSession().getAttribute("WIZARD_BEAN_" + editorId) != null)
{
System.out.println(" Wizard Object Found ");
if ("previous".equalsIgnoreCase(action) && "2".equalsIgnoreCase(formNo))
{
response.sendRedirect("/ibase/webitm/jsp/ItemTypeWiz.jsp?OBJ_NAME=" + objName + "&PRE_FORM_VAL=" + preFormVal);
}
}
}
else
{
htmlData = Messages.getString("ITMWizardHandlerServlet_notLoggedIn")+"\n"+Messages.getString("ITMWizardHandlerServlet_pleaseReLogin"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
}
catch (Exception e) {
// TODO: handle exception
}
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
protected InitialContext getInitialContext()throws ITMException
{
InitialContext ctx = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
}
catch(ITMException itme)
{
System.out.println("CrossDockAllocServlet.getInitialContext()");
throw itme;
}
catch(Exception e)
{
System.out.println("CrossDockAllocServlet.getInitialContext()"+e.getMessage());
throw new ITMException(e);
}
return ctx;
}
}
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