Commit e33fb626 authored by wansari's avatar wansari

W16CBAS005 added components BugListEJB and BugResolutionProcess


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@102611 ce508802-f39f-4f6c-b175-0d175dae99d5
parent dcde8fa6
/**
* Author : Wasim Ansari
* Date : 24-06-2016
* Description : Bug Fix Screen [W16CBAS005]
* */
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
@javax.ejb.Stateless
public class BugListEJB extends ValidatorEJB implements BugListEJBLocal, BugListEJBRemote
{
/**
* The method defined with no paramter and returns nothing
*/
public String wfValData() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for validation of required fields which inturn called overloded method
* Returns validation string in XML format if exist otherwise returns null
* @param xmlString contains the current form data in XML format
* @param xmlString1 contains always header form data in XML format
* @param xmlString2 contains all forms data in XML format
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginCode etc
*/
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;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
if( xmlString != null && xmlString.trim().length()!=0 )
{
dom = genericUtility.parseString(xmlString);
}
if( xmlString1 != null && xmlString1.trim().length()!=0 )
{
dom1 = genericUtility.parseString(xmlString1);
}
if( xmlString2 != null && xmlString2.trim().length()!=0 )
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams );
System.out.println ( "ErrString: " + errString);
}
catch(Exception e)
{
System.out.println ( "Exception: AsnLotStatIC: wfValData(String xmlString): " + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println ( "Returning from AsnLotStatIC wfValData" );
return ( errString );
}
/**
* The public overloded method is used for validation of required fields
* Returns validation string if exist otherwise returns null in XML format
* @param dom contains the current form data
* @param dom1 contains always header form data
* @param dom2 contains all forms data
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contais additional information such as loginEmpCode,loginCode,chgTerm etc
*/
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String columnValue = "";
String errString = "";
String lotNo = "";
String itemCode = "";
int currentFormNo = 0;
int count = 0;
String columnName = "";
String sql = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pStmt = null;
GenericUtility genericUtility = GenericUtility.getInstance();
StringBuffer valueXmlString = new StringBuffer();
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = "";
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
try
{
SimpleDateFormat sdft = new SimpleDateFormat( genericUtility.getApplDateFormat() );
//ConnDriver connDriver = null;
//connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
int noOfChilds = 0;
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
if ( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
switch( currentFormNo )
{
case 1 :
{
parentList = dom.getElementsByTagName( "Detail" + currentFormNo );
for ( int pctr = 0; pctr < parentList.getLength(); pctr++ )
{
parentNode = parentList.item( pctr);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
for ( int ctr = 0; ctr < childList.getLength(); ctr++ )
{
childNode = childList.item(ctr);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
String childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
columnName = childNode.getNodeName();
if( "obj_name".equalsIgnoreCase(columnName) )
{
String objName = checkNull((genericUtility.getColumnValue("obj_name",dom)));
if(objName == null || objName.length() ==0)
{
errList.add( "UVFDREQ" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = "select count(*) from transetup where tran_window =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, "w_"+columnValue.trim());
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();rs = null;
pStmt.close();pStmt = null;
if( count == 0 )
{
errList.add( "VTBLNKOBJ" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
else if( "solu_desired".equalsIgnoreCase(columnName) )
{
String soluDesired = checkNull((genericUtility.getColumnValue("solu_desired",dom)));
if(soluDesired == null || soluDesired.length() ==0)
{
errList.add( "VTSOLDES" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if( "resolved_ver".equalsIgnoreCase(columnName) )
{
String resolvedVer = checkNull((genericUtility.getColumnValue("resolved_ver",dom)));
if(resolvedVer == null || resolvedVer.length() ==0)
{
errList.add( "VTRESVER" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if( "trans_affected".equalsIgnoreCase(columnName) )
{
String transAffected = checkNull((genericUtility.getColumnValue("trans_affected",dom)));
if(transAffected == null || transAffected.length() ==0)
{
errList.add( "VTAFFTRAN" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if( "comp_delivered".equalsIgnoreCase(columnName) )
{
String compDelivered = checkNull((genericUtility.getColumnValue("comp_delivered",dom)));
if(compDelivered == null || compDelivered.length() ==0)
{
errList.add( "VTCOMPDEL" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
}
}//end of case 1
break;
}//end of switch
int errListSize = errList.size();
int cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = (String)errList.get(cnt);
errFldName = (String)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;//+"<trace>"+errMsg+"</trace>";
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}//end of try block
catch( Exception e )
{
throw new ITMException(e);
}//end of catch block
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null && !pStmt.isClosed() )
{
pStmt.close();
pStmt = null;
}
if( conn != null && !conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch( Exception e )
{
System.out.println( "Exception :Bug Fix:wfValData :==>\n"+e.getMessage());
throw new ITMException(e);
}
}//end of finally block
return ( errString );
}//
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if ( xmlString != null && xmlString.trim().length()!=0 )
{
dom = genericUtility.parseString(xmlString);
}
if ( xmlString1 != null && xmlString1.trim().length()!=0 )
{
dom1 = genericUtility.parseString(xmlString1);
}
if ( xmlString2 != null && xmlString2.trim().length()!=0 )
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch ( Exception e )
{
System.out.println ( "Exception :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
}
System.out.println ( "returning from Bug Fix itemChanged" );
return (errString);
}
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
String sql = "";
String columnValue = "";
String siteCode = "";
String siteDescr = "";
String empCodeAprv = "";
String firstName = "";
String middleName = "";
String lastName = "";
String itemDescr = "";
String lotNo = "";
String itemCode= "";
String holdStatus = "";
String loginSiteCode = "";
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("Inside bug list itemChanged");
//ConnDriver connDriver = null;
//connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("DriverValidator");
conn = getConnection();
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"chgTerm");
columnValue = genericUtility.getColumnValue( currentColumn, dom );
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch( currentFormNo )
{
case 1:
{
valueXmlString.append( "<Detail1>\r\n" );
if("itm_default".equalsIgnoreCase(currentColumn))
{
valueXmlString.append("<bug_id><![CDATA[").append(checkNull("")).append("]]></bug_id>\r\n");
valueXmlString.append("<obj_name><![CDATA[").append(checkNull("")).append("]]></obj_name>\r\n");
valueXmlString.append("<descr><![CDATA[").append(checkNull("")).append("]]></descr>\r\n");
valueXmlString.append("<solu_desired><![CDATA[").append(checkNull("")).append("]]></solu_desired>\r\n");
valueXmlString.append("<resolved_ver><![CDATA[").append(checkNull("")).append("]]></resolved_ver>\r\n");
valueXmlString.append("<status><![CDATA[").append(checkNull("P")).append("]]></status>\r\n" );
valueXmlString.append("<trans_affected><![CDATA[").append(checkNull("")).append("]]></trans_affected>\r\n");
valueXmlString.append("<comp_delivered><![CDATA[").append(checkNull("")).append("]]></comp_delivered>\r\n");
valueXmlString.append("<add_date><![CDATA[").append(checkNull(sysDate)).append("]]></add_date>\r\n");
valueXmlString.append("<add_term><![CDATA[").append(checkNull(chgTerm)).append("]]></add_term>\r\n" );
valueXmlString.append("<add_user><![CDATA[").append(checkNull(userId)).append("]]></add_user>\r\n" );
}
else if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
valueXmlString.append( "<chg_user><![CDATA[" ).append(checkNull(userId)).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append(checkNull(sysDate)).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_term><![CDATA[" ).append(checkNull(chgTerm)).append( "]]></chg_term>\r\n" );
}
valueXmlString.append( "</Detail1>\r\n" );
}//end of case 1
break;
}//end of switch
}//end of try block
catch( Exception e )
{
throw new ITMException(e);
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null && !pStmt.isClosed() )
{
pStmt.close();
pStmt = null;
}
if( conn != null && !conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch( Exception e )
{
System.out.println( "Exception :Bug List :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append( "</Root>\r\n" );
return valueXmlString.toString();
}//end of itemchange
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input.trim();
}
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;
}
}
/**
* Author : Wasim Ansari
* Date : 24-06-2016
* Description : Bug Fix Screen
* */
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Local
public interface BugListEJBLocal extends ValidatorLocal
{
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
/**
* Author : Wasim Ansari
* Date : 24-06-2016
* Description : Bug Fix Screen
* */
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface BugListEJBRemote 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;
}
package ibase.webitm.ejb.dis;
/*
* Author:Wasim Ansari
* Date:24-JUNE-16
* Request W16CBAS005 (Bug Resolution Process)
*/
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.reports.utility.XSDParser;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
import oracle.jdbc.OracleTypes;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@javax.ejb.Stateless
public class BugResolutionPrc extends ProcessEJB implements BugResolutionPrcLocal, BugResolutionPrcRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
boolean isError = false;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Entered in bug resolution process.");
String retStr = "";
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("xmlString--->>" + xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("xmlString2 --->>" + xmlString2);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
e.printStackTrace();
retStr = e.getMessage();
}
return retStr;
}
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retString = "";
String loginEmpCode = "",userId = "",loginSite = "",chgTerm = "",bufFixesTranID = "",objName = "",status = "";
String errString = "";
String bugID = "",tranID = "";
//ConnDriver connDriver = new ConnDriver();
Connection conn = null;
String sql = "";
ResultSet rs = null,rsInsert = null;
PreparedStatement pstmt = null;
CallableStatement cstmt = null;
int count = 0;
try
{
System.out.println("Inside Try Block in PreSave");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
java.sql.Timestamp currDate = getCurrtDate();
System.out.println("Current date is"+currDate);
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
String currDateStr = sdfAppl.format(currDate);
loginEmpCode = checkNullAndTrim(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = checkNullAndTrim((genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode")));
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
bugID = checkNullAndTrim(( genericUtility.getColumnValue( "bug_id", dom )));
System.out.println("Bug Id="+bugID);
tranID = checkNullAndTrim(( genericUtility.getColumnValue( "tran_id", dom )));
System.out.println("Tran Id="+tranID);
if(!bugID.equalsIgnoreCase("") && !tranID.equalsIgnoreCase(""))
{
sql = " SELECT OBJ_NAME,STATUS FROM BUGLIST WHERE BUG_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bugID);
rs = pstmt.executeQuery();
if(rs.next())
{
objName = checkNullAndTrim(rs.getString("OBJ_NAME"));
status = checkNullAndTrim(rs.getString("STATUS"));
count++;
}
if ( rs != null )
{
rs.close();rs = null;
}
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
if(count == 0)
{
System.out.println("Bug Id is not found");
errString = itmDBAccessEJB.getErrorString("","VTINVBUGID","","",conn);
return errString;
}
else if("D".equalsIgnoreCase(status))//if already deployed
{
System.out.println("Transaction is already deployed");
errString = itmDBAccessEJB.getErrorString("","VTDEPLOYED","","",conn);
return errString;
}
String SQL = "{call bugfixes_proc (?, ?, ?)}";
cstmt = conn.prepareCall (SQL);
cstmt.setString(1, bugID);
cstmt.setString(2, tranID);
//cstmt.registerOutParameter(3, OracleTypes.CURSOR);
cstmt.registerOutParameter(3, java.sql.Types.VARCHAR);
cstmt.executeUpdate();
String resultStr = cstmt.getString(3);
System.out.println("Result String recived=["+resultStr+"]");
//rs = (ResultSet) cstmt.getObject(3);//For cusrosr
//while (rs.next())
//{
//String bugIdRes = rs.getString("BUG_ID");
//String objName = rs.getString("OBJ_NAME");
//String refID = rs.getString("REF_ID");
//String executeDate = rs.getString("EXECUTE_DATE");
bufFixesTranID = generateTranTd("w_bugfixes",currDateStr,loginSite,conn);
sql = " INSERT INTO BUG_FIXES (TRAN_ID,BUG_ID,OBJ_NAME,REF_ID,EXECUT_DATE,RESULT_STR)"
+" VALUES (?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bufFixesTranID);
pstmt.setString(2, bugID);
pstmt.setString(3, objName);
pstmt.setString(4, tranID);
pstmt.setTimestamp(5, currDate);
pstmt.setString(6, resultStr);
int cnt = pstmt.executeUpdate();
System.out.println("Insert count="+cnt);
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
if("SUCCESS".equalsIgnoreCase(resultStr))
{
sql = "UPDATE BUGLIST SET STATUS = 'D' WHERE BUG_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bugID);
pstmt.executeUpdate();
cnt = pstmt.executeUpdate();
System.out.println("Update count="+cnt);
if( pstmt != null )
{
pstmt.close();pstmt = null;
}
}
//}
if( cstmt != null )
{
cstmt.close();cstmt = null;
}
}
else
{
if(bugID.length() == 0)
{
System.out.println("Bug Id is blank");
errString = itmDBAccessEJB.getErrorString("","VTBUGID","","",conn);
return errString;
}
else if (tranID.length() == 0)
{
System.out.println("Tran Id is blank");
errString = itmDBAccessEJB.getErrorString("","VMTRANID","","",conn);//Tran Id should not be null
return errString;
}
}
}
catch(Exception e)
{
isError = true;
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if( cstmt != null )
{
cstmt.close();
cstmt = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(isError)
{
System.out.println("Rollbacking.................");
retString = itmDBAccessEJB.getErrorString("","VTPRCERR","","",conn);//Process Not Completed Successfully
conn.rollback();
}
else
{
System.out.println("commiting.................");
conn.commit();
retString = itmDBAccessEJB.getErrorString("","VTCOMPL","","",conn);//Process Completed Successfully
}
if( conn != null )
{
conn.close();
conn = null;
}
}
catch( Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
private String generateTranTd(String windowName,String tranDate,String siteCode, Connection conn )throws ITMException
{
System.out.println("inside generateTranTd@@.........");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String tranId = "";
String newKeystring = "",tranSer1 = "",keyString = "",keyCol = "";
CommonConstants commonConstants = new CommonConstants();
try
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, windowName);
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql);
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
else
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "GENERAL");
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql);
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>"+ tranDate + "</tran_date>";
xmlValues = xmlValues + "<tran_type>"+"U"+"</tran_type>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId ::"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return tranId;
}
private java.sql.Timestamp getCurrtDate() throws RemoteException,ITMException
{
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString()+ " 00:00:00.0");
}
catch (Exception e)
{
throw new ITMException(e);
}
return (currDate);
}
@Override
public String process() throws RemoteException, ITMException {
// TODO Auto-generated method stub
return null;
}
}
/**
Title : BugResolutionPrcLocal
Date : 05/07/2016
Author: Wasim Ansari
*/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Local
public interface BugResolutionPrcLocal extends ProcessLocal
{
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;
}
\ No newline at end of file
/**
Title : BugResolutionPrcRemote
Date : 05/07/2016
Author: Wasim Ansari
*/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface BugResolutionPrcRemote 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;
}
\ 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