removed code smells 62/105062/1
authorRupinder <rupinsi1@in.ibm.com>
Fri, 3 Apr 2020 08:23:12 +0000 (13:53 +0530)
committerRupinder <rupinsi1@in.ibm.com>
Fri, 3 Apr 2020 08:25:16 +0000 (13:55 +0530)
Improved code quality by removing code smells

Issue-ID: PORTAL-865
Change-Id: Ic68e75d36672a9b51800853c0ac485e9bb603d3b
Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/IdNameSql.java
ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java
ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java
ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java

index d727171..3091fa9 100644 (file)
@@ -255,7 +255,9 @@ public class IdNameSql extends IdNameList {
                        
                }
                if(searchString!=null && searchString.length()>0 && !searchString.equals("%")) {
-                       if(pageNo == -2) query.append(" WHERE ");
+                       if(pageNo == -2){
+                                       query.append(" WHERE ");
+                               }
                        else query.append(" and ");
                    query.append("name like '"+ searchString +"'");
                }
index 4778d2f..69837d0 100644 (file)
@@ -2887,7 +2887,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
                                 posFormField = sql.indexOf(fieldDisplay);
                                 int posSelectField = sql.lastIndexOf("SELECT ", posFormField);
                                 int andField = 0;
-                                int whereField = 0, whenField = 0;
+                                int whereField = 0;
+                                                               int     whenField = 0;
                                 andField = sql.lastIndexOf(" AND ", posFormField);
                                 whereField = sql.indexOf(" WHERE", posSelectField);
                                 whenField = sql.indexOf(" WHEN", posSelectField);
@@ -4242,7 +4243,9 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject {
         // reportSQL = reportSQL.replaceAll("[\\s]*\\(", "(");
         colName = colName.replaceAll(",[\\s]*\\(", ",(");
         StringBuffer colNameBuf = new StringBuffer(colName);
-        int pos = 0, posFormatStart = 0, posFormatEnd = 0;
+        int pos = 0;
+               int     posFormatStart = 0;
+               int     posFormatEnd = 0;
         String format = "";
         if (colNameBuf.indexOf("999") == -1 && colNameBuf.indexOf("990") == -1) {
             logger.debug(EELFLoggerDelegate.debugLogger, (" return colName " + colNameBuf.toString()));
index 96e8804..e51913e 100644 (file)
@@ -853,7 +853,8 @@ public class ReportDefinition extends ReportWrapper implements Serializable {
                                                break;
                                        }
                                }
-                               if(flag == 1) return javascriptItemType;
+                               if(flag == 1)
+                                       return javascriptItemType;
                                else {
                                        javascriptItemType = objFactory.createJavascriptItemType();
                                        getJavascriptList().getJavascriptItem().add(javascriptItemType);
@@ -1357,7 +1358,8 @@ public class ReportDefinition extends ReportWrapper implements Serializable {
                        String extracted        = null;
                        nextToken = getNextCYMBALSQLParseToken(sql,true);
                        while (nextToken.length() > 0) {
-                               if (lastToken == null) lastToken = nextToken;
+                               if (lastToken == null)
+                                       lastToken = nextToken;
                                
                                if( lastToken.toUpperCase().startsWith("DO DISPLAY")) {
                                        re              = Pattern.compile("each(.*)\\[.(.*?)\\]");   //\\[(.*?)\\]
@@ -1503,7 +1505,8 @@ public class ReportDefinition extends ReportWrapper implements Serializable {
                        String extracted        = null;
                        nextToken = getNextCYMBALSQLParseToken(sql,true);
                        while (nextToken.length() > 0) {
-                               if (lastToken == null) lastToken = nextToken;
+                               if (lastToken == null)
+                                       lastToken = nextToken;
                                
                                if( lastToken.toUpperCase().startsWith("DO DISPLAY")) {
                                        re              = Pattern.compile("each(.*)\\[.(.*?)\\]");   //\\[(.*?)\\]
index d56391e..5db298b 100644 (file)
@@ -666,7 +666,9 @@ public class ReportSchedule extends RaptorObject implements Serializable{
                             
                             paramValue = Utils.replaceInString(paramValue, "''", "'");
                             ds = ConnectionUtils.getDataSet(paramValue, dbInfo);
-                            if (ds.getRowCount() > 0) paramValue = ds.getString(0, 0);
+                            if (ds.getRowCount() > 0){
+                                                               paramValue = ds.getString(0, 0);
+                                                       }
                         }
                         logger.debug(EELFLoggerDelegate.debugLogger, ("SQLSQLBASED B4^^^^^^^^^ " + sql + " " + fft.getValidationType() + " " + fft.getFieldName() + " " + fft.getFieldId()));
                         if(fft!=null && (fft.getValidationType()!=null && (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) ||fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ||fft.getValidationType().equals(FormField.VT_DATE) ))) {
@@ -741,8 +743,10 @@ public class ReportSchedule extends RaptorObject implements Serializable{
                                                re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL);
                                posFormField = sql.indexOf(fieldDisplay);
                                posAnd = sql.lastIndexOf(" AND ", posFormField);                                                
-                               if(posAnd < 0) posAnd = 0;
-                               else if (posAnd > 2) posAnd = posAnd - 2;
+                               if(posAnd < 0)
+                                                               posAnd = 0;
+                               else if (posAnd > 2)
+                                                               posAnd = posAnd - 2;
                                                matcher = re1.matcher(sql);
                                                if (matcher.find(posAnd)) {
                                                        sql = sql.replace(matcher.group(), "");
@@ -763,8 +767,10 @@ public class ReportSchedule extends RaptorObject implements Serializable{
                                        re1 = Pattern.compile("(^[\r\n]|[\\s]|[^0-9a-zA-Z])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ "\\](.*?)\\s", Pattern.DOTALL); //+[\'\\)|\'|\\s]
                                posFormField = sql.indexOf(fieldDisplay);
                                posAnd = sql.lastIndexOf(" AND ", posFormField);
-                               if(posAnd < 0) posAnd = 0;
-                               else if (posAnd > 2) posAnd = posAnd - 2;
+                               if(posAnd < 0)
+                                                               posAnd = 0;
+                               else if (posAnd > 2)
+                                                               posAnd = posAnd - 2;
                                        matcher = re1.matcher(sql);
                                        if (matcher.find(posAnd)) {
                                                sql = sql.replace(matcher.group(), " ");
@@ -1190,7 +1196,8 @@ public class ReportSchedule extends RaptorObject implements Serializable{
        }catch(NumberFormatException ex){
                numInt = 0;
        }
-       if(numInt < 10) return "0"+numInt;
+       if(numInt < 10)
+                       return "0"+numInt;
        else return ""+numInt;
     }