Commit 3e60f4e0 authored by prahate's avatar prahate

Updated EJB Component for Report Request[D15FSUN005]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98839 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7f7d9dc4
/********************************************************
Title : ReportRequestSubmit
ReqId : [D15FSUN005]
Date : 01/OCT/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.util.*;
import java.io.File;
import java.sql.*;
import org.w3c.dom.*;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.StockAllocationPrc;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
public class ReportRequestSubmit
{
E12GenericUtility e12genericUtility = new E12GenericUtility();
private String user_lang ="en";
private String user_country = "US";
public String preSaveForm(String xmlString1 , String siteCode,String entityType, String entityCode, String chgUser , String chgTerm )throws ITMException
{
String retStr="";
Document dom = null;
System.out.println("Changes Done NOWW ReportRequestSubmit EJB called.>>>>>>>");
try
{
System.out.println("xmlString1>>>>>>>>>["+xmlString1+"]");
System.out.println("Site Code>>>>>"+siteCode);
System.out.println("entity Type>>>>>"+entityType);
System.out.println("entityCode>>>>>"+entityCode);
System.out.println("Inside bean chgUser>>>>>>>>>["+chgUser+"]::chgTerm["+chgTerm+"]");
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
// dom = GenericUtility.getInstance().parseString(xmlString1);
dom = e12genericUtility.parseString(xmlString1);
retStr=executepreSaveForm(dom,siteCode,entityType,entityCode,chgUser,chgTerm,xmlString1);
}
}
catch(Exception e)
{
System.out.println("Exception :ReportRequestSubmit ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String executepreSaveForm(Document dom , String siteCode,String entityType,String entityCode, String chgUser , String chgTerm, String xmlString1)throws ITMException
{
PreparedStatement pstmt = null;
String sql = "";
ResultSet rs = null;
String label="",name="",value="",type="";
String retString="",errString="";
String argumentString="",reportName="",suppName="";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String winName="",winNameTemp="",siteDescr="",shDescr="",tranID="",detail="",remarks="";
int parentNodeListLength=0;
int detField1=0;
Document dom1 = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
java.util.Date currentDate = new java.util.Date();
java.sql.Date date = new java.sql.Date(currentDate.getTime());
Timestamp sysDate = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
SimpleDateFormat sdf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println(" Now the date is>>>>>>> " + sysDateStr);
sysDate = Timestamp.valueOf(e12genericUtility.getValidDateString(sysDateStr, e12genericUtility.getApplDateFormat(),
e12genericUtility.getDBDateFormat())+ " 00:00:00.0");
System.out.println("TRAN DATE>>>>> :-"+sysDate);
parentNodeList = dom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
argumentString= "<Arguments>";
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{
parentNode = parentNodeList.item(lineCount);
childNodeList = parentNode.getChildNodes();
for (int detField = 0; detField < childNodeList.getLength(); detField++)
{
childNode = childNodeList.item(detField);
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("label_1_t") )
{
label = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>label:"+label);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("label_1") )
{
name = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>name:"+name);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("value_1") )
{
value = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>value:"+value);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("type") )
{
type = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>type:"+type);
String[] arrType = type.split("\\.");
System.out.println("Arr Length>"+arrType.length);
type = arrType[2];
System.out.println("type>>>"+type);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("win_name") )
{
winNameTemp = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>winName:"+winName);
}
}
argumentString += "<Argument id=\"" + name + "\">";
argumentString += "<name>" + name +"</name>";
argumentString += "<argType>" + type +"</argType>";
argumentString += "<value>" + value +"</value>";
argumentString += "</Argument>" ;//end detail field for loop
}//end detail line no for loop
argumentString += "</Arguments>";
System.out.println("argumentString>>>>>> : "+argumentString);
winName=winNameTemp.substring(2);
winName="w_"+winName;
reportName=winNameTemp;
System.out.println("WinName>>>>>"+winName);
System.out.println("WinNameTemp>>>>>"+winNameTemp);
System.out.println("reportName>>>>>"+reportName);
sql = "select sh_descr from gencodes where fld_name='REPORT_NAME' and descr= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, winName);
rs = pstmt.executeQuery();
if(rs.next())
{
shDescr = rs.getString("sh_descr");
System.out.println("shDescr>>>>>"+shDescr);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = rs.getString("descr");
System.out.println("siteDescr>>>>>"+siteDescr);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select supp_name from supplier where supp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, entityCode);
rs = pstmt.executeQuery();
if(rs.next())
{
suppName = rs.getString("supp_name");
System.out.println("suppName>>>>>"+suppName);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
StringBuffer xmlBuff = null;
String xmlString = "";
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='UTF-8'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("report_req").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext=\"1\" objName=\"report_req\" domID=\"\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(sysDate) +"]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<site_descr><![CDATA["+ siteDescr +"]]></site_descr>");
xmlBuff.append("<win_name><![CDATA["+ reportName +"]]></win_name>");
xmlBuff.append("<report_descr><![CDATA["+ shDescr +"]]></report_descr>");
xmlBuff.append("<arg_xml><![CDATA["+ argumentString +"]]></arg_xml>");
xmlBuff.append("<user_id><![CDATA["+ chgUser +"]]></user_id>");
xmlBuff.append("<entity_type><![CDATA["+ entityType +"]]></entity_type>");
xmlBuff.append("<entity_code><![CDATA["+ entityCode +"]]></entity_code>");
xmlBuff.append("<supp_name><![CDATA["+ suppName +"]]></supp_name>");
xmlBuff.append("<remarks><![CDATA["+ remarks +"]]></remarks>");
xmlBuff.append("<wf_status><![CDATA["+ "S" +"]]></wf_status>");
// xmlBuff.append("<status_date><![CDATA["+ sdf.format(sysDate) +"]]></status_date>");
// xmlBuff.append("<emp_code__aprv><![CDATA["+userId+"]]></emp_code__aprv>");
xmlBuff.append("<add_date><![CDATA["+ sdf.format(sysDate) +"]]></add_date>");
xmlBuff.append("<add_user><![CDATA["+ chgUser +"]]></add_user>");
xmlBuff.append("<add_term><![CDATA["+ chgTerm +"]]></add_term>");
xmlBuff.append("<chg_date><![CDATA["+ sdf.format(sysDate) +"]]></chg_date>");
xmlBuff.append("<chg_user><![CDATA["+chgUser+"]]></chg_user>");
xmlBuff.append("<chg_term><![CDATA["+chgTerm+"]]></chg_term>");
xmlBuff.append("</Detail1>");
if(xmlBuff!=null)
{
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("xmlString>>>>>>>>>>>>:"+xmlBuff.toString());
}
System.out.println("just before savdata()?>>>>>>>>>");
if(xmlString != null && xmlString.trim().length()>0)
{
retString = saveData(siteCode,xmlString,conn);
System.out.println("retString after saveData()>>>>>"+retString);
//Added on 20/OCT/15 for tran_id
if(retString!=null && retString.trim().length()>0)
{
dom1 = e12genericUtility.parseString(retString);
System.out.println("dom1>>>>>: "+dom1);
}
parentNodeList = dom1.getElementsByTagName("Root");
parentNodeListLength = parentNodeList.getLength();
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{
parentNode = parentNodeList.item(lineCount);
childNodeList = parentNode.getChildNodes();
for (detField1 = 0; detField1 < childNodeList.getLength(); detField1++)
{
childNode = childNodeList.item(detField1);
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("Detail") )
{
detail = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>Detail : "+detail);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("TranID") )
{
tranID = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>TranID : "+tranID);
}
}
retString=""+detail+":"+tranID+"";
System.out.println("After Parsing Return String>>>>"+retString);
}
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in ReportRequestSubmit :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in ReportRequestSubmit :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (errString == null || errString.trim().length() == 0)
{
System.out.println("@@@@@@commit errString :::"+ errString );
conn.commit();
//return errString;
}
if (pstmt!= null)
{
pstmt = null;
}
if( conn != null )
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println("The SQLException occurs in ReportRequestSubmit :"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
retString = masterStateful.processRequest(authencate, siteCode, true ,xmlString, true, conn);
}
catch(ITMException itme)
{
throw itme;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
public String getReportName( String reportName,String search ,String dbID) throws ITMException
{
System.out.println(">>>>>Inside getReportName>>>>>");
String reportNameData = "";
ReportRequestWizRemote reportReqWizRemote = null;
try
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
reportReqWizRemote = (ibase.webitm.ejb.dis.ReportRequestWizRemote)ctx.lookup("ibase/ReportRequestWiz/remote");
reportNameData = reportReqWizRemote.getReportName(reportName, search, dbID);
reportReqWizRemote = null;
System.out.println("reportNameData String=="+reportNameData);
String xslFileName = getXSLFileName( "report_req_name_set_wiz_" + this.user_lang + "_" + this.user_country + ".xsl" );
System.out.println("Inside Submit xslFileName >>>>"+xslFileName);
reportNameData = (e12genericUtility).transformToString( xslFileName, reportNameData, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
System.out.println("reportNameData= After(transformToString) ==>"+reportNameData);
}
catch ( Exception e )
{
throw new ITMException(e);
}
finally
{
if ( reportReqWizRemote != null )
{
reportReqWizRemote = null;
}
}
return reportNameData;
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
}
/********************************************************
Title : ReportRequestWiz
ReqId : [D15FSUN005]
Date : 21/SEP/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.reports.utility.XSDParser;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;
import javax.ejb.Stateless;
import java.sql.Timestamp;
@Stateless
public class ReportRequestWiz extends ValidatorEJB implements ReportRequestWizRemote,ReportRequestWizLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
System.out.println("wfValdata() called for ReportRequestWiz>>>>>");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("@@@@@@@@@@@@@@@xmlString["+xmlString+"]@@@@@@@@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@@@@@xmlString1["+xmlString1+"]@@@@@@@@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@@@@@xmlString2["+xmlString2+"]@@@@@@@@@@@@@@@@@@");
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0 )
{
dom1 = parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String errorType = "";
String childNodeName = null;
String errString = "";
String errCode = "";
String userId = "";
String reportName="",winName="";
int ctr=0;
int cnt = 0;
int currentFormNo = 0;
int childNodeListLength;
String sql="";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
System.out.println(">><<<<<<<<<<<<<<editFlag"+editFlag);
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("report_name"))
{
reportName=genericUtility.getColumnValue("report_name", dom);
System.out.println("Report Name>>>>>"+reportName);
if(reportName == null || reportName.trim().length() == 0)
{
errCode = "VTREPNULL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
/*else
{
System.out.println("Inside wfValData report!null");
sql="select count(*) from gencodes where fld_name='REPORT_NAME' and mod_name='W_REPORT_REQUEST_WIZ' and descr like ? order by descr ";
System.out.println("sql:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "%"+reportName+"%");
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "ERRORMSG";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}*/
}
}
}//end switch
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode);
if(errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if(errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//end try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
return errString;
} // end of wfValData
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;
System.out.println("itemChanged() called for ReportRequestWiz");
String valueXmlString = "";
try
{
System.out.println("xmlString:::"+xmlString);
System.out.println("xmlString1:::"+xmlString1);
System.out.println("xmlString2:::"+xmlString2);
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ReportRequestWiz][itemChanged( String, String )] :==>\n" + e.getMessage());
}
return valueXmlString;
}
//start of itemchange
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0 , currentFormNo = 0,childNodeListLength=0 ;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
ConnDriver connDriver = new ConnDriver();
SimpleDateFormat simpleDateFormat = null;
String xsdName="",xsdNameTemp="",sql="",descr="";
String loginSiteCode="";
SimpleDateFormat sdf = null;
Timestamp timestamp = null;
String currDate="";
String argValueFinal="w_",argValueTemp="";
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
timestamp = new Timestamp(System.currentTimeMillis());
currDate = (sdf.format(timestamp).toString()).trim();
System.out.println("Current Date>>>>>>>>>"+currDate);
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
if(currentColumn.trim().equals("itm_default"))
{
System.out.println("In Case(1) Itemchange()>>>>");
xsdName=genericUtility.getColumnValue("report_name", dom);
System.out.println("XSD File Name>>>"+xsdName);
}
valueXmlString.append("</Detail1>");
break;
case 2 :
parentNodeList = dom1.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
xsdName=genericUtility.getColumnValue("report_name", dom1);
System.out.println("XSD File Name>>>"+xsdName);
XSDParser xsdParser = new XSDParser(xsdName);
String argString=xsdParser.getArgumentMetaDataString();
System.out.println(">>>argStringBuff.toString():"+argString.toString());
Document domfinal = parseString(argString.toString());
NodeList argNodeList = domfinal.getElementsByTagName("argument");
int noOfArgs = argNodeList.getLength();
xsdNameTemp=xsdName.substring(2);
xsdNameTemp="w_"+xsdNameTemp;
System.out.println("Final XSD(Report Win Name>>>) : "+xsdNameTemp);
sql="select sh_descr from gencodes where fld_name='REPORT_NAME' and descr= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, xsdNameTemp);
rs = pstmt.executeQuery();
if (rs.next())
{
descr= checkNull(rs.getString("sh_descr"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
for(ctr = 0; ctr < noOfArgs; ctr++)
{
Node curArgNode = argNodeList.item(ctr);
String argLabel=curArgNode.getAttributes().getNamedItem("label").getNodeValue();
String argName=curArgNode.getAttributes().getNamedItem("name").getNodeValue();
String argType=curArgNode.getAttributes().getNamedItem("type").getNodeValue();
String argValue=curArgNode.getAttributes().getNamedItem("value").getNodeValue();
String argVisible=curArgNode.getAttributes().getNamedItem("visible").getNodeValue();
String argEditable=curArgNode.getAttributes().getNamedItem("editable").getNodeValue();
String argSize=curArgNode.getAttributes().getNamedItem("size").getNodeValue();
// String argReportTitle=curArgNode.getAttributes().getNamedItem("reportTitle").getNodeValue();
String argDisplayType=curArgNode.getAttributes().getNamedItem("displayType").getNodeValue();
String argrowNo=curArgNode.getAttributes().getNamedItem("displayType").getNodeValue();
String argcolNo=curArgNode.getAttributes().getNamedItem("displayType").getNodeValue();
if(argName.equalsIgnoreCase("design_source"))
{
argVisible="Y";
argValue=removeLastChar(argValue);
}
if("login_site".equalsIgnoreCase(argValue) || "Login_site".equalsIgnoreCase(argValue) || "login_Site".equalsIgnoreCase(argValue))
{
argValue = loginSiteCode;
}
if("java.util.Date".equalsIgnoreCase(argType))
{
argValue = currDate;
}
if("Y".equalsIgnoreCase(argVisible))
{
valueXmlString.append("<Detail2 dbID=\"\" domID= '"+ (ctr + 1) +"'>");
valueXmlString.append("<label_1_t>").append("<![CDATA["+argLabel+"]]>").append("</label_1_t>");
valueXmlString.append("<label_1>").append("<![CDATA["+argName+"]]>").append("</label_1>");
valueXmlString.append("<value_1>").append("<![CDATA["+argValue+"]]>").append("</value_1>");
valueXmlString.append("<editable>").append("<![CDATA["+argEditable+"]]>").append("</editable>");
valueXmlString.append("<type>").append("<![CDATA["+argType+"]]>").append("</type>");
valueXmlString.append("<win_name>").append("<![CDATA["+xsdName+"]]>").append("</win_name>");
valueXmlString.append("<descr>").append("<![CDATA["+descr+"]]>").append("</descr>");
valueXmlString.append("<visible>").append("<![CDATA["+argVisible+"]]>").append("</visible>");
valueXmlString.append("<size>").append("<![CDATA["+argSize+"]]>").append("</size>");
valueXmlString.append("<displayType>").append("<![CDATA["+argDisplayType+"]]>").append("</displayType>");
valueXmlString.append("<rowNo>").append("<![CDATA["+argrowNo+"]]>").append("</rowNo>");
valueXmlString.append("<colNo>").append("<![CDATA["+argcolNo+"]]>").append("</colNo>");
valueXmlString.append("</Detail2>");
}
}
System.out.println("xml string::::"+valueXmlString);
}
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
public String getReportName(String reportName, String search, String dbID) throws ITMException
{
System.out.println("reportName >>>>>>>>>>>["+reportName+"]");
System.out.println("search >>>>>>>>>>>>>>>["+search+"]");
System.out.println("dbID >>>>>>>>>>>>>>>>>["+dbID+"]");
String selectSql = "",descr="",shDescr="",reportNameTemp="d_";
StringBuffer valueXmlString = new StringBuffer("<Root>\r\n");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
if(reportName == null || reportName.trim().length() == 0)
{
selectSql = "select descr,sh_descr from gencodes where fld_name='REPORT_NAME' and mod_name='W_REPORT_REQUEST_WIZ' order by descr";
pstmt = conn.prepareStatement(selectSql);
rs = pstmt.executeQuery();
int num = 1;
while (rs.next())
{
descr= checkNull(rs.getString("descr"));
shDescr=checkNull(rs.getString("sh_descr"));
descr=descr.substring(2);
reportName=reportNameTemp+descr;
valueXmlString.append("<Report domID='" + num + "' selected = 'N'>\r\n");
valueXmlString.append("<report_name>").append("<![CDATA[" + reportName + "]]>").append("</report_name>\r\n");
valueXmlString.append("<report_descr protect = '1'>").append("<![CDATA[" + shDescr + "]]>").append("</report_descr>\r\n");
valueXmlString.append("</Report>\r\n");
num++;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
selectSql = "select descr,sh_descr from gencodes where fld_name='REPORT_NAME' and mod_name='W_REPORT_REQUEST_WIZ' and descr like ? order by descr ";
pstmt = conn.prepareStatement(selectSql);
pstmt.setString(1, "%"+reportName+"%");
rs = pstmt.executeQuery();
int num = 1;
while (rs.next())
{
descr= checkNull(rs.getString("descr"));
shDescr=checkNull(rs.getString("sh_descr"));
descr=descr.substring(2);
reportName=reportNameTemp+descr;
valueXmlString.append("<Report domID='" + num + "' selected = 'N'>\r\n");
valueXmlString.append("<report_name>").append("<![CDATA[" + reportName + "]]>").append("</report_name>\r\n");
valueXmlString.append("<report_descr protect = '1'>").append("<![CDATA[" + shDescr + "]]>").append("</report_descr>\r\n");
valueXmlString.append("</Report>\r\n");
num++;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :ReportRequestWiz :getReportName(String,String):" + e.getMessage() + ":");
valueXmlString = valueXmlString.append(genericUtility.createErrorString(e));
}
finally
{
try
{
if (conn != null && !conn.isClosed())
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("Exception :ReportRequestWiz :getReportName(String,String) :==>\n"+ e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
System.out.println("\n****ValueXmlString ::" + valueXmlString.toString() + ":********");
return valueXmlString.toString();
}
//end of itemchange
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}//end of errorType
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
private static String removeLastChar(String str)
{
return str.substring(0,str.length()-6);
}
private String getObjName(Node node) throws Exception
{
String objName = "";
NamedNodeMap attrMap = node.getAttributes();
objName = attrMap.getNamedItem("objName").getNodeValue();
System.out.println(" Object Name is-->" + objName);
return objName;
}
}
/********************************************************
Title : ReportRequestWizLocal
ReqId : [D15FSUN005]
Date : 21/SEP/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface ReportRequestWizLocal extends ValidatorLocal
{
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(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;
public String getReportName(String reportName, String search, String dbID)throws ITMException;
}
\ No newline at end of file
/********************************************************
Title : ReportRequestWizRemote
ReqId : [D15FSUN005]
Date : 21/SEP/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface ReportRequestWizRemote extends ValidatorRemote
{
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(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;
public String getReportName(String reportName, String search, String dbID)throws ITMException;
}
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