Commit cc6f0e74 authored by sghate's avatar sghate

Done changes on ItDeclarationFmt Master Component

ItDeclarationFmt.java



git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@205334 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cbd095ea
package ibase.webitm.ejb.adm;
//modified by Shital on 01/08/2019 [Start]
//import ibase.system.config.ConnDriver;
//modified by Shital on 01/08/2019 [End]
import ibase.utility.E12GenericUtility;//Modified By Hemlata on[20/11/2014] [As per changes in framework to use genericUtility ]
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
//modified by Shital on 01/08/2019 [Start]
//import java.sql.SQLException;
//import java.sql.Statement;
//import javax.ejb.Stateless;
//modified by Shital on 01/08/2019 [End]
import java.util.ArrayList;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//modified by Shital on 01/08/2019 [Start]
//@Stateless
//modified by Shital on 01/08/2019 [End]
public class ItDeclarationFmt extends ValidatorEJB implements ItDeclarationFmtLocal ,ItDeclarationFmtRemote
{
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;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
System.out.println("ItDeclarationFmt xmlString in itemChanged..::["+xmlString+"]");
System.out.println("ItDeclarationFmt xmlString1 in itemChanged..:: ["+xmlString1+"]");
System.out.println("ItDeclarationFmt xmlString2 in itemChanged..:: ["+xmlString2+"]");
if(xmlString != null && xmlString.length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
System.out.println("ItDeclarationFmt errString Returing at Stage 1["+errString+"]");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :ItDeclarationFmt [:" + e.getMessage() + ":]" );
errString = genericUtility.createErrorString(e);
//modified by Shital on 01/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 01/08/2019 [End]
}
System.out.println("ItDeclarationFmt errString returing at Stage 2[" + errString+"]");
return errString;
}
//Start of itemChanged block
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String objNameDefault = "";
int currentFormNo = 0;
String proofRequired = "";
String adCode = "";
String sql = "";
Connection conn = null;
//modified by Shital on 01/08/2019 [Start]
//ConnDriver connDriver = new ConnDriver();
//modified by Shital on 01/08/2019 [End]
PreparedStatement pstmt = null;
ResultSet rs = null;
String description = "";
String declRequired = "";
String updproofRequired = "";
E12GenericUtility genericUtility = new E12GenericUtility();
AdmCommon admCommon = new AdmCommon();
//To get login Employee Code And Login Site
String loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
StringBuffer valueXmlString = new StringBuffer();
System.out.println("Login Employee got..:: ["+loginEmpCode+"]");
System.out.println("objContext ..:: ["+objContext+"]");
System.out.println("currentColumn ..:: ["+currentColumn+"]");
System.out.println("editFlag ..:: ["+editFlag+"]");
System.out.println("xtraParams ..:: ["+xtraParams+"]");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
try
{
//modified by Shital on 01/08/2019 [Start]
//conn = connDriver.getConnectDB("Driver");
conn = getConnection();
//modified by Shital on 01/08/2019 [End]
conn.setAutoCommit(false);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
objNameDefault = checkNull(getObjName(dom ,"1"));
System.out.println("objNameDefault ..:: ["+objNameDefault+"]");
switch (currentFormNo)
{
case 1:
{
valueXmlString.append("<Detail1 domID='1' dbID='' objContext='1' objName='"+objNameDefault+"' selected='Y'>\r\n");
if(currentColumn.equalsIgnoreCase("itm_default"))
{
valueXmlString.append("<decl_upd_flag ><![CDATA[").append("R").append("]]></decl_upd_flag>\r\n");
valueXmlString.append("<appl_mode ><![CDATA[").append("B").append("]]></appl_mode>\r\n");
valueXmlString.append("<appl_prd ><![CDATA[").append("4").append("]]></appl_prd>\r\n");
valueXmlString.append("<allow_negative ><![CDATA[").append("N").append("]]></allow_negative>\r\n");
valueXmlString.append("<access_to ><![CDATA[").append("A").append("]]></access_to>\r\n");
valueXmlString.append("<appl_prd_new ><![CDATA[").append("4").append("]]></appl_prd_new>\r\n");
valueXmlString.append("<proof_required ><![CDATA[").append("N").append("]]></proof_required>\r\n");
valueXmlString.append("<decl_required ><![CDATA[").append("N").append("]]></decl_required>\r\n");//Modified by Vallabh Kadam on 25/Jul/2017[To set decl_required as N by default]
//valueXmlString.append("<template_file_name protect=\"1\"><![CDATA[").append("").append("]]></template_file_name>\r\n");
valueXmlString.append("<updproof_required ><![CDATA[").append("N").append("]]></updproof_required>\r\n");//Modifed By Onkar Rane on 27/10/2017[To set updproof_required as N by default]
}
// Modified by Vallabh Kadam on 25/Jul/2017[To set decl_required as N if null]
else if(currentColumn.equalsIgnoreCase("itm_defaultedit"))
{
//modified by Shital on 01/08/2019 [Start]
//declRequired = checkNull(getColumnValue("decl_required",dom,"1")) ;
declRequired = checkNull(genericUtility.getColumnValue("decl_required",dom,"1"));
//modified by Shital on 01/08/2019 [End]
if(declRequired == null || declRequired.trim().length() == 0)
{
valueXmlString.append("<decl_required ><![CDATA[").append("N").append("]]></decl_required>\r\n");
}
else
{
valueXmlString.append("<decl_required ><![CDATA["+declRequired+"]]></decl_required>\r\n");
}
/**Modified by Onkar Rane on 30/OCT/2017[To set updproof_required as N if null]**/
//modified by Shital on 01/08/2019 [Start]
//updproofRequired = checkNull(getColumnValue("updproof_required",dom,"1")) ;
updproofRequired = checkNull(genericUtility.getColumnValue("updproof_required",dom,"1"));
//modified by Shital on 01/08/2019 [End]
System.out.println("Update Proof value::::["+updproofRequired+"]");
if(updproofRequired == null || updproofRequired.trim().length() == 0)
{
valueXmlString.append("<updproof_required ><![CDATA[").append("N").append("]]></updproof_required>\r\n");
}
else
{
valueXmlString.append("<updproof_required ><![CDATA["+updproofRequired+"]]></updproof_required>\r\n");
}
/**Closed..**/
}
// Modified by Vallabh Kadam on 25/Jul/2017[To set decl_required as N if null]
else if (currentColumn.equalsIgnoreCase("ad_code"))
{
//modified by Shital on 01/08/2019 [Start]
//adCode = checkNull(getColumnValue("ad_code",dom,"1")) ;
adCode = checkNull(genericUtility.getColumnValue("ad_code",dom,"1")) ;
//modified by Shital on 01/08/2019 [End]
System.out.println("adCode [:" + adCode+ ":]" );
if(adCode != null && adCode.trim().length() > 0)
{
sql = "SELECT DESCR FROM ALLWDEDN WHERE AD_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,adCode);
rs = pstmt.executeQuery();
if(rs.next())
{
description = checkNull(rs.getString("DESCR"));
}
System.out.println("description [:" + description+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<description><![CDATA[").append(description).append("]]></description>\r\n");
}
else
{
valueXmlString.append("<description><![CDATA[").append("").append("]]></description>\r\n");
}
}
else if (currentColumn.equalsIgnoreCase("proof_required"))
{
//modified by Shital on 01/08/2019 [Start]
//proofRequired = checkNull(getColumnValue("proof_required",dom,"1")) ;
proofRequired = checkNull(genericUtility.getColumnValue("proof_required",dom,"1")) ;
//modified by Shital on 01/08/2019 [End]
System.out.println("proofRequired [:" + proofRequired+ ":]" );
//Modified by Ahmed on 31/Jul/2017[To not set blank xsl value on itemchange of proof_required field][START]
/*if(proofRequired.equalsIgnoreCase("Y"))
{
valueXmlString.append("<template_file_name protect=\"0\"><![CDATA[").append("").append("]]></template_file_name>\r\n");
}
else
{
valueXmlString.append("<template_file_name protect=\"1\"><![CDATA[").append("").append("]]></template_file_name>\r\n");
}*/
//Modified by Ahmed on 31/Jul/2017[To not set blank xsl value on itemchange of proof_required field][END]
}
valueXmlString.append("</Detail1>\r\n");
}//End of Case 1
break;
}//END OF SWITCH
}//End of try block
catch(Exception e)
{
e.printStackTrace();
System.out.println( "Exception :ItDeclarationFmt [itemChanged(String xmlString)] : ==>\n"+e.getMessage());
throw new ITMException(e);
}//End of cacth block
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 e)
{
System.out.println("[ItDeclarationFmt][itemChanged]Exception ::"+e);
e.printStackTrace();
//modified by Shital on 01/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 01/08/2019 [End]
}
}//End of finally block
valueXmlString.append("</Root>\r\n");
System.out.println("valueXmlString....["+valueXmlString.toString());
return valueXmlString.toString();
}//End of itemChanged block
//Start of wfValData Start
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("Came Inside 1 wfValData:::");
E12GenericUtility genericUtility = new E12GenericUtility();
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("xmlString ["+xmlString+"]");
System.out.println("xmlString1["+xmlString1+"]");
System.out.println("xmlString2["+xmlString2+"]");
try
{
if(xmlString != null && xmlString.trim().length() != 0)
{
dom = parseString(xmlString);
}
else
{
System.out.println("xmlstring is null");
}
if(xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = parseString(xmlString1);
}
else
{
System.out.println("xmlstring1 is null");
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = parseString(xmlString2);
}
else
{
System.out.println("xmlstring2 is null");
}
System.out.println("Before call valdata");
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ItDeclarationFmt][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
errString = genericUtility.createErrorString(e);
//modified by Shital on 01/08/2019 [Start]
throw new ITMException(e);
//modified by Shital on 01/08/2019 [End]
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Node parentNode = null;
Node childNode = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
String errString = "";
String childNodeName = "";
int currentFormNo = 0;
int childNodeListLength = 0;
String msgType = "";
String errCode = "";
String errFldName = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
int cnt = 0;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int ctr = 0;
int count = 0;
int count1 = 0;
String seqNo = "" ;
String userId = "" ;
String adCode = "" ;
String description = "";
String templateFile = "";
String proofRequired = "";
E12GenericUtility genericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
System.out.println("editFlag...wfValdata ["+editFlag+"]");
Connection conn = null;
try
{
//modified by Shital on 01/08/2019 [Start]
//ConnDriver connDriver = new ConnDriver();
//conn = connDriver.getConnectDB("Driver");
conn = getConnection();
//modified by Shital on 01/08/2019 [End]
conn.setAutoCommit(false);
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail"+currentFormNo);
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
System.out.println("childNode"+childNode);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("seq_no"))
{
count = 0;
seqNo = checkNull(genericUtility.getColumnValue("seq_no",dom,objContext));
System.out.println("seqNo got in the validation ..::["+seqNo+"]");
if(seqNo == null || seqNo.trim().length() == 0)
{
System.out.println("Invalid seqNo ::::");
errList.add( "VMINVSEQ" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMINVSEQ" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = " SELECT COUNT(*) AS SEQ_CNT FROM ITDECL_FMT WHERE SEQ_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,seqNo);
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getInt("SEQ_CNT");
}
System.out.println("count:::: "+count);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (editFlag.equalsIgnoreCase("A"))
{
if(count > 0)
{
System.out.println("Invalid seqNo , Can not enter duplicate seq no::::");
errList.add( "VMDUPSEQ" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMDUPSEQ" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
else
{
if(count > 1)
{
System.out.println("Invalid seqNo , Can not enter duplicate seq no::::");
errList.add( "VMDUPSEQ" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMDUPSEQ" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
if(childNodeName.equalsIgnoreCase("ad_code"))
{
count = 0;
count1 = 0;
adCode = checkNull(genericUtility.getColumnValue("ad_code",dom,objContext));
System.out.println("adCode got in the validation ..::["+adCode+"]");
if(adCode == null || adCode.trim().length() == 0)
{
System.out.println("Invalid adCode ::::");
errList.add( "VMINVADCOD" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMINVADCOD" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = "SELECT COUNT(*) AS ADCODE_CNT FROM ALLWDEDN WHERE AD_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,adCode);
rs = pstmt.executeQuery();
if( rs.next())
{
count1 = rs.getInt("ADCODE_CNT");
}
System.out.println("count1:::: "+count1);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(count1 == 0)
{
System.out.println("Invalid adCode , AdCode not defined in ALLOWEDN table::::");
errList.add( "VMINADCOD" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMINADCOD" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
else
{
sql = " SELECT COUNT(*) AS ADCODE_CNT FROM ITDECL_FMT WHERE AD_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,adCode);
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getInt("ADCODE_CNT");
}
System.out.println("count:::: "+count);
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (editFlag.equalsIgnoreCase("A"))
{
if(count > 0)
{
System.out.println("Invalid adCode , Can not enter duplicate adCode::::");
errList.add( "VMDUPADCOD" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMDUPADCOD" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
else
{
if(count > 1)
{
System.out.println("Invalid adCode , Can not enter duplicate adCode::::");
errList.add( "VMDUPADCOD" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMDUPADCOD" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
}
if(childNodeName.equalsIgnoreCase("description"))
{
description = checkNull(genericUtility.getColumnValue("description",dom,objContext));
System.out.println("description got in the validation ..::["+description+"]");
if(description == null || description.trim().length() == 0)
{
System.out.println("Invalid description ::::");
errList.add( "VMINVDESCR" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMINVDESCR" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
if(childNodeName.equalsIgnoreCase("template_file_name"))
{
count = 0;
templateFile = checkNull(genericUtility.getColumnValue("template_file_name",dom,objContext));
System.out.println("templateFile got in the validation ..::["+templateFile+"]");
proofRequired = checkNull(genericUtility.getColumnValue("proof_required",dom,objContext));
System.out.println("proofRequired got in the validation ..::["+proofRequired+"]");
if(proofRequired.equalsIgnoreCase("Y"))
{
if(templateFile == null || templateFile.trim().length() == 0)
{
System.out.println("Invalid adCode ::::");
errList.add( "VMINVTMPFL" );
errFields.add( childNodeName.toLowerCase() );
msgType = errorType( conn , "VMINVTMPFL" );
if ( msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
}
}//End of case
break;
}//End of Switch
int errListSize = errList.size();
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);
//modified by Shital on 01/08/2019 [Start]
//errString = getErrorString( errFldName, errCode, userId );
errString = itmDBAccessEJB.getErrorString(errFldName, errCode, userId, "", conn);
//modified by Shital on 01/08/2019 [End]
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>"));
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();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}
catch(Exception e)
{
System.out.println( "Exception : [ItDeclarationFmt][wfValData(String xmlString)] : ==>\n"+e.getMessage());
e.printStackTrace();
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 e1)
{
//modified by Shital on 01/08/2019 [Start]
e1.printStackTrace();
//modified by Shital on 01/08/2019 [End]
System.out.println( "Exception : [ItDeclarationFmt][wfValData] : ==>\n"+e1.getMessage());
throw new ITMException(e1);
}
}
return errString;
}
//Start of wfValData End
private String checkNull( String input )
{
if (input == null)
{
input = "";
}
else
{
input = input.trim();
}
return input;
}
private String getObjName(Document dom,String objContext)
{
Node elementName = null;
NodeList elementList = null;
String objName = "";
elementList = dom.getElementsByTagName("Detail"+objContext);
elementName = elementList.item(0);
if (elementName != null && ("Detail"+objContext).equalsIgnoreCase(elementName.getNodeName()))
{
NamedNodeMap etlAttributes = elementName.getAttributes();
if (etlAttributes != null)
{
if (etlAttributes.getNamedItem("objName") != null)
{
objName = etlAttributes.getNamedItem("objName").getNodeValue();
}
}
}
return objName;
}
private String errorType( Connection conn , String errorCode ) throws ITMException
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
String sql = "";
try
{
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();
throw new ITMException(ex);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
}
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