Commit 8378ecf8 authored by smane's avatar smane

Add EJB File for QC Sampling Wizard(M14HFRA001)


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96899 ce508802-f39f-4f6c-b175-0d175dae99d5
parent fea70be3
/********************************************************
Title : QCSampleWizIC[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.mfg.MfgCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.sql.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import ibase.system.config.ConnDriver;
import javax.ejb.Stateless;
@Stateless
public class QCSampleWizIC extends ValidatorEJB implements QCSampleWizICLocal,QCSampleWizICRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
//GenWOIssue genWOIssue =null;
String curTranId = null;
boolean isShortQtyWithinMcVar = false;
double shortQtyActual = 0;
boolean actStkLess = false;
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println(">>>>>>>>>>>>wfValData start>>>>>>>>>>>");
System.out.println(">>>>>>>>>>>>Val xmlString :: " + xmlString );
System.out.println(">>>>>>>>>>>>Val xmlString1 :: " + xmlString1 );
System.out.println(">>>>>>>>>>>>Val xmlString2 :: " + xmlString2 );
System.out.println(">>>>>>>>>>>>wfValData end>>>>>>>>>>>");
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);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
throw new ITMException( e );
}
return (errString);
}
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;
GenericUtility genericUtility = GenericUtility.getInstance();
String childNodeName = null;
String errString = "";
String errCode = "";
Connection conn = null;
//Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null,rs1 = null;
String sql = "";
String userId = "";
String qcOrdNo="",status="";
String itemCode = null,siteCode = null,childNodeValue = null;
int currentFormNo=0,cnt=0,childNodeListLength;
int ctr=0;
String loginSite = "",columnValue="",lotNo ="",lotSl="",locCodeTo="",invStat="",sampleQtyStr="";
double sampleQty=0.0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println(">>>>>>>>>>>>>>>>>>>>In Validation currentFormNo:"+currentFormNo);
switch(currentFormNo)
{
case 1 :
{
parentNodeList = dom.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();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if( childNodeName.equalsIgnoreCase("qc_ord__no"))
{
System.out.println(">>>>>>>>>>>>>>>>Check qc_ord__no Validation:"+childNodeName);
qcOrdNo = getColumnValue("qc_ord__no",dom);
System.out.println(">>>qcOrdNo Validation:" + qcOrdNo);
siteCode = getColumnValue("site_code",dom);
itemCode = getColumnValue("item_code",dom);
lotNo = getColumnValue("lot_no",dom);
if(qcOrdNo != null && qcOrdNo.trim().length() > 0 )
{
sql = "select count(1) from qc_order where qorder_no = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>qorder_no cnt:"+qcOrdNo);
if (cnt == 0)
{
errCode = "VMQCORM"; //error for not exist qc order no in qc_order
errString = getErrorString("qorder_no",errCode,userId);
break;
}
else
{
sql = "select status from qc_order where qorder_no = ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>qorder_no status:"+status);
if ( status != null && status.trim().length() > 0 && status.equalsIgnoreCase("C") )
{
errCode = "VMQCORC"; //error for confirmed qc order no
errString = getErrorString("qorder_no",errCode,userId);
break;
}
}//end else status = C
} //end qorder_no ! null
else
{
errCode = "VTQCNOBLNK"; //error for blank qc order no
errString = getErrorString("qorder_no",errCode,userId);
break;
}
}
} //end for
}//end case 1
break;
case 2 :
{
System.out.println(">>>>>>>>>>>>>>>>>>QCSampleWizIC Validation Call Case 2>>>>>>>>>>>>>>>>>>>>>>");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(">>>>>>>>>childNodeName:"+childNodeName);
if(childNodeName.equalsIgnoreCase("tran_date"))
{
System.out.println(">>>>>>>Validaion for tran_date "+genericUtility.getColumnValue("tran_date", dom));
if(genericUtility.getColumnValue("tran_date", dom) == null)
{
errString = getErrorString("tran_date","VTTRNDTNUL",userId);
break;
}
}
else if(childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
System.out.println(">>>>>>>Validaion for site_code "+siteCode);
if(siteCode==null || siteCode.trim().length() == 0)
{
errString = getErrorString("site_code","VTSITEEMT",userId);
break;
}
else
{
cnt = isValueExist("site","site_code",siteCode, conn);
if(cnt == 0)
{
errString = getErrorString("site_code","VMSITE",userId);
break;
}
}
}
}//END FOR
} //end case 2
break;
case 3 :
{
System.out.println(">>>>>>>>>>>>>>>>>>QCSampleWizIC Validation Call Case 3>>>>>>>>>>>>>>>>>>>>>>");
NodeList parentNodeList1 = dom2.getElementsByTagName("Detail3");
Node parentNode1 = parentNodeList1.item(0);
System.out.println(">>>>>>>>>>parentNode1.getNodeName().length():"+parentNode1.getNodeName().length());
String selectValue = this.getSelectValue(parentNode1);
System.out.println(">>>>>>>>>>>selectValue:"+selectValue);
if("N".equals(selectValue))
{
errCode = "VTINVSCAN";
errString = getErrorString("",errCode,userId);
break;
}
}//case 3 end
break;
case 4 :
{
System.out.println(">>>>>>>>>>>>>>>>>>QCSampleWizIC Validation Call Case 4>>>>>>>>>>>>>>>>>>>>>>");
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNode != null && childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if (childNodeName.equalsIgnoreCase("loc_code__to"))
{
locCodeTo = genericUtility.getColumnValue("loc_code__to", dom);
System.out.println(">>>Scan Input locCodeTo:"+locCodeTo);
if (locCodeTo != null && locCodeTo.trim().length() > 0)
{
sql = " select count(1) cnt from location where loc_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCodeTo);
rs = pstmt.executeQuery();
cnt = 0;
if (rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
errString = getErrorString("loc_code__to","VMINVLOC",userId);
break;
}
else
{
sql = " select inv_stat from location where loc_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCodeTo);
rs = pstmt.executeQuery();
cnt = 0;
if (rs.next())
{
invStat = rs.getString("inv_stat").trim();
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (!("TEST".equalsIgnoreCase(invStat)))
{
errString = getErrorString("loc_code__to","VTINVSTLOC",userId);
break;
}
}
}
else
{
errString = getErrorString("","VTINVSCAN",userId);
break;
}
}
if (childNodeName.equalsIgnoreCase("sample_qty"))
{
sampleQtyStr = genericUtility.getColumnValue("sample_qty", dom);
System.out.println(">>>Scan Input Sample Quantity:"+sampleQtyStr);
if (sampleQtyStr != null && sampleQtyStr.trim().length() > 0)
{
sampleQty= Double.parseDouble(sampleQtyStr);
if( sampleQty == 0 )
{
errCode = "VMQCQTN";
errString = getErrorString("sample_qty",errCode,userId);
break ;
}
if( sampleQty < 0 )
{
errCode = "VMQCQTM";
errString = getErrorString("sample_qty",errCode,userId);
break ;
}
}
}
}
}//case 4 end
}//end catch switch
}//end try
catch(Exception e)
{
e.printStackTrace();
errString=e.getMessage();
throw new ITMException( e );
}
finally
{
try
{
if(conn!=null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt =null;
}
conn.close();
conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
return errString;
}
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
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 valueXmlString = "";
try
{
System.out.println(">>>>>>>>>>>>>>>>In WeighingWizIC itemChanged xmlString>>>>>>>>>>>>>>>>>>");
//genWOIssue = new GenWOIssue();
//dom = parseString(xmlString);
//dom1 = parseString(xmlString1);
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);
}
System.out.println("xml str1 in Detail --->["+xmlString+"]");
System.out.println("xml str2 in Detail --->["+xmlString1+"]");
System.out.println("xml str3 in Detail --->["+xmlString2+"]");
valueXmlString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
//genWOIssue = null;
}
catch(Exception e)
{
System.out.println("Exception : [TrainingEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
throw new ITMException( e );
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null , pstmt1 = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
java.text.SimpleDateFormat sdf = null,sdf1 = null;
java.util.Date currDate = new java.util.Date();
String tranId="", sql = "",qcOrdNo="",locDescr="",loginSite="",refSer="XFRX";
String itemCode = "",siteCode = "",itemDescr = "",currDateStr="";
String lotNo="",locCode="",lotSl="",locCodeFrom="",locDescrFrom="",lotNoFrom="",lotNoTo="",lotSlFrom="",lotSlTo="",locCodeTo="";
String descr = "",unit = "";
String userId = "", termId = "",errCode="",chgTerm="";
int lineNo = 0;
int currentFormNo =0;
int noArt=0,domId=0;
int parentNodeListLength = 0;
double quantity=0.0;
NodeList parentNodeList = null;
Node parentNode = null;
String currAppdate ="";
java.sql.Timestamp sysDate = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println(">>>>>>>>>>>>> itemChanged dom currentColumn:"+currentColumn);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
userId = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" ));
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if (userId == null || userId.trim().length() == 0)
{
userId = "SYSTEM";
}
if (termId == null || termId.trim().length() == 0)
{
termId = "SYSTEM";
}
System.out.println(">>>>>>currentFormNo:"+currentFormNo);
switch(currentFormNo)
{
case 2 :
{
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println(">>>>>>>>>>>>>>>>>>QCSampleWizIC ItemChange Call>>>>>>>>>>>>>>>>>>>>>>");
siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
valueXmlString.append("<Detail2 domID='1' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append("<tran_id/>\r\n");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(sysDate).toString();
valueXmlString.append("<tran_date>").append(currAppdate).append("</tran_date>");
valueXmlString.append("<site_code protect =\"1\">").append(siteCode).append("</site_code>");
if( siteCode != null && siteCode.trim().length() > 0)
{
sql = "Select descr from site where site_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_descr>").append("<![CDATA["+descr.trim()+"]]>").append("</site_descr>");
valueXmlString.append("<ref_ser__for>").append("<![CDATA["+refSer+"]]>").append("</ref_ser__for>");
valueXmlString.append( "<confirmed><![CDATA[" ).append("N").append( "]]></confirmed>\r\n" );
valueXmlString.append( "<chg_user><![CDATA[" ).append( userId ).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append( currAppdate ).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_term><![CDATA[" ).append( chgTerm ).append( "]]></chg_term>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
}
}
break;
case 3:
{
System.out.println(">>>>>>>>>>>case 3 currentColumn:"+currentColumn);
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
qcOrdNo = genericUtility.getColumnValue("qc_ord__no", dom1);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>qcOrdNo dom1:"+qcOrdNo);
qcOrdNo = genericUtility.getColumnValue("qc_ord__no", dom2);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>qcOrdNo dom2:"+qcOrdNo);
siteCode = genericUtility.getColumnValue("site_code", dom2);
System.out.println(">>>>>>>>>dom2 siteCode:"+siteCode);
sql = "select site_code,item_code,lot_no,loc_code from qc_order where qorder_no= ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCode = rs.getString("site_code") == null ? "" : rs.getString("site_code");
itemCode = rs.getString("item_code") == null ? "" : rs.getString("item_code");
lotNo = rs.getString("lot_no") == null ? "" : rs.getString("lot_no");
locCode = rs.getString("loc_code") == null ? "" : rs.getString("loc_code");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>siteCode:"+siteCode);
System.out.println(">>>>>itemCode:"+itemCode);
System.out.println(">>>>>lotNo:"+lotNo);
System.out.println(">>>>>locCode:"+locCode);
sql = " SELECT stock.item_ser,stock.item_code,stock.unit,stock.loc_code,stock.lot_no, stock.lot_sl, "
+ " stock.site_code, stock.exp_date, stock.retest_date, stock.pack_code, stock.quantity - case "
+" when stock.alloc_qty is null then 0 else stock.alloc_qty end as quantity "
+" FROM stock,invstat "
+" WHERE ( stock.inv_stat = invstat.inv_stat ) and "
+" ( stock.item_code = ? ) AND "
+" ( stock.site_code = ?) AND "
+" ( stock.lot_no = ?) AND "
+" ( stock.inv_stat = 'NOSL') AND "
+" ( stock.quantity - case when stock.alloc_qty is null then 0 else stock.alloc_qty end > 0 )"; //Add location Code "QUAR"
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, lotNo);
rs= pstmt.executeQuery();
while(rs.next())
{
locCode= rs.getString("loc_code") == null ? "" : rs.getString("loc_code");
itemCode= rs.getString("item_code") == null ? "" : rs.getString("item_code");
lotNo= rs.getString("lot_no") == null ? "" : rs.getString("lot_no");
lotSl= rs.getString("lot_sl")== null ? "" : rs.getString("lot_sl");
quantity= rs.getDouble("quantity");
unit= rs.getString("unit") == null ? "" : rs.getString("unit");
itemDescr = findValue(conn, "descr", "item", "item_code", itemCode);
locDescr = findValue(conn, "descr", "location", "loc_code", locCode);
System.out.println(">>>>>Display Stock details>>>>>");
domId++;
System.out.println(">>>>>>domId:"+domId);
valueXmlString.append("<Detail3 domID='" + domId + "' selected=\"N\">\r\n");
//valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append("<tran_id/>\r\n");
valueXmlString.append("<line_no><![CDATA[").append(domId).append("]]></line_no>\r\n");
valueXmlString.append("<item_code><![CDATA[").append(checkNull(itemCode)).append("]]></item_code>\r\n");
valueXmlString.append("<item_descr><![CDATA[").append(checkNull(itemDescr)).append("]]></item_descr>\r\n");
valueXmlString.append("<loc_code__fr><![CDATA[").append(checkNull(locCode)).append("]]></loc_code__fr>\r\n");
valueXmlString.append("<loc_descr__fr><![CDATA[").append(checkNull(locDescr)).append("]]></loc_descr__fr>\r\n");
valueXmlString.append("<loc_code__to><![CDATA[").append("").append("]]></loc_code__to>\r\n");
valueXmlString.append("<lot_no__fr><![CDATA[").append(checkNull(lotNo)).append("]]></lot_no__fr>\r\n");
valueXmlString.append("<lot_no__to><![CDATA[").append(checkNull(lotNo)).append("]]></lot_no__to>\r\n");
valueXmlString.append("<lot_sl__fr><![CDATA[").append(checkNull(lotSl)).append("]]></lot_sl__fr>\r\n");
valueXmlString.append("<lot_sl__to><![CDATA[").append(checkNull(lotSl)).append("]]></lot_sl__to>\r\n");
valueXmlString.append("<quantity><![CDATA[").append(quantity).append("]]></quantity>\r\n");
valueXmlString.append("<unit><![CDATA[").append(unit).append("]]></unit>\r\n");
valueXmlString.append("<no_art><![CDATA[").append(noArt).append("]]></no_art>\r\n");
valueXmlString.append("<line_no_sl><![CDATA[").append(checkNull(lotSl)).append("]]></line_no_sl>\r\n");
valueXmlString.append("</Detail3>\r\n");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}//end itm_default in case 3
}//end case 3 in itemchange...
break;
case 4:
{
System.out.println(">>>>>>>>Calling case 4 IC:"+currentFormNo);
int newInt = 0;
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
parentNodeList = dom2.getElementsByTagName("Detail3");
System.out.println(">>>>>>>>parentNodeList:"+parentNodeList);
parentNodeListLength = parentNodeList.getLength();
System.out.println(">>>>>>>>in case 4:parentNodeListLength:"+parentNodeListLength);
for(int ctr = 0; ctr < parentNodeListLength ; ctr++ )
{
parentNode = parentNodeList.item(ctr);
System.out.println(">>>>>>>>>>parentNode:"+parentNode);
String selected = getAttribValue(parentNode, "attribute", "selected");
System.out.println(">>>>>status ="+getAttribValue(parentNode, "attribute", "status"));
System.out.println(">>>>>>>Value for selected dom:"+selected);
newInt++;
tranId = genericUtility.getColumnValueFromNode("tran_id", parentNode) ;
lineNo = Integer.parseInt(genericUtility.getColumnValueFromNode("line_no", parentNode).trim());
itemCode = genericUtility.getColumnValueFromNode("item_code", parentNode);
itemDescr = genericUtility.getColumnValueFromNode("item_descr", parentNode);
locCodeFrom = genericUtility.getColumnValueFromNode("loc_code__fr", parentNode);
locDescrFrom = genericUtility.getColumnValueFromNode("item_descr", parentNode);
locCodeTo = genericUtility.getColumnValueFromNode("loc_code__to", parentNode);
lotNoFrom = genericUtility.getColumnValueFromNode("lot_no__fr", parentNode);
lotNoTo = genericUtility.getColumnValueFromNode("lot_no__to", parentNode);
lotSlFrom = genericUtility.getColumnValueFromNode("lot_sl__fr", parentNode);
lotSlTo = genericUtility.getColumnValueFromNode("lot_sl__to", parentNode);
quantity = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", parentNode));
noArt = Integer.parseInt(genericUtility.getColumnValueFromNode("no_art", parentNode));
//Prepare Selected row..
valueXmlString.append("<Detail4 domID='" + newInt + "' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id/>" );
valueXmlString.append( "<line_no><![CDATA[" ).append( newInt ).append( "]]></line_no>\r\n");
valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode ).append( "]]></item_code>\r\n");
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr ).append( "]]></item_descr>\r\n");
valueXmlString.append( "<loc_code__fr><![CDATA[" ).append( locCodeFrom ).append( "]]></loc_code__fr>\r\n");
valueXmlString.append( "<loc_descr__fr><![CDATA[" ).append( locDescrFrom ).append( "]]></loc_descr__fr>\r\n");
valueXmlString.append( "<loc_code__to><![CDATA[" ).append(locCodeTo).append( "]]></loc_code__to>\r\n" );
valueXmlString.append( "<lot_no__fr><![CDATA[" ).append( lotNoFrom ).append( "]]></lot_no__fr>\r\n" );
valueXmlString.append( "<lot_no__to><![CDATA[" ).append( lotNoTo ).append( "]]></lot_no__to>\r\n" );
valueXmlString.append( "<lot_sl__fr><![CDATA[" ).append( lotSlFrom ).append( "]]></lot_sl__fr>\r\n" );
valueXmlString.append( "<lot_sl__to><![CDATA[" ).append( lotSlTo ).append( "]]></lot_sl__to>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( quantity ).append( "]]></quantity>\r\n" );
valueXmlString.append( "<no_art><![CDATA[" ).append( noArt ).append( "]]></no_art>\r\n" );
valueXmlString.append( "<sample_qty><![CDATA[" ).append( "" ).append( "]]></sample_qty>\r\n" );
valueXmlString.append("</Detail4>\r\n");
}//end for loop for get selected/...
}//end itemdefault in case 4..
}//end case 4 in itemChange..
}//end switch
valueXmlString.append("</Root>");
System.out.println(">>>>>>>>>>>["+valueXmlString+"]");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
//Validation calling method start
private int isValueExist(String tableName, String columnName, String columnValue,Connection conn) throws Exception,ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int cnt = 0 ;
sql = " select count(1) as count from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("count");
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
System.out.println("cnt--------------"+cnt);
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
throw new ITMException(exception);
}
return cnt;
}
//Validation calling method end
private String checkNull( String input )
{
if( input == null )
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
public double getRequiredDecimal(double actVal, int prec)
{
String fmtStr = "############0";
String strValue = null;
double retVal = 0;
if (prec > 0)
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec);
}
DecimalFormat decFormat = new DecimalFormat(fmtStr);
retVal = Double.parseDouble(decFormat.format(actVal));
if (Math.abs(retVal) == 0)
{
retVal = 0;
}
return retVal;
}
private String findValue(Connection conn, String columnName, String tableName, String columnName2, String value) throws ITMException, RemoteException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 + "= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value);
rs = pstmt.executeQuery();
if (rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (findValue == null || findValue.trim().length()== 0)
{
findValue = "";
}
} catch (Exception e)
{
System.out.println("Exception in findValue ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from findValue " + findValue);
return findValue;
}
private String getAttribValue(Node detailNode, String nodeName, String attribStr)
{
String attribValue = "";
try
{
String domStr = GenericUtility.getInstance().serializeDom(detailNode);
Document dom = GenericUtility.getInstance().parseString(domStr);
if( dom != null /*&& dom.getAttributes() != null*/)
{
Node attributeNode = dom.getElementsByTagName( nodeName ).item(0);
attribValue = getAttribValue(attributeNode, attribStr);
}
}
catch(Exception e)
{
System.out.println("Exception : getAttribValue :" + e.getMessage());
}
return attribValue;
}
//
private String getAttribValue(Node detailNode, String attribStr)
{
String attribValue = "";
try
{
if( detailNode != null && detailNode.getAttributes() != null)
{
Node attribNode = detailNode.getAttributes().getNamedItem( attribStr );
if( attribNode != null )
{
attribValue = checkNull( attribNode.getNodeValue() );
}
}
}
catch(Exception e)
{
System.out.println("Exception : getAttribValue :" + e.getMessage());
}
return attribValue;
}
//private String getSelectValue(Node node) throws Exception
private String getSelectValue(Node node)
{
String selectValue = "";
int selectLength=0;
NamedNodeMap attrMap = node.getAttributes();
selectLength=attrMap.getLength();
System.out.println(">>>>>>>>>In getSelectValue attrMap.getLength():"+selectLength);
if(selectLength == 5)
{
selectValue = attrMap.getNamedItem("selected").getNodeValue();
}
else
{
selectValue="N";
}
return selectValue;
}
}
/********************************************************
Title : QCSampleWizICLocal[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import javax.ejb.Local;
public interface QCSampleWizICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlCurrFrmString, String xmlHdrFrmString, String xmlAllFrmString, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/********************************************************
Title : QCSampleWizICRemote[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface QCSampleWizICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlCurrFrmString, String xmlHdrFrmString, String xmlAllFrmString, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/********************************************************
Title : QCSampleWizPos[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.dis.adv.StockTransferConf;
import ibase.webitm.ejb.mfg.adv.ConfirmQcSample;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
@javax.ejb.Stateless
public class QCSampleWizPos extends ValidatorEJB implements QCSampleWizPosLocal, QCSampleWizPosRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
StockTransferConf stockTranConf = new StockTransferConf();
ConfirmQcSample qcSampleConf= new ConfirmQcSample();
GenericUtility genericUtility = GenericUtility.getInstance();
DistCommon dist = new DistCommon();
String empCodeSample="";
String xmlString = null;
String siteCode="",qorderNo="",itemCode="",lotNo="",lotSl="",remarks="",unit="";
String qcOrdNo="",locCodeTo="",lotNoTo="",lotSlTo="",procMth="",chgTerm="",userId="",tranIdQcSamp="";
String forcedFlag = "false";
String errString = "";
String sql = "";
int lineNo=0,lineNoSl=0,stepNo=1,newLine=0;
int parentNodeListLength = 0;
double sampleQty=0.0,convFactor=0.0,stdQty=0.0;
Document dom = null;
NodeList hdrDom=null;
NodeList parentNodeList = null;
Node parentNode = null;
StringBuffer xmlBuff = null;
Date currentDate = new Date();
boolean isError = false;
boolean toCommit = false;
try
{
System.out.println(">>>>>>>In post Save conn:"+conn);
conn.setAutoCommit(false);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" ));
System.out.println( ">>>>>>>>>QCSampleWizPos tranId:"+tranId);
System.out.println(">>>>>>>>>>>>>>>>>>>>>domString in post save:"+domString);
dom = genericUtility.parseString(domString);
System.out.println(">>>>>>>>>>Calling stockTranConf Confirm method:"+tranId);
errString = stockTranConf.confirm( tranId, xtraParams, forcedFlag, conn, toCommit);
System.out.println(">>>>>>>>stockTranConf.confirm return errString:"+errString);
if(errString == null || errString.trim().length() == 0)
{
hdrDom = dom.getElementsByTagName("Detail2");
if(hdrDom != null && hdrDom.getLength() > 0)
{
qcOrdNo = genericUtility.getColumnValueFromNode("qc_ord__no", dom.getElementsByTagName("Detail1").item(0));
siteCode = genericUtility.getColumnValueFromNode("site_code", dom.getElementsByTagName("Detail2").item(0));
System.out.println(">>>>>>>>>>qcOrdNo:"+qcOrdNo);
System.out.println(">>>>>>>>>>siteCode:"+siteCode);
}
//Get data from qc Order..
sql = "select item_code,lot_no,lot_sl,unit from qc_order where qorder_no = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
itemCode = rs.getString(1) == null ? "" : rs.getString(1);
lotNo = rs.getString(2) == null ? "" : rs.getString(2);
lotSl = rs.getString(3) == null ? "" : rs.getString(3);
unit = rs.getString(4) == null ? "" : rs.getString(4);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
//if unit is null then get unit from item..
if(unit == null || unit.trim().length() == 0 )
{
sql = "select unit from item where item_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
unit = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
System.out.println(">>>>>>Generate XML For saveDate() of QC Sample Header>>>>>>");
remarks="Auto Generate From QC Sampling Wiz";
//Start prepare xml..
xmlBuff = null;
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("qc_sample").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"qc_sample\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currentDate).toString() +"]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+ siteCode.trim() +"]]></site_code>");
xmlBuff.append("<qorder_no><![CDATA["+ qcOrdNo.trim() +"]]></qorder_no>");
xmlBuff.append("<tran_type/>");
xmlBuff.append("<item_code><![CDATA["+ itemCode.trim() +"]]></item_code>");
xmlBuff.append("<loc_code><![CDATA["+ locCodeTo.trim() +"]]></loc_code>");
xmlBuff.append("<lot_no><![CDATA["+ lotNo.trim() +"]]></lot_no>");
xmlBuff.append("<lot_sl><![CDATA["+ lotSl.trim() +"]]></lot_sl>");
xmlBuff.append("<remarks><![CDATA["+ remarks +"]]></remarks>");
xmlBuff.append("<emp_code__sample><![CDATA["+ empCodeSample +"]]></emp_code__sample>");
xmlBuff.append("<confirmed><![CDATA["+ "N" +"]]></confirmed>");
xmlBuff.append("<conf_date/>");
xmlBuff.append("<emp_code__aprv/>");
xmlBuff.append("<chg_date><![CDATA["+ sdf.format(currentDate).toString() +"]]></chg_date>");
xmlBuff.append("<chg_user><![CDATA["+ userId +"]]></chg_user>");
xmlBuff.append("<chg_term><![CDATA["+ chgTerm +"]]></chg_term>");
xmlBuff.append("</Detail1>");
sql = "select proc_mth from siteitem where site_code = ? and item_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
procMth = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(procMth == null || procMth.trim().length() == 0)
{
sql = " select proc_mth from item where item_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
procMth = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
//Get Detail4 data from dom......
parentNodeList = dom.getElementsByTagName("Detail4");
parentNodeListLength = parentNodeList.getLength();
System.out.println(">>>>>>>>in parentNodeListLength:"+parentNodeListLength);
for(int ctr = 0; ctr < parentNodeListLength ; ctr++ )
{
newLine++;
System.out.println(">>>>>>>>>>>>>Get dom (Detail4 details:"+newLine);
parentNode = parentNodeList.item(ctr);
lineNo = Integer.parseInt(genericUtility.getColumnValueFromNode("line_no", parentNode).trim());
locCodeTo = genericUtility.getColumnValueFromNode("loc_code__to", parentNode);
lotNoTo = genericUtility.getColumnValueFromNode("lot_no__to", parentNode);
lotSlTo = genericUtility.getColumnValueFromNode("lot_sl__to", parentNode);
sampleQty = Double.parseDouble(genericUtility.getColumnValueFromNode("sample_qty", parentNode));
System.out.println(">>>>>>dom sampleQty:"+sampleQty);
//Get Std. Quantity and Conv. Factor...
ArrayList unitList = null;
Object factOb = null,qtyOb = null;
unitList = dist.getConvQuantityFact( unit,unit, itemCode, sampleQty, 0,conn);
factOb = unitList.get(0);
qtyOb = unitList.get(1);
convFactor=Double.parseDouble(factOb.toString());
stdQty=Double.parseDouble(qtyOb.toString());
lineNoSl= Integer.parseInt(lotSlTo.trim());
System.out.println(">>>>>>>>convFactor:"+convFactor);
System.out.println(">>>>>>>>stdQty:"+stdQty);
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"qc_sample\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<line_no>" + newLine + "</line_no>");
xmlBuff.append("<iss_type><![CDATA["+ "A" +"]]></iss_type>");
xmlBuff.append("<loc_code><![CDATA["+ locCodeTo.trim() +"]]></loc_code>");
xmlBuff.append("<lot_no><![CDATA["+ lotNoTo.trim() +"]]></lot_no>");
xmlBuff.append("<lot_sl><![CDATA["+ lotSlTo.trim() +"]]></lot_sl>");
xmlBuff.append("<stock_det/>");
xmlBuff.append("<qty_sample><![CDATA["+ sampleQty +"]]></qty_sample>");
xmlBuff.append("<unit><![CDATA["+ unit.trim() +"]]></unit>");
xmlBuff.append("<unit__std><![CDATA["+ unit.trim() +"]]></unit__std>");
xmlBuff.append("<conv_qty__stduom><![CDATA["+ convFactor +"]]></conv_qty__stduom>");
xmlBuff.append("<qty_sample_stduom><![CDATA["+ stdQty +"]]></qty_sample_stduom>");
xmlBuff.append("<remarks><![CDATA["+ remarks +"]]></remarks>");
xmlBuff.append("<step_no><![CDATA["+ stepNo +"]]></step_no>");
xmlBuff.append("<proc_mth><![CDATA["+ procMth.trim() +"]]></proc_mth>");
xmlBuff.append("<line_no_sl><![CDATA["+ lineNoSl +"]]></line_no_sl>");
xmlBuff.append("<bal_qty/>");
xmlBuff.append("</Detail2>");
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
//End prepare xml..
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
errString = saveData(siteCode,xmlString,conn);
System.out.println(">>>>>>errString after saveData:"+errString);
if (errString.indexOf("Success") > -1)
{
String[] arrayForTranId = errString.split("<TranID>");
System.out.println("@@@@ arrayForTranId:["+arrayForTranId.toString()+"]arrayForTranId.length["+arrayForTranId.length+"]");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
tranIdQcSamp = arrayForTranId[1].substring(0,endIndex);
System.out.println(">>>>>>>>>>>>>>>QC Sampling Tran Id:"+tranIdQcSamp);
errString="";
//Call QC Sample Confirmation......
errString =qcSampleConf.actionConfirm(tranIdQcSamp, xtraParams, conn);
System.out.println(">>>>>>>>After Calling QC Sample Confirmation errString:"+errString);
if(errString.indexOf("CONQCSUCC") > -1)
{
System.out.println(">>>>>>>>>>QC Sample Transaction Confirmed Successfully:"+tranIdQcSamp);
isError=false;
}
else
{
System.out.println(">>>>>>>>>>QC Sample Transaction Not Confirmed:"+tranIdQcSamp);
isError=true;
}
}
else
{
isError=true;
}
}
else
{
isError=true;
}
}
catch(Exception e)
{
isError = true;
System.out.println("Exception "+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println(">>>>>>>>>>in finaly conn:"+conn);
if(!isError)
{
conn.commit();
System.out.println(">>>>>>>Transaction commit successfully");
}
else if(isError)
{
conn.rollback();
System.out.println(">>>>>>>Transaction rollback successfully");
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
private String checkNull( String input )
{
if( input == null )
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
System.out.println(">>>>>>> In saving data method xmlString :"+xmlString);
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);
}
catch(ITMException itme)
{
System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme;
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e);
}
return retString;
}
}
/********************************************************
Title : QCSampleWizPosLocal[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface QCSampleWizPosLocal extends ValidatorLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : QCSampleWizPosRemote[M14HFRA001]
Date : 02/12/14
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface QCSampleWizPosRemote extends ValidatorRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ 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