From 4e8bda756645b881fa2769f2710446081f8d251a Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Mon, 1 Jun 2020 15:49:23 +0530 Subject: lowered code smells in ReportParamValuesForPDFExce lowered code smells in ReportParamValuesForPDFExcel.java Issue-ID: PORTAL-813 Change-Id: Ief9283b47dd8cb050ef5d770c2ff7bc09b04bdac Signed-off-by: Indrijeet Kumar --- .../runtime/ReportParamValuesForPDFExcel.java | 32 ++-------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java index 483e9fe4..62d95efb 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java @@ -91,12 +91,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // for } // ReportParamValues - /* - * public ReportParamValues(ReportFormFields rff, HttpServletRequest - * request) { this(rff); - * - * setParamValues(request); } // ReportParamValues - */ public boolean isParameterMultiValue(String fieldName) { Boolean b = (Boolean) paramIsMultiValue.get(fieldName); return (b != null) ? b.booleanValue() : false; @@ -108,7 +102,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // isParameterMultiValue public boolean setParamValues(HttpServletRequest request, boolean refresh) { - //debugLogger.debug("ReportParamValues for PDF Excel setParamValues called " + refresh); long currentTime = System.currentTimeMillis(); boolean paramUpdated = false; if(refresh) @@ -141,7 +134,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { for (Iterator iter = rff.iterator(); iter.hasNext();) { name=""; //just added ff = (FormField) iter.next(); - //debugLogger.debug("ff.getFieldName " + ff.getFieldName() + " " + ff.getFieldDisplayName() + " " + ff.getFieldType()+ " " +ff.getBaseSQLForPDFExcel()+ " "+ rr.getParamValue(ff.getFieldName())); if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { sql = ff.getBaseSQLForPDFExcel(); if(sql!=null && sql.trim().length()>0) @@ -197,34 +189,28 @@ public class ReportParamValuesForPDFExcel extends Hashtable { if(name.length()<=0) name = ff.getFieldName(); value = rr.getParamValue(name); - //debugLogger.debug("Name "+ name+ " value:" + value); String paramValue = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), getParamValueForSQL(name, value)); - //debugLogger.debug("PDFEXCEL " + name+ " " + ff.getFieldName()+ " " + value + " " + sql +" "+ paramValue); if(name!=null && name.equals(ff.getFieldName())) sql = Utils.replaceInString(sql, "[VALUE]", paramValue); if(paramValue == null) { if(sql.lastIndexOf("where id = ''")>0) sql = sql.substring(0, sql.lastIndexOf("where id = ''")); } - //debugLogger.debug("SQL Modified " + sql); FormField ff2 = null; for (Iterator iter1 = rff.iterator(); iter1.hasNext();) { ff2 = (FormField)iter1.next(); sql = Utils.replaceInString(sql, "[" + ff2.getFieldDisplayName() +"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),getParamValue(ff2.getFieldName()))); } - //debugLogger.debug("SQL Modified after replacing formfield" + sql); try { String[] reqParameters = Globals.getRequestParams().split(","); String[] sessionParameters = Globals.getSessionParams().split(","); String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(","); - javax.servlet.http.HttpSession session = request.getSession(); - //debugLogger.debug("B4 Session " + sql); + javax.servlet.http.HttpSession session = request.getSession(); if(session != null ) { for (int i = 0; i < sessionParameters.length; i++) { sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - } - //debugLogger.debug("B4 request " + sql); + } if(request != null ) { for (int i = 0; i < scheduleSessionParameters.length; i++) { sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(scheduleSessionParameters[i]) )); @@ -243,8 +229,7 @@ public class ReportParamValuesForPDFExcel extends Hashtable { else sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i]) )); } - } - //debugLogger.debug("After request " + sql); + } DataSet ds = null; try { ds = ConnectionUtils.getDataSet(sql, dbInfo); @@ -255,12 +240,9 @@ public class ReportParamValuesForPDFExcel extends Hashtable { StringBuffer multiValue = new StringBuffer(""); if(ds!=null) { for(int i = 0; i < ds.getRowCount(); i++) { - //if(i==0) multiValue.append("("); multiValue.append(ds.getString(i,1)); if(i 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Sec")))) : ""); } - //debugLogger.debug("77777777777777 " + value1); put(ff.getFieldName(), nvl(value1)); } else { @@ -293,15 +274,12 @@ public class ReportParamValuesForPDFExcel extends Hashtable { logger.debug(EELFLoggerDelegate.debugLogger, ("sql not complete" + sql)); } catch (Exception ex) {} - - //debugLogger.debug("66666666666666666 " + ff.getValidationType()); //Added for TimeStamp validation } else { if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { //Added for TimeStamp validation - //debugLogger.debug("666666666666 " + ff.getValidationType()); if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) { value1 = nvl(rr.getParamValue(ff.getFieldName())) + " "+addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Hr")))); @@ -315,7 +293,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { .getParamValue(ff.getFieldName()+"_Sec")).length() > 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Sec")))) : ""); } - //debugLogger.debug("77777777777777 " + value1); } else value1 = nvl(rr.getParamValue(ff.getFieldName())); if(value1.length()<=0) @@ -331,7 +308,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // dbInfo } // !=null - //printValues(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for Adding/Clearing Param Values for FormField Info Bar " + (System.currentTimeMillis() - currentTime))); return paramUpdated; } // setParamValues @@ -351,7 +327,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // getParamValue public String getParamDisplayValue(String key) { - //debugLogger.debug("Key is " + key +" Value is " + getParamValue(key)); String value = getParamValue(key); if (isParameterMultiValue(key)) value = "(" + Utils.replaceInString(value, "|", ",") + ")"; @@ -397,7 +372,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { if(nvl(defaultValue).length()>0) { put(key,ff.getDefaultValue()); } else if(nvl(defaultSQL).length() > 0) { - //defaultSQL = Utils.replaceInString(defaultSQL, "[LOGGED_USERID]", userId); if(!(isParameterMultiValue(key) || isParameterTextAreaValue(key))) { defaultQuery = "SELECT id, name FROM (SELECT rownum r, id, name FROM (" + defaultSQL + ") x " -- cgit 1.2.3-korg