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;
}
}
This diff is collapsed.
/**
* 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