Commit 80c98707 authored by SABURI PATEKAR's avatar SABURI PATEKAR

Add department check — If Support/Implementation, force EXEC_APRV = 'Y', EXEC_RIGHTS = Live

Add REVIEW_YN handling — When KB sir sets review, notify PP/SM Sir via mail
parent e8d0dc33
/*
* Author: Gagan B., Ajit D.
* Date: 11-NOV-2025
* Purpose: Logic for activities to be done Post Manage SQL Transaction
* */
package ibase.webitm.ejb.sys;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import org.w3c.dom.Document;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class ManageSQLAprv extends ValidatorEJB {
E12GenericUtility genericUtility = new E12GenericUtility();
public String updateWFStatus() throws RemoteException, ITMException {
return "";
}
public String updateWFStatus(String domString, Connection conn) throws RemoteException, ITMException {
String refSer = "";
String tranID = "";
String signStatus = "";
boolean isLocalConn = false;
String empCode = "";
String allocatedTo = "";
String signRemarks = "";
String retString = "";
String reviewYn = "";
PreparedStatement updPstmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
UserInfoBean userInfo = getUserInfo();
BaseLogger.log("3", null, null, "userInfo 91::" + userInfo.toString() + "]");
System.out.println("ManageSQLAprv.updateWFStatus() domString testtttttttt[" + domString + "]");
if (conn == null) {
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB(userInfo.getTransDB());
isLocalConn = true;
}
Document dom = genericUtility.parseString(domString);
signStatus = checkNull(genericUtility.getColumnValue("sign_status", dom, "1"));
signRemarks = checkNull(genericUtility.getColumnValue("sign_remarks", dom, "1"));
refSer = genericUtility.getColumnValue("ref_ser", dom, "1");
tranID = genericUtility.getColumnValue("ref_id", dom, "1");
empCode = genericUtility.getColumnValue("emp_code", dom, "1");
allocatedTo = checkNull(genericUtility.getColumnValue("allocated_to", dom, "1"));
System.out.println("tran_id::" + tranID + " signStatus::" + signStatus);
// ===== UPDATE =====
String updSql = "UPDATE sql_changes SET wf_status = ?, wf_remarks = ?, aprv_level = ? WHERE tran_id = ?";
updPstmt = conn.prepareStatement(updSql);
if ("R".equalsIgnoreCase(signStatus)) {
updPstmt.setString(1, "R");
updPstmt.setString(2, signRemarks);
updPstmt.setNull(3, java.sql.Types.INTEGER);
} else if ("S".equalsIgnoreCase(signStatus)) {
updPstmt.setString(1, "A");
updPstmt.setNull(2, java.sql.Types.VARCHAR);
updPstmt.setInt(3, 2);
}
updPstmt.setString(4, tranID);
int updCnt = updPstmt.executeUpdate();
System.out.println("Updated count:: " + updCnt);
// STOP if rejected
if ("R".equalsIgnoreCase(signStatus)) {
System.out.println("Workflow rejected");
return "";
}
// ===== FETCH XML ===== //Added By Saburi
String sql = "select OST.TRANS_INFO_XML.getClobval() XML_DATA from obj_sign_trans OST where ref_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranID);
rs = pstmt.executeQuery();
if (rs.next()) {
String xmlData = rs.getString("XML_DATA");
BaseLogger.log("3", null, null, "ManageSQLAprv in xmlData:: " + xmlData);
if (xmlData != null && xmlData.trim().length() > 0) {
Document detailDom = genericUtility.parseString(xmlData);
BaseLogger.log("3", null, null, "ManageSQLAprv in detailDom:: " + detailDom);
reviewYn = genericUtility.getColumnValue("review_yn", detailDom);
BaseLogger.log("3", null, null, "ManageSQLAprv in reviewYn:: " + reviewYn);
if ("Y".equalsIgnoreCase(reviewYn) && "S".equalsIgnoreCase(signStatus))
{
sendReviewMail(tranID, reviewYn, userInfo, detailDom, conn);
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
if (rs != null)
rs.close();
} catch (Exception e) {
}
try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}
try {
if (updPstmt != null)
updPstmt.close();
} catch (Exception e) {
}
try {
if (conn != null && isLocalConn) {
conn.close();
conn = null;
}
} catch (Exception e) {
}
}
return retString;
}
public static String formatDateTime(LocalDate tranDate, LocalTime tranTime) {
LocalDateTime tranDateTime = LocalDateTime.of(tranDate, tranTime);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = tranDateTime.format(formatter);
return formattedDateTime;
}
public static String dateFormatter(String inputDateString) {
String result = "";
String inputFormat = "yyyy-MM-dd HH:mm:ss";
String outputFormat = "dd/MM/yy HH:mm:ss";
try {
// Parse input date string
SimpleDateFormat inputFormatter = new SimpleDateFormat(inputFormat);
Date date = inputFormatter.parse(inputDateString);
// Format the date in the desired output format
SimpleDateFormat outputFormatter = new SimpleDateFormat(outputFormat);
String outputDateString = outputFormatter.format(date);
System.out.println("Input Date: " + inputDateString);
System.out.println("Formatted Date: " + outputDateString);
result = outputDateString;
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception in dateFormatter. [" + E12GenericUtility.getStackTrace(e) + "]");
}
return result;
}
private void closeResources(ResultSet rs, PreparedStatement pstmt, Connection conn) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private String checkNull(String input) {
if (input == null) {
input = "";
}
return input;
}
//Added By Saburi-24Apr2026 for sending email for sql review request
private void sendReviewMail(String tranID, String reviewYn, UserInfoBean userInfo, Document detailDom, Connection conn)
{
try {
BaseLogger.log("3", null, null, "===== sendReviewMail START =====");
BaseLogger.log("3", null, null, "tranID:: " + tranID);
BaseLogger.log("3", null, null, "reviewYn:: " + reviewYn);
if (detailDom == null) {
BaseLogger.log("3", null, null, "ERROR: detailDom is NULL");
return;
}
EMail email = new EMail();
String mailSubject = "Request for Approval: SQL Execution [" + tranID + "]";
// ===== Fetch values from XML =====
String reqId = checkNull(genericUtility.getColumnValue("req_id", detailDom)).trim();
String reqDescr = checkNull(genericUtility.getColumnValue("req_descr", detailDom));
String addedBy = checkNull(genericUtility.getColumnValue("name", detailDom));
String custName = checkNull(genericUtility.getColumnValue("cust_name", detailDom));
String tranDate = checkNull(genericUtility.getColumnValue("tran_date", detailDom));
String enterprise = checkNull(genericUtility.getColumnValue("enterprises", detailDom));
String sql = "SELECT ORA_STMNT FROM SQL_CHANGES_DET WHERE TRAN_ID = ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranID);
ResultSet rs = pstmt.executeQuery();
StringBuilder sqlBuilder = new StringBuilder();
while (rs.next())
{
String sqlStmt = checkNull(rs.getString("ORA_STMNT"));
BaseLogger.log("3", null, null, "Fetched SQL:: " + sqlStmt);
if (sqlStmt != null && sqlStmt.trim().length() > 0) {
sqlBuilder.append(sqlStmt);
sqlBuilder.append("\n\n----------------------------------------\n\n"); // separator
}
}
String finalSql = sqlBuilder.toString();
// ===== HTML Body =====
StringBuilder body = new StringBuilder();
body.append("<html><body style='font-family: Arial, sans-serif; font-size: 13px;'>");
body.append("<p>Dear Piyush Sir / SM Sir,</p>");
body.append(
"<p>KB Sir has requested your review for the below Transaction SQL.</p>");
// ===== Transaction Summary Box =====
body.append("<div style='border:1px solid #d3d3d3; background-color:#f5f5f5; padding:15px; width:600px;'>");
body.append("<h4 style='margin-top:0;'>Transaction Summary:</h4>");
body.append("<table style='width:100%;'>");
String labelStyle = "style='padding:4px 8px; font-weight:bold; width:40%;'";
String valueStyle = "style='padding:4px 8px;'";
body.append(
"<tr><td " + labelStyle + ">Transaction ID:</td><td " + valueStyle + ">" + tranID + "</td></tr>");
body.append("<tr><td " + labelStyle + ">Request ID / Ticket ID:</td><td " + valueStyle + ">" + reqId
+ "</td></tr>");
body.append("<tr><td " + labelStyle + ">Request Description:</td><td " + valueStyle + ">" + reqDescr
+ "</td></tr>");
body.append("<tr><td " + labelStyle + ">Added By:</td><td " + valueStyle + ">" + addedBy + "</td></tr>");
body.append(
"<tr><td " + labelStyle + ">Customer Name:</td><td " + valueStyle + ">" + custName + "</td></tr>");
body.append("<tr><td " + labelStyle + ">Initiation Date:</td><td " + valueStyle + ">" + tranDate
+ "</td></tr>");
body.append(
"<tr><td " + labelStyle + ">Enterprises:</td><td " + valueStyle + ">" + enterprise + "</td></tr>");
body.append("</table>");
body.append("</div>");
// =========================
// ✅ ADD THIS BLOCK (SQL UI)
// =========================
body.append("<div style='margin-top:25px;'>");
body.append("<h4 style='margin-bottom:10px; font-size:14px; color:#333;'>SQL Details:</h4>");
body.append(
"<table style='width:600px; border:1px solid #dcdcdc; border-collapse:collapse; background-color:#fafafa;'>");
body.append("<tr>");
body.append(
"<td style='padding:0; border:1px solid #dcdcdc;'>");
body.append(
"<div style='background-color:#2b2b2b; color:#f8f8f2; " +
"padding:15px; font-family:Courier New, monospace; " +
"font-size:12px; line-height:1.6; " +
"white-space:pre-wrap; word-wrap:break-word;'>");
body.append(finalSql);
body.append("</div>");
body.append("</td>");
body.append("</tr>");
body.append("</table>");
body.append("</div>");
// =========================
body.append("</body></html>");
String mailBody = body.toString();
BaseLogger.log("3", null, null, "mailBody:: " + mailBody);
// ===== Emails =====
// String toEmails = "saburi.patekar@proteustech.in";
String toEmail1 = getSysparmValue(conn, "MS_REV_EMAIL_1");
String toEmail2 = getSysparmValue(conn, "MS_REV_EMAIL_2");
String ccEmail = getSysparmValue(conn, "MS_REV_EMAIL_EXEC");
// Combine TO emails
String toEmails = toEmail1;
if (toEmail2 != null && toEmail2.length() > 0)
{
toEmails = toEmails + "," + toEmail2;
BaseLogger.log("3", null, null, "toEmails::@@@ " + toEmails);
}
String mailXml = "<ROOT>" +
"<MAIL>" +
"<EMAIL_TYPE>page</EMAIL_TYPE>" +
"<ENTITY_CODE>BASE</ENTITY_CODE>" +
"<ENTITY_TYPE>E</ENTITY_TYPE>" +
"<MESSAGE_TYPE><![CDATA[text/html]]></MESSAGE_TYPE>" +
"<SUBJECT><![CDATA[" + mailSubject + "]]></SUBJECT>" +
"<BODY_TEXT><![CDATA[" + mailBody + "]]></BODY_TEXT>" +
"<TO_ADD>" + toEmails + "</TO_ADD>" +
"<CC_ADD>" + ccEmail + "</CC_ADD>" +
"<BCC_ADD></BCC_ADD>" +
"<ATTACHMENT><BODY></BODY><LOCATION></LOCATION></ATTACHMENT>" +
"</MAIL>" +
"</ROOT>";
BaseLogger.log("3", null, null, "Mail XML:: " + mailXml);
String result = email.sendMail(mailXml, "ITM", userInfo);
BaseLogger.log("3", null, null, "Mail sent result:: " + result);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error sending review mail:: " + e.getMessage());
}
}
private String getSysparmValue(Connection conn, String varName) throws SQLException {
String value = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String sql = "SELECT var_value FROM sysparm WHERE var_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, varName);
rs = pstmt.executeQuery();
if (rs.next()) {
value = checkNull(rs.getString("var_value")).trim();
}
} finally {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
}
return value;
}
}
\ No newline at end of file
package ibase.webitm.ejb.wsfa.masters;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
//import org.apache.poi.util.SystemOutLogger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class ManageSql extends ValidatorEJB {
public String wfValData() throws RemoteException, ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
System.out.println("Inside wfValData updated method 20/07/22 ::: Ajit");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("wfValData value of xmlString ["+xmlString+"]");
System.out.println("wfValData value of xmlString ["+xmlString1+"]");
System.out.println("wfValData value of xmlString ["+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: wfValData(String xmlString): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println ("Returning from wfValData");
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("20/07/22 ::: jay");
try {
BaseLogger.log("3", getUserInfo(), null, "dom case2*>>>> Elements>>["+genericUtility.serializeDom(dom).toString()+"]");//added for testing
BaseLogger.log("3", getUserInfo(), null, "dom2 case2*>>>> Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");//added for testing
BaseLogger.log("3", getUserInfo(), null, "dom1 case2*>>>> Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
} catch (BaseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}//added for testing
String userId = "";
String requestId = "";//changed by Ashish.J
String sql="";
String errString = "";
Connection connection = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
ITMDBAccessEJB itmDBAccess = null;
String reqid="";//changed by Ashish.J
int noOfChilds = 0;
int currentFormNo = 0;
try
{
SimpleDateFormat DOB = new SimpleDateFormat(getApplDateFormat());
itmDBAccess = new ITMDBAccessEJB();
connection = getConnection();
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);
int parentNodeListLength = parentList.getLength();
System.out.println("parentNodeListLength["+parentNodeListLength+"]");
for (int prntCtr = 0; prntCtr < parentNodeListLength; prntCtr++ )
{
parentNode = parentList.item(prntCtr);
System.out.println("value of parentNode"+parentNode);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
System.out.println("value of noOfChilds"+noOfChilds);
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item(ctr);
System.out.println("childNode"+childNode);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
childNodeName = childNode.getNodeName();
if( childNodeName.equalsIgnoreCase("enterprises") )
{
String appldb = checkNull(genericUtility.getColumnValue("appl_db", dom));
if (childNode.getFirstChild() == null )
{
if(appldb.equalsIgnoreCase("S"))
{
errString = getErrorString("enterprises","NULENTRPRS",userId);
break;
}
}
else
{
String enterprise = checkNull(getColumnValue("enterprises",dom,"1"));
String [] temp = enterprise.split(",");
for(int i = 0 ;i < temp.length;i++)
{
String ent = temp[i];
int count=0;
sql = "SELECT COUNT(*) AS COUNT FROM ENTERPRISE WHERE ENTERPRISE=?";
System.out.println("pophelp query for enterprise " + sql);
pstmt = connection.prepareStatement(sql);
pstmt.setString(1, ent);
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
errString = getErrorString("enterprises","INVENTRPRS",userId);
break;
}
}
}
}
if( childNodeName.equalsIgnoreCase("req_id") )
{
reqid = genericUtility.getColumnValue("req_id", dom);//changed by Ashish.J
if (reqid!=null && reqid.trim().length()>0 )
{
sql = "SELECT COUNT(*) AS COUNT FROM SER_REQUEST WHERE REQ_ID =?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,reqid);
rs = pstmt.executeQuery();
int count = 0;
if( rs.next() )
{
count = rs.getInt("COUNT");
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
System.out.println("not a Valid Field name"+reqid);
errString = getErrorString("req_id","INVLDREQID",userId);
break;
}
}
}
if( childNodeName.equalsIgnoreCase("itm_ver") )
{
if (childNode.getFirstChild() == null )
{
}
else
{
String div = checkNull(getColumnValue("itm_ver",dom,"1"));
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER =?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,div);
rs = pstmt.executeQuery();
int count = 0;
if( rs.next() )
{
count = rs.getInt("COUNT");
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
System.out.println("not a Valid Field name"+div);
errString = getErrorString("itm_ver","INVLDDIV",userId);
break;
}
}
}
if( childNodeName.equalsIgnoreCase("emp_code__given") )
{
if (childNode.getFirstChild() == null )
{
}
else
{
String empcg = checkNull(getColumnValue("emp_code__given",dom,"1"));
sql = "SELECT COUNT(1) NAME FROM USERS WHERE CODE =?";
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,empcg);
rs = pstmt.executeQuery();
int count = 0;
if( rs.next() )
{
count = rs.getInt(1);
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
errString = getErrorString("emp_code__given","INVLDSUB",userId);
break;
}
}
}
if( childNodeName.equalsIgnoreCase("emp_code__merge") )
{
if (childNode.getFirstChild() == null )
{
}
else
{
String empcm = checkNull(getColumnValue("emp_code__merge",dom,"1"));
sql = "SELECT COUNT(1) NAME FROM USERS WHERE CODE =?";
System.out.println("pophelp query for enterprise " + sql);
pstmt = connection.prepareStatement(sql);
pstmt.setString(1,empcm);
rs = pstmt.executeQuery();
int count = 0;
if( rs.next() )
{
count = rs.getInt(1);
}
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count == 0)
{
System.out.println("not a Valid Field name"+empcm);
errString = getErrorString("emp_code__merge","INVLDMER",userId);
break;
}
}
}
//End elseif
}//End for loop
}//End for loop
break;
}//case1
}//switch
}//try
catch (Exception e)
{
System.out.println ("Exception: wfValData(Document dom): " + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(connection != null)
{
connection.close();
connection = null;
}
}
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
}
}
return (errString);
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext,
String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
try {
E12GenericUtility genericUtility = new ibase.utility.E12GenericUtility();
if (xmlString != null && xmlString.trim().length() != 0) {
BaseLogger.log("3", null, null, "itemchange header xmlString>>>>" + xmlString);
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
BaseLogger.log("3", null, null, "xmlString1>>>>" + xmlString1);
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
BaseLogger.log("3", null, null, "xmlString2>>>>" + xmlString2);
dom2 = genericUtility.parseString(xmlString2);
BaseLogger.log("3", null, null, "dom2::: gsb-" + genericUtility.serializeDom(dom2));
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} catch (Exception e) {
BaseLogger.log("3", null, null, "Exception itemChanged::::" + e.getMessage() + ":");
e.printStackTrace();
}
BaseLogger.log("3", null, null, "returning from itemChanged method");
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException, ITMException
{
System.out.println(" itemchange method called...");
BaseLogger.log("3", null, null, "Itemchanged Called ");
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
String userId = "",sql="",empmcode="";//changed by Ashish.J
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn=null;
try
{
E12GenericUtility genericUtility = new ibase.utility.E12GenericUtility();
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");//changed by Ashish.J
if (objContext != null && objContext.trim().length() > 0)
currentFormNo = Integer.parseInt(objContext);
currentColumn = currentColumn == null ? "" : currentColumn.trim();
BaseLogger.log("3", null, null, "currentColumn>>>"+ currentColumn);
SimpleDateFormat formatter = new SimpleDateFormat(genericUtility.getApplDateFormat());
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
switch (currentFormNo)
{
case 1:// first From //this code for auto date generates
valueXmlString.append("<Detail1>");
if ("itm_default".equalsIgnoreCase(currentColumn))
{
Date dte = new Date();
String currentDate = "";
currentDate = formatter.format(dte);
valueXmlString.append("<tran_date>").append("<![CDATA[" + currentDate + "]]>").append("</tran_date>");
valueXmlString.append("<emp_code__given>").append("<![CDATA[" + userId + "]]>").append("</emp_code__given>");//changed by Ashish.J
valueXmlString.append("<emp_code__merge>").append("<![CDATA[" + userId + "]]>").append("</emp_code__merge>");
valueXmlString.append("<exec_rights>").append("<![CDATA[]]>").append("</exec_rights>");
valueXmlString.append("<APRV_LEVEL>").append("<![CDATA["+0+"]]>").append("</APRV_LEVEL>");
String reviewYn = checkNull(genericUtility.getColumnValue("review_yn", dom));
if (reviewYn == null || reviewYn.trim().length() == 0)
{
reviewYn = "N"; // default only if empty
}
valueXmlString.append("<review_yn>").append("<![CDATA[" + reviewYn + "]]>").append("</review_yn>");
sql = "SELECT NAME FROM USERS WHERE CODE='" + userId + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String empgName = "";
String deptCode = "";
String execAprv = "";
if (rs.next())
{
empgName = rs.getString("NAME") != null ? rs.getString("NAME").trim() : "";
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
sql = "SELECT dept_code FROM employee WHERE emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, getUserInfo().getEmpCode());
rs = pstmt.executeQuery();
if (rs.next())
{
deptCode = rs.getString("dept_code") != null ? rs.getString("dept_code").trim() : "";
BaseLogger.log("3", null, null, "deptCode 503>>>"+ deptCode);
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if ("0110".equals(deptCode) || "0120".equals(deptCode))
{
execAprv = "Y";
valueXmlString.append("<exec_rights>").append("<![CDATA[A]]>").append("</exec_rights>");
valueXmlString.append("<exec_aprv protect='1'>").append("<![CDATA["+execAprv+"]]>").append("</exec_aprv>\r\n");
BaseLogger.log("3", null, null, "execAprv 520>>>"+ execAprv);
}
valueXmlString.append("<name><![CDATA[").append(empgName).append("]]></name>\r\n");
valueXmlString.append("<users_name><![CDATA[").append(empgName).append("]]></users_name>\r\n");
valueXmlString.append("<exec_aprv>").append("<![CDATA["+execAprv+"]]>").append("</exec_aprv>\r\n");
BaseLogger.log("3", null, null, "execAprv 523@@>>>"+ execAprv);
//changed by Ashish.J
}
else if ("itm_defaultedit".equalsIgnoreCase(currentColumn))
{
String applDB = checkNull(genericUtility.getColumnValue("appl_db", dom));
String selEnterprises = checkNull(genericUtility.getColumnValue("enterprises", dom));
String empgName = "";
String deptCode = "";
String execAprv = "";
if (applDB.equalsIgnoreCase("E"))
{
valueXmlString.append("<enterprises protect='1'>").append("<![CDATA[" + selEnterprises + "]]>").append("</enterprises>");
}
else
{
valueXmlString.append("<enterprises protect='0'>").append("<![CDATA[" + selEnterprises + "]]>").append("</enterprises>");
}
//changed by Ashish.J
valueXmlString.append("<emp_code__given>").append("<![CDATA[" + userId + "]]>").append("</emp_code__given>");
sql = "SELECT NAME FROM USERS WHERE CODE='" + userId + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
empgName = rs.getString("NAME") != null ? rs.getString("NAME").trim() : "";
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
sql = "SELECT dept_code FROM employee WHERE emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, getUserInfo().getEmpCode());
rs = pstmt.executeQuery();
if (rs.next())
{
deptCode = rs.getString("dept_code") != null ? rs.getString("dept_code").trim() : "";
BaseLogger.log("3", null, null, "deptCode 503>>>"+ deptCode);
}
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
// if ("0110".equals(deptCode) || "0120".equals(deptCode))
// {
// execAprv = "Y";
// valueXmlString.append("<exec_aprv protect='1'>").append("<![CDATA["+execAprv+"]]>").append("</exec_aprv>\r\n");
// BaseLogger.log("3", null, null, "execAprv 593>>>"+ execAprv);
// }
valueXmlString.append("<name><![CDATA[").append(empgName).append("]]></name>\r\n");
// valueXmlString.append("<exec_aprv>").append("<![CDATA["+execAprv+"]]>").append("</exec_aprv>\r\n");
// BaseLogger.log("3", null, null, "execAprv 598>>>"+ execAprv);
//changed by Ashish.J
}
else if (currentColumn.trim().equalsIgnoreCase("req_id"))
{
Timestamp requestDate = null;//changed by Ashish.J
String reqID = checkNull(genericUtility.getColumnValue("req_id", dom));
sql = "select req_date from ser_request where req_id= '" + reqID + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
requestDate = rs.getTimestamp("req_date");
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
//changed by Ashish.J
//formatter = new SimpleDateFormat(genericUtility.getApplDateFormat());
//String reqDate = formatter.format(requestDate);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(requestDate !=null)
{
//valueXmlString.append("<req_date>").append("<![CDATA[" + requestDate + "]]>").append("</req_date>");
valueXmlString.append("<req_date>").append("<![CDATA["+ sdf.format(requestDate).toString() +"]]>").append("</req_date>");
}
else
{
//valueXmlString.append("<req_date>").append("<![CDATA[" + "" + "]]>").append("</req_date>");
valueXmlString.append("<req_date>").append("<![CDATA["+ "" +"]]>").append("</req_date>");
}//changed by Ashish.J
}
else if ("appl_db".equalsIgnoreCase(currentColumn)) {
String appldb = checkNull(genericUtility.getColumnValue("appl_db", dom));
if (appldb.equalsIgnoreCase("E"))
{
valueXmlString.append("<enterprises protect='1'>").append("</enterprises>");
}
else
{
valueXmlString.append("<enterprises protect='0'>").append("</enterprises>");
}
}
else if ("emp_code__given".equalsIgnoreCase(currentColumn))
{
String empgcode = checkNull(genericUtility.getColumnValue("emp_code__given", dom));
sql = "SELECT NAME FROM USERS WHERE CODE='" + empgcode + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String empgName = "";
if (rs.next())
{
empgName = rs.getString("NAME") != null ? rs.getString("NAME").trim() : "";
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<name><![CDATA[").append(empgName).append("]]></name>\r\n");
}
else if ("emp_code__merge".equalsIgnoreCase(currentColumn))
{
empmcode = checkNull(genericUtility.getColumnValue("emp_code__merge", dom));
sql = "SELECT NAME FROM USERS WHERE CODE='" + empmcode + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String empmName = "";
if (rs.next())
{
empmName = rs.getString("NAME") != null ? rs.getString("NAME").trim() : "";
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<users_name><![CDATA[").append(empmName).append("]]></users_name>\r\n");
}
else if ("enterprises".equalsIgnoreCase(currentColumn))
{
String entrpcode = genericUtility.getColumnValue("enterprises", dom1);
String sqlForEnterpriseDescr = "SELECT ENTERPRISE_DESCR FROM ENTERPRISE WHERE ENTERPRISE in('"+ entrpcode.replaceAll(",", "','") + "')";
pstmt = conn.prepareStatement(sqlForEnterpriseDescr);
rs = pstmt.executeQuery();
String entrpname = "";
while (rs.next())
{
String enterpriseDescr = rs.getString("ENTERPRISE_DESCR");
if (entrpname.length() == 0)
{
entrpname = enterpriseDescr;
}
else
{
entrpname = entrpname + " , " + enterpriseDescr;
}
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<enterprise_descr><![CDATA[").append(entrpname).append("]]></enterprise_descr>\r\n");
}
/* else if ("enterprises".equalsIgnoreCase(currentColumn))
{
String entrpcode = genericUtility.getColumnValue("enterprises", dom1);
String sql = "SELECT ENTERPRISE_DESCR FROM ENTERPRISE WHERE ENTERPRISE in('"+ entrpcode.replaceAll(",", "','") + "')";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String entrpname = "";
while (rs.next())
{
String enterpriseDescr = rs.getString("ENTERPRISE_DESCR");
if (entrpname.length() == 0)
{
entrpname = enterpriseDescr;
}
else
{
entrpname = entrpname + " , " + enterpriseDescr;
}
}
if (rs!= null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<enterprise_descr><![CDATA[").append(entrpname).append("]]></enterprise_descr>\r\n");
} */
else if ("itm_ver".equalsIgnoreCase(currentColumn))
{
String itmver = checkNull(genericUtility.getColumnValue("itm_ver", dom));
sql = "SELECT DESCR FROM ITEMSER WHERE ITEM_SER='" + itmver + "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String itmvername = "";
if (rs.next())
{
System.out.println("enter in customer");
itmvername = rs.getString("DESCR") != null ? rs.getString("DESCR").trim() : "";
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<descr><![CDATA[").append(itmvername).append("]]></descr>\r\n");
}
valueXmlString.append("</Detail1>");
break;
case 2:
valueXmlString.append("<Detail2>");
BaseLogger.log("3", null, null, "ItemChange called currentColumn gsb: [" + currentColumn + "]");
if ("itm_default".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "Detail svrj Form: item_default");
} else if ("ora_stmnt".equalsIgnoreCase(currentColumn.trim())) {
BaseLogger.log("3", null, null, "Detail gsb Form: Item Change of ora_stmnt");
}
valueXmlString.append("</Detail2>");
break;
}// End Switch
valueXmlString.append("</Root>");
} // End Try
catch (Exception e) {
e.printStackTrace();
BaseLogger.log("3", null, null, "Exception ::" + e.getMessage());
throw new ITMException(e);
} 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 d)
{
d.printStackTrace();
}
}
BaseLogger.log("3", null, null, "\n HealthProfile:ValueXmlString :" + valueXmlString + ":*******");
return valueXmlString.toString();
}
public String checkNull(String input)
{
if (input == null || "null".equalsIgnoreCase(input))
{
input= "";
}
return input.trim();
}
}
\ No newline at end of file
-- Note:
-- In TO: MS_REV_EMAIL_1, MS_REV_EMAIL_2 (SM Sir, Piyush Sir)
-- In CC: MS_REV_EMAIL_EXEC (Kandarp Sir mail ID)
-- For testing, use testing email IDs.
-- For live, use actual user email IDs.
Insert into SYSYPARM (VAR_NAME,VAR_TYPE,VAR_VALUE,DESCR,VAR_SUBS,CHG_DATE,CHG_USER,CHG_TERM) values ('MS_REV_EMAIL_1','E','saburi.patekar@proteustech.in','Testing for SQL Review request',0,to_date('24-04-26','DD-MM-RR'),'SABURI ','SABURI');
Insert into SYSYPARM (VAR_NAME,VAR_TYPE,VAR_VALUE,DESCR,VAR_SUBS,CHG_DATE,CHG_USER,CHG_TERM) values ('MS_REV_EMAIL_2','E','ajit.deshmukh@proteustech.in','Testing for SQL Review request',0,to_date('24-04-26','DD-MM-RR'),'SABURI ','SABURI');
Insert into SYSYPARM (VAR_NAME,VAR_TYPE,VAR_VALUE,DESCR,VAR_SUBS,CHG_DATE,CHG_USER,CHG_TERM) values ('MS_REV_EMAIL_EXEC','E','gagandeep.bhatia@proteustech.in','Testing for SQL Review request',0,to_date('24-04-26','DD-MM-RR'),'SABURI ','SABURI');
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/ibase/webitm/css/summary.css"/>
<title>Manage SQL</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
.sum_Container {
height: 100%;
box-sizing: border-box;
overflow: visible;
}
.sum_Content {
height: 100%;
overflow: visible;
padding: 10px 12px;
box-sizing: border-box;
}
.content_Row .txtData {
overflow: visible;
white-space: normal;
}
.txtData.sqlBox {
height: 150px !important;
width: 600px !important;
overflow-y: auto !important;
overflow-x: auto !important;
border: 1px solid #ccc;
padding: 8px;
background: #f9f9f9;
box-sizing: border-box;
white-space: pre-wrap;
word-wrap: break-word;
font-family: monospace;
scrollbar-gutter: stable;
}
.switch {
position: relative;
display: inline-block;
width: 50px;
height: 24px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .3s;
}
.slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .3s;
}
input:checked + .slider {
background-color: #4CAF50;
}
input:checked + .slider:before {
transform: translateX(26px);
}
.slider.round {
border-radius: 24px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
<script>
function setValue(obj) {
obj.setAttribute("ISCHANGED", "true");
obj.setAttribute("value", obj.value);
}
</script>
</head>
<body>
<div class="sum_Container">
<div class="sum_Content">
<form id="detail" method="POST" style="margin-bottom:0;">
<div class="sum_Header">
<img src="/ibase/webitm/images/Summary/Header.png"
class="sum_Icon pdLeft_16"
alt="Header Icon"/>
Manage SQL
</div>
<xsl:for-each select="//Detail1">
<xsl:variable name="dbID"><xsl:value-of select="@dbID" /></xsl:variable>
<xsl:variable name="domID"><xsl:value-of select="@domID" /></xsl:variable>
<xsl:variable name="review_yn"><xsl:value-of select="review_yn" /></xsl:variable>
<input type="hidden" id="DBIDVAL" name="DBIDVAL" value="{$domID}" isReq="false" ISCHANGED="false" class="descriptions"/>
<input type="hidden" id="DBIDVAL1" name="DBIDVAL1" value="{$dbID}" isReq="false" ISCHANGED="false" class="descriptions"/>
<div class="content_BG colomn_View">
<!-- Add User -->
<div class="content_Row">
<div class="txtlbl txtdark">Add User:</div>
<div class="txtData" contentEditable="false">
<xsl:value-of select="concat(users_name, ' (', emp_code__merge, ')')"/>
</div>
</div>
<!-- Enterprise -->
<div class="content_Row">
<div class="txtlbl txtdark">Enterprise:</div>
<div class="txtData" contentEditable="false">
<xsl:choose>
<xsl:when test="normalize-space(enterprises) != ''">
<xsl:value-of select="enterprises"/>
</xsl:when>
<xsl:otherwise>
All Enterprise
</xsl:otherwise>
</xsl:choose>
</div>
</div>
<!-- Review Required -->
<div class="content_Row">
<!-- LABEL -->
<div class="txtlbl txtdark">Review Required?:</div>
<!-- VALUE -->
<div class="txtData">
<select class="editInputClass"
id="Detail1.{normalize-space($dbID)}.review_yn"
NAME="Detail1.{normalize-space($dbID)}.review_yn"
fontCase="any"
TABINDEX="10"
TABORDER="30"
MAXLENGTH="1"
POPUPEXISTS="false"
protectExpr=""
ISCHANGED="true"
SRVCALLONCHANGE="true"
REQUIRED=""
onfocus="gotFocus(this)"
onblur="gotBlur(this)"
title="Review Required?">
<option value="Y">
<xsl:if test="$review_yn = 'Y'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
<![CDATA[Yes]]>
</option>
<option value="N">
<xsl:if test="$review_yn = 'N'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
<![CDATA[No]]>
</option>
</select>
</div>
</div>
<!-- SQL Statement -->
<div class="content_Row">
<div class="txtlbl txtdark">SQL Statement:</div>
<div class="txtData sqlBox">
<xsl:for-each select="//Detail2">
<div style="margin-bottom:8px;">
<xsl:number format="1. "/>
<xsl:value-of select="ora_stmnt"/>
</div>
</xsl:for-each>
</div>
</div>
</div>
</xsl:for-each>
</form>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
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