diff options
author | burdziak <olaf.burdziakowski@nokia.com> | 2019-09-23 09:26:50 +0200 |
---|---|---|
committer | burdziak <olaf.burdziakowski@nokia.com> | 2019-09-23 09:26:50 +0200 |
commit | bbd24c40d38985d30e1aec3cfc69838db4aa75ab (patch) | |
tree | bc6b0754a7acd21f59a5ea5e1aab94fb791421da | |
parent | c4df8f3822c115df2c53beac8b531e20bb383afd (diff) |
Fix sonar issues (part) in ReportDefinition
Change-Id: I68536d6a7c5b5f44a6f0431df2da756a38abc61f
Issue-ID: PORTAL-523
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java index 72eb64b8..96e8804f 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java @@ -52,7 +52,6 @@ import javax.servlet.http.HttpServletRequest; import javax.xml.bind.JAXBException; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; -//import javax.xml.transform.stream.*; import org.onap.portalsdk.analytics.controller.WizardSequence; import org.onap.portalsdk.analytics.controller.WizardSequenceCrossTab; @@ -130,7 +129,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { String menuID, boolean menuApproved, HttpServletRequest request) throws RaptorException { super(crType, reportID, ownerID, createID, createDate, updateID, updateDate, menuID, menuApproved); - if(reportID.equals("-1")) + if("-1".equals(reportID)) reportSchedule = new ReportSchedule(getReportID(), getOwnerID(), false, request); else reportSchedule = new ReportSchedule(getReportID(), getOwnerID(), true, request); @@ -158,7 +157,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { throws RaptorException { ReportDefinition rn = null; CustomReportType crType = ReportWrapper.unmarshalCR(reportXML); - //Log.write("Report [" + reportID + "]: XML unmarshalled", 4); + logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report [" + reportID + "]: XML unmarshalled")); rn = new ReportDefinition(crType, reportID, null, null, null, null, null, null, false, request); @@ -168,12 +167,8 @@ public class ReportDefinition extends ReportWrapper implements Serializable { public static ReportDefinition createBlank(HttpServletRequest request) throws RaptorException { String curTime = Utils.getCurrentDateTime(); String userID = AppUtils.getUserID(request); - ReportDefinition rd = new ReportDefinition(ReportWrapper.createBlankCR(userID), "-1", + return new ReportDefinition(ReportWrapper.createBlankCR(userID), "-1", userID, userID, curTime, userID, curTime, "", false, request); - - // Necessary initialization - - return rd; } // ReportDefinition public void setAsCopy(HttpServletRequest request) throws RaptorException { @@ -195,9 +190,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { if(request!=null) { userId = AppUtils.getUserID(request); if (userId != null) - userIsAuthorizedToSeeLog = AppUtils.isAdminUser(request) - || AppUtils.isAdminUser(request); - //System.out.println("******** Report Type "+getReportType() + " userIsAuthorizedToSeeLog " + userIsAuthorizedToSeeLog); + userIsAuthorizedToSeeLog = AppUtils.isAdminUser(request); } if (getReportType().equals(AppConstants.RT_LINEAR)){ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) @@ -220,27 +213,15 @@ public class ReportDefinition extends ReportWrapper implements Serializable { } // generateWizardSequence private boolean canPersistDashboard() { - //System.out.println(" getDashBoardReports().getReportsList().size() " + getDashBoardReports().getReportsList().size()); - /* Commented for New DashBoard - if (getDashBoardReports()!=null && getDashBoardReports().getReportsList()!=null && getDashBoardReports().getReportsList().size() > 0) { - for (Iterator iter = getDashBoardReports().getReportsList().iterator(); iter.hasNext();) { - Reports report = (Reports)iter.next(); - try { - if(Integer.parseInt(report.getReportId())>0) return true; - } catch (NumberFormatException ex) {} - } // for - } //if - */ - - //if( ) + return nvl(getDashboardLayoutHTML()).length() > 0; } //canPersistDashboard private boolean canPersistLinearReport() { - System.out.println("&&&&&&&&&&&&&&&&&&&&&& canPersistLinearReport"); + logger.debug(EELFLoggerDelegate.debugLogger,"&&&&&&&&&&&&&&&&&&&&&& canPersistLinearReport"); boolean visibleColExist = false; - if (getDataSourceList().getDataSource().size() > 0) { + if (!getDataSourceList().getDataSource().isEmpty()) { for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) { DataColumnType dct = (DataColumnType) iter.next(); @@ -251,7 +232,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { } // for } // if - System.out.println("&&&&&&&&&&&&&&&&&&&&&& visibleColExist " + visibleColExist); + logger.debug(EELFLoggerDelegate.debugLogger,"&&&&&&&&&&&&&&&&&&&&&& visibleColExist " + visibleColExist); return visibleColExist; } // canPersistLinearReport @@ -260,7 +241,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { boolean colColExist = false; boolean valColExist = false; - if (getDataSourceList().getDataSource().size() > 0) { + if (!getDataSourceList().getDataSource().isEmpty()) { for (Iterator iter = getAllColumns().iterator(); iter.hasNext();) { DataColumnType dct = (DataColumnType) iter.next(); @@ -278,15 +259,17 @@ public class ReportDefinition extends ReportWrapper implements Serializable { private boolean canPersistReport() { return getReportType().equals(AppConstants.RT_CROSSTAB) ? canPersistCrossTabReport() - : (getReportType().equals(AppConstants.RT_LINEAR)? canPersistLinearReport():((getReportType().equals(AppConstants.RT_HIVE)? canPersistLinearReport():canPersistDashboard()))); + : (getReportType().equals(AppConstants.RT_LINEAR)? canPersistLinearReport() + :(getReportType().equals(AppConstants.RT_HIVE)? canPersistLinearReport() + :canPersistDashboard())); } // canPersistReport public void persistReport(HttpServletRequest request) throws RaptorException { if (!canPersistReport()) { - System.out.println("&&&&&&&&&&&&&&&&&&&&&& In !canPersistReport ReportType: " + getReportType()); + logger.debug(EELFLoggerDelegate.debugLogger,"&&&&&&&&&&&&&&&&&&&&&& In !canPersistReport ReportType: " + getReportType()); return; } else { - System.out.println("&&&&&&&&&&&&&&&&&&&&&& Not In !canPersistReport"); + logger.debug(EELFLoggerDelegate.debugLogger,"&&&&&&&&&&&&&&&&&&&&&& Not In !canPersistReport"); } Connection connection = null; @@ -294,18 +277,16 @@ public class ReportDefinition extends ReportWrapper implements Serializable { String userID = AppUtils.getUserID(request); String reportXML = marshal(); logger.debug(EELFLoggerDelegate.debugLogger, ("Ocurring during Schedule ")); - System.out.println("&&&&&&&&&&&&&&&&&&&&&& Report ID " + reportID); - if (nvl(reportID, "-1").equals("-1")) { + logger.debug(EELFLoggerDelegate.debugLogger,"&&&&&&&&&&&&&&&&&&&&&& Report ID " + reportID); + if ("-1".equals(nvl(reportID, "-1"))) { connection = DbUtils.startTransaction(); // Add report String sql = ""; if (nvl(Globals.getAdhocReportSequence()).length()> 0 && nvl(Globals.getAdhocUserRoldId()).length() > 0 && AppUtils.isUserInRole(request, Globals.getAdhocUserRoldId()) && !AppUtils.isAdminUser(request)) { - //sql = "SELECT "+ Globals.getAdhocReportSequence() + ".nextval FROM dual"; sql = Globals.getPersistReportAdhoc(); sql = sql.replace("[Globals.getAdhocReportSequence()]", Globals.getAdhocReportSequence()); - } else{ - //sql = "SELECT seq_cr_report.nextval FROM dual"; + } else{ sql = Globals.getNewReportData(); } DataSet ds = DbUtils.executeQuery(connection,sql); |