Commit 7c04cb09 authored by sghate's avatar sghate

shital: updated Component on 20/8/2019

CadreIC.java
CadreLocal.java
CadreRemote.java
 

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@205479 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a43fe0b6
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -10,6 +9,8 @@ import org.w3c.dom.Document; ...@@ -10,6 +9,8 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import java.rmi.RemoteException;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
...@@ -30,11 +31,10 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote ...@@ -30,11 +31,10 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote
Document dom2 = null; Document dom2 = null;
String errString = null; String errString = null;
E12GenericUtility genericUtility = null; E12GenericUtility genericUtility = new E12GenericUtility();
try try
{ {
genericUtility = new E12GenericUtility();
if (xmlString != null && xmlString.trim().length() != 0) if (xmlString != null && xmlString.trim().length() != 0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
...@@ -54,12 +54,12 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote ...@@ -54,12 +54,12 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception :DeptIC :wfValData(String xmlString):"+ e.getMessage() + ":"); System.out.println("Exception :CadreIC :wfValData(String xmlString):"+ e.getMessage() + ":");
errString = genericUtility.createErrorString(e); errString = genericUtility.createErrorString(e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("returning from DeptIC wfvaldata"); System.out.println("returning from CadreIC wfvaldata");
return errString; return errString;
} }
...@@ -70,130 +70,165 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote ...@@ -70,130 +70,165 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
int currentFormNo = 0; int currentFormNo = 0;
int childNodeListLength = 0;
String userId = ""; String userId = "";
String childNodeName = null; String childNodeName = null;
String errString = ""; String errString = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String errCode = "";
String errFldName = "";
String msgType = "";
StringBuffer errStringXml = null; StringBuffer errStringXml = null;
ITMDBAccessEJB itmDbAccess =null; ITMDBAccessEJB itmDbAccess =new ITMDBAccessEJB();
NodeList parentList = null;
NodeList childList = null;
String descr = ""; String descr = "";
String shDescr = ""; String shDescr = "" , cadreCode = "" , sql = "";
int noOfChilds = 0 , counter = 0 , cnt = 0;
E12GenericUtility genericUtility = null; E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errlist = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
ArrayList<String> errfields = new ArrayList<String>();
try try
{ {
conn = getConnection(); conn = getConnection();
conn.setAutoCommit(false); errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
genericUtility = new E12GenericUtility();
itmDbAccess =new ITMDBAccessEJB();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch (currentFormNo) parentList = dom.getElementsByTagName("Detail" + currentFormNo);
{ parentNode = parentList.item(0);
case 1: childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
System.out.println("noOfChilds--->>>" + noOfChilds);
for (counter = 0; counter < noOfChilds; counter++)
{ {
parentNodeList = dom.getElementsByTagName("Detail1"); childNode = childList.item(counter);
parentNode = parentNodeList.item(0); childNodeName = childNode.getNodeName();
childNodeList = parentNode.getChildNodes(); System.out.println("childNodeName>>>>>" + childNodeName + "childNode>>>>>>" +childNode + "counter>>>" +counter);
childNodeListLength = childNodeList.getLength();
for (int ctr = 0; ctr < childNodeListLength; ctr++) switch (currentFormNo)
{ {
childNode = childNodeList.item(ctr); case 1:
if (childNode.getNodeType() != Node.ELEMENT_NODE)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("childNodeName.editFlag." + childNodeName + "" + editFlag);
System.out.println("@V@ Edit flag :- ["+editFlag+"");
if (childNodeName.equalsIgnoreCase("descr")) parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
int childNodeListLength = childNodeList.getLength();
System.out.println("child Node List Length::::::" + childNodeListLength);
for (int ctr = 0; ctr < childNodeListLength; ctr++)
{ {
descr = checkNull(genericUtility.getColumnValue("descr", dom)).trim(); childNode = childNodeList.item(ctr);
System.out.println("childNode" + childNode);
if(descr == null || descr.trim().length() == 0) if (childNode.getNodeType() != Node.ELEMENT_NODE)
{ {
errlist.add("VTDESC1"); continue;
errfields.add(childNodeName.toLowerCase());
} }
} childNodeName = childNode.getNodeName();
else if (childNodeName.equalsIgnoreCase("sh_descr")) System.out.println("childNodeName.editFlag." + childNodeName + "@V@ Edit flag :-" + editFlag);
{
shDescr = checkNull(genericUtility.getColumnValue("sh_descr", dom)).trim(); if ("cadre_code".equalsIgnoreCase(childNodeName))
if(shDescr == null || shDescr.trim().length() == 0)
{ {
errlist.add("VEADN2"); cadreCode = checkNull(genericUtility.getColumnValue("cadre_code", dom)).trim();
errfields.add(childNodeName.toLowerCase()); System.out.println("cadre_code :: ["+cadreCode+"]");
if(cadreCode == null || cadreCode.trim().length() == 0)
{
errList.add("VTCAN81");
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = "select count(*) as cnt from cadre where cadre_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cadreCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errList.add("VTCAN81");
errFields.add(childNodeName.toLowerCase());
}
}
} }
} else if ("descr".equalsIgnoreCase(childNodeName))
break;
}
if ( errlist != null && errlist.size() > 0 )
{
int errListSize = errlist.size();
System.out.println("errListSize:::::::["+errListSize+"]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++ )
{
System.out.println("in error For:::::::::::::::");
errCode = (String)errlist.get(i);
errFldName = (String)errfields.get(i);
System.out.println("errCode .........."+errCode);
errString = itmDbAccess.getErrorString(errFldName, errCode, userId, "", conn);
System.out.println("errString is : ::::>>>> " + errString);
msgType = errorType( conn , errCode );
if ( errString.length() > 0)
{ {
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); descr = checkNull(genericUtility.getColumnValue("descr", dom)).trim();
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); if(descr == null || descr.trim().length() == 0)
System.out.println("errStringXml .........."+errStringXml); {
errString = ""; errList.add("VTDESC1");
errFields.add(childNodeName.toLowerCase());
}
} }
if ( msgType.equalsIgnoreCase("E")) else if ("sh_descr".equalsIgnoreCase(childNodeName))
{ {
break; shDescr = checkNull(genericUtility.getColumnValue("sh_descr", dom)).trim();
if(shDescr == null || shDescr.trim().length() == 0)
{
errList.add("VEADN2");
errFields.add(childNodeName.toLowerCase());
}
} }
} }
errlist.clear(); break;
errlist = null;
errfields.clear();
errfields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
} }
errString = errStringXml.toString();
} }
System.out.println("errStringXml.toString()---1= "+errStringXml.toString());
if (errList != null && errList.size() > 0)
{
System.out.println("errList==[" + errList + "]");
int errListSize = errList.size();
System.out.println("errListSize:::::::[" + errListSize + "]");
System.out.println("in error::::::::::");
for (int i = 0; i < errListSize; i++) {
System.out.println("in error For:::::::::::::::");
String errCode = (String) errList.get(i);
String errFldName = (String) errFields.get(i);
System.out.println("errCode .........." + errCode);
errString = itmDbAccess.getErrorString(errFldName, errCode, userId, "", conn);
System.out.println("errString is : ::::>>>> " + errString);
String msgType = 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);
System.out.println("errStringXml .........." + errStringXml);
errString = "";
}
if (msgType.equalsIgnoreCase("E")) {
break;
}
}
errList.clear();
errFields.clear();
} }
errStringXml.append("</Errors></Root>\r\n");
System.out.println("errStringXml.toString()---2= "+errStringXml.toString());
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception ::" + e); System.out.println("Exception CadreIC::" + e);
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
...@@ -225,64 +260,67 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote ...@@ -225,64 +260,67 @@ public class CadreIC extends ValidatorEJB implements CadreLocal,CadreRemote
throw new ITMException(d); throw new ITMException(d);
} }
} }
errString = errStringXml.toString();
System.out.println("ErrString ::" + errString); System.out.println("ErrString ::" + errString);
return errString; return errString;
} }
private String errorType( Connection conn , String errorCode ) throws ITMException
{ private String errorType(Connection conn, String errorCode) throws ITMException {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; try {
if (conn == null) {
try System.out.println("Connection is null");
{ } else {
sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? "; System.out.println("Connection is not null");
pstmt = conn.prepareStatement( sql ); }
pstmt.setString(1, errorCode);
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if (rs.next())
{ {
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
if (rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception ex)
catch (Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} }
finally finally
{ {
try try
{ {
if (rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e)
catch ( Exception e )
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return msgType; return msgType;
} }
......
...@@ -2,15 +2,16 @@ package ibase.webitm.ejb.adm; ...@@ -2,15 +2,16 @@ package ibase.webitm.ejb.adm;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal; import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
public interface CadreLocal extends ValidatorLocal public interface CadreLocal 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(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 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;
*/
} }
package ibase.webitm.ejb.adm; package ibase.webitm.ejb.adm;
import org.w3c.dom.Document;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote; import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
...@@ -12,4 +10,8 @@ public interface CadreRemote extends ValidatorRemote ...@@ -12,4 +10,8 @@ public interface CadreRemote extends ValidatorRemote
public String wfValData() throws RemoteException, ITMException; 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(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 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;
*/
} }
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