package ibase.webitm.ejb.dis;

import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

@Stateless
public class BillofQuantityAct extends ActionHandlerEJB
implements BillofQuantityActLocal, BillofQuantityActRemote
{
	GenericUtility genericUtility = GenericUtility.getInstance();
	String act_type = null;

	@Override
	public String actionHandler()
			throws RemoteException, ITMException
			{
		return "";
			}

	@Override
	public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams)
			throws RemoteException, ITMException
			{
		Document dom = null;
		Document dom1 = null;
		String retString = null;
		try
		{
			if ((xmlString != null) && (xmlString.trim().length() != 0))
			{
				System.out.println("XML String ===================>:" + xmlString);
				dom = this.genericUtility.parseString(xmlString);
				System.out.println("dom :" + dom);
			}
			if ((xmlString1 != null) && (xmlString1.trim().length() != 0))
			{
				System.out.println("@@@@@XML String1 ===================>:" + xmlString1);
				dom1 = this.genericUtility.parseString(xmlString1);
			}

			System.out.println("actionType:" + actionType + ":");

			if (actionType.equalsIgnoreCase("ITEMList"))
			{
				retString = getItemListDetails(dom, dom1, objContext, xtraParams);
			}

		}
		catch (Exception e)
		{
			System.out.println("Exception :ModelHandler :actionHandler(String xmlString):" + e.getMessage() + ":");
			e.printStackTrace();
			throw new ITMException(e);
		}
		System.out.println("returning String from ModelHandler : actionHandler" + retString);
		return retString;
			}

	@Override
	public String actionHandlerTransform(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams, String selDataStr) throws RemoteException, ITMException
	{
		System.out.println("[PorderActEJB] actionHandlerTransform is calling.............");
		Document dom = null;
		Document dom1 = null;
		Document selDataDom = null;

		String retString = null;
		try
		{
			if ((xmlString != null) && (xmlString.trim().length() != 0))
			{
				dom = GenericUtility.getInstance().parseString(xmlString);
			}
			if ((xmlString1 != null) && (xmlString1.trim().length() != 0))
			{
				dom1 = GenericUtility.getInstance().parseString(xmlString1);
			}
			if ((selDataStr != null) && (selDataStr.length() > 0))
			{
				selDataDom = GenericUtility.getInstance().parseString(selDataStr);
			}

			System.out.println("actionType:" + actionType + ":");

			if (actionType.equalsIgnoreCase("ITEMList"))
			{
				retString = itemListTransform(dom, dom1, objContext, xtraParams, selDataDom);
			}
		}
		catch (Exception e)
		{
			System.out.println("Exception :PorderActEJB :actionHandlerTransform(String xmlString):" + e.getMessage() + ":");
			e.printStackTrace();
			throw new ITMException(e);
		}
		System.out.println("returning String from PorderActEJB : actionHandlerTransform" + retString);
		return retString;
	}

	private String getItemListDetails(Document dom, Document dom1, String objContext, String xtraParams)
			throws RemoteException, ITMException
			{
		System.out.println("getItemListDetails is callled..");
		String itemCode = ""; String itemSer = ""; String unit = ""; String sql = ""; String sql1 = ""; String unitStd = ""; String unitRate = ""; String convRateStduom = ""; String packCode = ""; String remarks = ""; String amount = ""; String siteCode = ""; String indentNo = "";
		String packInstr = ""; String specInstr = ""; String splInstr = ""; String hremarks = ""; String currCode = ""; String exchRate = ""; String projCode = ""; String hstatus = ""; String amountBc = ""; String suppCodePref = ""; String hunit = ""; String hamount = ""; String splInstrh = ""; String hsplInstr = "";
		String hRate = ""; String tranId = ""; String hItemCode = ""; String htranType = ""; String hindentNo = ""; String hunitStd = ""; String hpackCode = ""; String hpackInstr = ""; String netAmountBc = ""; String hunitRate = ""; String hspecInstr = "",hsitecode = "",hitemSer = "",ditemCode = "",dItemCode = "",confirm = "", errString = "" ; 

		StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
		PreparedStatement pstmt = null; PreparedStatement pstmt1 = null;
		ResultSet rs = null;
		Connection conn = null;

		double quantity = 0.0D; double hquantity = 0.0D; double rate = 0.0D; double hrate = 0.0D; double quantityStduom = 0.0D; double convQtyStduom = 0.0D;
		double hquantityStduom = 0.0D; double hconvQtyStduom = 0.0D; double hnetAmount = 0.0D; double hnetAmountBc = 0.0D; double hconvRateStduom = 0.0D; double hnoArt = 0.0D; double noArt = 0.0D; double rateStduom = 0.0D,hrateStduom = 0.0;
		ConnDriver connDriver = new ConnDriver();
		ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
		GenericUtility genericUtility = GenericUtility.getInstance();
		try
		{
			SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
			itemCode = genericUtility.getColumnValue("item_code", dom);
			System.out.println("item code = " + itemCode);
			conn = connDriver.getConnectDB("DriverITM");
			//changes for temp test 
			sql = "select confirmed from boqhdr where item_code = ?";
			pstmt = conn.prepareStatement(sql);
			//dItemCode
			pstmt.setString(1, itemCode);
			rs = pstmt.executeQuery();
			if(rs.next())
			{
				confirm = checkNull(rs.getString("confirmed"));
				System.out.println("confirm --->>>["+confirm+"]");
			}
			rs.close();
			rs = null;
			pstmt.close();
			pstmt = null;
			//end of changes 
			if("Y".equalsIgnoreCase(confirm))
			{
				System.out.println("SQL START DETAIL-->>");
				sql = "select (case when d.item_code is null then ' ' else d.item_code end) as item_code," +
						"(case when d.item_ser is null then ' ' else d.item_ser end) as item_ser," +
						"(case when d.tran_id is null then ' ' else d.tran_id end) as tran_id," +
						"(case when d.quantity is null then 0 else d.quantity end) as quantity," +
						"(case when d.unit is null then ' ' else d.unit end) as unit," +
						"(case when d.quantity__stduom is null then 0 else d.quantity__stduom end) as quantity__stduom," +
						"(case when d.conv__qty_stduom is null then 0 else d.conv__qty_stduom end) as conv__qty_stduom," +
						"(case when d.unit__std is null then ' ' else d.unit__std end) as unit__std," +
						"(case when d.rate is null then 0 else d.rate end) as rate ," +
						"(case when d.unit__rate is null then ' ' else d.unit__rate end) as unit__rate, " +
						"(case when d.conv__rate_stduom is null then 0 else d.conv__rate_stduom end) as conv__rate_stduom ," +
						"(case when d.no_art is null then 0 else d.no_art end) as no_art," +
						"(case when d.pack_code is null then ' ' else d.pack_code end) as pack_code," +
						"(case when d.remarks is null then ' ' else d.remarks end) as remarks," +
						"(case when d.pack_instr is null then ' ' else d.pack_instr end) as pack_instr," +
						"(case when d.spec_instr is null then ' ' else d.spec_instr end) as spec_instr," +
						"(case when d.spl_instr is null then ' ' else d.spl_instr end) as spl_instr," +
						"(case when h.item_code is null then ' ' else h.item_code end) as hitemcode , " +
						"(case when h.site_code is null then ' ' else h.site_code end) as hsitecode , " +
						"(case when h.indent_no is null then ' ' else h.indent_no end) as hindentno , " +
						"(case when d.rate__stduom is null then 0 else d.rate__stduom end) as rate__stduom," +
						"(case when d.amount is null then 0 else d.amount end) as amount  from boqdet d,boqhdr h where d.tran_id = h.tran_id  and h.item_code = ? ";

				System.out.println("Detail data sql [PorderActEJB] sql==>" + sql);
				pstmt = conn.prepareStatement(sql);
				//dItemCode
				pstmt.setString(1, itemCode);
				rs = pstmt.executeQuery();
				while (rs.next())
				{
					ditemCode = checkNull(rs.getString("item_code"));
					System.out.println("Deatail ITEM CODE --->>[" + itemCode + "]");
					itemSer = checkNull(rs.getString("item_ser"));
					tranId = checkNull(rs.getString("tran_id"));
					System.out.println("tranId--[" + tranId + "]>>");
					quantity = rs.getDouble("quantity");
					System.out.println("quantity --->>[" + quantity + "]");
					unit = checkNull(rs.getString("unit"));
					quantityStduom = rs.getDouble("quantity__stduom");
					rate = rs.getDouble("rate");
					convQtyStduom = rs.getDouble("conv__qty_stduom");
					unitStd = checkNull(rs.getString("unit__std"));
					unitRate = checkNull(rs.getString("unit__rate"));
					convRateStduom = checkNull(rs.getString("conv__rate_stduom"));
					noArt = rs.getDouble("no_art");
					packCode = checkNull(rs.getString("pack_code"));
					remarks = checkNull(rs.getString("remarks"));
					packInstr = checkNull(rs.getString("pack_instr"));
					specInstr = checkNull(rs.getString("spec_instr"));
					splInstr = checkNull(rs.getString("spl_instr"));
					amount = checkNull(rs.getString("amount"));
					hItemCode = checkNull(rs.getString("hitemcode"));
					System.out.println("hItemCode-->>["+hItemCode+"]");
					siteCode = checkNull(rs.getString("hsitecode"));
					System.out.println("siteCode-->>["+siteCode+"]");
					indentNo = checkNull(rs.getString("hindentno"));
					System.out.println("indentNo-->>["+indentNo+"]");
					rateStduom = rs.getDouble("rate__stduom");
					System.out.println("te Stduom --[" + rateStduom + "]>>");

					valueXmlString.append("<Detail>\r\n");
					valueXmlString.append("<item_code>").append("<![CDATA[").append(ditemCode).append("]]>").append("</item_code>\r\n");
					valueXmlString.append("<item_ser>").append("<![CDATA[").append(itemSer).append("]]>").append("</item_ser>\r\n");
					valueXmlString.append("<rate>").append("<![CDATA[").append(rate).append("]]>").append("</rate>\r\n");
					valueXmlString.append("<quantity>").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>\r\n");
					valueXmlString.append("<unit>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
					valueXmlString.append("<amount>").append("<![CDATA[").append(amount).append("]]>").append("</amount>\r\n");
					valueXmlString.append("<no_art>").append("<![CDATA[").append(noArt).append("]]>").append("</no_art>\r\n");
					valueXmlString.append("<pack_code>").append("<![CDATA[").append(packCode).append("]]>").append("</pack_code>\r\n");
					valueXmlString.append("<pack_instr>").append("<![CDATA[").append(packInstr).append("]]>").append("</pack_instr>\r\n");
					valueXmlString.append("<spec_instr>").append("<![CDATA[").append(specInstr).append("]]>").append("</spec_instr>\r\n");
					valueXmlString.append("<spl_instr>").append("<![CDATA[").append(splInstr).append("]]>").append("</spl_instr>\r\n");
					valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
					valueXmlString.append("<unit__rate>").append("<![CDATA[").append(unitRate).append("]]>").append("</unit__rate>\r\n");
					valueXmlString.append("<conv__qty_stduom>").append("<![CDATA[").append(convQtyStduom).append("]]>").append("</conv__qty_stduom>\r\n");
					valueXmlString.append("<conv__rate_stduom>").append("<![CDATA[").append(convRateStduom).append("]]>").append("</conv__rate_stduom>\r\n");
					valueXmlString.append("<unit__std>").append("<![CDATA[").append(unitStd).append("]]>").append("</unit__std>\r\n");
					valueXmlString.append("<quantity__stduom>").append("<![CDATA[").append(quantityStduom).append("]]>").append("</quantity__stduom>\r\n");
					valueXmlString.append("<rate__stduom>").append("<![CDATA[").append(rateStduom).append("]]>").append("</rate__stduom>\r\n");
					valueXmlString.append("<ind_no>").append("<![CDATA[").append(indentNo).append("]]>").append("</ind_no>\r\n");
					valueXmlString.append("<remarks>").append("<![CDATA[").append(remarks).append("]]>").append("</remarks>\r\n");

					valueXmlString.append("</Detail>\r\n");
				}

				rs.close();
				rs = null;
				pstmt.close();
				pstmt = null;
				sql1 = "select " +
						//"(case when d.item_code is null then ' ' else d.item_code end) as item_code ," +
						"(case when h.quantity is null then 0 else h.quantity end) as quantity," +
						"(case when h.item_ser is null then ' ' else h.item_ser end ) as item_ser ," +
						"(case when h.site_code is null then ' ' else h.site_code end) as site_code," +
						"(case when h.indent_no is null then ' ' else h.indent_no end ) as indent_no ," +
						"(case when h.remarks is null then ' ' else h.remarks end) as remarks," +
						"(case when h.curr_code is null then ' ' else h.curr_code end) as curr_code," +
						"(case when h.exch_rate is null then 0 else h.exch_rate end) as exch_rate," +
						"(case when h.proj_code is null then ' ' else h.proj_code end) as proj_code," +
						"(case when h.status is null then ' ' else h.status end) as status," +
						"(case when h.amount__bc is null then 0 else h.amount__bc end) as amount__bc," +
						"(case when h.supp_code__pref is null then ' ' else h.supp_code__pref end) as supp_code__pref," +
						"(case when h.unit is null then ' ' else h.unit end) as unit," +
						"(case when h.amount is null then 0 else h.amount end) as amount,  h.tran_date as tran_date, " +
						"(case when h.tran_type is null then ' 'else h.tran_type end) as tran_type, " +
						"(case when h.indent_no is null then ' ' else h.indent_no end) as indent_no, " +
						"(case when h.quantity__stduom is null then 0 else h.quantity__stduom end) as quantity__stduom, " +
						"(case when h.conv__qty_stduom is null then 0 else h.conv__qty_stduom end) as conv__qty_stduom, " +
						"(case when h.unit__std is null then ' ' else h.unit__std end) as unit__std, " +
						"(case when h.rate is null then 0 else h.rate end) as rate, " +
						"(case when h.net_amount is null then 0 else h.net_amount end) as net_amount, " +
						"(case when h.pack_code is null then ' ' else h.pack_code end) as pack_code, " +
						"(case when h.pack_instr is null then ' ' else h.pack_instr end) as pack_instr, " +
						"(case when h.spl_instr is null then ' ' else h.spl_instr end) as spl_instr, " +
						"(case when h.net_amount__bc is null then 0 else h.net_amount__bc end) as net_amount__bc, " +
						"(case when h.unit__rate is null then ' ' else h.unit__rate end) as unit__rate, " +
						"(case when h.conv__rate_stduom is null then 0 else h.conv__rate_stduom end) as conv__rate_stduom," +
						"(case when h.spec_instr is null then ' ' else h.spec_instr end) as spec_instr, " +
						"(case when h.no_art is null then 0 else h.no_art end) as no_art," +
						"(case when h.rate__stduom is null then 0 else h.rate__stduom end) as rate__stduom from boqhdr h,item itm where itm.item_code = h.item_code and h.item_code = ? ";

				System.out.println("[Header Data for PorderActEJB] sql==>" + sql);
				pstmt1 = conn.prepareStatement(sql1);
				//
				pstmt1.setString(1,hItemCode);
				rs = pstmt1.executeQuery();
				while (rs.next())
				{
					//	dItemCode = rs.getString("item_code");
					hitemSer = checkNull(rs.getString("item_ser"));
					hquantity = rs.getDouble("quantity");
					hremarks = checkNull(rs.getString("remarks"));
					currCode = checkNull(rs.getString("curr_code"));
					siteCode = checkNull(rs.getString("site_code"));
					exchRate = checkNull(rs.getString("exch_rate"));
					projCode = checkNull(rs.getString("proj_code"));
					hstatus = checkNull(rs.getString("status"));
					amountBc = checkNull(rs.getString("amount__bc"));
					suppCodePref = checkNull(rs.getString("supp_code__pref"));
					hunit = checkNull(rs.getString("unit"));
					hamount = checkNull(rs.getString("amount"));
					htranType = checkNull(rs.getString("tran_type"));
					hindentNo = checkNull(rs.getString("indent_no"));
					hquantityStduom = rs.getDouble("quantity__stduom");
					hconvQtyStduom = rs.getDouble("conv__qty_stduom");
					hunitStd = checkNull(rs.getString("unit__std"));
					hrate = rs.getDouble("rate");
					hnetAmount = rs.getDouble("net_amount");
					hpackCode = checkNull(rs.getString("pack_code"));
					hpackInstr = checkNull(rs.getString("pack_instr"));
					hsplInstr = checkNull(rs.getString("spl_instr"));
					hspecInstr = checkNull(rs.getString("spec_instr"));
					hnoArt = rs.getDouble("no_art");
					hnetAmountBc = rs.getDouble("net_amount__bc");
					hunitRate = checkNull(rs.getString("unit__rate"));
					hconvRateStduom = rs.getDouble("conv__rate_stduom");
					hrateStduom = rs.getDouble("rate__stduom");

					valueXmlString.append("<Detail>\r\n");
					valueXmlString.append("<item_code>").append("<![CDATA[").append(hItemCode).append("]]>").append("</item_code>\r\n");
					valueXmlString.append("<item_ser>").append("<![CDATA[").append(hitemSer).append("]]>").append("</item_ser>\r\n");
					valueXmlString.append("<rate>").append("<![CDATA[").append(hrate).append("]]>").append("</rate>\r\n");
					valueXmlString.append("<quantity>").append("<![CDATA[").append(hquantity).append("]]>").append("</quantity>\r\n");
					valueXmlString.append("<unit>").append("<![CDATA[").append(hunit).append("]]>").append("</unit>\r\n");
					valueXmlString.append("<amount>").append("<![CDATA[").append(hamount).append("]]>").append("</amount>\r\n");
					valueXmlString.append("<no_art>").append("<![CDATA[").append(hnoArt).append("]]>").append("</no_art>\r\n");
					valueXmlString.append("<pack_code>").append("<![CDATA[").append(hpackCode).append("]]>").append("</pack_code>\r\n");
					valueXmlString.append("<pack_instr>").append("<![CDATA[").append(hpackInstr).append("]]>").append("</pack_instr>\r\n");
					valueXmlString.append("<spec_instr>").append("<![CDATA[").append(hspecInstr).append("]]>").append("</spec_instr>\r\n");
					valueXmlString.append("<spl_instr>").append("<![CDATA[").append(hsplInstr).append("]]>").append("</spl_instr>\r\n");
					valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
					valueXmlString.append("<unit__rate>").append("<![CDATA[").append(hunitRate).append("]]>").append("</unit__rate>\r\n");
					valueXmlString.append("<conv__qty_stduom>").append("<![CDATA[").append(hconvQtyStduom).append("]]>").append("</conv__qty_stduom>\r\n");
					valueXmlString.append("<conv__rate_stduom>").append("<![CDATA[").append(hconvRateStduom).append("]]>").append("</conv__rate_stduom>\r\n");
					valueXmlString.append("<unit__std>").append("<![CDATA[").append(hunitStd).append("]]>").append("</unit__std>\r\n");
					valueXmlString.append("<quantity__stduom>").append("<![CDATA[").append(hquantityStduom).append("]]>").append("</quantity__stduom>\r\n");
					valueXmlString.append("<rate__stduom>").append("<![CDATA[").append(hrateStduom).append("]]>").append("</rate__stduom>\r\n");
					valueXmlString.append("<ind_no>").append("<![CDATA[").append(hindentNo).append("]]>").append("</ind_no>\r\n");
					valueXmlString.append("<remarks>").append("<![CDATA[").append(remarks).append("]]>").append("</remarks>\r\n");
					valueXmlString.append("</Detail>\r\n");
				}

				rs.close();
				rs = null;
				pstmt1.close();
				pstmt1 = null;
				valueXmlString.append("</Root>\r\n");
			}
			else 
			{
				errString = itmDBAccessEJB.getErrorString("","UNCONFBIL","","",conn);
				return errString;
			}
			System.out.println("Header data from boqhdr ITEM CODE -->>" + itemCode);
			System.out.println("Header data from boqhdr-->>");
		}
		catch (Exception e)
		{
			System.out.println("Exception : PorderActEJB : actionHandler :(Document dom)" + e.getMessage());
			throw new ITMException(e);
		}
		finally
		{
			try
			{
				System.out.println("Closing Connection.....");
				conn.close();
				conn = null;
			} catch (Exception localException1) {
			}
		}
		return valueXmlString.toString();
			}

	private String itemListTransform(Document dom, Document dom1, String objContext, String xtraParams, Document selDataDom) throws ITMException
	{
		System.out.println("[PorderActEJB] gpListTransform is calling.............");
		Connection conn = null;
		StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
		Node currDetail = null; Node currDetail1 = null;
		int count = 0;
		double stkQty = 0.0D;
		ConnDriver connDriver = new ConnDriver();
		ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
		GenericUtility genericUtility = GenericUtility.getInstance();
		String objName = "";
		try
		{
			conn = connDriver.getConnectDB("DriverITM");

			NodeList detailList = selDataDom.getElementsByTagName("Detail");
			//Node parentNode = parentNodeList.item(0);
			int noOfDetails = detailList.getLength();

			for (int ctr = 0; ctr < noOfDetails; ctr++)
			{
				currDetail = detailList.item(ctr);
			}
			if (noOfDetails > 0)
			{
				for (int ctr = 0; ctr < noOfDetails; ctr++)
				{
					valueXmlString.append("<Detail>");
					currDetail1 = detailList.item(ctr);

					valueXmlString.append("<item_ser>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("item_ser", currDetail1)).append("]]>").append("</item_ser>\r\n");
					valueXmlString.append("<item_code>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("item_code", currDetail1)).append("]]>").append("</item_code>\r\n");
					valueXmlString.append("<quantity>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("quantity", currDetail1)).append("]]>").append("</quantity>\r\n");
					valueXmlString.append("<unit>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("unit", currDetail1)).append("]]>").append("</unit>\r\n");
					valueXmlString.append("<rate>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("rate", currDetail1)).append("]]>").append("</rate>\r\n");
					valueXmlString.append("<amount>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("amount", currDetail1)).append("]]>").append("</amount>\r\n");
					valueXmlString.append("<no_art>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("no_art", currDetail1)).append("]]>").append("</no_art>\r\n");
					valueXmlString.append("<pack_code>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("pack_code", currDetail1)).append("]]>").append("</pack_code>\r\n");
					valueXmlString.append("<pack_instr>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("pack_instr", currDetail1)).append("]]>").append("</pack_instr>\r\n");
					valueXmlString.append("<spec_instr>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("spec_instr", currDetail1)).append("]]>").append("</spec_instr>\r\n");
					valueXmlString.append("<spl_instr>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("spl_instr", currDetail1)).append("]]>").append("</spl_instr>\r\n");
					valueXmlString.append("<site_code>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("site_code", currDetail1)).append("]]>").append("</site_code>\r\n");
					valueXmlString.append("<unit__rate>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("unit__rate", currDetail1)).append("]]>").append("</unit__rate>\r\n");
					//valueXmlString.append("<ind_no>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("ind_no", currDetail1)).append("]]>").append("</ind_no>\r\n");
					valueXmlString.append("<remarks>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("remarks", currDetail1)).append("]]>").append("</remarks>\r\n");
					valueXmlString.append("<unit__std>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("unit__std", currDetail1)).append("]]>").append("</unit__std>\r\n");
					valueXmlString.append("<unit__std>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("unit__std", currDetail1)).append("]]>").append("</unit__std>\r\n");
					valueXmlString.append("<conv__qty_stduom>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("conv__qty_stduom", currDetail1)).append("]]>").append("</conv__qty_stduom>\r\n");
					valueXmlString.append("<conv__rtuom_stduom>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("conv__rate_stduom", currDetail1)).append("]]>").append("</conv__rtuom_stduom>\r\n");
					valueXmlString.append("<quantity__stduom>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("quantity__stduom", currDetail1)).append("]]>").append("</quantity__stduom>\r\n");
					valueXmlString.append("<rate__stduom>").append("<![CDATA[").append(genericUtility.getColumnValueFromNode("rate__stduom", currDetail1)).append("]]>").append("</rate__stduom>\r\n");
					valueXmlString.append("</Detail>");
				}
			}

			valueXmlString.append("</Root>");
		}
		catch (ITMException itme)
		{
			throw itme;
		}
		catch (Exception e)
		{
			throw new ITMException(e);
		}
		finally
		{
			try
			{
				System.out.println("Closing Connection...");
				conn.close();
				conn = null;
			} catch (Exception localException1) {
			}
		}
		System.out.println("[PorderActEJB] gpListTransform() : valueXmlString from :" + valueXmlString.toString());
		return valueXmlString.toString();
	}

	private String getObjName(Node node) throws Exception {
		String objName = null;
		NodeList nodeList = null;
		Node detaulNode = null;
		Node detailNode = null;
		nodeList = node.getChildNodes();
		NamedNodeMap attrMap = node.getAttributes();
		objName = attrMap.getNamedItem("objName").getNodeValue();

		return "w_" + objName;
	}

	private String checkNull(String input)
	{
		if (input == null)
		{
			input = "";
		}
		return input;
	}
}