Commit 40eb4782 authored by manohar's avatar manohar

This commit was generated by cvs2svn to compensate for changes in r187,

which included commits to RCS files with non-trunk default branches.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91252 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e4102c3a
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class SFrcastSitesCrossTab extends ValidatorEJB implements SFrcastSitesCrossTabLocal, SFrcastSitesCrossTabRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
/* public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("SFrcastSitesModCpyEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : SFrcastSitesModCpyEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String columnValue = null;
String childNodeName = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String errCode = null;
String userId = null,loginSite = null;
int cnt = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
String option = genericUtility.getColumnValue( "option", dom );
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 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 ( childNodeName.equalsIgnoreCase( "prd_from" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("prd_from","VMINVPDCDF",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "prd_to" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("prd_to","VMINVPDCDT",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "item_ser" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_ser","VMINVITMSR",userId);
break;
}
else
{
String itemSeries = genericUtility.getColumnValue( "item_ser", dom );
if( itemSeries != null && itemSeries.trim().length() > 0 )
{
sql = "SELECT count(1) from itemser "
+" WHERE item_ser = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,itemSeries.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("item_ser","VMINVITEMS",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
//END OF CASE1
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId );
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < SFrcastSitesModCpyEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
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 = null;
try
{
System.out.println("xmlString" + xmlString);
dom = parseString(xmlString);
System.out.println("xmlString1" + xmlString1);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [SFrcastSitesModCpyEJB][itemChanged] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
String chguserhdr = null;
String chgtermhdr = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
chguserhdr = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgtermhdr = getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if(currentColumn.trim().equals( "item_ser" ))
{
String itemSeries = genericUtility.getColumnValue( "item_ser", dom );
String descr = "";
if( itemSeries != null && itemSeries.trim().length() > 0 )
{
sql = "SELECT descr FROM itemser "
+" WHERE item_ser = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,itemSeries.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<item_ser_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</item_ser_descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}//END OF SWITCH
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import org.w3c.dom.*;
//import javax.ejb.CreateException;
//import javax.ejb.EJBHome;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface SFrcastSitesCrossTabLocal extends ValidatorLocal
{
//public Validator create() throws RemoteException, CreateException;
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 dom, Document dom1,Document dom2, 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 dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.system.config.*;
import java.text.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class SFrcastSitesCrossTabPrc extends ProcessEJB implements SFrcastSitesCrossTabPrcLocal, SFrcastSitesCrossTabPrcRemote
{
String[] siteArr;
/* public void ejbCreate() throws RemoteException, CreateException
{
try
{
System.out.println("ProcessEJB ejbCreate called.........");
}
catch (Exception e)
{
System.out.println("Exception :ProcessEJB :ejbCreate :==>"+e);
throw new CreateException();
}
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String process() throws RemoteException,ITMException
{
return "";
}
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtrStr = "";
Document dom = null;
Document dom1 = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :"+xmlString2);
dom1 = genericUtility.parseString(xmlString2);
}
rtrStr = getData(dom, dom1, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :BankRecoEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
return rtrStr;
}
public String getData(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String resultString = "";
String errCode = "";
String periodFrom = "";
String periodTo = "";
String itemSeries = "";
String sql = "";
String allSites = "";
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
StringBuffer disDemMatrixStrBuff = new StringBuffer();
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
conn = connDriver.getConnectDB("DriverITM");
periodFrom = genericUtility.getColumnValue("prd_from",dom);
periodTo = genericUtility.getColumnValue("prd_to",dom);
itemSeries = genericUtility.getColumnValue("item_ser",dom);
ArrayList allDataList = null;
siteArr = new String[50];
allDataList = new ArrayList();
getAllDataBean dataBean = null;
int i = 0;
sql = "select a.item_code , b.descr , c.site_code , a.quantity "
+" from salesforecast_det a , item b , salesforecast_hdr c "
+" where a.tran_id = c.tran_id "
+" and a.item_code = b.item_code "
+" and a.prd_code__for = ? "
+" and c.item_ser = ? "
+" and c.prd_code__from = ? "
+" and c.prd_code__to = ? order by a.item_code";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, periodFrom.trim() );
pstmt.setString( 2, itemSeries.trim() );
pstmt.setString( 3, periodFrom.trim() );
pstmt.setString( 4, periodTo.trim() );
rs = pstmt.executeQuery();
while( rs.next() )
{
dataBean = new getAllDataBean();
dataBean.itemCdBn = rs.getString( "item_code" );
dataBean.itemDcrBn = rs.getString( "descr" );
dataBean.siteCdBn = rs.getString( "site_code" );
dataBean.quantity = rs.getDouble( "quantity" );
allDataList.add(dataBean);
if( allSites.indexOf( dataBean.siteCdBn.trim() ) == -1 )
{
allSites = allSites + dataBean.siteCdBn.trim();
if( i < 50 )
{
siteArr[i] = dataBean.siteCdBn.trim();
i++;
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( allDataList.size() > 0 )
{
resultString = getXmlData( allDataList, siteArr, conn );
}
if( resultString.equals("") )
{
errCode ="VTNORECFND";
resultString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
}
}
catch (SQLException e)
{
System.out.println("Exception :SFrcastSitesCrossTab :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
catch (Exception e)
{
System.out.println("Exception :SFrcastSitesCrossTab :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Connection.....");
conn.close();
conn = null;
}catch(Exception e){}
}
return resultString;
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("Detail XML String :"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("Header XML String :"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :SFrcastSitesCrossTab :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String resultString = "";
String childNodeName = "";
String errString = "";
String procQuantity = "";
String destSite = "";
boolean errFlag = true;
Connection conn = null;
int childNodeListLength = 0;
int parentNodeListLength = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String distDemandType = "";
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
String[] destSiteQtyArr = new String[50];
ArrayList procList = new ArrayList();
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for (int header = 0; header < parentNodeListLength; header++)
{
parentNode = parentNodeList.item(header);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
procDataBean procdb = new procDataBean();
for (int cntr = 0; cntr < childNodeListLength; cntr++)
{
childNode = childNodeList.item(cntr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("item_code"))
{
procdb.itemCdBn = childNode.getFirstChild().getNodeValue();
if( procdb.itemCdBn != null && procdb.itemCdBn.trim().length() > 0 )
{
if( procdb.itemCdBn.trim().equals("Site Codes") || procdb.itemCdBn.trim().equals("Description") )
{
System.out.println("Executing break ......");
break;
}
}
}
else if (childNodeName.equals("total"))
{
//total = childNode.getFirstChild().getNodeValue();
}
else if (childNodeName.equals("rate"))
{
//rate = childNode.getFirstChild().getNodeValue();
}
else if (childNodeName.equals("value"))
{
//value = childNode.getFirstChild().getNodeValue();
}
else if (childNodeName.equals("pack_size"))
{
//packSize = childNode.getFirstChild().getNodeValue();
}
else if (childNodeName.equals("item_descr"))
{
procdb.itemDcrBn = childNode.getFirstChild().getNodeValue();
}
else
{
for( int i = 1; i <= 50; i++ )
{
if(childNodeName.equals("site"+i))
{
procQuantity = childNode.getFirstChild() == null ? "0" : childNode.getFirstChild().getNodeValue();
procdb.SiteQtyArr[i-1] = procQuantity;
//procdb.siteCdBn[i-1] = siteArr[i-1];
}
}
}
}
procList.add(procdb);
}
errString = updateSalesForecast( procList, headerDom, conn );
if( errString.equals("") )
{
errFlag = false;
}
}
catch(Exception e)
{
System.out.println("Exception :SFrcastSitesCrossTab :process(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
errFlag = true;
throw new ITMException(e);
}
finally
{
try
{
if(errFlag)
{
conn.rollback();
System.out.println("connection rollback.............");
errString = "PROCFAIL";
resultString = itmDBAccessEJB.getErrorString("",errString,userId);
}
else
{
conn.commit();
System.out.println("commiting connection.............");
if(errString.equals(""))
{
errString = "PROCSUCC";
}
resultString = itmDBAccessEJB.getErrorString("",errString,userId);
}
System.out.println("Closing Connection.....");
conn.close();
conn = null;
}catch(Exception se){}
}
return resultString;
}
private String updateSalesForecast( ArrayList procList, Document headerDom, Connection conn ) throws RemoteException,ITMException
{
ResultSet rs = null;
PreparedStatement updtPstmt = null;
PreparedStatement pstmt = null;
String quantity = "", tranId = "", siteCode = "";
double updtQty = 0.0;
procDataBean procBn = null;
GenericUtility genericUtility = GenericUtility.getInstance();
procBn = new procDataBean();
try
{
String periodFrom = genericUtility.getColumnValue("prd_from",headerDom);
String periodTo = genericUtility.getColumnValue("prd_to",headerDom);
String itemSeries = genericUtility.getColumnValue("item_ser",headerDom);
for( int listCtr = 0; listCtr < procList.size(); listCtr++)
{
procBn = (procDataBean)procList.get(listCtr);
for( int qtyCnt = 0; qtyCnt < 50; qtyCnt++)
{
quantity = procBn.SiteQtyArr[qtyCnt];
siteCode = siteArr[qtyCnt];
System.out.println("quantity is ==>"+quantity);
System.out.println("siteCode is ==>"+siteCode);
if( quantity != null && quantity.trim().length() > 0 && !quantity.trim().equals("0") && siteCode != null )
{
System.out.println("Inside quantity if......");
updtQty = Double.parseDouble(quantity);
String sql = "Select a.tran_id from salesforecast_hdr a, salesforecast_det b "
+" where a.tran_id = b.tran_id "
+" and b.item_code = ? "
+" and b.prd_code__for = ? "
+" and a.item_ser = ? "
+" and a.prd_code__from = ? "
+" and a.prd_code__to = ? "
+" and a.site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, procBn.itemCdBn );
pstmt.setString( 2, periodFrom );
pstmt.setString( 3, itemSeries );
pstmt.setString( 4, periodFrom );
pstmt.setString( 5, periodTo );
pstmt.setString( 6, siteCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
tranId = rs.getString("tran_id");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
sql = "Update salesforecast_det set quantity = ? "
+" where tran_id = ? "
+" and item_code = ? "
+" and prd_code__for = ? ";
updtPstmt = conn.prepareStatement(sql);
updtPstmt.setDouble( 1, updtQty );
updtPstmt.setString( 2, tranId );
updtPstmt.setString( 3, procBn.itemCdBn );
updtPstmt.setString( 4, periodFrom );
int updtCnt = updtPstmt.executeUpdate();
updtPstmt.close();
updtPstmt = null;
}
}
}
}
catch( Exception e )
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(updtPstmt != null)updtPstmt.close();
updtPstmt = null;
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
}
return "";
}
public String getXmlData( ArrayList dataList, String[] siteArr, Connection conn ) throws RemoteException,ITMException
{
StringBuffer salesForecastStrBuff = new StringBuffer();
getAllDataBean dataBean = new getAllDataBean();
ResultSet rs = null;
PreparedStatement pstmt = null;
String packSize = "";
try
{
String allItems = "";
double total = 0.0;
double value = 0.0;
double rate = 0.0;
String sql = "";
salesForecastStrBuff.append("Site Codes").append("\t");
salesForecastStrBuff.append("").append("\t"); //item description
salesForecastStrBuff.append("").append("\t"); //pack size
for( int Sitectr = 0; Sitectr < 50; Sitectr++ )
{
String siteClm = siteArr[Sitectr];
salesForecastStrBuff.append( siteClm == null ? "" : siteClm ).append("\t");
}
salesForecastStrBuff.append("").append("\t"); //value
salesForecastStrBuff.append("").append("\t"); //total
salesForecastStrBuff.append("").append("\t"); //rate
salesForecastStrBuff.append("\n");
salesForecastStrBuff.append("Description").append("\t");
salesForecastStrBuff.append("").append("\t");
salesForecastStrBuff.append("").append("\t");
for( int Sitectr = 0; Sitectr < 50; Sitectr++ )
{
String siteClm = siteArr[Sitectr];
String siteDescr = "";
if( siteClm != null && siteClm.trim().length() > 0 )
{
sql = "Select city from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, siteClm.trim());
rs = pstmt.executeQuery();
if( rs.next() )
{
siteDescr = rs.getString("city");
}
rs.close();
pstmt.close();
rs = null;
pstmt = null;
}
salesForecastStrBuff.append( siteDescr == null ? "" : siteDescr ).append("\t");
}
salesForecastStrBuff.append("").append("\t");
salesForecastStrBuff.append("").append("\t");
salesForecastStrBuff.append("").append("\t");
salesForecastStrBuff.append("\n");
for( int listCtr1 = 0; listCtr1 < dataList.size(); listCtr1++ )
{
dataBean = ( getAllDataBean )dataList.get( listCtr1 );
String itemCode = dataBean.itemCdBn;
String itemDescr = dataBean.itemDcrBn;
if( allItems.indexOf(itemCode) == -1 )
{
total = 0.0;
salesForecastStrBuff.append( itemCode ).append("\t");
salesForecastStrBuff.append( itemDescr ).append("\t");
salesForecastStrBuff.append( packSize ).append("\t");
for( int Sitectr = 0; Sitectr < 50; Sitectr++ )
{
String siteCode = siteArr[Sitectr];
for( int listCtr = 0; listCtr < dataList.size(); listCtr++ )
{
dataBean = ( getAllDataBean )dataList.get( listCtr );
if( dataBean.itemCdBn.equals(itemCode) && dataBean.siteCdBn.equals(siteCode) )
{
salesForecastStrBuff.append( dataBean.quantity );
total = total + dataBean.quantity;
}
}
salesForecastStrBuff.append("\t");
}
rate = getRate( itemCode, conn );
value = rate * total;
salesForecastStrBuff.append( value ).append("\t");
salesForecastStrBuff.append( total ).append("\t");
salesForecastStrBuff.append( rate ).append("\t");
salesForecastStrBuff.append("\n");
allItems = allItems + itemCode;
}
}
}
catch( Exception e )
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return salesForecastStrBuff.toString();
}
private double getRate( String itemCode, Connection conn ) throws RemoteException,ITMException
{
ResultSet rs = null;
PreparedStatement pstmt = null;
double rate = 0;
String sql = "", priceList = "", lotNoFrom = "";
String parentPrLst = "";
try
{
sql = "select var_value from disparm where prd_code ='999999' and var_name ='DEFAULT_PRICE_LIST'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if( rs.next() )
{
priceList = rs.getString("var_value");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("priceList is ==>"+priceList);
System.out.println("Inside while loop....");
sql = " select lot_no__from, price_list__parent from pricelist "
+" where price_list = ? "
+" and item_code = ? "
+" and eff_from = (select max(eff_from) from pricelist "
+" where price_list = ? "
+" and item_code = ? )"
+" and valid_upto >= ? "
+" and rownum = '1'";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, priceList );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, priceList );
pstmt.setString( 4, itemCode );
pstmt.setTimestamp( 5, getCurrdateTsFormat() );
rs = pstmt.executeQuery();
if( rs.next() )
{
lotNoFrom = rs.getString("lot_no__from");
parentPrLst = rs.getString("price_list__parent");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("lotNoFrom is .."+lotNoFrom);
System.out.println("parentPrLst is .."+parentPrLst);
sql = " select rate from pricelist"
+" where price_list = ? "
+" and item_code = ? "
+" and lot_no__from <= ? "
+" and lot_no__to >= ? "
+" and list_type = 'B'";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, priceList );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, lotNoFrom );
pstmt.setString( 4, lotNoFrom );
rs = pstmt.executeQuery();
if( rs.next() )
{
rate = rs.getDouble("rate");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
System.out.println("rate is .."+rate);
if( rate == 0 )
{
System.out.println("Inside rate == 0 .....");
sql = " select lot_no__from, price_list__parent from pricelist "
+" where price_list = ? "
+" and item_code = ? "
+" and eff_from = (select max(eff_from) from pricelist "
+" where price_list = ? "
+" and item_code = ? )"
+" and valid_upto >= ? "
+" and rownum = '1'";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, parentPrLst );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, parentPrLst );
pstmt.setString( 4, itemCode );
pstmt.setTimestamp( 5, getCurrdateTsFormat() );
rs = pstmt.executeQuery();
if( rs.next() )
{
lotNoFrom = rs.getString("lot_no__from");
//parentPrLst = rs.getString("price_list__parent");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
sql = " select rate from pricelist"
+" where price_list = ? "
+" and item_code = ? "
+" and lot_no__from <= ? "
+" and lot_no__to >= ? "
+" and list_type = 'B'";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, parentPrLst );
pstmt.setString( 2, itemCode );
pstmt.setString( 3, lotNoFrom );
pstmt.setString( 4, lotNoFrom );
rs = pstmt.executeQuery();
if( rs.next() )
{
rate = rs.getDouble("rate");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
}
catch( Exception e )
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return rate;
}
private class getAllDataBean
{
public String itemCdBn = "";
public String itemDcrBn = "";
public String siteCdBn = "";
public double quantity = 0.0;
}
private class procDataBean
{
public String itemCdBn = "";
public String itemDcrBn = "";
public String siteCdBn = "";
public String[] SiteQtyArr = new String[50];
}
private Timestamp getCurrdateTsFormat()
{
String s = "";
Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return timestamp;
}
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.CreateException;
//import javax.ejb.EJBHome;
//import ibase.webitm.ejb.ProcessHome;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
import ibase.webitm.utility.ITMException;
@Local // added for ejb3`
public interface SFrcastSitesCrossTabPrcLocal extends ProcessLocal
{
//public ibase.webitm.ejb.Process create() throws RemoteException, CreateException;
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface SFrcastSitesCrossTabPrcRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface SFrcastSitesCrossTabRemote 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 dom, Document dom1,Document dom2, 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 dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class SFrcastSitesModCpy extends ValidatorEJB implements SFrcastSitesModCpyLocal, SFrcastSitesModCpyRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
/* public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("SFrcastSitesModCpyEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : SFrcastSitesModCpyEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String columnValue = null;
String childNodeName = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String errCode = null;
String userId = null,loginSite = null;
int cnt = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
String option = genericUtility.getColumnValue( "option", dom );
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 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 ( childNodeName.equalsIgnoreCase( "option" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("option","VMINVOPTN",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "prd_from" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("prd_from","VMINVPDCDF",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "prd_to" ) )
{
if( option != null && option.equals("C") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("prd_to","VMINVPDCDT",userId);
break;
}
}
}
if ( childNodeName.equalsIgnoreCase( "new_period_plan" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("new_period_plan","VMINVPDCDP",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "new_prd_for" ) )
{
if( option != null && option.equals("C") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("new_prd_for","VMINVPDCDF",userId);
break;
}
}
}
if ( childNodeName.equalsIgnoreCase( "item_ser" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_ser","VMINVITMSR",userId);
break;
}
else
{
String itemSeries = genericUtility.getColumnValue( "item_ser", dom );
if( itemSeries != null && itemSeries.trim().length() > 0 )
{
sql = "SELECT count(1) from itemser "
+" WHERE item_ser = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,itemSeries.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("item_ser","VMINVITEMS",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
if ( childNodeName.equalsIgnoreCase( "item_to" ) )
{
if( option != null && option.equals("M") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_to","VMINVIMCDT",userId);
break;
}
else
{
String itemCode = genericUtility.getColumnValue( "item_to", dom );
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = "SELECT count(1) from item "
+" WHERE item_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,itemCode.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("item_to","VMITMCDMST",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
if ( childNodeName.equalsIgnoreCase( "item_from" ) )
{
if( option != null && option.equals("M") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("item_from","VMINVITMCD",userId);
break;
}
else
{
String itemCode = genericUtility.getColumnValue( "item_from", dom );
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = "SELECT count(1) from item "
+" WHERE item_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,itemCode.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("item_from","VMITMCDMST",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
if ( childNodeName.equalsIgnoreCase( "site_code_from" ) )
{
if( option != null && option.equals("M") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("site_code_from","VMINVSTCD",userId);
break;
}
else
{
String siteCode = genericUtility.getColumnValue( "site_code_from", dom );
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = "SELECT count(1) from site "
+" WHERE site_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,siteCode.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("site_code","VMSTCDNMST",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
if ( childNodeName.equalsIgnoreCase( "site_code_to" ) )
{
if( option != null && option.equals("M") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("site_code_to","VMINVSTCD",userId);
break;
}
else
{
String siteCode = genericUtility.getColumnValue( "site_code_to", dom );
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = "SELECT count(1) from site "
+" WHERE site_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1,siteCode.trim() );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt( 1 );
}
if(cnt == 0)
{
errString =itmDBAccessEJB.getErrorString("site_to","VMSTCDNMST",userId);
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
}
if ( childNodeName.equalsIgnoreCase( "chg_by" ) )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("chg_by","VMINVCHGBY",userId);
break;
}
}
if ( childNodeName.equalsIgnoreCase( "chg_by_ddl" ) )
{
if( option != null && option.equals("M") )
{
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("chg_by_ddl","VMINVCHGBD",userId);
break;
}
}
}
}
//END OF CASE1
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId );
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < SFrcastSitesModCpyEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
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 = null;
try
{
System.out.println("xmlString" + xmlString);
dom = parseString(xmlString);
System.out.println("xmlString1" + xmlString1);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [SFrcastSitesModCpyEJB][itemChanged] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
String chguserhdr = null;
String chgtermhdr = null;
String siteCode = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
chguserhdr = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgtermhdr = getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if(currentColumn.trim().equals( "option" ))
{
String option = genericUtility.getColumnValue( "option", dom );
if( option != null && option.equals("M") )
{
valueXmlString.append("<item_to protect=\"0\" >").append("").append("</item_to>");
valueXmlString.append("<item_from protect=\"0\" >").append("").append("</item_from>");
valueXmlString.append("<site_code_from protect=\"0\" >").append("").append("</site_code_from>");
valueXmlString.append("<site_code_to protect=\"0\" >").append("").append("</site_code_to>");
valueXmlString.append("<new_period_plan protect=\"0\" >").append("").append("</new_period_plan>");
valueXmlString.append("<new_prd_for protect=\"1\" >").append("").append("</new_prd_for>");
valueXmlString.append("<chg_by_ddl protect=\"0\" >").append("").append("</chg_by_ddl>");
valueXmlString.append("<item_from_descr>").append("").append("</item_from_descr>");
valueXmlString.append("<item_to_descr>").append("").append("</item_to_descr>");
valueXmlString.append("<site_frm_descr>").append("").append("</site_frm_descr>");
valueXmlString.append("<site_to_descr>").append("").append("</site_to_descr>");
valueXmlString.append("<new_period_plan>").append("").append("</new_period_plan>");
valueXmlString.append("<new_prd_for>").append("").append("</new_prd_for>");
valueXmlString.append("<prd_from>").append("").append("</prd_from>");
valueXmlString.append("<prd_to protect=\"1\" >").append("").append("</prd_to>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
valueXmlString.append("<item_ser_descr>").append("").append("</item_ser_descr>");
valueXmlString.append("<chg_by>").append("").append("</chg_by>");
}
else if( option != null && option.equals("C") )
{
valueXmlString.append("<item_to protect=\"1\" >").append("").append("</item_to>");
valueXmlString.append("<item_from protect=\"1\" >").append("").append("</item_from>");
valueXmlString.append("<site_code_from protect=\"1\" >").append("").append("</site_code_from>");
valueXmlString.append("<site_code_to protect=\"1\" >").append("").append("</site_code_to>");
valueXmlString.append("<new_period_plan protect=\"0\" >").append("").append("</new_period_plan>");
valueXmlString.append("<new_prd_for protect=\"0\" >").append("").append("</new_prd_for>");
valueXmlString.append("<chg_by_ddl protect=\"1\" >").append("P").append("</chg_by_ddl>");
valueXmlString.append("<item_from_descr>").append("").append("</item_from_descr>");
valueXmlString.append("<item_to_descr>").append("").append("</item_to_descr>");
valueXmlString.append("<site_frm_descr>").append("").append("</site_frm_descr>");
valueXmlString.append("<site_to_descr>").append("").append("</site_to_descr>");
valueXmlString.append("<prd_from>").append("").append("</prd_from>");
valueXmlString.append("<prd_to protect=\"0\" >").append("").append("</prd_to>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
valueXmlString.append("<item_ser_descr>").append("").append("</item_ser_descr>");
valueXmlString.append("<chg_by>").append("").append("</chg_by>");
}
else
{
valueXmlString.append("<item_to protect=\"0\" >").append("").append("</item_to>");
valueXmlString.append("<item_from protect=\"0\" >").append("").append("</item_from>");
valueXmlString.append("<item_from_descr>").append("").append("</item_from_descr>");
valueXmlString.append("<item_to_descr>").append("").append("</item_to_descr>");
valueXmlString.append("<prd_from>").append("").append("</prd_from>");
valueXmlString.append("<prd_to>").append("").append("</prd_to>");
valueXmlString.append("<new_period_plan>").append("").append("</new_period_plan>");
valueXmlString.append("<new_prd_for>").append("").append("</new_prd_for>");
valueXmlString.append("<item_ser>").append("").append("</item_ser>");
valueXmlString.append("<item_ser_descr>").append("").append("</item_ser_descr>");
valueXmlString.append("<site_frm_descr>").append("").append("</site_frm_descr>");
valueXmlString.append("<site_to_descr>").append("").append("</site_to_descr>");
valueXmlString.append("<chg_by>").append("").append("</chg_by>");
valueXmlString.append("<chg_by_ddl>").append("").append("</chg_by_ddl>");
}
}
if(currentColumn.trim().equals( "item_ser" ))
{
String itemSeries = genericUtility.getColumnValue( "item_ser", dom );
String descr = "";
if( itemSeries != null && itemSeries.trim().length() > 0 )
{
sql = "SELECT descr FROM itemser "
+" WHERE item_ser = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,itemSeries.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<item_ser_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</item_ser_descr>");
}
if(currentColumn.trim().equals( "item_to" ))
{
String itemCode = genericUtility.getColumnValue( "item_to", dom );
String descr = "";
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = "SELECT descr FROM item "
+" WHERE item_code = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,itemCode.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<item_to_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</item_to_descr>");
}
if(currentColumn.trim().equals( "item_from" ))
{
String itemCode = genericUtility.getColumnValue( "item_from", dom );
String descr = "";
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = "SELECT descr FROM item "
+" WHERE item_code = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,itemCode.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<item_from_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</item_from_descr>");
}
if (currentColumn.trim().equals( "site_code_from" ))
{
siteCode = genericUtility.getColumnValue( "site_code_from", dom );
String descr = "";
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = "SELECT descr FROM site "
+" WHERE site_code = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,siteCode.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<site_frm_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</site_frm_descr>");
}
if (currentColumn.trim().equals( "site_code_to" ))
{
siteCode = genericUtility.getColumnValue( "site_code_to", dom );
String descr = "";
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = "SELECT descr FROM site "
+" WHERE site_code = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString( 1,siteCode.trim() );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<site_to_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</site_to_descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}//END OF SWITCH
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
}
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.CreateException;
//import javax.ejb.EJBHome;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface SFrcastSitesModCpyLocal extends ValidatorLocal
{
//public Validator create() throws RemoteException, CreateException;
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 dom, Document dom1,Document dom2, 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 dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : SFrcastSitesModCpyPrcEJB
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.*;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.rmi.RemoteException;
import java.util.*;
import java.lang.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class SFrcastSitesModCpyPrc extends ProcessEJB implements SFrcastSitesModCpyPrcLocal, SFrcastSitesModCpyPrcRemote
{
/* public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("Create Method Called....");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
} */
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams)
throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String retStr = "";
System.out.println("Process method called......");
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :SFrcastSitesModCpyPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}//END OF PROCESS (1)
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
PreparedStatement updtPstmt = null;
ResultSet rs = null;
ResultSet rs1 = null;
String sql = "";
String resultString = "";
String errString = "";
boolean isError = true;
boolean updtFlag = false;
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String option = genericUtility.getColumnValue("option",headerDom);
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
String tranId = "", itemCode = "";
double quantity = 0.0, updtQty = 0.0;
int updtCnt = 0;
String chgBy = genericUtility.getColumnValue("chg_by",headerDom);
String chgByDpdwn = genericUtility.getColumnValue("chg_by_ddl",headerDom);
String itemSeries = genericUtility.getColumnValue("item_ser",headerDom);
String prdFrom = genericUtility.getColumnValue("prd_from",headerDom);
String prdTo = genericUtility.getColumnValue("prd_to",headerDom);
String newPrdPln = genericUtility.getColumnValue("new_period_plan",headerDom);
String newPrdFor = genericUtility.getColumnValue("new_prd_for",headerDom);
String siteCdFr = genericUtility.getColumnValue("site_code_from",headerDom);
String siteCdTo = genericUtility.getColumnValue("site_code_to",headerDom);
if( option.equals("M") )
{
//String siteCode = genericUtility.getColumnValue("site_code",headerDom);
String itemCdFr = genericUtility.getColumnValue("item_from",headerDom);
String itemCdTo = genericUtility.getColumnValue("item_to",headerDom);
sql = "Select a.tran_id, b.item_code, b.quantity from salesforecast_hdr a, "
+" salesforecast_det b, item c where "
+" a.tran_id = b.tran_id "
+" and a.item_ser = ? "
+" and b.item_code = c.item_code "
+" and (b.item_code between ? and ?) "
+" and (a.site_code between ? and ? ) "
+" and b.prd_code__for = ? "
+" and a.prd_code__from = ? "
+" and a.prd_code__to = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, itemSeries.trim() );
pstmt.setString( 2, itemCdFr );
pstmt.setString( 3, itemCdTo );
pstmt.setString( 4, siteCdFr );
pstmt.setString( 5, siteCdTo );
pstmt.setString( 6, prdFrom.trim() );
pstmt.setString( 7, prdFrom.trim() );
pstmt.setString( 8, newPrdPln.trim() );
rs = pstmt.executeQuery();
while( rs.next() )
{
tranId = rs.getString("tran_id");
itemCode = rs.getString("item_code");
quantity = rs.getDouble("quantity");
System.out.println("quantity==>"+quantity);
if( chgByDpdwn.equals("P") )
{
updtQty = quantity + ( (Double.parseDouble(chgBy.trim())* quantity ) / 100 );
}
if( chgByDpdwn.equals("R") )
{
updtQty = Double.parseDouble(chgBy.trim());
}
if( chgByDpdwn.equals("F") )
{
updtQty = quantity + Double.parseDouble(chgBy.trim());
}
System.out.println("updtQty==>"+updtQty);
sql = "update salesforecast_det set quantity_org = ?, quantity = ? "
+" where tran_id = ? "
+" and item_code = ? "
// +" and prd_code__plan = ?"
+" and prd_code__for = ? ";
updtPstmt = conn.prepareStatement(sql);
updtPstmt.setDouble( 1, quantity );
updtPstmt.setDouble( 2, updtQty );
updtPstmt.setString( 3, tranId.trim() );
updtPstmt.setString( 4, itemCode.trim() );
updtPstmt.setString( 5, prdFrom.trim() );
//updtPstmt.addBatch();
updtCnt = updtPstmt.executeUpdate();
}
if( updtCnt > 0 )
{
errString = "PROCSUCC";
isError = false;
}
else
{
errString = "NORECINDTL";
}
}
if( option.equals("C") )
{
String siteCode = "";
String unit = "";
sql = "select site_code , tran_id from salesforecast_hdr"
+" where prd_code__from = ? and item_ser = ? order by site_code";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, prdFrom.trim() );
pstmt.setString( 2, itemSeries.trim() );
rs = pstmt.executeQuery();
while( rs.next() )
{
siteCode = rs.getString("site_code");
tranId = rs.getString("tran_id");
if( tranId != null )
{
sql = "SELECT SALESFORECAST_DET.ITEM_CODE , SALESFORECAST_DET.UNIT , SALESFORECAST_DET.QUANTITY"
+" FROM SALESFORECAST_DET "
+" WHERE SALESFORECAST_DET.TRAN_ID = ? "
+" and prd_code__plan = ? and prd_code__for = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString( 1, tranId.trim() );
pstmt1.setString( 2, prdFrom.trim() );
pstmt1.setString( 3, prdTo.trim() );
//pstmt1.setString( 3, newPrdPln.trim() );
rs1 = pstmt1.executeQuery();
while( rs1.next() )
{
itemCode = rs1.getString("ITEM_CODE");
unit = rs1.getString("UNIT");
quantity = rs1.getDouble("QUANTITY");
System.out.println("quantity==>"+quantity+" ==>"+itemCode);
updtQty = quantity + ( (Double.parseDouble(chgBy.trim()) * quantity) / 100 );
System.out.println("updtQty==>"+updtQty);
sql = "update salesforecast_det set quantity = ? "
+" where tran_id = ? "
+" and item_code = ? "
+" and prd_code__plan = ?"
+" and prd_code__for = ? ";
updtPstmt = conn.prepareStatement(sql);
updtPstmt.setDouble( 1, updtQty );
updtPstmt.setString( 2, tranId.trim() );
updtPstmt.setString( 3, itemCode.trim() );
updtPstmt.setString( 4, newPrdPln.trim() );
updtPstmt.setString( 5, newPrdFor.trim() );
updtCnt = updtPstmt.executeUpdate();
System.out.println("updtCnt is ==>"+updtCnt);
updtPstmt.close();
updtPstmt = null;
if( updtCnt > 0 )
{
System.out.println("Inside if of updtCnt > 0");
updtFlag = true;
}
}
pstmt1.close();
pstmt1 = null;
rs1.close();
rs1 = null;
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( updtFlag )
{
System.out.println("Inside if of if( updtFlag )");
errString = "PROCSUCC";
isError = false;
}
else
{
System.out.println("Inside else of if( updtFlag )");
errString = "NORECFND";
}
}
}
catch(Exception e)
{
isError = true;
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if( isError )
{
System.out.println("Inside if of if( isError )");
conn.rollback();
System.out.println("connection rollback.............");
}
else
{
System.out.println("Inside else of if( isError )");
conn.commit();
System.out.println("Commiting connection.............");
}
if( conn != null )
{
conn.close();
conn = null;
}
if( updtPstmt != null )
{
updtPstmt.close();
updtPstmt = null;
}
if( pstmt1 != null )
{
pstmt1.close();
pstmt1 = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
resultString = itmDBAccessEJB.getErrorString("",errString,userId);
}
catch(Exception sqle)
{
sqle.printStackTrace();
// throw new Exception(sqle);
}
}
return resultString;
} //end process
}//end class
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import javax.ejb.CreateException;
//import javax.ejb.EJBHome;
//import ibase.webitm.ejb.ProcessHome;
//import ibase.webitm.ejb.Process;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
import ibase.webitm.utility.ITMException;
@Local // added for ejb3`
public interface SFrcastSitesModCpyPrcLocal extends ProcessLocal
{
//public ibase.webitm.ejb.Process create() throws RemoteException, CreateException;
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
//import ibase.webitm.ejb.Process;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface SFrcastSitesModCpyPrcRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface SFrcastSitesModCpyRemote 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 dom, Document dom1,Document dom2, 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 dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) 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