Commit 6843f898 authored by ngadkari's avatar ngadkari

Request Id - S17KGTP006 Fin entity wise period open/close facility will be made available.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@180992 ce508802-f39f-4f6c-b175-0d175dae99d5
parent aa6f3335
...@@ -35,169 +35,156 @@ import ibase.webitm.utility.ITMException; ...@@ -35,169 +35,156 @@ import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator; import ibase.webitm.utility.TransIDGenerator;
@javax.ejb.Stateless @javax.ejb.Stateless
public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLocal, PeriodStatUpdWizRemote public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLocal, PeriodStatUpdWizRemote {
{
public String globalXtraParams = ""; public String globalXtraParams = "";
@Override @Override
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, 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 {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String retString = null; String retString = null;
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
try try {
{
globalXtraParams = xtraParams; globalXtraParams = xtraParams;
if (xmlString != null && xmlString.trim().length()!=0) if (xmlString != null && xmlString.trim().length() != 0) {
{
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length()!=0) if (xmlString1 != null && xmlString1.trim().length() != 0) {
{
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length()!=0) if (xmlString2 != null && xmlString2.trim().length() != 0) {
{
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
retString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams ); retString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
} } catch (Exception e) {
catch (Exception e) System.out.println("Exception :PeriodStatUpdWiz :itemChanged(String,String):" + e.getMessage() + ":");
{
System.out.println ( "Exception :PeriodStatUpdWiz :itemChanged(String,String):" + e.getMessage() + ":" );
retString = genericUtility.createErrorString(e); retString = genericUtility.createErrorString(e);
} }
System.out.println ( "Return String from PeriodStatUpdWiz ["+retString+"]" ); System.out.println("Return String from PeriodStatUpdWiz [" + retString + "]");
return retString; return retString;
} }
@Override @Override
public String itemChanged(Document dom, Document dom1, Document dom2, 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 {
E12GenericUtility e12genericUtility = new E12GenericUtility(); E12GenericUtility e12genericUtility = new E12GenericUtility();
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
String loginUser=""; String loginUser = "";
int currentFormNo = 0; int currentFormNo = 0;
String siteCode = "", currDate = "", retString ="", dateFormat = ""; String siteCode = "", currDate = "", retString = "", dateFormat = "";
boolean selectFlag=false,offerSelect=false; boolean selectFlag = false, offerSelect = false;
int existCnt=0; int existCnt = 0;
InitialContext ctx = null; InitialContext ctx = null;
ResultSet rs=null; ResultSet rs = null;
PreparedStatement pstmt=null; PreparedStatement pstmt = null;
String finEntity="",prdCodeFrm="",prdCodeTo=""; String finEntity = "", prdCodeFrm = "", prdCodeTo = "";
String nodeName = ""; String nodeName = "";
String errCode =""; String errCode = "";
String effFrom1=null,validUpto1=null,remarks=null,prdCode=null; String effFrom1 = null, validUpto1 = null, remarks = null, prdCode = null;
int domID = 0, detDomId = 0,previousCnt=0; int domID = 0, detDomId = 0, previousCnt = 0;
Connection conn = null; Connection conn = null;
try try {
{
System.out.println("itemChanged called for PeriodStatUpdWiz"); System.out.println("itemChanged called for PeriodStatUpdWiz");
conn = getConnection(); conn = getConnection();
siteCode = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); siteCode = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
loginUser=e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); loginUser = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
dateFormat = e12genericUtility.getApplDateFormat(); dateFormat = e12genericUtility.getApplDateFormat();
if( objContext != null && objContext.trim().length() > 0 ) if (objContext != null && objContext.trim().length() > 0) {
{ currentFormNo = Integer.parseInt(objContext);
currentFormNo = Integer.parseInt( objContext );
} }
SimpleDateFormat sdf = new SimpleDateFormat(e12genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
SimpleDateFormat adf = new SimpleDateFormat(e12genericUtility.getApplDateFormat()); SimpleDateFormat adf = new SimpleDateFormat(e12genericUtility.getApplDateFormat());
currDate = sdf.format(new java.util.Date()); currDate = sdf.format(new java.util.Date());
System.out.println("currDate"+currDate); System.out.println("currDate" + currDate);
System.out.println("currentColumn["+currentColumn+"] currentFormNo["+currentFormNo+"]" ); System.out.println("currentColumn[" + currentColumn + "] currentFormNo[" + currentFormNo + "]");
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?><Root><Header><editFlag>" ); valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
valueXmlString.append( editFlag ).append( "</editFlag></Header>" ); valueXmlString.append(editFlag).append("</editFlag></Header>");
switch(currentFormNo) switch (currentFormNo) {
{ case 1: {
case 1:
{
System.out.println(" -------- Inside itemchange case 1111111 ------------ "); System.out.println(" -------- Inside itemchange case 1111111 ------------ ");
existCnt=0; existCnt = 0;
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
System.out.println("loginUser"+loginUser);
if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
System.out.println("loginUser" + loginUser);
valueXmlString.append("<Detail1 domID='1'>"); valueXmlString.append("<Detail1 domID='1'>");
valueXmlString.append("<fin_entity><![CDATA[").append("").append( "]]></fin_entity>"); valueXmlString.append("<fin_entity><![CDATA[").append("").append("]]></fin_entity>");
valueXmlString.append("<prd_code__from><![CDATA[" ).append("").append( "]]></prd_code__from>"); valueXmlString.append("<prd_code__from><![CDATA[").append("").append("]]></prd_code__from>");
valueXmlString.append("<prd_code__to><![CDATA[").append("").append( "]]></prd_code__to>"); valueXmlString.append("<prd_code__to><![CDATA[").append("").append("]]></prd_code__to>");
valueXmlString.append("</Detail1>" ); valueXmlString.append("</Detail1>");
} }
break; break;
} }
case 2: case 2: {
{
System.out.println(" -------- Inside itemchange case 222222 ------------ "); System.out.println(" -------- Inside itemchange case 222222 ------------ ");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" )) if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
{
finEntity=checkNull(e12genericUtility.getColumnValue("fin_entity",dom1));
prdCodeFrm=checkNull(e12genericUtility.getColumnValue("prd_code__from",dom1));
prdCodeTo=checkNull(e12genericUtility.getColumnValue("prd_code__to",dom1));
finEntity = checkNull(e12genericUtility.getColumnValue("fin_entity", dom1));
prdCodeFrm = checkNull(e12genericUtility.getColumnValue("prd_code__from", dom1));
prdCodeTo = checkNull(e12genericUtility.getColumnValue("prd_code__to", dom1));
valueXmlString.append("<Detail1 domID='1'>"); valueXmlString.append("<Detail1 domID='1'>");
valueXmlString.append("<fin_entity><![CDATA[").append(finEntity).append( "]]></fin_entity>"); valueXmlString.append("<fin_entity><![CDATA[").append(finEntity).append("]]></fin_entity>");
valueXmlString.append("<prd_code__from><![CDATA[" ).append(prdCodeFrm).append( "]]></prd_code__from>"); valueXmlString.append("<prd_code__from><![CDATA[").append(prdCodeFrm)
valueXmlString.append("<prd_code__to><![CDATA[").append(prdCodeTo).append( "]]></prd_code__to>"); .append("]]></prd_code__from>");
valueXmlString.append("<prd_code__to><![CDATA[").append(prdCodeTo).append("]]></prd_code__to>");
valueXmlString.append("</Detail1>" ); valueXmlString.append("</Detail1>");
String getDataSql= "SELECT A.SITE_CODE,B.DESCR,A.PRD_CODE,A.STAT_ADM,A.STAT_FIN,A.STAT_SAL,A.STAT_IC,A.STAT_PUR,A.STAT_MFG " String getDataSql = "SELECT A.SITE_CODE,B.DESCR,A.PRD_CODE,A.STAT_ADM,A.STAT_FIN,A.STAT_SAL,A.STAT_IC,A.STAT_PUR,A.STAT_MFG "
+" FROM PERIOD_STAT A, SITE B WHERE A.SITE_CODE = B.SITE_CODE AND A. PRD_CODE> = '"+prdCodeFrm+"' " + " FROM PERIOD_STAT A, SITE B WHERE A.SITE_CODE = B.SITE_CODE AND A. PRD_CODE> = '"
+"AND A.PRD_CODE <='"+prdCodeTo+"' AND B.FIN_ENTITY = '"+finEntity+"'"; + prdCodeFrm + "' " + "AND A.PRD_CODE <='" + prdCodeTo + "' AND B.FIN_ENTITY = '"
+ finEntity + "'";
pstmt = conn.prepareStatement(getDataSql); pstmt = conn.prepareStatement(getDataSql);
System.out.println("The getDataSql becomes .................:"+getDataSql); System.out.println("The getDataSql becomes .................:" + getDataSql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next()) {
{ valueXmlString.append("<Detail2 domID='" + (++detDomId) + "'>");
valueXmlString.append("<Detail2 domID='"+(++detDomId)+"'>");
valueXmlString.append("<site_code>").append("<![CDATA[" + rs.getString(1) + "]]>")
valueXmlString.append("<site_code>").append("<![CDATA[" + rs.getString(1) +"]]>").append("</site_code>"); .append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + rs.getString(2) +"]]>").append("</descr>"); valueXmlString.append("<descr>").append("<![CDATA[" + rs.getString(2) + "]]>")
valueXmlString.append("<prd_code>").append("<![CDATA[" + rs.getString(3) +"]]>").append("</prd_code>"); .append("</descr>");
valueXmlString.append("<stat_adm>").append("<![CDATA[" + rs.getString(4) +"]]>").append("</stat_adm>"); valueXmlString.append("<prd_code>").append("<![CDATA[" + rs.getString(3) + "]]>")
valueXmlString.append("<stat_fin>").append("<![CDATA[" + rs.getString(5) +"]]>").append("</stat_fin>"); .append("</prd_code>");
valueXmlString.append("<stat_sal>").append("<![CDATA[" + rs.getString(6) +"]]>").append("</stat_sal>"); valueXmlString.append("<stat_adm>").append("<![CDATA[" + rs.getString(4) + "]]>")
valueXmlString.append("<stat_ic>").append("<![CDATA[" + rs.getString(7) +"]]>").append("</stat_ic>"); .append("</stat_adm>");
valueXmlString.append("<stat_pur>").append("<![CDATA[" + rs.getString(8) +"]]>").append("</stat_pur>"); valueXmlString.append("<stat_fin>").append("<![CDATA[" + rs.getString(5) + "]]>")
valueXmlString.append("<stat_mfg>").append("<![CDATA[" + rs.getString(9) +"]]>").append("</stat_mfg>"); .append("</stat_fin>");
valueXmlString.append("<stat_sal>").append("<![CDATA[" + rs.getString(6) + "]]>")
.append("</stat_sal>");
valueXmlString.append("<stat_ic>").append("<![CDATA[" + rs.getString(7) + "]]>")
.append("</stat_ic>");
valueXmlString.append("<stat_pur>").append("<![CDATA[" + rs.getString(8) + "]]>")
.append("</stat_pur>");
valueXmlString.append("<stat_mfg>").append("<![CDATA[" + rs.getString(9) + "]]>")
.append("</stat_mfg>");
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
valueXmlString.append("\n"); valueXmlString.append("\n");
} }
rs.close(); rs.close();
...@@ -205,41 +192,29 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -205,41 +192,29 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} }
} }
valueXmlString.append( "</Root>" ); valueXmlString.append("</Root>");
} } catch (Exception e) {
catch(Exception e) System.out.println("PeriodStatUpdWiz.itemChanged():catchBlock" + e.getMessage());
{
System.out.println("PeriodStatUpdWiz.itemChanged():catchBlock"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
} } finally {
finally try {
{ if (rs != null) {
try
{
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;
} }
if(!conn.isClosed() && conn != null) if (!conn.isClosed() && conn != null) {
{
conn.close(); conn.close();
conn = null; conn = null;
} }
} } catch (Exception e) {
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.itemChanged():finally block"); System.out.println("PeriodStatUpdWiz.itemChanged():finally block");
e.printStackTrace(); e.printStackTrace();
} }
...@@ -247,41 +222,36 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -247,41 +222,36 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
return valueXmlString.toString(); return valueXmlString.toString();
} }
@Override @Override
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 {
String errString = ""; String errString = "";
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
System.out.println("PricelistGenEJB.wfValData()"); System.out.println("PricelistGenEJB.wfValData()");
System.out.println("xmlString :"+xmlString); System.out.println("xmlString :" + xmlString);
System.out.println("xmlString1 :"+xmlString1); System.out.println("xmlString1 :" + xmlString1);
System.out.println("xmlString2 :"+xmlString2); System.out.println("xmlString2 :" + xmlString2);
System.out.println("objContext :"+objContext); System.out.println("objContext :" + objContext);
System.out.println("editFlag :"+editFlag); System.out.println("editFlag :" + editFlag);
System.out.println("xtraParams :"+xtraParams); System.out.println("xtraParams :" + xtraParams);
try try {
{ if (xmlString != null && xmlString.trim().length() > 0) {
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
System.out.println("Before calling function wfvalData****"); System.out.println("Before calling function wfvalData****");
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
System.out.println("After calling method wfVAlData Error String===="+errString); System.out.println("After calling method wfVAlData Error String====" + errString);
} } catch (Exception e) {
catch (Exception e)
{
System.out.println("Exception : [PeriodStatUpdWiz][wfValData( String, String )] :==>\n" + e.getMessage()); System.out.println("Exception : [PeriodStatUpdWiz][wfValData( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -289,8 +259,9 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -289,8 +259,9 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
} }
@Override @Override
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams)throws RemoteException, ITMException public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext,
{ String finEntity="",prdCodeFrm="",prdCodeTo=""; String editFlag, String xtraParams) throws RemoteException, ITMException {
String finEntity = "", prdCodeFrm = "", prdCodeTo = "";
String errString = ""; String errString = "";
int currentFormNo = 0; int currentFormNo = 0;
NodeList parentNodeList = null; NodeList parentNodeList = null;
...@@ -299,112 +270,93 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -299,112 +270,93 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
Node parentNode = null; Node parentNode = null;
int childNodeListLength; int childNodeListLength;
Node childNode = null; Node childNode = null;
String errCode=null,errorType=null,productCode=null,userId=null,grpCode=null; String errCode = null, errorType = null, productCode = null, userId = null, grpCode = null;
int ctr=0,count=0,cnt=0; int ctr = 0, count = 0, cnt = 0;
E12GenericUtility e12genericUtility = new E12GenericUtility(); E12GenericUtility e12genericUtility = 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>();
ResultSet rs=null; ResultSet rs = null;
PreparedStatement pstmt=null; PreparedStatement pstmt = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
Connection conn = null; Connection conn = null;
try try {
{ conn = getConnection();
conn=getConnection(); userId = e12genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
userId = e12genericUtility.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);
System.out.println("currentFormNo ["+currentFormNo+"]"); System.out.println("currentFormNo [" + currentFormNo + "]");
} }
switch (currentFormNo) switch (currentFormNo) {
{ case 1: {
case 1:
{
parentNodeList = currFormDataDom.getElementsByTagName("Detail1"); parentNodeList = currFormDataDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
System.out.println("Child name --->> "+childNodeName); System.out.println("Child name --->> " + childNodeName);
if(childNodeName.equalsIgnoreCase("fin_entity"))
{
if (childNodeName.equalsIgnoreCase("fin_entity")) {
finEntity = e12genericUtility.getColumnValue("fin_entity", currFormDataDom);
finEntity=e12genericUtility.getColumnValue("fin_entity", currFormDataDom); if (finEntity == null || finEntity.trim().length() == 0) {
errCode = "VEFENTY2";
if ( finEntity == null || finEntity.trim().length() == 0 ) errList.add(errCode);
{ errFields.add(childNodeName.toLowerCase());
errCode="VEFENTY2";
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
} }
String sql="Select count(*) from site where fin_entity= ?"; String sql = "Select count(*) from site where fin_entity= ?";
pstmt=conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity); pstmt.setString(1, finEntity);
rs=pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ count = rs.getInt(1);
count=rs.getInt(1);
} }
pstmt.close(); pstmt.close();
pstmt=null; pstmt = null;
rs.close(); rs.close();
rs=null; rs = null;
if(count==0) if (count == 0) {
{ errCode = "VMFENTY1";
errCode="VMFENTY1"; errList.add(errCode);
errList.add( errCode ); errFields.add(childNodeName.toLowerCase());
errFields.add( childNodeName.toLowerCase() );
} }
} }
if(childNodeName.equalsIgnoreCase("prd_code__from")) if (childNodeName.equalsIgnoreCase("prd_code__from")) {
{
prdCodeFrm=e12genericUtility.getColumnValue("prd_code__from", currFormDataDom); prdCodeFrm = e12genericUtility.getColumnValue("prd_code__from", currFormDataDom);
if ( prdCodeFrm == null || prdCodeFrm.equals("null") || prdCodeFrm.trim().length() == 0 ) if (prdCodeFrm == null || prdCodeFrm.equals("null") || prdCodeFrm.trim().length() == 0) {
{ errCode = "VTBLNKPRD";
errCode="VTBLNKPRD"; errList.add(errCode);
errList.add( errCode ); errFields.add(childNodeName.toLowerCase());
errFields.add( childNodeName.toLowerCase() );
} }
if (prdCodeFrm!=null) if (prdCodeFrm != null) {
{ if (!"0".equalsIgnoreCase(prdCodeFrm.trim()) && !"00".equalsIgnoreCase(prdCodeFrm.trim())) {
if(!"0".equalsIgnoreCase(prdCodeFrm.trim()) && !"00".equalsIgnoreCase(prdCodeFrm.trim()) )
{
String sql1 = "Select count(*) FROM period_stat WHERE PRD_CODE= ?";
String sql1="Select count(*) FROM period_stat WHERE PRD_CODE= ?"; pstmt = conn.prepareStatement(sql1);
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, prdCodeFrm); pstmt.setString(1, prdCodeFrm);
rs=pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ count = rs.getInt(1);
count=rs.getInt(1);
} }
pstmt.close(); pstmt.close();
pstmt=null; pstmt = null;
rs.close(); rs.close();
rs=null; rs = null;
if(count==0) if (count == 0) {
{ errCode = "CNDIPRDINV";
errCode="CNDIPRDINV"; errList.add(errCode);
errList.add( errCode ); errFields.add(childNodeName.toLowerCase());
errFields.add( childNodeName.toLowerCase() );
} }
} }
...@@ -412,85 +364,75 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -412,85 +364,75 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
} }
} }
if(childNodeName.equalsIgnoreCase("prd_code__to")) if (childNodeName.equalsIgnoreCase("prd_code__to")) {
{
prdCodeTo=e12genericUtility.getColumnValue("prd_code__to", currFormDataDom); prdCodeTo = e12genericUtility.getColumnValue("prd_code__to", currFormDataDom);
if ( prdCodeTo == null || prdCodeTo.equals("null") || prdCodeTo.trim().length() == 0 ) if (prdCodeTo == null || prdCodeTo.equals("null") || prdCodeTo.trim().length() == 0) {
{ errCode = "VTBLNKPRD";
errCode="VTBLNKPRD"; errList.add(errCode);
errList.add( errCode ); errFields.add(childNodeName.toLowerCase());
errFields.add( childNodeName.toLowerCase() );
} }
if (prdCodeTo!=null) if (prdCodeTo != null) {
{ if (!"zz".equalsIgnoreCase(prdCodeTo.trim())) {
if( !"zz".equalsIgnoreCase(prdCodeTo.trim()) ) String sql1 = "Select count(*) FROM period_stat WHERE PRD_CODE= ?";
{ pstmt = conn.prepareStatement(sql1);
String sql1="Select count(*) FROM period_stat WHERE PRD_CODE= ?";
pstmt=conn.prepareStatement(sql1);
pstmt.setString(1, prdCodeTo); pstmt.setString(1, prdCodeTo);
rs=pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ count = rs.getInt(1);
count=rs.getInt(1);
} }
pstmt.close(); pstmt.close();
pstmt=null; pstmt = null;
rs.close(); rs.close();
rs=null; rs = null;
if(count==0) if (count == 0) {
{ errCode = "CNDIPRDINV";
errCode="CNDIPRDINV"; errList.add(errCode);
errList.add( errCode ); errFields.add(childNodeName.toLowerCase());
errFields.add( childNodeName.toLowerCase() );
} }
} }
} }
} }
} }
System.out.println("errString["+errString+"]"); System.out.println("errString[" + errString + "]");
break; break;
} }
case 2: case 2: {
{ System.out.println("errString[" + errString + "]");
System.out.println("errString["+errString+"]");
break; break;
} }
} }
int errListSize = errList.size(); int errListSize = errList.size();
cnt =0; cnt = 0;
String errFldName = null; String errFldName = null;
if ( errList != null && errListSize > 0 ) if (errList != null && errListSize > 0) {
{ for (cnt = 0; cnt < errListSize; cnt++) {
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = errList.get(cnt); errCode = errList.get(cnt);
errFldName = errFields.get(cnt); errFldName = errFields.get(cnt);
System.out.println("errCode .........."+errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString( errFldName, errCode, userId ); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType( conn, errCode ); errorType = errorType(conn, errCode);
if ( errString.length() > 0) if (errString.length() > 0) {
{ String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>")); bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml); System.out.println("errStringXml .........." + errStringXml);
errString = ""; errString = "";
} }
if ( errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E")) {
{
break; break;
} }
} }
...@@ -500,104 +442,103 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -500,104 +442,103 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
errFields = null; errFields = null;
errStringXml.append("</Errors></Root>\r\n"); errStringXml.append("</Errors></Root>\r\n");
} } else {
else errStringXml = new StringBuffer("");
{
errStringXml = new StringBuffer( "" );
} }
} } catch (Exception e) {
catch(Exception e)
{
System.out.println("PeriodStatUpdWiz.wfValData()"); System.out.println("PeriodStatUpdWiz.wfValData()");
e.printStackTrace(); e.printStackTrace();
} }
finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (!conn.isClosed() && conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
System.out.println("PeriodStatUpdWiz.itemChanged():finally block");
e.printStackTrace();
}
}
return errStringXml.toString(); return errStringXml.toString();
} }
@Override @Override
public String handleRequest(HashMap<String, String> reqParamMap) public String handleRequest(HashMap<String, String> reqParamMap) {
{
String action = "", retXMLStr = ""; String action = "", retXMLStr = "";
try try {
{
action = (String)reqParamMap.get("action"); action = (String) reqParamMap.get("action");
if("ITEM_CHANGE".equalsIgnoreCase(action)) if ("ITEM_CHANGE".equalsIgnoreCase(action)) {
{ String currXmlDataStr = "", hdrXmlDataStr = "", allXmlDataStr = "", currentColumn = "", objContext = "",
String currXmlDataStr = "", hdrXmlDataStr = "", allXmlDataStr = "", currentColumn = "", objContext = "", editFlag = ""; editFlag = "";
currXmlDataStr = (String)reqParamMap.get("CUR_XML_STR"); currXmlDataStr = (String) reqParamMap.get("CUR_XML_STR");
hdrXmlDataStr = (String)reqParamMap.get("HDR_XML_STR"); hdrXmlDataStr = (String) reqParamMap.get("HDR_XML_STR");
allXmlDataStr = (String)reqParamMap.get("ALL_XML_STR"); allXmlDataStr = (String) reqParamMap.get("ALL_XML_STR");
currentColumn = (String)reqParamMap.get("CUR_COLUMN"); currentColumn = (String) reqParamMap.get("CUR_COLUMN");
objContext = (String)reqParamMap.get("OBJ_CONTEXT"); objContext = (String) reqParamMap.get("OBJ_CONTEXT");
editFlag = (String)reqParamMap.get("EDIT_FLAG"); editFlag = (String) reqParamMap.get("EDIT_FLAG");
retXMLStr = itemChanged(currXmlDataStr, hdrXmlDataStr, allXmlDataStr, objContext, currentColumn, editFlag, globalXtraParams); retXMLStr = itemChanged(currXmlDataStr, hdrXmlDataStr, allXmlDataStr, objContext, currentColumn,
editFlag, globalXtraParams);
System.out.println("retXMLStr["+retXMLStr+"] for action ["+action+"]"); System.out.println("retXMLStr[" + retXMLStr + "] for action [" + action + "]");
} } else if ("DELETE".equalsIgnoreCase(action)) {
else if("DELETE".equalsIgnoreCase(action))
{
} }
} } catch (Exception e) {
catch(Exception e) System.out.println("PeriodStatUpdWiz.handleRequest()" + e.getMessage());
{
System.out.println("PeriodStatUpdWiz.handleRequest()"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
return retXMLStr; return retXMLStr;
} }
private static String checkNull(String input) private static String checkNull(String input) {
{ if (input == null) {
if (input==null) input = "";
{
input="";
} }
return input; return input;
} }
public InitialContext getInitialContext()throws ITMException public InitialContext getInitialContext() throws ITMException {
{
InitialContext ctx = null; InitialContext ctx = null;
try try {
{
AppConnectParm appConnect = new AppConnectParm(); AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty()); ctx = new InitialContext(appConnect.getProperty());
} } catch (ITMException itme) {
catch(ITMException itme)
{
System.out.println("PeriodStatUpdWiz.getInitialContext()"); System.out.println("PeriodStatUpdWiz.getInitialContext()");
throw itme; throw itme;
} } catch (Exception e) {
catch(Exception e) System.out.println("PeriodStatUpdWiz.getInitialContext()" + e.getMessage());
{
System.out.println("PeriodStatUpdWiz.getInitialContext()"+e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return ctx; return ctx;
} }
public String getValue(String lineItemStr, String column) throws ITMException public String getValue(String lineItemStr, String column) throws ITMException {
{
String retValue = ""; String retValue = "";
Document lineDom = null; Document lineDom = null;
try try {
{ lineDom = new E12GenericUtility().parseString("<detail>" + lineItemStr + "</detail>");
lineDom =new E12GenericUtility().parseString("<detail>"+lineItemStr+"</detail>");
retValue = lineDom.getElementsByTagName(column).item(0).getTextContent(); retValue = lineDom.getElementsByTagName(column).item(0).getTextContent();
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -605,72 +546,48 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo ...@@ -605,72 +546,48 @@ public class PeriodStatUpdWiz extends ValidatorEJB implements PeriodStatUpdWizLo
return retValue; return retValue;
} }
private static String checkNullAndTrim(String input) private static String checkNullAndTrim(String input) {
{ if (input == null) {
if (input==null) input = "";
{
input="";
} }
return input.trim(); return input.trim();
} }
private String errorType( Connection conn , String errorCode )
{ private String errorType(Connection conn, String errorCode) {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try {
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? "; String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql ); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(errorCode)); pstmt.setString(1, checkNull(errorCode));
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while( rs.next() ) while (rs.next()) {
{
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} } catch (Exception ex) {
catch (Exception ex)
{
ex.printStackTrace(); ex.printStackTrace();
} } finally {
finally try {
{ if (rs != null) {
try
{
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;
} }
if(!conn.isClosed() && conn != null)
{ } catch (Exception e) {
conn.close();
conn = null;
}
}
catch ( Exception e )
{
e.printStackTrace(); e.printStackTrace();
} }
} }
return msgType; return msgType;
} }
} }
\ 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