Commit 8d0c97ca authored by sshinde's avatar sshinde

Add new new functionallity on dated 28062013


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93300 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c50bd4a1
......@@ -16,26 +16,26 @@ import javax.naming.InitialContext;
import javax.ejb.Stateless;
@Stateless
public class RequirementIC extends ValidatorEJB implements RequirementICLocal,RequirementICRemote //SessionBean
public class RequirementIC extends ValidatorEJB implements RequirementICLocal, RequirementICRemote // SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
SimpleDateFormat simpleDateFormat = null;
public String wfValData() throws RemoteException,ITMException
public String wfValData() throws RemoteException, ITMException
{
System.out.println("wfValData()...");
return "";
}
// Item Change
public String itemChanged() throws RemoteException,ITMException
public String itemChanged() throws RemoteException, ITMException
{
System.out.println("itemChanged Called...");
return "";
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
......@@ -45,42 +45,43 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString.........::"+xmlString);
System.out.println("xmlString1.........::"+xmlString1);
System.out.println("xmlString2.........::"+xmlString2);
if (xmlString != null && xmlString.trim().length()!=0)
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)
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
} catch (Exception e)
{
System.out.println ("Exception :ProcessControlEJB :itemChanged(String,String):" + e.getMessage() + ":");
System.out.println("Exception :ProcessControlEJB :itemChanged(String,String):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
System.out.println ("returning from ProcessControlEJB itemChanged");
System.out.println("returning from ProcessControlEJB itemChanged");
return errString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String loginSiteCode = "";
String sql = "";
String columnValue = "";
String userId = "";
String errString="";
String errString = "";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int lineNo = 0;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
......@@ -129,6 +130,9 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
double quantity = 0d;
double yieldPerc = 0d;
String winName = ""; // Added by sachin on 26/6/13
double batchReq = 0d;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
......@@ -138,13 +142,13 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
connDriver = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
columnValue = genericUtility.getColumnValue(currentColumn,dom);
if(objContext != null && objContext.trim().length()>0)
columnValue = genericUtility.getColumnValue(currentColumn, dom);
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
......@@ -154,7 +158,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
{
case 1:
valueXmlString.append("<Detail1>");
if(currentColumn.trim().equals("itm_default"))
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<site_code__fr>").append(loginSiteCode).append("</site_code__fr>");
valueXmlString.append("<site_code__to>").append(loginSiteCode).append("</site_code__to>");
......@@ -162,67 +166,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
valueXmlString.append("</Detail1>");
break;
case 2:
if(currentColumn.trim().equals("itm_default"))
if (currentColumn.trim().equals("itm_default"))
{
int detCnt = 0;
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to", dom1);
/*
* "SELECT A.TRAN_ID, A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.QUANTITY, A.DUE_DATE, A.UNIT, A.YIELD_PERC "
* + "FROM MPS_ORDER A, ITEM B "+
* "WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " +
* "AND A.SITE_CODE >= ? AND A.SITE_CODE <= ? "+
* "AND A.STATUS IN ('P','T','M')";
*/
selectSql = "SELECT A.TRAN_ID, A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.QUANTITY, A.DUE_DATE, A.UNIT, A.YIELD_PERC " +
"FROM MPS_ORDER A, ITEM B "+
"WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " +
"AND A.SITE_CODE >= ? AND A.SITE_CODE <= ? "+
"AND A.STATUS IN ('P','T','M')";
/* Change By Sachin on 26/6/2013 */
selectSql = "SELECT A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.UNIT, C.BATCH_QTY, SUM(A.QUANTITY) AS QUANTITY " + "FROM MPS_ORDER A, ITEM B ,BOM C " + "WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) " + "AND A.SITE_CODE >= ? AND A.SITE_CODE <=? " + "AND A.STATUS IN ('P','T','M') " + "AND A.BOM_CODE=C.BOM_CODE " + "GROUP BY A.SITE_CODE, A.ITEM_CODE, B.DESCR, A.UNIT, C.BATCH_QTY";
pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1, siteCodeFr);
pstmt.setString(2, siteCodeTo);
rs = pstmt.executeQuery();
while ( rs.next() )
while (rs.next())
{
detCnt++;
dueDate = rs.getDate("DUE_DATE");
if(dueDate != null)
{
dueDate1 = sdf.format(dueDate);
}
else
{
dueDate1 = "";
}
valueXmlString.append("<Detail2>\r\n");
valueXmlString.append("<site_code>").append("<![CDATA["+rs.getString("SITE_CODE")+"]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA["+rs.getString("ITEM_CODE")+"]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr protect = '1'>").append("<![CDATA["+rs.getString("DESCR")+"]]>").append("</item_descr>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA["+rs.getDouble("QUANTITY")+"]]>").append("</quantity>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA["+dueDate1+"]]>").append("</due_date>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA["+rs.getString("UNIT")+"]]>").append("</unit>\r\n");
valueXmlString.append("<yield_perc protect = '1'>").append("<![CDATA["+rs.getString("YIELD_PERC")+"]]>").append("</yield_perc>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("<![CDATA["+rs.getString("TRAN_ID")+"]]>").append("</tran_id>\r\n");
lineNo++;
quantity = rs.getDouble("QUANTITY");
batchQty = rs.getDouble("BATCH_QTY");
batchReq = (quantity / batchQty);
System.out.println(" aFTER CALUCLATION Quantity is =" + quantity + " batch quantity is =" + batchQty + "batch Requirement is =" + batchReq);
/*
* dueDate = rs.getDate("DUE_DATE"); if (dueDate !=
* null) { dueDate1 = sdf.format(dueDate); } else {
* dueDate1 = ""; }
*/
valueXmlString.append("<Detail2 domID='" + lineNo + "' objContext = '" + currentFormNo + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<site_code>").append("<![CDATA[" + rs.getString("SITE_CODE") + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[" + rs.getString("ITEM_CODE") + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr protect = '1'>").append("<![CDATA[" + rs.getString("DESCR") + "]]>").append("</item_descr>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + rs.getString("UNIT") + "]]>").append("</unit>\r\n");
valueXmlString.append("<no_of_batch protect = '1'>").append("<![CDATA[" + batchReq + "]]>").append("</no_of_batch>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[" + rs.getDouble("QUANTITY") + "]]>").append("</quantity>\r\n");
valueXmlString.append("</Detail2>");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if ( detCnt == 0 )
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (detCnt == 0)
{
valueXmlString.append("<Detail2>\r\n");
// valueXmlString.append("<Detail2>\r\n");
valueXmlString.append("<Detail2 domID='" + lineNo + "' objContext = '" + currentFormNo + "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<site_code>").append("").append("</site_code>\r\n");
valueXmlString.append("<item_code>").append("").append("</item_code>\r\n");
valueXmlString.append("<item_descr protect = '1'>").append("").append("</item_descr>\r\n");
valueXmlString.append("<quantity>").append("0").append("</quantity>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("").append("</due_date>\r\n");
valueXmlString.append("<no_of_batch protect = '1'>").append("0").append("</no_of_batch>\r\n");
valueXmlString.append("<unit protect = '1'>").append("").append("</unit>\r\n");
valueXmlString.append("<yield_perc protect = '1'>").append("").append("</yield_perc>\r\n");
valueXmlString.append("<tran_id protect = '1'>").append("").append("</tran_id>\r\n");
valueXmlString.append("</Detail2>");
}
/* End Change By Sachin on 26/6/2013 */
}
break;
//added by akhilesh
// added by akhilesh
case 3:
if(currentColumn.trim().equals("itm_default"))
if (currentColumn.trim().equals("itm_default"))
{
TreeSet itemTreeSet = new TreeSet();
TreeSet siteTreeSet = new TreeSet();
ArrayList tranIdList = new ArrayList();
......@@ -234,8 +251,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
String tranIdDom = "";
String qtyStr = "";
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom1);
siteCodeTo = genericUtility.getColumnValue("site_code__to", dom1);
insertSql = "INSERT INTO MPS_ORDER(TRAN_ID, ORDER_TYPE, ITEM_CODE, SITE_CODE, QUANTITY, ORD_DATE, DUE_DATE, STATUS, STATUS_DATE, YIELD_PERC, UNIT ) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
......@@ -250,14 +267,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for(int p = 0; p < parentNodeListLength; p++)
for (int p = 0; p < parentNodeListLength; p++)
{
tranIdDom = ""; itemCode = ""; siteCode = ""; qtyStr = ""; quantity = 0d;
tranIdDom = "";
itemCode = "";
siteCode = "";
qtyStr = "";
quantity = 0d;
parentNode = parentNodeList.item(p);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(int c = 0; c < childNodeListLength; c++)
for (int c = 0; c < childNodeListLength; c++)
{
childNode = childNodeList.item(c);
childNodeName = childNode.getNodeName();
......@@ -269,78 +290,76 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
{
tranIdDom = checkNull(childNode.getFirstChild().getNodeValue());
}
}
else if (childNodeName.equals("item_code"))
} else if (childNodeName.equals("item_code"))
{
if (childNode.getFirstChild() != null)
{
itemCode = checkNull(childNode.getFirstChild().getNodeValue());
}
}
else if (childNodeName.equals("site_code"))
} else if (childNodeName.equals("site_code"))
{
if (childNode.getFirstChild() != null)
{
siteCode = checkNull(childNode.getFirstChild().getNodeValue());
}
}
else if (childNodeName.equals("quantity"))
} else if (childNodeName.equals("quantity"))
{
if (childNode.getFirstChild() != null)
{
qtyStr = childNode.getFirstChild().getNodeValue();
if ( qtyStr != null && qtyStr.trim().length() > 0 )
if (qtyStr != null && qtyStr.trim().length() > 0)
{
try
{
quantity = Double.parseDouble(qtyStr);
}
catch (NumberFormatException n)
} catch (NumberFormatException n)
{
quantity = 0;
}
}
}
}
}//End of Inner for loop
if ( itemCode != null && itemCode.trim().length() > 0 )
}// End of Inner for loop
if (itemCode != null && itemCode.trim().length() > 0)
{
itemTreeSet.add(itemCode);
}
if ( siteCode != null && siteCode.trim().length() > 0 )
if (siteCode != null && siteCode.trim().length() > 0)
{
siteTreeSet.add(siteCode);
}
if ( tranIdDom == null || tranIdDom.trim().length() == 0 )
if (tranIdDom == null || tranIdDom.trim().length() == 0)
{
newDataCnt++;
ArrayList newDataList = new ArrayList();
newDataList.add(siteCode);
newDataList.add(itemCode);
newDataList.add(quantity);
mpsDataMap.put(""+newDataCnt,newDataList);
mpsDataMap.put("" + newDataCnt, newDataList);
pstmtSel1.setString(1, itemCode);
rs = pstmtSel1.executeQuery();
if ( rs.next() )
if (rs.next())
{
unit = rs.getString("UNIT");
yieldPerc = rs.getDouble("YIELD_PERC");
}
pstmtSel1.clearParameters();
rs.close(); rs = null;
rs.close();
rs = null;
pstmtSel.setString(1, siteCode);
pstmtSel.setString(2, itemCode);
rs = pstmtSel.executeQuery();
if ( rs.next() )
if (rs.next())
{
batchQty = rs.getDouble("BATCH_QTY");
}
pstmtSel.clearParameters();
rs.close(); rs = null;
rs.close();
rs = null;
//quantity = batchQty * noOfBatch;
// quantity = batchQty * noOfBatch;
tranIdSuffix++;
......@@ -350,40 +369,40 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
tranIdList.add(newTranId);
pstmtIns.setString(1,newTranId);
pstmtIns.setString(2,orderType);
pstmtIns.setString(3,itemCode);
pstmtIns.setString(4,siteCode);
pstmtIns.setDouble(5,quantity);
pstmtIns.setTimestamp(6,sysDate);
pstmtIns.setTimestamp(7,sysDate);
pstmtIns.setString(8,status);
pstmtIns.setTimestamp(9,sysDate);
pstmtIns.setDouble(10,yieldPerc);
pstmtIns.setString(11,unit);
pstmtIns.setString(1, newTranId);
pstmtIns.setString(2, orderType);
pstmtIns.setString(3, itemCode);
pstmtIns.setString(4, siteCode);
pstmtIns.setDouble(5, quantity);
pstmtIns.setTimestamp(6, sysDate);
pstmtIns.setTimestamp(7, sysDate);
pstmtIns.setString(8, status);
pstmtIns.setTimestamp(9, sysDate);
pstmtIns.setDouble(10, yieldPerc);
pstmtIns.setString(11, unit);
pstmtIns.addBatch();
pstmtIns.clearParameters();
}
}
noOfItem = itemTreeSet.size();
if ( noOfItem > 0 )
if (noOfItem > 0)
{
itemCodeFr = (String)itemTreeSet.first();
itemCodeTo = (String)itemTreeSet.last();
itemCodeFr = (String) itemTreeSet.first();
itemCodeTo = (String) itemTreeSet.last();
}
noOfSite = siteTreeSet.size();
if ( noOfSite > 0 )
if (noOfSite > 0)
{
siteCodeFr = (String)siteTreeSet.first();
siteCodeTo = (String)siteTreeSet.last();
siteCodeFr = (String) siteTreeSet.first();
siteCodeTo = (String) siteTreeSet.last();
}
int insCnt[] = null;
insCnt = pstmtIns.executeBatch();
if ( insCnt.length > 0 )
if (insCnt.length > 0)
{
System.out.println("Record inserted into mps_order successfully for tran id =["+insCnt.length +"]");
System.out.println("Record inserted into mps_order successfully for tran id =[" + insCnt.length + "]");
conn.commit();
}
......@@ -391,12 +410,12 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Date d = new Date();
String runDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.set(Calendar.DATE,1);
cal.set(Calendar.DATE, 1);
d = cal.getTime();
String fromDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.add(Calendar.MONTH,3);
cal.set(Calendar.DATE,0);
cal.add(Calendar.MONTH, 3);
cal.set(Calendar.DATE, 0);
d = cal.getTime();
String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate);
......@@ -414,7 +433,8 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n");
argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n");
argData.append("<process_cycle>").append("3").append("</process_cycle>\r\n");
argData.append("<run_date>").append(runDate).append("</run_date>\r\n"); // 01-10-2007 manoharan
argData.append("<run_date>").append(runDate).append("</run_date>\r\n"); // 01-10-2007
// manoharan
argData.append("<dis_plan>").append("N").append("</dis_plan>\r\n");
argData.append("<mfg_plan>").append("N").append("</mfg_plan>\r\n");
argData.append("<mat_plan>").append("Y").append("</mat_plan>\r\n");
......@@ -430,88 +450,90 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
String mrpGetData = "";
RunMRPPrc runMRPObj = new RunMRPPrc();
mrpGetData = runMRPObj.getData(argDom, dom2, "", xtraParams);
System.out.println("mrpGetData =["+mrpGetData+"]");
/* Added by sachin */
parentNode = parentNodeList.item(0);
winName = this.getWinName(parentNode);
mrpGetData = runMRPObj.getData(argDom, dom2, winName, xtraParams);
/* End Added by sachin */
System.out.println("mrpGetData =[" + mrpGetData + "]");
String tranIdStr = "'";
if ( tranIdList != null && tranIdList.size() > 0 )
if (tranIdList != null && tranIdList.size() > 0)
{
for (int i = 0; i < tranIdList.size(); i++)
{
tranIdStr = tranIdStr + tranIdList.get(i) + "','";
}
}
if ( tranIdStr.length() >= 2 )
if (tranIdStr.length() >= 2)
{
tranIdStr = tranIdStr.substring(0, tranIdStr.length()-2);
}
else
tranIdStr = tranIdStr.substring(0, tranIdStr.length() - 2);
} else
{
tranIdStr = "";
}
if ( tranIdStr != null && tranIdStr.trim().length() > 0 )
if (tranIdStr != null && tranIdStr.trim().length() > 0)
{
deleteSql = "DELETE FROM MPS_ORDER WHERE TRAN_ID IN("+tranIdStr+")";
deleteSql = "DELETE FROM MPS_ORDER WHERE TRAN_ID IN(" + tranIdStr + ")";
pstmt = conn.prepareStatement(deleteSql);
delCnt = pstmt.executeUpdate();
if ( delCnt > 0 )
if (delCnt > 0)
{
System.out.println("Record deleted from mps_order successfully for tran id =["+tranIdStr+"]");
System.out.println("Record deleted from mps_order successfully for tran id =[" + tranIdStr + "]");
}
pstmt.close();
pstmt = null;
}
return mrpGetData;
}
break;
//ended by akhilesh
// ended by akhilesh
}
valueXmlString.append("</Root>");
}
catch(Exception e)
} catch (Exception e)
{
isError = true;
System.out.println("Exception :[RequirementIC][itemChanged::case 1:] :==>\n"+e.getMessage());
System.out.println("Exception :[RequirementIC][itemChanged::case 1:] :==>\n" + e.getMessage());
e.printStackTrace();
return genericUtility.createErrorString(e);
//throw new ITMException(e);
}
finally
// throw new ITMException(e);
} finally
{
try
{
if ( conn != null )
if (conn != null)
{
if ( !isError )
if (!isError)
{
conn.commit();
}
else
} else
{
conn.rollback();
}
if ( rs != null )
if (rs != null)
{
rs.close();
rs = null;
}
if ( pstmtIns != null )
if (pstmtIns != null)
{
pstmtIns.close();
pstmtIns = null;
}
if ( pstmtSel != null )
if (pstmtSel != null)
{
pstmtSel.close();
pstmtSel = null;
}
if ( pstmtSel1 != null )
if (pstmtSel1 != null)
{
pstmtSel1.close();
pstmtSel1 = null;
......@@ -519,8 +541,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
conn.close();
conn = null;
}
}
catch (Exception e)
} catch (Exception e)
{
}
}
......@@ -528,7 +549,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
}
// Validation
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
......@@ -538,18 +559,17 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
try
{
dom = parseString(xmlString);
System.out.println("RequirementIC : wfValData(String xmlString) : ==>\n" + xmlString );
System.out.println("RequirementIC : wfValData(String xmlString1) : ==>\n" + xmlString1 );
System.out.println("RequirementIC : wfValData(String xmlString) : ==>\n" + xmlString);
System.out.println("RequirementIC : wfValData(String xmlString1) : ==>\n" + xmlString1);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
if (xmlString2.trim().length() > 0)
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} catch (Exception e)
{
System.out.println("Exception : RequirementIC : wfValData(String xmlString) : ==>\n"+e.getMessage());
System.out.println("Exception : RequirementIC : wfValData(String xmlString) : ==>\n" + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
......@@ -564,7 +584,7 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Node childNode = null;
String childNodeName = "";
String errString = "";
int ctr,currentFormNo=0;
int ctr, currentFormNo = 0;
int childNodeListLength;
int count = 0;
......@@ -580,19 +600,18 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"userId");
if(objContext != null && objContext.trim().length()>0)
userId = getValueFromXTRA_PARAMS(xtraParams, "userId");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
switch (currentFormNo)
{
case 1:
{
......@@ -601,33 +620,33 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to") )
if (childNodeName.equals("site_code__fr") || childNodeName.equals("site_code__to"))
{
siteCodeFr = genericUtility.getColumnValue("site_code__fr",dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom);
if ( siteCodeFr == null || siteCodeFr.trim().length() == 0 )
siteCodeFr = genericUtility.getColumnValue("site_code__fr", dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to", dom);
if (siteCodeFr == null || siteCodeFr.trim().length() == 0)
{
errCode = "VMSITE11";
errString = getErrorString("site_code__fr",errCode,userId);
errString = getErrorString("site_code__fr", errCode, userId);
break;
}
if ( siteCodeTo == null || siteCodeTo.trim().length() == 0 )
if (siteCodeTo == null || siteCodeTo.trim().length() == 0)
{
errCode = "VMSITE12";
errString = getErrorString("site_code__fr",errCode,userId);
errString = getErrorString("site_code__fr", errCode, userId);
break;
}
}
}
}//End of Case 1
}// End of Case 1
break;
case 2:
{
......@@ -636,20 +655,20 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if ( childNodeName.equals("site_code") )
if (childNodeName.equals("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code",dom);
if ( siteCode == null || siteCode.trim().length() == 0 )
siteCode = genericUtility.getColumnValue("site_code", dom);
if (siteCode == null || siteCode.trim().length() == 0)
{
errCode = "VMSITECD";
errString = getErrorString("site_code",errCode,userId);
errString = getErrorString("site_code", errCode, userId);
break;
}
......@@ -658,25 +677,25 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if ( rs.next() )
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close(); rs = null;
if ( count == 0 )
rs.close();
rs = null;
if (count == 0)
{
errCode = "VMSITE";
errString = getErrorString(childNodeName,errCode,userId);
errString = getErrorString(childNodeName, errCode, userId);
break;
}
}
else if ( childNodeName.equals("item_code") )
} else if (childNodeName.equals("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
if ( itemCode == null || itemCode.trim().length() == 0 )
itemCode = genericUtility.getColumnValue("item_code", dom);
if (itemCode == null || itemCode.trim().length() == 0)
{
errCode = "VMITEMCD";
errString = getErrorString("item_code",errCode,userId);
errString = getErrorString("item_code", errCode, userId);
break;
}
......@@ -685,68 +704,80 @@ public class RequirementIC extends ValidatorEJB implements RequirementICLocal,R
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if ( rs.next() )
if (rs.next())
{
count = rs.getInt("COUNT");
}
rs.close(); rs = null;
if ( count == 0 )
rs.close();
rs = null;
if (count == 0)
{
errCode = "VMITEM1";
errString = getErrorString(childNodeName,errCode,userId);
errString = getErrorString(childNodeName, errCode, userId);
break;
}
}
else if ( childNodeName.equals("quantity") )
} else if (childNodeName.equals("quantity"))
{
quantity = genericUtility.getColumnValue("quantity",dom);
if ( quantity == null || quantity.trim().length() == 0 || quantity.equals("0") )
quantity = genericUtility.getColumnValue("quantity", dom);
if (quantity == null || quantity.trim().length() == 0 || quantity.equals("0"))
{
errCode = "VMWEQTY";
errString = getErrorString("quantity",errCode,userId);
errString = getErrorString("quantity", errCode, userId);
break;
}
}
}
}//End of Case 1
}// End of Case 1
break;
}//End of Switch block
}
catch(Exception e)
}// End of Switch block
} catch (Exception e)
{
System.out.println("Exception ::"+e);
System.out.println("Exception ::" + e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
} finally
{
try
{
//System.out.println("Closing Connection.....");
if ( rs != null )
// System.out.println("Closing Connection.....");
if (rs != null)
{
rs.close();
rs = null;
}
if ( pstmt != null )
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}catch(Exception se){}
} catch (Exception se)
{
}
}
return errString;
}
private String checkNull(String value)
{
if ( value == null )
if (value == null)
{
value = "";
}
return value;
}
/* Added by sachin on 26/6/13 */
private String getWinName(Node node) throws Exception
{
String objName = "";
NamedNodeMap attrMap = node.getAttributes();
objName = attrMap.getNamedItem("objName").getNodeValue();
System.out.println(" Object Name is==>" + objName);
return "w_" + objName;
}
/* End Added by sachin on 26/6/13 */
}
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