diff options
author | Sunder Tattavarada <statta@research.att.com> | 2020-05-18 15:17:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-05-18 15:17:41 +0000 |
commit | 45505117ccea62c60cd57df471a757c77749671f (patch) | |
tree | 79feb9ec88278406c70c538c20278bdb45f7f708 /ecomp-sdk/epsdk-analytics/src/main | |
parent | 4c8ce62291707a0cb10d5b599d87e6c7dd6bfd9f (diff) | |
parent | 759e9e75fc0b5978f98f901744c87c0c8d5ef4fd (diff) |
Merge "Raptor backend java API Code(Analytics), UI Code(Overlay) and pages component in os project"
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main')
29 files changed, 1199 insertions, 1207 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java index a50a04eb..0846efda 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java @@ -73,6 +73,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -95,6 +96,7 @@ import org.onap.portalsdk.analytics.error.RaptorSchedularException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.error.UserDefinedException; import org.onap.portalsdk.analytics.error.ValidationException; +import org.onap.portalsdk.analytics.model.DashboardChildReport; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; import org.onap.portalsdk.analytics.model.ReportLoader; @@ -131,7 +133,10 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -322,9 +327,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID); String strHTML = rr1.getDashboardLayoutHTML(); - - TreeMap treeMap = getListOfReportsFromDashBoardHTML(strHTML); - + String strJson = rr1.getDashboardLayoutJSON(); + TreeMap treeMap = getListOfReportsFromDashBoardJson(strJson); + TreeMap treeMapHtml = getListOfReportsFromDashBoardHTML(strHTML); Set set = treeMap.entrySet(); HashMap reportsRuntimeMap = new HashMap(); @@ -350,10 +355,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { record++; Map.Entry entry = (Entry) iter.next(); reportIDFromMap = entry.getValue().toString().substring(1); - // The below line is used to optimize, so that if there is already same report id it wouldn't go through the whole process + // The below line is used to optimize, so that if there is + // already same report id it wouldn't go through the whole + // process similiarReportRuntime = getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap); if(similiarReportRuntime != null ) { - rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap).clone(); + rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap, + reportIDFromMap).clone(); intObj = getKey(reportsRuntimeMap,reportIDFromMap); } else { rrDashboardReports = rh.loadReportRuntime(request, reportIDFromMap, true, requestFlag); @@ -364,10 +372,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rrDashboardReports.setDisplayMode(ReportRuntime.DISPLAY_DATA_ONLY); } - downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); + downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload() > 0) + ? rrDashboardReports.getMaxRowsInExcelDownload() : Globals.getDownloadLimit(); if(record == 1) { - if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) { + if (rrDashboardReports.getReportFormFields() != null + && rrDashboardReports.getReportFormFields().size() > 0) { buildReportdata = false; if(rDisplayContent) buildReportdata = true; @@ -380,26 +390,37 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ds = (DataSet) reportChartDataMap.get(intObj); } else { if (!rrDashboardReports.getReportType().equals(AppConstants.RT_HIVE)) - rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit,request, false /*download*/); + rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit, request, + false /* download */); else - rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(), userId, 2,request); + rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(), + userId, 2, request); ds = rrDashboardReports.loadChartData(userId,request); } } - long totalTime = System.currentTimeMillis() - currentTime; formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS); if(buildReportdata) { - rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),formFields); - rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields); + /* + * rrDashboardReports.logReportRun(userId, String.valueOf(totalTime), + * formFields); rrDashboardReports.logReportExecutionTime(userId, + * String.valueOf(totalTime), AppConstants.RLA_EXECUTION_TIME, formFields); + */ } - - reportsRuntimeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rrDashboardReports); - reportDisplayTypeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), entry.getValue().toString().substring(0,1)); + if(!entry.getValue().toString().toLowerCase().startsWith("c")) { + reportsRuntimeMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), + rrDashboardReports); + reportDisplayTypeMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), + entry.getValue().toString().substring(0, 1)); if(buildReportdata) { - reportDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rd); - reportChartDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), ds); + reportDataMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), rd); + reportChartDataMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), ds); + } } } @@ -417,7 +438,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME, rr1); } - return "raptor/report_dashboard_run_container.jsp"; + return "{\"return\" : \"raptor/report_dashboard_run_container.jsp\"}"; } else { fromDashboard = AppUtils.getRequestFlag(request,"fromDashboard"); if(isDashboardInDrillDownList(request)) @@ -465,7 +486,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { int requestFlag = DASH; ReportHandler rh = new ReportHandler(); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID); - //rr = null; // get dashboard HTML from report runtime. getListOfReportsFromDashBoardHTML String strHTML = rr.getDashboardLayoutHTML(); //System.out.println("StrHTML " + strHTML); @@ -511,17 +531,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); - if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) - widthFlag = 1; - if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) - heightFlag = 1; + if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) widthFlag = 1; + if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) heightFlag = 1; if(record == 1) { if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) { buildReportdata = false; - if(rDisplayContent){ - buildReportdata = true; - } - + if(rDisplayContent) buildReportdata = true; } } if(buildReportdata) { @@ -805,8 +820,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { else rr.logReportExecutionTime(userId, "", "On Demand: " + AppConstants.RLA_ERROR, formFields); } - + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(e.getMessage()); errorJSONRuntime.setStacktrace(getStackTrace(e)); ObjectMapper mapper = new ObjectMapper(); @@ -825,7 +844,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } catch (RaptorException ex) { nextPage = (new ErrorHandler()).processFatalError(request, ex); + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(ex.getMessage()); errorJSONRuntime.setStacktrace(getStackTrace(ex)); ObjectMapper mapper = new ObjectMapper(); @@ -844,7 +868,14 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { //nextPage = (new ErrorHandler()).processFatalError(request, e); } catch (Exception t) { logger.error(EELFLoggerDelegate.errorLogger,t.getMessage(), t); + + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } + ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(t.toString()); errorJSONRuntime.setStacktrace(getStackTrace(t)); ObjectMapper mapper = new ObjectMapper(); @@ -891,7 +922,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { for(Iterator iter = set.iterator(); iter.hasNext(); ) { Map.Entry entry = (Entry) iter.next(); if (((ReportRuntime) entry.getValue()).getReportID().equals(reportID)) { - return new Integer(((String) entry.getKey()).substring(2)); + return new Integer(((String) entry.getKey()).substring(((String) entry.getKey()).indexOf("_")+1)); } } return null; @@ -1377,8 +1408,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { value = (String) entry.getValue(); } // added so empty string would be treated as null value if not given in single quotes. - if(value==null || value.trim().length()<=0) - value="NULL"; + if(value==null || value.trim().length()<=0) value="NULL"; SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", Utils.oracleSafe(value)); } if(request.getParameter(ff.getFieldName())!=null) { @@ -1391,10 +1421,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } //lookup.loadData("0"); } - if(lookup instanceof IdNameSql){ - ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination. - } - + if(lookup instanceof IdNameSql) ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination. } if(lookup instanceof IdNameSql) { ((IdNameSql)lookup).loadUserData(request.getParameter(AppConstants.RI_NEXT_PAGE), @@ -1749,8 +1776,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportRuntime rr = null; if(!isFromSchedule) { rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); - if(rr!=null) - AppUtils.getUserEmail(request); + if(rr!=null) AppUtils.getUserEmail(request); } String scheduleId = ""; @@ -1966,9 +1992,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } public String getChildDropDown(HttpServletRequest request, String nextPage) throws RaptorRuntimeException { - if(request.getParameter("firstTime") != null){ - return nextPage; - } + if(request.getParameter("firstTime") != null) { return nextPage; } /*ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute( AppConstants.SI_REPORT_RUNTIME); @@ -2033,11 +2057,25 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } + private TreeMap getListOfReportsFromDashBoardJson(String jsonString) throws Exception { + HashMap hashReports = new HashMap(); + ObjectMapper mapper = new ObjectMapper(); + + TypeReference<List<DashboardChildReport>> mapType = new TypeReference<List<DashboardChildReport>>() { + }; + List<DashboardChildReport> reportList = mapper.readValue(jsonString, mapType); + int index = 1; + for (DashboardChildReport childRep : reportList) { + String str = childRep.getHasContent().get("id"); + hashReports.put(index, (str.substring(0).toLowerCase().startsWith("chart") ? "c" : "d") + + str.substring(str.indexOf("#") + 1, str.length())); + index++; + } + return new TreeMap(hashReports); + } + private TreeMap getListOfReportsFromDashBoardHTML(String htmlString) { - //String sourcestring = "<table border=1><tr><td>[Report#123]</td><td>[Report#124]</td></tr><tr><td>[Report#125]</td><td>[Report#126]</td></tr></table>"; String sourcestring = htmlString; - //Pattern re = Pattern.compile("([a-z]+)\\[([a-z]+)([=<>]+)([a-z]+)\\]",Pattern.CASE_INSENSITIVE); - //Pattern re = Pattern.compile("\\[([R][e][p][o][r][t][#])[(*)]\\]"); Pattern re = Pattern.compile("\\[(.*?)\\]"); //\\[(.*?)\\] Matcher m = re.matcher(sourcestring); HashMap hashReports = new HashMap(); @@ -2045,24 +2083,10 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { while (m.find()){ for( int groupIdx = 0; groupIdx < m.groupCount(); groupIdx++ ){ String str = m.group(groupIdx); - //System.out.println(str); hashReports.put(new String(Integer.toString(mIdx+1)), (str.substring(1).toLowerCase().startsWith("chart")?"c":"d") + str.substring(str.indexOf("#")+1, str.length()-1)); } mIdx++; } - // Sorting HashMap based on Keys - /*List mapKeys = new ArrayList(hashReports.keySet()); - List mapValues = new ArrayList(hashReports.values()); - hashReports.clear(); - hashReports = null; - hashReports = new HashMap(); - - TreeSet sortedSet = new TreeSet(mapKeys); - Object[] sortedArray = sortedSet.toArray(); - int size = sortedArray.length; - for (int i=0; i<size; i++) { - hashReports.put(sortedArray[i], mapValues.get(mapKeys.indexOf(sortedArray[i]))); - }*/ return new TreeMap(hashReports); } @@ -2201,8 +2225,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { // "[ReportRuntime.loadLinearReportData] The number of visible columns // does not match the number of data columns"); //TODO: This should be optimized to accept -1 for flat file download - if(maxRows > totalRows) - maxRows = totalRows; + if(maxRows > totalRows) maxRows = totalRows; ArrayList reportDataList = new ArrayList(); for (int r = 0; r < maxRows; r++) { DataRow dr = new DataRow(); @@ -2329,4 +2352,4 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { return ""; } -} // ActionHandler +} // ActionHandler
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java index 30ec7b15..278f6739 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java @@ -49,6 +49,7 @@ import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; import org.onap.portalsdk.analytics.model.runtime.ErrorJSONRuntime; +import org.onap.portalsdk.analytics.model.runtime.ReportJSONRuntime; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.Globals; @@ -132,6 +133,7 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); errorJSONRuntime.setErrormessage(e.toString()); errorJSONRuntime.setStacktrace(getStackTrace(e)); + errorJSONRuntime.setAllowEdit(isAllowEdit(request)); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -146,6 +148,24 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return jsonInString; } // processFatalError + private boolean isAllowEdit(HttpServletRequest request) { + HttpSession session = request.getSession(); + ReportRuntime rr = (ReportRuntime) session.getAttribute(AppConstants.SI_REPORT_RUNTIME); + boolean allowEdit = false; + String userId = AppUtils.getUserID(request); + try { + if( AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request) ) { + allowEdit = true; + } else { + if(rr.getOwnerID().equals(userId)) allowEdit = true; + else allowEdit = false; + } + } catch (RaptorException ex) { + allowEdit = false; + } + return allowEdit; + } + public static String getStackTrace(Throwable aThrowable) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java index 298f2517..8605f208 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java @@ -1161,8 +1161,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setClassifier(classifiers); String dateAttrColId = AppUtils.getRequestNvlValue(request, "timeAttribute"); String timeFormat = AppUtils.getRequestNvlValue(request, "timeFormat"); - if(timeFormat.equals("Default")) - timeFormat = "yyyy-MM-dd HH:mm:ss"; + if(timeFormat.equals("Default")) timeFormat = "yyyy-MM-dd HH:mm:ss"; String forecastingPeriod = AppUtils.getRequestNvlValue(request, "forecastingPeriod"); String[] forecastCols = request.getParameterValues("forecastCol"); @@ -1177,8 +1176,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { dct = (DataColumnType) iter.next(); if(dct.getColId().equals(dateAttrColId)) { dct.setDataMiningCol(AppConstants.DM_DATE_ATTR); - if(timeFormat!=null) - rdef.setForecastingTimeFormat(timeFormat); + if(timeFormat!=null) rdef.setForecastingTimeFormat(timeFormat); break; } } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/Dashboard.xlsx b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/Dashboard.xlsx Binary files differnew file mode 100644 index 00000000..be0601d4 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/Dashboard.xlsx diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DashboardChildReport.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DashboardChildReport.java new file mode 100644 index 00000000..90e4d48d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/DashboardChildReport.java @@ -0,0 +1,88 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portalsdk.analytics.model; + +import java.util.HashMap; + +public class DashboardChildReport { + + private String x; + private String y; + private String cols; + private String rows ; + private HashMap<String, String> hasContent; + public String getX() { + return x; + } + public void setX(String x) { + this.x = x; + } + public String getY() { + return y; + } + public void setY(String y) { + this.y = y; + } + public String getCols() { + return cols; + } + public void setCols(String cols) { + this.cols = cols; + } + public String getRows() { + return rows; + } + public void setRows(String rows) { + this.rows = rows; + } + public HashMap<String, String> getHasContent() { + return hasContent; + } + public void setHasContent(HashMap<String, String> hasContent) { + this.hasContent = hasContent; + } + @Override + public String toString() { + return "DashboardChildReport [x=" + x + ", y=" + y + ", cols=" + cols + ", rows=" + rows + ", hasContent=" + + hasContent + "]"; + } + + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/IdNameSql.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/IdNameSql.java index 8d2cabcc..1ef28a26 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/IdNameSql.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/IdNameSql.java @@ -62,13 +62,25 @@ import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component public class IdNameSql extends IdNameList { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(IdNameSql.class); + private static RemDbInfo remDbInfo; + + @SuppressWarnings("static-access") + @Autowired + public void setRemDbInfo(RemDbInfo remDbInfo) { + this.remDbInfo = remDbInfo; + } + protected int dataSize = -1; protected int dataSizeUsedInPopup = -1; @@ -202,7 +214,6 @@ public class IdNameSql extends IdNameList { String dbType = Globals.getDBType(); if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -242,9 +253,7 @@ 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 +"'"); } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java index 69837d04..8c95d71a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java @@ -77,7 +77,9 @@ import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.CachingUtils; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.SQLCorrector; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.xmlobj.ChartAdditionalOptions; @@ -111,6 +113,8 @@ import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /**<HR/> * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/> @@ -136,10 +140,19 @@ import org.owasp.esapi.ESAPI; * */ +@Component public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportWrapper.class); + protected static RemDbInfo remDbInfo; + + @SuppressWarnings("static-access") + @Autowired + public void setRemDbInfo(RemDbInfo remDbInfo) { + this.remDbInfo = remDbInfo; + } + protected CustomReportType cr = null; protected Vector allColumns = null; @@ -152,7 +165,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { protected String generatedChartSQL = null; - protected String wholeSQL = null; // For display purposes only + protected String wholeSQL = null; + protected String reportID = null; @@ -168,6 +182,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { protected String reportSQLOnlyFirstPart = null; + + public ReportWrapper() { + super(); + } + private ReportWrapper(CustomReportType cr, String reportID, ReportSecurity reportSecurity) { super(); @@ -178,33 +197,24 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { this.reportID = reportID; this.reportSecurity = reportSecurity; - } // ReportWrapper + } public ReportWrapper(ReportWrapper rw) { - this(rw.getCustomReport(), // .cloneCustomReport() + this(rw.getCustomReport(), rw.getReportID(), rw.reportSecurity); this.menuID = rw.getMenuID(); this.menuApproved = rw.isMenuApproved(); this.reportDefType = rw.getReportDefType(); - } // ReportWrapper - + } public ReportWrapper(CustomReportType cr, String reportID, String ownerID, String createID, String createDate, String updateID, String updateDate, String menuID, boolean menuApproved) throws RaptorException { this(cr, reportID, null); if (ownerID == null && !"-1".equals(reportID)) { - // Need to load the report record from the database try { - /* - * DataSet ds = DbUtils - * .executeQuery("SELECT NVL(cr.owner_id, cr.create_id) owner_id, cr.create_id, TO_CHAR(cr.create_date, '" - * + Globals.getOracleTimeFormat() + "') create_date, maint_id, TO_CHAR(cr.maint_date, '" + - * Globals.getOracleTimeFormat() + - * "') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id=" + reportID); - */ String rSql = Globals.getReportWrapperFormat(); rSql = rSql.replace("[Globals.getTimeFormat()]", Globals.getTimeFormat()); @@ -222,7 +232,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { menuApproved = nvl(ds.getString(0, 6)).equals("Y"); } catch (Exception e) { String eMsg = "ReportWrapper.ReportWrapper: Unable to load report record details. Exception: "; - // Log.write(eMsg); logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] " + eMsg), e); throw new RaptorRuntimeException(eMsg); } @@ -236,8 +245,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { reportSecurity = new ReportSecurity(reportID, ownerID, createID, createDate, updateID, updateDate, cr.isPublic()); - } // ReportWrapper - + } public CustomReportType getCustomReport() { return cr; } @@ -379,11 +387,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return cr.getChartHeight() == null ? "500" : cr.getChartHeight(); } - /* - * public boolean isChartMultiSeries() { //String s = cr.getChartMultiSeries(); return return - * (nvl(s).length()>0)? (s.equals("Y")||s.equals("y")||s.equalsIgnoreCase("true")?true:false):true; - * } - */ public boolean displayPieOrderinRunPage() { String s = ""; @@ -866,8 +869,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return cr.isDashboardType() != null ? cr.isDashboardType().booleanValue() : false; } - // public String getCreateId() { return cr.getCreateId(); } - // public Calendar getCreateDate() { return cr.getCreateDate(); } + public String getReportSQL() { return cr.getReportSQL(); } @@ -908,7 +910,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return cr.getDisplayOptions(); } - // Additional Methods + public int getJumpTo() { return cr.getJumpTo() == null ? 1 : cr.getJumpTo(); @@ -998,7 +1000,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { else return "top"; - // return cr.getNavPosition(); + } public void setNavPosition(String value) { @@ -1118,7 +1120,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { getPDFAdditionalOptions().setPDFFooter2(value); } - // End of Additional Methods public String getDataContainerHeight() { return cr.getDataContainerHeight(); @@ -1137,7 +1138,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return cr.getAllowSchedule(); } - /* Multi Group */ + public boolean isMultiGroupColumn() { String multiGroupColumn = getMultiGroupColumn(); @@ -1155,7 +1156,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { private int getColumnGroupLevel(String colId) throws RaptorException { DataColumnType dc = getColumnById(colId); return (dc == null) ? 0 : dc.getLevel(); - } // getColumnGroupLevel + } public int getMaxGroupLevel() { List reportCols = getAllColumns(); @@ -1166,19 +1167,19 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (maxLevel < dc.getLevel()) maxLevel = dc.getLevel(); } - } // for + } return maxLevel; - } // getMaxGroupLevel + } private int getColumnGroupStart(String colId) throws RaptorException { DataColumnType dc = getColumnById(colId); return (dc == null) ? 0 : dc.getStart(); - } // getColumnGroupStart + } private int getColumnGroupColSpan(String colId) throws RaptorException { DataColumnType dc = getColumnById(colId); return (dc == null) ? 0 : dc.getColspan(); - } // getColumnGroupColSpan + } public void setTopDown(String value) { cr.setTopDown(value); @@ -1288,6 +1289,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return cr.getDashboardLayoutHTML(); } + public String getDashboardLayoutJSON() { + return cr.getDashboardLayoutJSON(); + } + public FormFieldList getFormFieldList() { return cr.getFormFieldList(); } @@ -1329,12 +1334,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } public void setDBInfo(String value) { - if (!(cr.getDbInfo() != null && cr.getDbInfo().length() > 0)) cr.setDbInfo(value); } public void setDBType(String value) { - if (!(cr.getDbType() != null && cr.getDbType().length() > 0)) cr.setDbType(value); } @@ -1466,8 +1469,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { reportSecurity.setPublic(value); } - // public void setCreateId(String value) { cr.setCreateId(value); } - // public void setCreateDate(Calendar value) { cr.setCreateDate(value); } public void setReportSQL(String value) { cr.setReportSQL(value); } @@ -1605,11 +1606,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { cr.setChartDrillOptions(chartDrillOptions); } - /**** Report Maps - End ****/ - /** - * ************************************************************************************************* - */ public String getFormHelpText() { String formHelpText = nvl(getComment()); @@ -1618,7 +1615,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { formHelpText = formHelpText.substring(formHelpText.lastIndexOf('|') + 1); return formHelpText; - } // getFormHelpText + } public void setFormHelpText(String formHelpText) { String comment = nvl(getComment()); @@ -1629,7 +1626,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { comment += '|'; setComment(comment + formHelpText); - } // setFormHelpText + } public boolean isRuntimeColSortDisabled() { String comment = nvl(getComment()); @@ -1638,8 +1635,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return false; return "Y".equals(comment.substring(0, comment.indexOf('|'))); - } // isRuntimeColSortDisabled - + } public void setRuntimeColSortDisabled(boolean value) { String comment = nvl(getComment()); @@ -1647,7 +1643,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { comment = comment.substring(comment.indexOf('|') + 1); setComment((value ? "Y" : "N") + "|" + comment); - } // setRuntimeColSortDisabled + } /** * ************************************************************************************************* @@ -1659,7 +1655,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { && (!Globals.getAllowSQLBasedReports()) && (!AppUtils.isAdminUser(request))) throw new org.onap.portalsdk.analytics.error.UserAccessException(reportID, "[" + userID + "] " + AppUtils.getUserName(request), AppConstants.UA_WRITE); - } // verifySQLBasedReportAccess + } /** * ************************************************************************************************* @@ -1668,10 +1664,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { private String getColumnNameById(String colId) throws RaptorException { DataColumnType dc = getColumnById(colId); return (dc == null) ? "NULL" : dc.getColName(); - } // getColumnNameById - - // Checks if drill-down URL points to individual record display (return - // true) or another report (return false) + } private boolean isViewAction(String value) throws RaptorException { try { Vector viewActions = org.onap.portalsdk.analytics.model.DataCache.getDataViewActions(); @@ -1686,21 +1679,13 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } return false; - } // isViewAction + } public String getSelectExpr(DataColumnType dct) { - // String colName = - // dct.isCalculated()?dct.getColName():((nvl(dct.getTableId()).length()>0)?(dct.getTableId()+"."+dct.getColName()):dct.getColName()); return getSelectExpr(dct, dct.getColName() /* colName */); - } // getSelectExpr - - /* - * private String getSelectExpr(DataColumnType dct, String colName) { String colType = - * dct.getColType(); if (colType.equals(AppConstants.CT_CHAR) || ((nvl(dct.getColFormat()).length() - * == 0) && (!colType .equals(AppConstants.CT_DATE)))) return colName; else return "TO_CHAR(" + - * colName + ", '" + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) + "')"; } // - * getSelectExpr - */ + } + + private String getSelectExpr(DataColumnType dct, String colName) { String colType = dct.getColType(); @@ -1714,35 +1699,32 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { else return "TO_CHAR(" + colName + ", '" + nvl(dct.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) + "')"; - } // getSelectExpr + } + - /** - * ************************************************************************************************* - */ public DataSourceType getTableById(String tableId) { for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); if (ds.getTableId().equals(tableId)) return ds; - } // for - + } return null; - } // getTableById + } public DataSourceType getTableByDBName(String tableName) { for (Iterator iter = getDataSourceList().getDataSource().iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); if (ds.getTableName().equals(tableName)) return ds; - } // for + } return null; - } // getTableByDBName + } public DataSourceType getColumnTableById(String colId) { return getTableById(getColumnById(colId).getTableId()); - } // getColumnTableById + } public DataColumnType getColumnById(String colId) { List reportCols = getAllColumns(); @@ -1751,10 +1733,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (dc.getColId().equalsIgnoreCase(colId)) { return dc; } - } // for + } return null; - } // getColumnById + } public DataColumnType getChartLegendColumn() { List reportCols = getAllColumns(); @@ -1762,17 +1744,9 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND)) return dc; - } // for + } return null; - } // getChartLegendColumn - - /* - * public DataColumnType getChartValueColumn() { List reportCols = getAllColumns(); for(Iterator - * iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType) iter.next(); - * if(dc.getChartSeq()>0) return dc; } // for - * - * return null; } // getChartValueColumn - */ + } public List getChartValueColumnsList(int filter, HashMap formValues) { /* * filter; all=0;create without new chart =1; @@ -1785,7 +1759,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); - // if(filter == 2 || filter == 1) { flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { @@ -1803,32 +1776,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { chartValueCols.add(dc); } } - // } else - // chartValueCols.add(dc); - } // for + + } Collections.sort(chartValueCols, new ChartSeqComparator()); return chartValueCols; - } // getChartValueColumnsList - - /* - * public ListModelList<Item> getChartValueColumnsListModelList( int filter, HashMap formValues) { / - * *filter; all=0;create without new chart =1; createNewChart=2 * / List reportCols = - * getAllColumns(); - * - * ArrayList chartValueCols = new ArrayList(); ListModelList<Item> chartValueListModelList = new - * ListModelList<Item>(); int flag = 0; for (Iterator iter = reportCols.iterator(); iter.hasNext();) - * { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); // if(filter == 2 || filter == 1) { - * flag = getDependsOnFormFieldFlag(dc, formValues); - * - * if( (dc.getChartSeq()!=null && dc.getChartSeq()> 0) && flag == 0 ) { - * if(nvl(dc.getChartGroup()).length()<=0) { if( filter == 2 && (dc.isCreateInNewChart()!=null && - * dc.isCreateInNewChart().booleanValue())) { chartValueCols.add(dc); } else if (filter == 1 && - * (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) { - * chartValueCols.add(dc); } else if(filter == 0) chartValueCols.add(dc); } else - * chartValueCols.add(dc); } // } else // chartValueCols.add(dc); chartValueListModelList.add(new - * Item(dc.getColId(), dc.getDisplayName())); } // for Collections.sort(chartValueCols, new - * ChartSeqComparator()); return chartValueListModelList; } // getChartValueColumnsList - */ + } /** Check whether chart has series (Category) columns **/ public boolean hasSeriesColumn() { @@ -1838,14 +1790,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (dc.isChartSeries() != null && dc.isChartSeries().booleanValue()) return true; - } // for + } return false; - } // hasSeriesColumn + } - public List getChartDisplayNamesList(int filter, HashMap formValues) { /* - * filter; all=0;create without new chart =1; - * createNewChart=2 - */ + public List getChartDisplayNamesList(int filter, HashMap formValues) { List reportCols = getAllColumns(); ArrayList chartValueColNames = new ArrayList(); int flag = 0; @@ -1867,24 +1816,19 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (filter == 0) chartValueColNames.add(dc.getDisplayName()); } - // } else - // chartValueColNames.add(dc.getDisplayName()); + } return chartValueColNames; - } // getChartDisplayNamesList + } - public List getChartColumnColorsList(int filter, HashMap formValues) { /* - * filter; all=0;create without new chart =1; - * createNewChart=2 - */ + public List getChartColumnColorsList(int filter, HashMap formValues) { List reportCols = getAllColumns(); ArrayList chartValueColColors = new ArrayList(); int flag = 0; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); - // if(filter == 2 || filter == 1) { flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { @@ -1899,23 +1843,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (filter == 0) chartValueColColors.add(dc.getChartColor()); } - // } else - // chartValueColColors.add(dc.getChartColor()); } return chartValueColColors; - } // getChartColumnColorsList + } - public List getChartValueColumnAxisList(int filter, HashMap formValues) { /* - * filter; all=0;create without new chart - * =1; createNewChart=2 - */ + public List getChartValueColumnAxisList(int filter, HashMap formValues) { List reportCols = getAllColumns(); ArrayList chartValueColAxis = new ArrayList(); int flag = 0; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); - // if(filter == 2 || filter == 1) { flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { @@ -1930,18 +1868,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (filter == 0) chartValueColAxis.add(nvl(dc.getColOnChart(), "0")); } - // } else - // chartValueColAxis.add(nvl(dc.getColOnChart(), "0")); } return chartValueColAxis; - } // getChartColumnAxisList + } + public List getChartValueNewChartList() { ArrayList chartValueNewChartAxis = new ArrayList(); for (Iterator iter = getChartValueColumnsList(2, null).iterator(); iter.hasNext();) chartValueNewChartAxis.add(new Boolean(((DataColumnType) iter.next()).isCreateInNewChart())); return chartValueNewChartAxis; - } // getChartValueNewChartList + } public List getAllChartGroups() { ArrayList chartGroups = new ArrayList(); @@ -1958,7 +1895,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } List l = new ArrayList(groupSet); return l; - } // getAllChartGroups + } public HashMap getAllChartYAxis(ReportParamValues reportParamValues) { String chartYAxis = ""; @@ -1990,7 +1927,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } } return hashMap; - } // getAllChartGroups + } public List getChartGroupColumnAxisList(String chartGroupName, HashMap formValues) { /* * filter; all=0;create without @@ -2004,31 +1941,24 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); - // if(filter == 2 || filter == 1) { flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { if (nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|"))) .equals(chartGroup))) { - // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) - // { - // System.out.println("$$$$$$$DC " + dc.getColId()+ " " + dc.getColOnChart()); chartGroupColAxis.add(dc); } } - // } else - // chartValueColAxis.add(nvl(dc.getColOnChart(), "0")); } Collections.sort(chartGroupColAxis, new ChartSeqComparator()); return chartGroupColAxis; - } // getChartColumnAxisList + } public List getChartGroupValueColumnAxisList(String chartGroupName, HashMap formValues) { List reportCols = getAllColumns(); String index = chartGroupName.substring(chartGroupName.lastIndexOf("|") + 1); String chartGroup = chartGroupName.substring(0, chartGroupName.lastIndexOf("|")); - // System.out.println("$$$$INDEX " + index); ArrayList chartGroupValueColAxis = new ArrayList(); int flag = 0; @@ -2038,21 +1968,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { - // System.out.println(" Chartgroup " + - // dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))); if (nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|"))) .equals(chartGroup))) { - // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) - // { - // System.out.println(" Added Chartgroupname " + chartGroup + " " + dc.getChartGroup() + " " + - // index); chartGroupValueColAxis.add(dc); } } } return chartGroupValueColAxis; - } // getChartColumnAxisList + } public List getChartGroupDisplayNamesList(String chartGroupName, HashMap formValues) { List reportCols = getAllColumns(); @@ -2063,7 +1987,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { flag = 0; DataColumnType dc = (DataColumnType) iter.next(); - // System.out.println("$$$$$CHART " + dc.getChartSeq()+ " " + dc.getChartGroup()+ " " + chartGroup); flag = getDependsOnFormFieldFlag(dc, formValues); if ((dc.getChartSeq() != null && dc.getChartSeq() > 0) && flag == 0) { @@ -2075,7 +1998,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } } return chartGroupValueColNames; - } // getChartDisplayNamesList + } + public List getChartGroupColumnColorsList(String chartGroupName, HashMap formValues) { List reportCols = getAllColumns(); @@ -2091,14 +2015,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (nvl(dc.getChartGroup()).indexOf("|") > 0 && (nvl(dc.getChartGroup().substring(0, dc.getChartGroup().lastIndexOf("|"))) .equals(chartGroup))) { - // if( nvl(dc.getChartGroup().substring(0,dc.getChartGroup().lastIndexOf("|"))).equals(chartGroup)) - // { chartValueColColors.add(dc.getChartColor()); } } } return chartValueColColors; - } // getChartColumnColorsList + } public List getCrossTabRowColumns() { List reportCols = getAllColumns(); @@ -2108,10 +2030,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)) v.add(dc); - } // for + } return v; - } // getCrossTabRowColumns + } public List getCrossTabColColumns() { List reportCols = getAllColumns(); @@ -2121,10 +2043,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_COLUMN)) v.add(dc); - } // for + } return v; - } // getCrossTabColColumns + } public String getCrossTabDisplayTotal(String rowColPos) { DataColumnType dct = getCrossTabValueColumn(); @@ -2142,10 +2064,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { displayTotal = displayRowTotal; else if (displayColTotal.equals(displayRowTotal)) displayTotal = displayColTotal; - } // if + } return displayTotal; - } // getCrossTabDisplayTotal + } public DataColumnType getCrossTabValueColumn() { List reportCols = getAllColumns(); @@ -2153,13 +2075,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (nvl(dc.getCrossTabValue()).equals(AppConstants.CV_VALUE)) return dc; - } // for + } return null; - } // getCrossTabValueColumn + } - public int getCrossTabValueColumnIndex() { // Returns the index counting - // only visible columns + public int getCrossTabValueColumnIndex() { List reportCols = getAllColumns(); int idx = 0; @@ -2169,10 +2090,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { break; if (dc.isVisible()) idx++; - } // for + } return idx; - } // getCrossTabValueColumnIndex + } public ColFilterType getFilterById(String colId, int filterIndex) { DataColumnType dc = getColumnById(colId); @@ -2182,7 +2103,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in getFilterById ", e); return null; } - } // getFilterById + } public boolean needFormInput() { List reportCols = getAllColumns(); @@ -2196,12 +2117,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (nvl(cft.getArgType()).equals(AppConstants.AT_FORM)) return true; - } // for - } // if - } // for + } + } + } return false; - } // needFormInput + } public int getNumSortColumns() { int numSortCols = 0; @@ -2209,10 +2130,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dct = (DataColumnType) iter.next(); if (dct.getOrderBySeq() != null && dct.getOrderBySeq() > 0) numSortCols++; - } // for + } return numSortCols; - } // getNumSortColumns + } public SemaphoreType getSemaphoreById(String semaphoreId) { if (getSemaphoreList() != null && semaphoreId != null) @@ -2220,24 +2141,24 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { SemaphoreType sem = (SemaphoreType) iter.next(); if (sem.getSemaphoreId().equals(semaphoreId)) return sem; - } // for + } return null; - } // getSemaphoreById + } public void deleteSemaphore(SemaphoreType semaphore) { if (getSemaphoreList() != null) { if (getSemaphoreList().getSemaphore() != null) getSemaphoreList().getSemaphore().remove((SemaphoreType) semaphore); } - } // deleteSemaphore + } public void setSemaphore(SemaphoreType sem) { if (getSemaphoreList() != null) { getSemaphoreList().getSemaphore().add(sem); } - } // setSemaphore + } public static FormatType getSemaphoreFormatById(SemaphoreType semaphore, String formatId) { if (semaphore != null) @@ -2246,10 +2167,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { FormatType fmt = (FormatType) iter.next(); if (fmt.getFormatId().equals(formatId)) return fmt; - } // for + } return null; - } // getSemaphoreFormatById + } public FormFieldType getFormFieldById(String fieldId) { if (getFormFieldList() != null && fieldId != null) @@ -2257,30 +2178,25 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { FormFieldType fft = (FormFieldType) iter.next(); if (fft.getFieldId().equals(fieldId)) return fft; - } // for + } return null; - } // getFormFieldById + } public FormFieldType getFormFieldByDisplayValue(String fieldDisplay) { - // fieldDisplay expected to be [fieldName] if (getFormFieldList() != null && fieldDisplay != null) for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) { FormFieldType fft = (FormFieldType) iter.next(); if (fieldDisplay.equals(getFormFieldDisplayName(fft))) return fft; - } // for + } return null; - } // getFormFieldById - + } public String getFormFieldDisplayName(FormFieldType fft) { return "[" + fft.getFieldName() + "]"; - } // getFormFieldDisplayName + } - /** - * ************************************************************************************************* - */ public void resetCache(boolean sqlOnly) { generatedSQL = null; @@ -2288,25 +2204,22 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { allColumns = null; allFilters = null; } - } // resetCache + } public String getOuterJoinType(DataSourceType curTable) { String refDefinition = nvl(curTable.getRefDefinition()); int outerJoinIdx = refDefinition.indexOf(" (+)"); if (outerJoinIdx < 0) - // No outer join return ""; int equalSignIdx = refDefinition.indexOf("="); if (refDefinition.indexOf(curTable.getTableId()) < equalSignIdx) - // Cur. table is on the left side return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_CURRENT : AppConstants.OJ_JOINED; else - // Joined table is on the left side return (outerJoinIdx < equalSignIdx) ? AppConstants.OJ_JOINED : AppConstants.OJ_CURRENT; - } // getOuterJoinType + } public String getFormFieldName(ColFilterType filter) { FormFieldType fft = null; @@ -2316,7 +2229,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return (fft != null) ? fft.getFieldId() : filter.getColId() + "_f" + filter.getFilterSeq(); - } // getFormFieldName + } public String getFormFieldDisplayName(DataColumnType column, ColFilterType filter) { FormFieldType fft = null; @@ -2326,7 +2239,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return (fft != null) ? fft.getFieldName() : column.getDisplayName() + " " + filter.getExpression(); - } // getFormFieldDisplayName + } public Calendar getFormFieldRangeStart(ColFilterType filter) { FormFieldType fft = null; @@ -2334,16 +2247,14 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { fft = getFormFieldByDisplayValue(filter.getArgValue()); return (fft != null) ? fft.getRangeStartDate().toGregorianCalendar() : null; - } // getFormFieldRangeStart + } public Calendar getFormFieldRangeEnd(ColFilterType filter) { FormFieldType fft = null; if (filter.getArgType().equals(AppConstants.AT_FORM)) fft = getFormFieldByDisplayValue(filter.getArgValue()); - - // System.out.println("as " + fft.getRangeEndDate()); return (fft != null) ? fft.getRangeEndDate().toGregorianCalendar() : null; - } // getFormFieldRangeEnd + } public String getFormFieldRangeStartSQL(ColFilterType filter) { FormFieldType fft = null; @@ -2351,16 +2262,14 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { fft = getFormFieldByDisplayValue(filter.getArgValue()); return (fft != null) ? fft.getRangeStartDateSQL() : null; - } // getFormFieldRangeStart + } public String getFormFieldRangeEndSQL(ColFilterType filter) { FormFieldType fft = null; if (filter.getArgType().equals(AppConstants.AT_FORM)) fft = getFormFieldByDisplayValue(filter.getArgValue()); - - // System.out.println("as " + fft.getRangeEndDate()); return (fft != null) ? fft.getRangeEndDateSQL() : null; - } // getFormFieldRangeEnd + } public String getUniqueTableId(String tableName) { String tableIdPrefix = tableName.startsWith("MSA_") ? tableName.substring(4, 6) @@ -2373,11 +2282,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } while (getTableById(tableId) != null); return tableId; - } // getUniqueTableId - - /** - * ************************************************************************************************* - */ + } protected void deleteDataSourceType(String tableId) { List dsList = getDataSourceList().getDataSource(); @@ -2389,10 +2294,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { dst.setRefTableId(null); dst.setRefDefinition(null); } - } // for + } resetCache(false); - } // deleteDataSourceType + } public static void adjustColumnType(DataColumnType dct) { dct.setColType(dct.getDbColType()); @@ -2405,40 +2310,32 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { dct.setColType(AppConstants.CT_NUMBER); else if (dct.getColName().startsWith("DECODE(") || dct.getColName().startsWith("coalesce(")) dct.setColType(AppConstants.CT_CHAR); - } // adjustColumnType - + } public static boolean getColumnNoParseDateFlag(DataColumnType dct) { return (nvls(dct.getComment()).indexOf(AppConstants.CF_NO_PARSE_DATE) >= 0); - } // getColumnNoParseDateFlag + } public static void setColumnNoParseDateFlag(DataColumnType dct, boolean noParseDateFlag) { dct.setComment(noParseDateFlag ? AppConstants.CF_NO_PARSE_DATE : null); - } // setColumnNoParseDateFlag + } - /** - * ************************************************************************************************* - */ public static String getSQLBasedFFTColTableName(String fftColId) { return fftColId.substring(0, fftColId.indexOf('.')); - } // getSQLBasedFFTColTableName + } public static String getSQLBasedFFTColColumnName(String fftColId) { fftColId = (fftColId.indexOf('|') < 0) ? fftColId : fftColId.substring(0, fftColId .indexOf('|')); return fftColId.substring(fftColId.indexOf('.') + 1); - } // getSQLBasedFFTColColumnName - + } public static String getSQLBasedFFTColDisplayFormat(String fftColId) { return (fftColId.indexOf('|') < 0) ? "" : fftColId .substring(fftColId.indexOf('|') + 1); - } // getSQLBasedFFTColDisplayFormat + } - /** - * ************************************************************************************************* - */ public List<DataColumnType> getAllColumns() { if (cr == null) @@ -2450,21 +2347,19 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { List dsList = getDataSourceList().getDataSource(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); - - // allColumns.addAll(ds.getDataColumnList().getDataColumn()); List dcList = ds.getDataColumnList().getDataColumn(); for (Iterator iterC = dcList.iterator(); iterC.hasNext();) { DataColumnType dc = (DataColumnType) iterC.next(); allColumns.add(dc); - } // for - } // for + } + } Collections.sort(allColumns, new OrderSeqComparator()); - } // if + } return allColumns; - } // getAllColumns + } public List getOnlyVisibleColumns() { if (cr == null) @@ -2476,22 +2371,19 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { List dsList = getDataSourceList().getDataSource(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); - - // allColumns.addAll(ds.getDataColumnList().getDataColumn()); List dcList = ds.getDataColumnList().getDataColumn(); for (Iterator iterC = dcList.iterator(); iterC.hasNext();) { DataColumnType dc = (DataColumnType) iterC.next(); if (dc.isVisible()) allVisibleColumns.add(dc); - } // for - } // for + } + } Collections.sort(allVisibleColumns, new OrderSeqComparator()); - } // if + } return allVisibleColumns; - } // getOnlyVisibleColumns - + } public int getVisibleColumnCount() { if (cr == null) throw new NullPointerException("CustomReport not initialized"); @@ -2499,15 +2391,13 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { List dsList = getDataSourceList().getDataSource(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); - - // allColumns.addAll(ds.getDataColumnList().getDataColumn()); List dcList = ds.getDataColumnList().getDataColumn(); for (Iterator iterC = dcList.iterator(); iterC.hasNext();) { DataColumnType dc = (DataColumnType) iterC.next(); if (dc.isVisible()) colCount++; - } // for - } // for + } + } return colCount; } @@ -2516,7 +2406,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (cr == null) throw new NullPointerException("CustomReport not initialized"); - // if(allFilters==null) { allFilters = new Vector(); List reportCols = getAllColumns(); @@ -2530,19 +2419,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ColFilterType cft = (ColFilterType) iterF.next(); allFilters.add(cft); - } // for - } // if - } // for - - // Collections.sort(allFilters, ??); - // } // if - + } + } + } return allFilters; - } // getAllFilters + } private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat) throws RaptorException { return formatValue(value, dc, useDefaultDateFormat, getColumnTableById(dc.getColId()), null); - } // formatValue + } private String formatValue(String value, DataColumnType dc, boolean useDefaultDateFormat, DataSourceType ds, FormFieldType fft) throws RaptorException { @@ -2572,7 +2457,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { + "', '" + (useDefaultDateFormat ? AppConstants.DEFAULT_DATE_FORMAT : nvl(dc - .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT));// +" HH24:MI:SS')"; + .getColFormat(), AppConstants.DEFAULT_DATE_FORMAT)); fmtValue = fmtValue + " HH24"; if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) @@ -2601,22 +2486,18 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } return fmtValue; - } // formatValue + } private String formatListValue(String listValue, DataColumnType dc, boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter) throws RaptorException { return formatListValue("", listValue, dc, useDefaultDateFormat, useOnlyPipeDelimiter, getColumnTableById(dc.getColId()), null); - } // formatListValue + } public String formatListValue(String fieldDisplay, String listValue, DataColumnType dc, boolean useDefaultDateFormat, boolean useOnlyPipeDelimiter, DataSourceType ds, String listBaseSQL) throws RaptorException { StringBuffer fmtValue = new StringBuffer(""); - // if(nvl(listValue,"").trim().length()>0) { - // The below statement is commented so that pipe is taken out from parsing for text area form field - // StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|" - // : ",|\n\r\f"); StringTokenizer st = new StringTokenizer(listValue, useOnlyPipeDelimiter ? "|" : ",\n\r\f"); @@ -2625,7 +2506,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { fmtValue.append(", "); if (dc == null) { - // For SQL-based reports - value always string String value = st.nextToken().trim(); if (value.startsWith("'")) fmtValue.append(value); @@ -2635,7 +2515,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { fmtValue.append(formatValue(st.nextToken().trim(), dc, useDefaultDateFormat, ds, null)); - } // while + } if (fmtValue.length() == 0) { if (nvl(fieldDisplay).length() > 0) { @@ -2649,11 +2529,9 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { fmtValue.insert(0, '('); fmtValue.append(')'); } - /* - * } else { fmtValue = new StringBuffer("()"); } - */ + return fmtValue.toString(); - } // formatListValue + } private String getColumnSelectStr(DataColumnType dc, ReportParamValues paramValues) { String colName = dc.isCalculated() ? dc.getColName() @@ -2679,41 +2557,37 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { paramValue, "NULL")); } } - } // for + } return colName; - } // getColumnSelectStr + } private void addExtraIdSelect(StringBuffer selectExtraIdCl, String drillDownParams, boolean includeSelectExpr) { - // drillDownParams - example value "c_master=[bo1.RECID$]" - drillDownParams = drillDownParams.substring(10, drillDownParams.length() - 1); // i.e. - // "bo1.RECID$" + drillDownParams = drillDownParams.substring(10, drillDownParams.length() - 1); selectExtraIdCl.append(", "); if (includeSelectExpr) { selectExtraIdCl.append(drillDownParams); selectExtraIdCl.append(" "); } // if - selectExtraIdCl.append(drillDownParams.replace('.', '_')); // i.e. - // "bo1_RECID$" - } // addExtraIdSelect + selectExtraIdCl.append(drillDownParams.replace('.', '_')); + } private void addExtraDateSelect(StringBuffer selectExtraDateCl, String drillDownParams, ReportParamValues paramValues, boolean includeSelectExpr) { - // drillDownParams - example value "ff1=[dl1]&fc2=[mo3]" String colId = ""; while (drillDownParams.indexOf('[') >= 0) { int startIdx = drillDownParams.indexOf('['); int endIdx = drillDownParams.indexOf(']'); if (startIdx <= endIdx) { - colId = drillDownParams.substring(startIdx + 1, endIdx); // i.e. + colId = drillDownParams.substring(startIdx + 1, endIdx); } else { drillDownParams = drillDownParams.substring(endIdx + 1); continue; } - // "dl1" + DataColumnType column = getColumnById(colId); if (column != null) @@ -2728,26 +2602,22 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { + getColumnSelectStr(column, paramValues) + ", '" + AppConstants.DEFAULT_DATE_FORMAT + "')"); selectExtraDateCl.append(" "); - } // if - selectExtraDateCl.append(colId + AppConstants.DD_COL_EXTENSION); // i.e. - // "dl1_dde" - } // if + } + selectExtraDateCl.append(colId + AppConstants.DD_COL_EXTENSION); + } drillDownParams = drillDownParams.substring(endIdx + 1); - } // while - } // addExtraDateSelect + } + } + - /* - * public String generateSQL() { return generateSQL(null); } // generateSQL - */ public String generateSQL(String userId, HttpServletRequest request) throws RaptorException { return generateSQL(new ReportParamValues(), userId, request); - } // generateSQL - + } public String generateSQL(ReportParamValues paramValues, String userId, HttpServletRequest request) throws RaptorException { return generateSQL(paramValues, null, AppConstants.SO_ASC, userId, request); - } // generateSQL + } public String generateSQL(ReportParamValues paramValues, String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException { @@ -2757,7 +2627,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return getWholeSQL(); if (paramValues.size() > 0) resetCache(true); - // resetCache(true); + if (generatedSQL == null) { if (getReportDefType().equals(AppConstants.RD_SQL_BASED) || getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN)) { @@ -2776,34 +2646,19 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { overrideSortByAscDesc, userId, request); } - // debugLogger.debug("******************"); - // debugLogger.debug("SQL Before Changing new line \n" + generatedSQL); - // debugLogger.debug("******************"); generatedSQL = replaceNewLine(generatedSQL, "" + '\n', " " + '\n' + " "); - // chart sql should not be null if (nvl(generatedChartSQL).trim().length() > 0) generatedChartSQL = replaceNewLine(generatedChartSQL, "" + '\n', " " + '\n' + " "); - // (generatedSQL, "\n", " \n "); - // debugLogger.debug("******************"); - // debugLogger.debug("SQL After Changing new line \n" + generatedSQL); - // debugLogger.debug("******************"); - // generatedSQL = replaceNewLine(generatedSQL, "SELECT", "SELECT "); - // generatedSQL = replaceNewLine(generatedSQL, "select", "select "); - // debugLogger.debug("SQL After Changing new line \n" + generatedSQL); - // debugLogger.debug("[[[[[[[[[[[[[[[[[["); - // generatedSQL = Utils.replaceInString(generatedSQL, "\n", " "); - // generatedSQL = Utils.replaceInString(generatedSQL, "\t", " "); - } // if + } return generatedSQL; - } // generateSQL + } public String generateSQLSQLBased(ReportParamValues paramValues, String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException { String sql = getReportSQL(); DataSet ds = null; - // debugLogger.debug(" generateSQLSQLBased " + sql); String[] reqParameters = Globals.getRequestParams().split(","); String[] sessionParameters = Globals.getSessionParams().split(","); String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(","); @@ -2811,7 +2666,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String dbType = ""; String dbInfo = getDBInfo(); int fieldCount = 0; - // For Daytona removing all formfields which has null param value Pattern re1 = null; Matcher matcher = null; int index = 0; @@ -2819,8 +2673,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { int posAnd = 0; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = - new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -2830,9 +2682,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sql = sql + " "; sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql) .replaceAll(" SELECT "); - // sql = - // Pattern.compile("(^[\r\n]*|([\\s]))[Ff][Rr][Oo][Mm]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" - // FROM "); sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql) .replaceAll(" WHERE "); sql = Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Nn]([\r\n]*|[\\s]*)", Pattern.DOTALL).matcher(sql) @@ -2856,34 +2705,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else { fieldCount++; if (fieldCount == 1) { - // sql = sql + " "; - // sql = - // Pattern.compile("(^[\r\n]*|([\\s]))[Ss][Ee][Ll][Ee][Cc][Tt]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" - // SELECT "); - // sql = - // Pattern.compile("(^[\r\n]*|([\\s]))[Ww][Hh][Ee][Rr][Ee]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" - // WHERE "); - // sql = - // Pattern.compile("(^[\r\n]*|([\\s]))[Aa][Nn][Dd]([\r\n]*|[\\s]*)",Pattern.DOTALL).matcher(sql).replaceAll(" - // AND "); } - // sql = getReportSQL(); while (sql.indexOf(fieldDisplay) > 0) { - /* - * sql = Utils.replaceInString(sql, "SELECT ", "select "); sql = - * Utils.replaceInString(sql, "WHERE", "where"); sql = Utils.replaceInString(sql, - * " AND ", " and "); - */ re1 = Pattern.compile( "(^[\r\n]|[\\s])AND(.*?[^\r\n]*)" + "\\[" + fft.getFieldName() + "\\](.*?)\\s", Pattern.DOTALL); - // re1 = Pattern.compile("(^[\r\n]|[\\s])AND(.*?[^\r\n]*)"+ "\\["+fft.getFieldName()+ - // "\\]", Pattern.DOTALL); - /* - * posFormField = sql.indexOf(fieldDisplay); posAnd = sql.lastIndexOf("and", - * posFormField); if(posAnd < 0) posAnd = 0; else if (posAnd > 2) posAnd = posAnd - 2; - * matcher = re1.matcher(sql); - */ posFormField = sql.indexOf(fieldDisplay); int posSelectField = sql.lastIndexOf("SELECT ", posFormField); int andField = 0; @@ -2902,7 +2728,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { matcher = re1.matcher(sql); if (posAnd > 0 && matcher.find(posAnd - 1)) { - // sql = Utils.replaceInString(sql, matcher.group(), " "); + matcher = re1.matcher(sql); index = sql != null ? sql.lastIndexOf("[" + fft.getFieldName() + "]") : -1; @@ -2915,7 +2741,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } } else { - // sql = sql.replace re1 = Pattern.compile( "(^[\r\n]|[\\s])WHERE(.*?[^\r\n]*)\\[" + fft.getFieldName() + "\\](.*?)\\s", Pattern.DOTALL); @@ -2927,13 +2752,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (index >= 0 && matcher.find(index - 30)) { sql = sql.replace(matcher.group(), " WHERE 1=1 "); } - // sql = Utils.replaceInString(sql, matcher.group(), " where 1=1 "); - } /* - * else { replaceValue = formatListValue("", Utils - * .oracleSafe(nvl(paramValues.getParamValue(fieldId))), null, false, true, - * null, paramValues.getParamBaseSQL(fieldId)); sql = - * Utils.replaceInString(sql, fieldDisplay, replaceValue); } - */ + } } else { sql = Utils.replaceInString(sql, fieldDisplay, replaceValue); } @@ -2942,26 +2761,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } } - // sql = Utils.replaceInString(sql, " select ", " SELECT "); - // sql = Utils.replaceInString(sql, " where ", " WHERE "); - // sql = Utils.replaceInString(sql, " and ", " AND "); - } else { String paramValue = ""; if (paramValues.isParameterTextAreaValueAndModified(fieldId)) { String value = ""; value = nvl(paramValues .getParamValue(fieldId)); - // value = Utils.oracleSafe(nvl(value)); - // if (!(dbType.equals("DAYTONA") && sql.trim().toUpperCase().startsWith("SELECT"))) { - // value = "('" + Utils.replaceInString(value, ",", "'|'") + "')"; - // value = Utils.replaceInString(value, "|", ","); - // paramValue = XSSFilter.filterRequestOnlyScript(value); - // } else if (nvl(value.trim()).length()>0) { - // value = "('" + Utils.replaceInString(value, ",", "'|'") + "')"; - // value = Utils.replaceInString(value, "|", ","); - // paramValue = XSSFilter.filterRequestOnlyScript(value); - // } paramValue = value; } else paramValue = Utils.oracleSafe(nvl(paramValues @@ -2978,15 +2783,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (ds.getRowCount() > 0) paramValue = ds.getString(0, 0); } - // debugLogger.debug("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)))) { - // System.out.println("paramValues.getParamValue(fieldId_Hr) Inside if " + - // fft.getValidationType() + " " + fieldDisplay); if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue) @@ -2996,11 +2797,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { .getParamValue(fieldId + "_Hr")))) : "")); } else if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { - /* - * System.out.println("paramValues.getParamValue(fieldId_Hr)" + paramValues - * .getParamValue(fieldId+"_Hr") + " " + paramValues .getParamValue(fieldId+"_Min")) - * ; - */ sql = Utils.replaceInString(sql, fieldDisplay, nvl( + sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue) + ((nvl(paramValues .getParamValue(fieldId + "_Hr")).length() > 0) @@ -3061,7 +2858,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { paramValue, "NULL")); } catch (NumberFormatException ex) { - if (/* dbType.equals("DAYTONA") && */ sql.trim().toUpperCase() + if (sql.trim().toUpperCase() .startsWith("SELECT")) { sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue, "NULL")); @@ -3070,10 +2867,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { "Expected number, Given String for the form field \"" + fieldDisplay + "\""); } - /* - * sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue, - * "NULL")); - */ + } else sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue, "NULL")); @@ -3124,41 +2918,20 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (fft.isGroupFormField() != null && fft.isGroupFormField().booleanValue()) { sql = Pattern.compile("[[\\s*][,]]\\[" + fft.getFieldName() + "\\](.*?)[,]", Pattern.MULTILINE).matcher(sql).replaceAll(" "); - // sql = - // Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\][\\s]",Pattern.MULTILINE).matcher(sql).replaceAll(" - // "); sql = Pattern .compile("(,.+?)[\\s*]\\[" + fft.getFieldName() + "\\][\\s]", Pattern.MULTILINE) .matcher(sql).replaceAll(" "); - // sql = - // Pattern.compile("(?:,?)[\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll(""); - // sql = - // Pattern.compile("[,][\\s*]\\["+fft.getFieldName()+"\\]",Pattern.MULTILINE).matcher(sql).replaceAll(" - // "); - // sql = Pattern.compile( - // "\\["+fft.getFieldName()+"\\](.*?[^\r\n]*)[,]",Pattern.DOTALL).matcher(sql).replaceAll(""); - - // sql = - // Pattern.compile("[,]|(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s",Pattern.DOTALL).matcher(sql).replaceAll(""); - // sql = - // Pattern.compile("(.*?[^\r\n]*)"+fieldDisplay+"(.*?)\\s|[,]",Pattern.DOTALL).matcher(sql).replaceAll(""); - /* - * sql = Utils.replaceInString(sql, "," + fieldDisplay , nvl( paramValue, "")); sql = - * Utils.replaceInString(sql, fieldDisplay + "," , nvl( paramValue, "")); - */ } else { - // debugLogger.debug("ParamValue |" + paramValue + "| Sql |" + sql + "| Multi Value |" + - // paramValues.isParameterMultiValue(fieldId)); + } else { sql = Utils.replaceInString(sql, "'" + fieldDisplay + "'", nvl( paramValue, "NULL")); sql = Utils.replaceInString(sql, fieldDisplay, nvl( paramValue, "NULL")); - // debugLogger.debug("SQLSQLBASED AFTER^^^^^^^^^ " + sql); } } - } // else - } // if BLANK - } // for + } + } + } if (request != null) { for (int i = 0; i < reqParameters.length; i++) { if (!reqParameters[i].startsWith("ff")) { @@ -3180,27 +2953,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } if (session != null) { for (int i = 0; i < sessionParameters.length; i++) { - // if(!sessionParameters[i].startsWith("ff")) - // paramValue = Utils.replaceInString(paramValue, "[" + sessionParameters[i].toUpperCase()+"]", - // (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - // else { - // debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + - // (String)session.getAttribute(sessionParameters[i])); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]", (String) session.getAttribute(sessionParameters[i])); - // } + } } } else { - // debugLogger.debug("BEFORE LOGGED USERID REPLACE " + sql); - // sql = Utils.replaceInString(sql, "'[logged_userId]'", "'"+userId+"'"); - // debugLogger.debug("Replacing string 2 " + sql); sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId); sql = Utils.replaceInString(sql, "[USERID]", userId); sql = Utils.replaceInString(sql, "[USER_ID]", userId); - // debugLogger.debug("AFTER LOGGED USERID REPLACE " + sql); - // Added for Simon's GM Project where they need to get page_id in their query - // debugLogger.debug("SQLSQLBASED no formfields " + sql); if (request != null) { for (int i = 0; i < reqParameters.length; i++) { sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]", ESAPI.encoder() @@ -3209,23 +2970,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } if (session != null) { for (int i = 0; i < sessionParameters.length; i++) { - // debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + - // (String)session.getAttribute(sessionParameters[i])); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]", (String) session.getAttribute(sessionParameters[i])); } } } - // if it is not multiple select and ParamValue is empty this is the place it can be replaced. sql = Utils.replaceInString(sql, "[LOGGED_USERID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId)); sql = Utils.replaceInString(sql, "[USERID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId)); sql = Utils.replaceInString(sql, "[USER_ID]", ESAPI.encoder().encodeForSQL(SecurityCodecUtil.getCodec(), userId)); - // debugLogger.debug("SQLSQLBASED no formfields after" + sql); - // debugLogger.debug("Replacing String 2 "+ sql); - // debugLogger.debug("Replaced String " + sql); int closeBracketPos = 0; if (nvl(overrideSortByColId).length() > 0) { @@ -3252,15 +3007,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { break; braketCount--; } - } // for + } sql = sql.substring(0, idxOrderBy) + " ORDER BY " + overrideSortByColId + " " + overrideSortByAscDesc + sql.substring(idxOrderByClauseEnd); - } // else - } // if + } + } sql = Pattern.compile("([\n][\\s]*)", Pattern.DOTALL).matcher(sql).replaceAll(" "); return sql; - } // generateSQLSQLBased + } public String generateSQLVisual(ReportParamValues paramValues, String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException { @@ -3278,7 +3033,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { int whereClCarryoverBrackets = 0; int havingClCarryoverBrackets = 0; - // Identifying FROM clause tables and WHERE clause joins List dsList = getDataSourceList().getDataSource(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); @@ -3293,8 +3047,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (whereCl.length() > 0) whereCl.append(" AND "); whereCl.append(ds.getRefDefinition()); - } // if - // Add the condition. + } TableSource tableSource = null; String dBInfo = this.cr.getDbInfo(); Vector userRoles = AppUtils.getUserRoles(request); @@ -3307,8 +3060,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { whereCl.append(Utils.replaceInString(Utils.replaceInString(tableSource .getFilterSql(), "[" + ds.getTableName() + "]", ds.getTableId()), "[USER_ID]", userId)); - } // if - } // for + } + } List reportCols = getAllColumns(); @@ -3318,46 +3071,33 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (dc.isGroupBreak()) { isGroupStmt = true; break; - } // if - } // for + } + } + - // Identifying SELECT and GROUP BY clause fields and WHERE and HAVING - // clause filters - // Collections.sort(reportCols, new OrderSeqComparator()); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); String colName = getColumnSelectStr(dc, paramValues); - // SELECT clause fields - // TODO: Uncomment if it's not working -- if (dc.isVisible()) { if (selectCl.length() > 0) selectCl.append(", "); selectCl.append(getSelectExpr(dc, colName)); selectCl.append(" "); selectCl.append(dc.getColId()); - // TODO } // if - - // Checking for extra fields necessary for drill-down if (nvl(dc.getDrillDownURL()).length() > 0) if (isViewAction(dc.getDrillDownURL())) addExtraIdSelect(selectExtraIdCl, nvl(dc.getDrillDownParams()), true); else addExtraDateSelect(selectExtraDateCl, nvl(dc.getDrillDownParams()), paramValues, true); - - // GROUP BY clause fields if (dc.isGroupBreak()) { if (groupByCl.length() > 0) groupByCl.append(", "); groupByCl.append(colName); - } // if - - // WHERE/HAVING clause fields - // boolean isHavingCl = isGroupStmt && dc.isVisible() && (!dc.isGroupBreak()); + } boolean isHavingCl = isGroupStmt && (!dc.isGroupBreak()); StringBuffer filterCl = isHavingCl ? havingCl : whereCl; - // StringBuffer filterCl = - // isGroupStmt?(dc.isVisible()?(dc.isGroupBreak()?whereCl:havingCl):whereCl):whereCl; + if (dc.getColFilterList() != null) { int fNo = 0; List fList = dc.getColFilterList().getColFilter(); @@ -3397,7 +3137,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { FormFieldType fft = getFormFieldByDisplayValue(cf.getArgValue()); if (fft == null) - // If not FormField => applying default value fieldValue = nvl(fieldValue, Utils .oracleSafe(cf.getArgValue())); else @@ -3405,7 +3144,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { FormField.FFT_CHECK_BOX) || fft.getFieldType().equals(FormField.FFT_LIST_MULTI); if (fft != null) { - // Added for TimeStamp validation String fieldId = fft.getFieldId(); if (fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) @@ -3430,11 +3168,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } } } - - // End if (nvl(fieldValue).length() == 0) - // Does not append filter with missing form - // field argument applyFilter = false; else if (isMultiValue || "IN".equals(nvl(cf.getExpression())) || "NOT IN".equals(nvl(cf.getExpression()))) @@ -3461,7 +3195,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { .length()) if (nvl(cf.getOpenBrackets()).length() > nvl(cf.getCloseBrackets()) .length()) { - // Carry over opening brackets if (isHavingCl) havingClCarryoverBrackets += (nvl(cf.getOpenBrackets()) .length() - nvl(cf.getCloseBrackets()).length()); @@ -3476,7 +3209,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl( cf.getCloseBrackets()).length()); } else { - // Adding closing brackets + if (filterCl.length() > 0) { for (int b = 0; b < nvl(cf.getCloseBrackets()).length() - nvl(cf.getOpenBrackets()).length(); b++) @@ -3488,13 +3221,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { else whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl( cf.getCloseBrackets()).length()); - } // if - } // else - } // for - } // if - } // for + } + } + } + } + } - // Identifying ORDER BY clause fields DataColumnType overrideSortByCol = null; if (overrideSortByColId != null) overrideSortByCol = getColumnById(overrideSortByColId); @@ -3504,16 +3236,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { orderByCl.append(" "); orderByCl.append(nvl(overrideSortByAscDesc, AppConstants.SO_ASC)); } else if (getReportType().equals(AppConstants.RT_CROSSTAB)) { - /* - * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType) - * iter.next(); - * - * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals( - * AppConstants.CV_COLUMN)) { if(orderByCl.length()>0) orderByCl.append(", "); - * orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" "); - * if(dc.getColType().equals(AppConstants.CT_DATE)) orderByCl.append(AppConstants.SO_DESC); else - * orderByCl.append(AppConstants.SO_ASC); } // if } // for - */ + } else { Collections.sort(reportCols, new OrderBySeqComparator()); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -3525,21 +3248,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" "); orderByCl.append(dc.getOrderByAscDesc()); - } // if - } // for + } + } Collections.sort(reportCols, new OrderSeqComparator()); - } // else + } - // Adding up the actual statement StringBuffer sql = new StringBuffer(); - // sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ "); sql.append(Globals.getGenerateSqlVisualSelect()); - // sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString()); sql.append((selectCl.length() == 0) ? Globals.getGenerateSqlVisualCount() : selectCl.toString()); if (groupByCl.length() == 0) sql.append(selectExtraIdCl.toString()); sql.append(selectExtraDateCl.toString()); - // sql.append(" FROM "); sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM " + fromCl.toString()); if (whereCl.length() > 0) { if (whereClBracketCount > 0) { @@ -3548,11 +3267,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (whereClBracketCount < 0) { for (int b = 0; b < Math.abs(whereClBracketCount); b++) whereCl.insert(0, '('); - } // else + } sql.append(" WHERE "); sql.append(whereCl.toString()); - } // if + } if (groupByCl.length() > 0) { sql.append(" GROUP BY "); sql.append(groupByCl.toString()); @@ -3564,7 +3283,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (havingClBracketCount < 0) { for (int b = 0; b < Math.abs(havingClBracketCount); b++) havingCl.insert(0, '('); - } // else + } sql.append(" HAVING "); sql.append(havingCl.toString()); @@ -3574,10 +3293,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sql.append(" ORDER BY "); sql.append(orderByCl.toString()); } - // String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId); - // return sqlStr; return sql.toString(); - } // generateSQLVisual + } public String generateSQLCrossTabVisual(ReportParamValues paramValues, String overrideSortByColId, String overrideSortByAscDesc, String userId, HttpServletRequest request) throws RaptorException { @@ -3595,7 +3312,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { int whereClCarryoverBrackets = 0; int havingClCarryoverBrackets = 0; - // Identifying FROM clause tables and WHERE clause joins List dsList = getDataSourceList().getDataSource(); for (Iterator iter = dsList.iterator(); iter.hasNext();) { DataSourceType ds = (DataSourceType) iter.next(); @@ -3610,8 +3326,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (whereCl.length() > 0) whereCl.append(" AND "); whereCl.append(ds.getRefDefinition()); - } // if - // Add the condition. + } TableSource tableSource = null; String dBInfo = this.cr.getDbInfo(); Vector userRoles = AppUtils.getUserRoles(request); @@ -3624,8 +3339,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { whereCl.append(Utils.replaceInString(Utils.replaceInString(tableSource .getFilterSql(), "[" + ds.getTableName() + "]", ds.getTableId()), "[USER_ID]", userId)); - } // if - } // for + } + } List reportCols = getAllColumns(); @@ -3635,26 +3350,23 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (dc.isGroupBreak()) { isGroupStmt = true; break; - } // if - } // for + } + } - // Identifying SELECT and GROUP BY clause fields and WHERE and HAVING - // clause filters - // Collections.sort(reportCols, new OrderSeqComparator()); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); String colName = getColumnSelectStr(dc, paramValues); - // SELECT clause fields + if (dc.isVisible()) { if (selectCl.length() > 0) selectCl.append(", "); selectCl.append(getSelectExpr(dc, colName)); selectCl.append(" "); selectCl.append(dc.getColId()); - } // if + } + - // Checking for extra fields necessary for drill-down if (nvl(dc.getDrillDownURL()).length() > 0) if (isViewAction(dc.getDrillDownURL())) addExtraIdSelect(selectExtraIdCl, nvl(dc.getDrillDownParams()), true); @@ -3662,17 +3374,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { addExtraDateSelect(selectExtraDateCl, nvl(dc.getDrillDownParams()), paramValues, true); - // GROUP BY clause fields if (dc.isGroupBreak()) { if (groupByCl.length() > 0) groupByCl.append(", "); groupByCl.append(colName); - } // if - - // WHERE/HAVING clause fields + } boolean isHavingCl = isGroupStmt && dc.isVisible() && (!dc.isGroupBreak()); - // boolean isHavingCl = isGroupStmt && (!dc.isGroupBreak()); - // StringBuffer filterCl = isHavingCl ? havingCl : whereCl; StringBuffer filterCl = isGroupStmt ? (dc.isVisible() ? (dc.isGroupBreak() ? whereCl : havingCl) : whereCl) : whereCl; if (dc.getColFilterList() != null) { @@ -3714,7 +3421,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { FormFieldType fft = getFormFieldByDisplayValue(cf.getArgValue()); if (fft == null) - // If not FormField => applying default value fieldValue = nvl(fieldValue, Utils .oracleSafe(cf.getArgValue())); else @@ -3723,8 +3429,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { || fft.getFieldType().equals(FormField.FFT_LIST_MULTI); if (nvl(fieldValue).length() == 0) - // Does not append filter with missing form - // field argument applyFilter = false; else if (isMultiValue || "IN".equals(nvl(cf.getExpression())) || "NOT IN".equals(nvl(cf.getExpression()))) @@ -3732,7 +3436,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { usePipeDelimiterOnly)); else curFilter.append(formatValue(fieldValue, dc, true)); - } // else + } curFilter.append(nvl(cf.getCloseBrackets())); if (applyFilter) { @@ -3751,7 +3455,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { .length()) if (nvl(cf.getOpenBrackets()).length() > nvl(cf.getCloseBrackets()) .length()) { - // Carry over opening brackets if (isHavingCl) havingClCarryoverBrackets += (nvl(cf.getOpenBrackets()) .length() - nvl(cf.getCloseBrackets()).length()); @@ -3766,7 +3469,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl( cf.getCloseBrackets()).length()); } else { - // Adding closing brackets if (filterCl.length() > 0) { for (int b = 0; b < nvl(cf.getCloseBrackets()).length() - nvl(cf.getOpenBrackets()).length(); b++) @@ -3778,13 +3480,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { else whereClBracketCount += (nvl(cf.getOpenBrackets()).length() - nvl( cf.getCloseBrackets()).length()); - } // if - } // else - } // for - } // if - } // for + } + } + } + } + } - // Identifying ORDER BY clause fields DataColumnType overrideSortByCol = null; if (overrideSortByColId != null) overrideSortByCol = getColumnById(overrideSortByColId); @@ -3794,16 +3495,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { orderByCl.append(" "); orderByCl.append(nvl(overrideSortByAscDesc, AppConstants.SO_ASC)); } else if (getReportType().equals(AppConstants.RT_CROSSTAB)) { - /* - * for(Iterator iter=reportCols.iterator(); iter.hasNext(); ) { DataColumnType dc = (DataColumnType) - * iter.next(); - * - * if(nvl(dc.getCrossTabValue()).equals(AppConstants.CV_ROW)||nvl(dc.getCrossTabValue()).equals( - * AppConstants.CV_COLUMN)) { if(orderByCl.length()>0) orderByCl.append(", "); - * orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" "); - * if(dc.getColType().equals(AppConstants.CT_DATE)) orderByCl.append(AppConstants.SO_DESC); else - * orderByCl.append(AppConstants.SO_ASC); } // if } // for - */ } else { Collections.sort(reportCols, new OrderBySeqComparator()); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -3815,21 +3506,18 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { orderByCl.append(getColumnSelectStr(dc, paramValues)); orderByCl.append(" "); orderByCl.append(dc.getOrderByAscDesc()); - } // if - } // for + } + } Collections.sort(reportCols, new OrderSeqComparator()); - } // else + } + - // Adding up the actual statement StringBuffer sql = new StringBuffer(); - // sql.append("SELECT "); // Need to add PK for /*+ FIRST_ROWS */ "); sql.append(Globals.getGenerateSqlVisualSelect()); - // sql.append((selectCl.length() == 0) ? "COUNT(*) cnt" : selectCl.toString()); sql.append((selectCl.length() == 0) ? Globals.getGenerateSqlVisualCount() : selectCl.toString()); if (groupByCl.length() == 0) sql.append(selectExtraIdCl.toString()); sql.append(selectExtraDateCl.toString()); - // sql.append(" FROM "); sql.append((fromCl.length() == 0) ? Globals.getGenerateSqlVisualDual() : "FROM " + fromCl.toString()); if (whereCl.length() > 0) { if (whereClBracketCount > 0) { @@ -3838,11 +3526,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (whereClBracketCount < 0) { for (int b = 0; b < Math.abs(whereClBracketCount); b++) whereCl.insert(0, '('); - } // else + } sql.append(" WHERE "); sql.append(whereCl.toString()); - } // if + } if (groupByCl.length() > 0) { sql.append(" GROUP BY "); sql.append(groupByCl.toString()); @@ -3854,8 +3542,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } else if (havingClBracketCount < 0) { for (int b = 0; b < Math.abs(havingClBracketCount); b++) havingCl.insert(0, '('); - } // else - + } sql.append(" HAVING "); sql.append(havingCl.toString()); } @@ -3867,10 +3554,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, "Created SQL statement: {}", sql); - // String sqlStr = Utils.replaceInString(sql.toString(), "[LOGGED_USERID]", userId); - // return sqlStr; return sql.toString(); - } // generateSQLCrossTabVisual + } public String generatePagedSQL(int pageNo, String userId, HttpServletRequest request, boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException { @@ -3879,17 +3564,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { counter = 1; return generateSubsetSQL(pageNo * getPageSize() + counter, ((pageNo + 1) * getPageSize()) + ((pageNo == 0) ? 1 : 0), userId, request, getColumnNamesFromReportSQL, paramValues); - } // generatePagedSQL + } public String generateSubsetSQL(int startRow, int endRow, String userId, HttpServletRequest request, boolean getColumnNamesFromReportSQL, ReportParamValues paramValues) throws RaptorException { - // debugLogger.debug(" ******** End Row ********* " + endRow); String dbInfo = getDBInfo(); String dbType = ""; + String partSql = ""; + String reportSQL = getWholeSQL(); + if (!CachingUtils.isReportSqlExists(request.getSession().getId()+reportSQL)) { if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = - new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -3897,7 +3582,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } List reportCols = getAllColumns(); String wholeSQL_OrderBy = getWholeSQL(); - String reportSQL = getWholeSQL(); reportSQL = reportSQL.replace(";", ""); setWholeSQL(reportSQL); if (nvl(reportSQL).length() > 0) @@ -3907,8 +3591,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (nvl(reportSQL).toUpperCase().indexOf("GROUP BY ") < 0) if (getDataSourceList().getDataSource().size() > 0) { - DataSourceType dst = (DataSourceType) getDataSourceList().getDataSource() - .get(0); + DataSourceType dst = (DataSourceType) getDataSourceList().getDataSource().get(0); String tId = dst.getTableId(); String tPK = dst.getTablePK(); if (nvl(tPK).length() > 0) { @@ -3920,23 +3603,20 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sortBy.append(tId); sortBy.append("."); sortBy.append(st.nextToken()); - } // while } - } // if + } + } if (nvl(reportSQL).trim().toUpperCase().startsWith("SELECT")) { - // if (!(dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT"))) - // reportSQL += " ORDER BY " + ((sortBy == null) ? "1" : sortBy.toString()); + } } StringBuffer colNames = new StringBuffer(); StringBuffer colExtraIdNames = new StringBuffer(); StringBuffer colExtraDateNames = new StringBuffer(); -// if (getDBType() != null && getDBType().equals(AppConstants.ORACLE)) { -// colNames.append("rownum rnum"); -// } if (getColumnNamesFromReportSQL) { - DataSet ds = ConnectionUtils.getDataSet(reportSQL, dbInfo); + String getColumnDef = "SELECT * FROM ( "+reportSQL+ ") derivedtable WHERE 1 > 2 "; + DataSet ds = ConnectionUtils.getDataSet(getColumnDef, dbInfo); List reportCols1 = getAllColumns(); reportCols = new Vector(); outer: for (Iterator iter = reportCols1.iterator(); iter.hasNext();) { @@ -3972,73 +3652,44 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); - // TODO: commented if (dc.isVisible()) { if (colNames.length() > 0) colNames.append(", "); colNames.append(dc.getColId()); - // TODO uncomment if it's not working} // if - - // Checking for extra fields necessary for drill-down if (nvl(dc.getDrillDownURL()).length() > 0) if (isViewAction(dc.getDrillDownURL())) addExtraIdSelect(colExtraIdNames, nvl(dc.getDrillDownParams()), false); else - addExtraDateSelect(colExtraDateNames, nvl(dc.getDrillDownParams()), null, - false); - } // for + addExtraDateSelect(colExtraDateNames, nvl(dc.getDrillDownParams()), null, false); + } if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0) colNames.append(colExtraIdNames.toString()); - // commented to avoid coldId_dde - // colNames.append(colExtraDateNames.toString()); - - /* - * if(pageNo==0) if(reportSQL.toUpperCase().indexOf(" WHERE ")<0) - * if(reportSQL.toUpperCase().indexOf(" GROUP BY ")<0) reportSQL = reportSQL.substring(0, - * reportSQL.toUpperCase().indexOf(" ORDER BY "))+" WHERE ROWNUM <= - * "+getPageSize()+reportSQL.substring(reportSQL.toUpperCase().indexOf(" ORDER BY - * ")); else reportSQL = "SELECT "+colNames.toString()+" FROM (SELECT ROWNUM rnum, - * "+colNames.toString()+" FROM ("+reportSQL+") x) y WHERE rnum <= "+getPageSize()+" ORDER BY rnum"; - * else reportSQL = reportSQL.substring(0, reportSQL.toUpperCase().indexOf(" WHERE "))+" WHERE - * ROWNUM <= "+getPageSize()+" AND "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" WHERE - * ")+7); else reportSQL = "SELECT "+colNames.toString()+" FROM (SELECT ROWNUM rnum, - * "+colNames.toString()+" FROM ("+reportSQL+") x) y WHERE rnum >= "+(pageNo*getPageSize()+1)+" AND - * rnum <= "+((pageNo+1)*getPageSize())+" ORDER BY rnum"; - */ + if ("DAYTONA".equals(dbType) && reportSQL.trim().toUpperCase().startsWith("SELECT")) { if (endRow == -1) - endRow = (getMaxRowsInExcelDownload() > 0) ? getMaxRowsInExcelDownload() : Globals.getDownloadLimit(); + endRow = (getMaxRowsInExcelDownload() > 0) ? getMaxRowsInExcelDownload() + : Globals.getDownloadLimit(); reportSQL = reportSQL + " LIMIT TO " + (startRow == 0 ? startRow + 1 : startRow) + "->" + endRow; return reportSQL; } else if ("DAYTONA".equals(dbType)) { return reportSQL; } - // reportSQL = "SELECT " + colNames.toString() + " FROM (SELECT ROWNUM rnum, " - // + colNames.toString() + " FROM (" + reportSQL + ") x "; String rSQL = Globals.getGenerateSubsetSql(); rSQL = rSQL.replace("[colNames.toString()]", colNames.toString()); rSQL = rSQL.replace("[reportSQL]", reportSQL); reportSQL = rSQL; - // added rownum for total report where row header need to be shown - // reportSQLOnlyFirstPart = "SELECT rnum," + colNames.toString() + " FROM (SELECT ROWNUM rnum, " - // + colNames.toString() + " FROM (" ; reportSQLOnlyFirstPart = Globals.getReportSqlOnlyFirstPart(); reportSQLOnlyFirstPart = reportSQLOnlyFirstPart.replace("[colNames.toString()]", colNames.toString()); reportSQLWithRowNum = reportSQL; - /* - * if( endRow != -1) reportSQL += " WHERE ROWNUM <= " + endRow; reportSQL += " ) y WHERE rnum >= " + - * startRow + " ORDER BY rnum"; return reportSQL; - */ String parta = Globals.getReportSqlOnlySecondPartA(); String partb = Globals.getReportSqlOnlySecondPartB(); - String partSql = ""; if (!AppUtils.isNotEmpty(getDBType())) { setDBType(Globals.getDBType()); } @@ -4057,50 +3708,41 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { partSql += " " + orderbyclause + " "; } + CachingUtils.putPageSql(request.getSession().getId()+getWholeSQL(), partSql); + CachingUtils.putReportSql(request.getSession().getId()+getWholeSQL(), reportSQL); + }else { + if (!AppUtils.isNotEmpty(getDBType())) { + setDBType(Globals.getDBType()); + } + } + if(startRow >= 0 && CachingUtils.isReportSqlExists(request.getSession().getId()+getWholeSQL()) ) { + partSql = CachingUtils.getPageSql(request.getSession().getId()+getWholeSQL()); + reportSQL = CachingUtils.getReportSql(request.getSession().getId()+getWholeSQL()); + } + if (getDBType().equals(AppConstants.MYSQL)) { partSql = partSql + " LIMIT " + String.valueOf(startRow) + " , " + String.valueOf(endRow); } else if (getDBType().equals(AppConstants.ORACLE)) { - reportSQL = reportSQL.replace(" AS ", " "); partSql = "where rnum >= " + String.valueOf(startRow) + " and rnum <= " - + (Integer.parseInt(String.valueOf(startRow)) + Integer.parseInt(String.valueOf(endRow))); + + ( Integer.parseInt(String.valueOf(endRow))); } else if (getDBType().equals(AppConstants.POSTGRESQL)) { - partSql = partSql + " LIMIT " + String.valueOf(endRow) + " , " + String.valueOf(startRow);// limit - // [pageSize] - // offset - // [startRow] + partSql = partSql + " LIMIT " + String.valueOf(endRow) + " , " + String.valueOf(startRow); } - // Limit only to MYSQL or MariaDB - // if (reportSQL.toUpperCase().indexOf("ORDER BY ") < 0) - // partSql += " ORDER BY 1"; - // else { - - /* - * if(!Globals.isMySQL()) parta = parta.replace("[endRow]", String.valueOf(endRow)); else parta = - * parta.replace("[startRow]", String.valueOf(startRow)); - * - * //String partb = Globals.getReportSqlOnlySecondPartB(); if(!Globals.isMySQL()) partb = - * partb.replace("[startRow]", String.valueOf(startRow)); else partb = partb.replace("[pageSize]", - * String.valueOf(getPageSize())); - * - * if( endRow != -1) reportSQL += parta; - */ + reportSQL += partSql; return reportSQL; - } // generateSubsetSQL + } public String generateChartSQL(ReportParamValues paramValues, String userId, HttpServletRequest request) throws RaptorException { List reportCols = getAllColumns(); - List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); // parameter is 0 has this - // requires all columns. + List chartValueCols = getChartValueColumnsList(AppConstants.CHART_ALL_COLUMNS, null); String reportSQL = generateSQL(userId, request); - // if(nvl(reportSQL).length()>0) reportSQL = generatedChartSQL; logger.debug(EELFLoggerDelegate.debugLogger, ("SQL " + reportSQL)); String legendCol = "1 a"; - // String valueCol = "1"; StringBuffer groupCol = new StringBuffer(); StringBuffer seriesCol = new StringBuffer(); StringBuffer valueCols = new StringBuffer(); @@ -4110,39 +3752,25 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String colName = getColumnSelectStr(dc, paramValues); if (nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND)) legendCol = getSelectExpr(dc, colName) + " " + dc.getColId(); - // if(dc.getChartSeq()>0) - // valueCol = "NVL("+colName+", 0) "+dc.getColId(); if ((!nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND)) && (dc.getChartSeq() == null || dc.getChartSeq() <= 0) && dc.isGroupBreak()) { groupCol.append(", "); groupCol.append(colName + " " + dc.getColId()); } - } // for + } for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); if (dc.isChartSeries() != null && dc.isChartSeries().booleanValue()) { - // System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ - // getSelectExpr(dc,getColumnSelectStr(dc, paramValues))); seriesCol.append(", " + getSelectExpr(dc, getColumnSelectStr(dc, paramValues)) + " " + dc.getColId()); } } - /* - * for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = - * (DataColumnType) iter.next(); if(!dc.isChartSeries() && - * !(nvl(dc.getColOnChart()).equals(AppConstants.GC_LEGEND))) { - * //System.out.println("*****************, "+ " " +getColumnSelectStr(dc, paramValues)+ " "+ - * getSelectExpr(dc,getColumnSelectStr(dc, paramValues))); seriesCol.append(", "+ - * formatChartColumn(getSelectExpr(dc,getColumnSelectStr(dc, paramValues)))+ " " + dc.getColId()); } - * } - */ for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); String colName = getColumnSelectStr(dc, paramValues); - // valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId()); seriesCol.append("," + formatChartColumn(colName) + " " + dc.getColId()); - } // for + } for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) iter.next(); @@ -4165,38 +3793,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { seriesCol.append(", " + AppConstants.RI_ANOMALY_TEXT + " " + AppConstants.RI_ANOMALY_TEXT); } - // debugLogger.debug("ReportSQL Chart " + reportSQL ); - /* - * for (Iterator iter = chartValueCols.iterator(); iter.hasNext();) { DataColumnType dc = - * (DataColumnType) iter.next(); String colName = getColumnSelectStr(dc, paramValues); - * //valueCols.append(", NVL(" + formatChartColumn(colName) + ",0) " + dc.getColId()); - * valueCols.append("," + formatChartColumn(colName) + " " + dc.getColId()); } // for for (Iterator - * iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dc = (DataColumnType) - * iter.next(); String colName = getColumnSelectStr(dc, paramValues); - * //if(colName.equals(AppConstants.RI_CHART_TOTAL_COL) || - * colName.equals(AppConstants.RI_CHART_COLOR)) { - * if(colName.equals(AppConstants.RI_CHART_TOTAL_COL)) valueCols.append(", " + - * AppConstants.RI_CHART_TOTAL_COL + " " + AppConstants.RI_CHART_TOTAL_COL ); if - * (colName.equals(AppConstants.RI_CHART_COLOR)) valueCols.append(", " + AppConstants.RI_CHART_COLOR - * + " " + AppConstants.RI_CHART_COLOR ); if (colName.equals(AppConstants.RI_CHART_INCLUDE)) - * valueCols.append(", " + AppConstants.RI_CHART_INCLUDE + " " + AppConstants.RI_CHART_INCLUDE ); - * //} } - */ + String final_sql = ""; reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM "); reportSQL = Utils.replaceInString(reportSQL, " select ", " SELECT "); reportSQL = Utils.replaceInString(reportSQL, " union ", " UNION "); - // reportSQL = reportSQL.replaceAll("[\\s]*\\(", "("); - // if(reportSQL.indexOf("UNION") != -1) { - // if(reportSQL.indexOf("FROM(")!=-1) - // final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM(") ); - // else if (reportSQL.indexOf("FROM (")!=-1) - // final_sql += " "+reportSQL.substring(reportSQL.indexOf("FROM (") ); - // //TODO ELSE THROW ERROR - // } - // else { - // final_sql += " "+reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM ")); - // } int pos = 0; int pos_first_select = 0; int pos_dup_select = 0; @@ -4205,11 +3806,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (reportSQL.indexOf("FROM", pos) != -1) { pos = reportSQL.indexOf("FROM", pos); pos_dup_select = reportSQL.lastIndexOf("SELECT", pos); - pos_first_select = reportSQL.indexOf("SELECT");// ,pos); + pos_first_select = reportSQL.indexOf("SELECT"); logger.debug(EELFLoggerDelegate.debugLogger, ("pos_select " + pos_first_select + " " + pos_dup_select)); if (pos_dup_select > pos_first_select) { logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select)); - // pos_dup_select1 = pos_dup_select; pos_prev_select = pos_first_select; pos_last_select = pos_dup_select; while (pos_last_select > pos_prev_select) { @@ -4232,7 +3832,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("Final sql in generateChartSQL " + sql)); return sql; - } // generateChartSQL + } private String formatChartColumn(String colName) { @@ -4240,7 +3840,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { colName = colName.trim(); colName = Utils.replaceInString(colName, "TO_CHAR", "to_char"); colName = Utils.replaceInString(colName, "to_number", "TO_NUMBER"); - // reportSQL = reportSQL.replaceAll("[\\s]*\\(", "("); colName = colName.replaceAll(",[\\s]*\\(", ",("); StringBuffer colNameBuf = new StringBuffer(colName); int pos = 0; @@ -4257,15 +3856,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { colNameBuf.insert(pos, " TO_NUMBER ( CR_RAPTOR.SAFE_TO_NUMBER ("); pos = colNameBuf.indexOf("to_char"); colNameBuf.replace(pos, pos + 7, "TO_CHAR"); - // colName = Utils.replaceInString(colNameBuf.toString(), "to_char", " TO_NUMBER ( - // CR_RAPTOR.SAFE_TO_NUMBER ( TO_CHAR "); logger.debug(EELFLoggerDelegate.debugLogger, ("After adding to_number " + colNameBuf.toString())); - // posFormatStart = colNameBuf.lastIndexOf(",'")+1; posFormatStart = colNameBuf.indexOf(",'", pos) + 1; posFormatEnd = colNameBuf.indexOf(")", posFormatStart); logger.debug(EELFLoggerDelegate.debugLogger, (posFormatStart + " " + posFormatEnd + " " + pos)); format = colNameBuf.substring(posFormatStart, posFormatEnd); - // posFormatEnd = colNameBuf.indexOf(")",posFormatEnd); colNameBuf.insert(posFormatEnd + 1, " ," + format + ") , " + format + ")"); logger.debug(EELFLoggerDelegate.debugLogger, ("colNameBuf " + colNameBuf.toString())); } @@ -4278,7 +3873,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { throws RaptorException { List reportCols = getAllColumns(); String reportSQL = generateSQL(userId, request); - // debugLogger.debug("After GenerateSQL " + reportSQL); StringBuffer sbSelect = new StringBuffer(); StringBuffer sbTotal = new StringBuffer(); @@ -4293,9 +3887,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = reportCols.iterator(); iter.hasNext();) { DataColumnType dct = (DataColumnType) iter.next(); - // if (!dct.isVisible()) - // continue; - String colName = getColumnSelectStr(dct, paramValues); sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", "); @@ -4306,8 +3897,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", "); if (nvl(dct.getDisplayTotal()).length() > 0) { - // sbTotal.append(getSelectExpr(dct, - // dct.getDisplayTotal()+dct.getColId()+")")); String displayTotal = dct.getDisplayTotal(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < displayTotal.length(); i++) { @@ -4315,28 +3904,21 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (ch == '+' || ch == '-') sb.append(dct.getColId() + ")"); sb.append(ch); - } // for + } sb.append(dct.getColId() + ")"); - - // debugLogger.debug("SB " + sb.toString() + "\n " + getSelectExpr(dct, sb.toString())); sbTotal.append(getSelectExpr(dct, sb.toString())); - // debugLogger.debug("SBTOTAL " + sbTotal.toString()); } else sbTotal.append("NULL"); sbTotal.append(" total_"); sbTotal.append(dct.getColId()); - } // for + } - // debugLogger.debug(" ****** " + sbTotal.toString()); logger.debug(EELFLoggerDelegate.debugLogger, ("REPORTWRAPPER " + reportSQL)); int pos = 0; int pos_first_select = 0; int pos_dup_select = 0; int pos_prev_select = 0; int pos_last_select = 0; - - // reportSQL = Utils.replaceInString(reportSQL, " from ", " FROM "); - // reportSQL = Utils.replaceInString(reportSQL, "select ", "SELECT "); reportSQL = replaceNewLine(reportSQL, " from ", " FROM "); reportSQL = replaceNewLine(reportSQL, "from ", " FROM "); reportSQL = replaceNewLine(reportSQL, "FROM ", " FROM "); @@ -4351,7 +3933,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("pos_select " + pos_first_select + " " + pos_dup_select)); if (pos_dup_select > pos_first_select) { logger.debug(EELFLoggerDelegate.debugLogger, ("********pos_dup_select ********" + pos_dup_select)); - // pos_dup_select1 = pos_dup_select; pos_prev_select = pos_first_select; pos_last_select = pos_dup_select; while (pos_last_select > pos_prev_select) { @@ -4366,10 +3947,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } - // sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM "))); - logger.debug(EELFLoggerDelegate.debugLogger, (" *************** " + pos + " " + reportSQL)); - // sbSelect.append(" "+ reportSQL.substring(pos)); sbSelect.append(" " + reportSQL.substring(pos)); logger.debug(EELFLoggerDelegate.debugLogger, (" **************** " + sbSelect.toString())); sbTotal.append(" FROM ("); @@ -4380,8 +3958,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String dbInfo = getDBInfo(); if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = - new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -4393,14 +3969,12 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String sql = sbTotal.toString(); sql = Utils.replaceInString(sql, " from ", " FROM "); sql = Utils.replaceInString(sql, "select ", "SELECT "); - // sql = Utils.replaceInString(sql, " select ", " SELECT "); logger.debug(EELFLoggerDelegate.debugLogger, ("Before SQL Corrector " + sql)); String corrected_SQL = new SQLCorrector().fixSQL(new StringBuffer(sql)); logger.debug(EELFLoggerDelegate.debugLogger, ("************")); logger.debug(EELFLoggerDelegate.debugLogger, ("Corrected SQL " + corrected_SQL)); return corrected_SQL; - // return sbTotal.toString(); - } // generateTotalSQLLinear + } public String generateTotalSQLCrossTab(String sql, String rowColPos, String userId, HttpServletRequest request, ReportParamValues paramValues) throws RaptorException { @@ -4409,7 +3983,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { StringBuffer sbSelect = new StringBuffer(); StringBuffer sbGroup = new StringBuffer(); - // StringBuffer sbOrder = new StringBuffer(); StringBuffer sbTotal = new StringBuffer(); StringBuffer colNames = new StringBuffer(); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -4431,32 +4004,26 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbSelect.append((sbSelect.length() == 0) ? "SELECT " : ", "); if (nvl(dct.getCrossTabValue()).equals(rowColPos)) { - // sbSelect.append(colExpr); sbSelect.append(dct.getColId()); sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", "); sbGroup.append(dct.getColId()); - /* - * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", "); sbOrder.append(dct.getColId()); - * if(dct.getColType().equals(AppConstants.CT_DATE)) sbOrder.append(" DESC"); - */ - sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", "); sbTotal.append(dct.getColId()); } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) { - // sbSelect.append(colName); + sbSelect.append(dct.getColId()); String displayTotal = getCrossTabDisplayTotal(rowColPos); if (displayTotal.length() > 0) { - // displayTotal += dct.getColId()+")"; + StringBuffer sb = new StringBuffer(); for (int i = 0; i < displayTotal.length(); i++) { char ch = displayTotal.charAt(i); if (ch == '+' || ch == '-') sb.append(dct.getColId() + ")"); sb.append(ch); - } // for + } sb.append(dct.getColId() + ")"); displayTotal = sb.toString(); @@ -4468,13 +4035,13 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbTotal.append(" total_"); sbTotal.append(dct.getColId()); } else { - // sbSelect.append(colExpr); + sbSelect.append(dct.getColId()); - } // if + } sbSelect.append(" "); sbSelect.append(dct.getColId()); - } // for + } sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM "))); @@ -4486,8 +4053,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String dbInfo = getDBInfo(); if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = - new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -4497,10 +4062,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbTotal.append("(" + colNames + ")"); } - // sbTotal.append(sbOrder.toString()); - - // debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED); - // debugLogger.debug("SQL To Delete " + sbTotal.toString()); sql = ""; if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) { sql = Utils.replaceInString(sbTotal.toString(), " from ", " FROM "); @@ -4510,7 +4071,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return sbTotal.toString(); - } // generateTotalSQLCrossTab + } public String generateTotalSQLCrossTab(ReportParamValues paramValues, String rowColPos, String userId, HttpServletRequest request) throws RaptorException { @@ -4519,7 +4080,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { StringBuffer sbSelect = new StringBuffer(); StringBuffer sbGroup = new StringBuffer(); - // StringBuffer sbOrder = new StringBuffer(); StringBuffer sbTotal = new StringBuffer(); StringBuffer colNames = new StringBuffer(); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -4546,11 +4106,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbGroup.append((sbGroup.length() == 0) ? " GROUP BY " : ", "); sbGroup.append(dct.getColId()); - /* - * sbOrder.append((sbOrder.length()==0)?" ORDER BY ":", "); sbOrder.append(dct.getColId()); - * if(dct.getColType().equals(AppConstants.CT_DATE)) sbOrder.append(" DESC"); - */ - sbTotal.append((sbTotal.length() == 0) ? "SELECT " : ", "); sbTotal.append(dct.getColId()); } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) { @@ -4558,14 +4113,13 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String displayTotal = getCrossTabDisplayTotal(rowColPos); if (displayTotal.length() > 0) { - // displayTotal += dct.getColId()+")"; StringBuffer sb = new StringBuffer(); for (int i = 0; i < displayTotal.length(); i++) { char ch = displayTotal.charAt(i); if (ch == '+' || ch == '-') sb.append(dct.getColId() + ")"); sb.append(ch); - } // for + } sb.append(dct.getColId() + ")"); displayTotal = sb.toString(); @@ -4578,11 +4132,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbTotal.append(dct.getColId()); } else { sbSelect.append(colExpr); - } // if + } sbSelect.append(" "); sbSelect.append(dct.getColId()); - } // for + } sbSelect.append(reportSQL.substring(reportSQL.toUpperCase().indexOf(" FROM "))); @@ -4594,8 +4148,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { String dbInfo = getDBInfo(); if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = - new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -4605,10 +4157,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sbTotal.append("(" + colNames + ")"); } - // sbTotal.append(sbOrder.toString()); - - // debugLogger.debug(getReportDefType() + " " + AppConstants.RD_SQL_BASED); - // debugLogger.debug("SQL To Delete " + sbTotal.toString()); String sql = ""; if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) { sql = Utils.replaceInString(sbTotal.toString(), " from ", " FROM "); @@ -4618,7 +4166,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return sbTotal.toString(); - } // generateTotalSQLCrossTab + } public String generateDistinctValuesSQL(ReportParamValues paramValues, DataColumnType dct, String userId, HttpServletRequest request) throws RaptorException { @@ -4631,8 +4179,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) { sb.append(dct.getColId()); sb.append(" FROM ("); - // paramvalues added below to filter distinct values based on formfields. - // sb.append(generateSQL(paramValues, userId, request)); sb.append(rr.getWholeSQL()); sb.append(") " + (Globals.isPostgreSQL() || Globals.isMySQL() ? " AS " : "") + " report_sql ORDER BY 1"); } else { @@ -4642,7 +4188,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (!colExpr.equals(colName)) { sb.append(", "); sb.append(colName); - } // if + } sb.append(" FROM "); sb.append(dst.getTableName()); sb.append(" "); @@ -4651,14 +4197,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { sb.append(colName); if (dct.getColType().equals(AppConstants.CT_DATE)) sb.append(" DESC"); - } // else + } return sb.toString(); - } // generateDistinctValuesSQL - - /** - * ************************************************************************************************* - */ + } public DataSourceType getTableWithoutColumns() { List dsList = getDataSourceList().getDataSource(); @@ -4667,10 +4209,10 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { if (ds.getDataColumnList().getDataColumn().isEmpty()) return ds; - } // for + } return null; - } // getTableWithoutColumns + } public CustomReportType cloneCustomReportClearTables() throws RaptorException { ReportWrapper nrw = new ReportWrapper(cloneCustomReport(), reportID, getOwnerID(), @@ -4682,7 +4224,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nrw.deleteDataSourceType(ndst.getTableId()); return nrw.getCustomReport(); - } // cloneCustomReportClearTables + } public String marshal() throws RaptorException { StringWriter sw = new StringWriter(); @@ -4692,9 +4234,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj"); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - // JAXBElement jaxbElement = new JAXBElement(new QName("customReport"), Object.class, ""); - // m.marshal( System.out ); - // m.marshal(jaxbElement, new StreamResult(sw)); m.marshal( (getTableWithoutColumns() == null) ? objFactory.createCustomReport(cr) : objFactory.createCustomReport(cloneCustomReportClearTables()), @@ -4704,10 +4243,9 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { throw new RaptorException(ex.getMessage(), ex.getCause()); } return sw.toString(); - } // marshal + } public static CustomReportType unmarshalCR(String reportXML) throws RaptorException { - // CustomReport cr = null; try { JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj"); Unmarshaller u = jc.createUnmarshaller(); @@ -4720,19 +4258,16 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { throw new RaptorException(ex.getMessage(), ex.getCause()); } - } // unmarshal + + } protected static CustomReportType createBlankCR() throws RaptorException { return createBlankCR("N/A"); - } // createBlank - + } protected static CustomReportType createBlankCR(String createID) throws RaptorException { ObjectFactory objFactory = new ObjectFactory(); CustomReportType cr = objFactory.createCustomReportType(); - // CustomReport cr = null; try { - // cr = (CustomReport) objFactory.createCustomReport(customReportType); - cr.setReportName(""); cr.setReportDescr(""); cr.setChartType(""); @@ -4749,7 +4284,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { throw new RaptorException(ex.getMessage(), ex.getCause()); } return cr; - } // createBlank + } protected void replaceCustomReportWithClone() throws RaptorException { try { @@ -4765,11 +4300,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { + reportID + "]. Exception: " + e.getMessage(), e.getCause()); } - } // replaceCustomReportWithClone - - /** - * ************************************************************************************************* - */ + } public FormatType cloneFormatType(ObjectFactory objFactory, FormatType ft) throws JAXBException { @@ -4796,7 +4327,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nft.setFormatId(ft.getFormatId()); return nft; - } // cloneFormatType + } public SemaphoreType cloneSemaphoreType(ObjectFactory objFactory, SemaphoreType st) throws JAXBException { @@ -4818,7 +4349,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } // if return nst; - } // cloneSemaphoreType + } public Reports cloneDashboardType(ObjectFactory objFactory, Reports rpt) throws JAXBException { @@ -4827,7 +4358,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nrpt.setReportId(rpt.getReportId()); nrpt.setBgcolor(rpt.getBgcolor()); return nrpt; - } // cloneDashboardType + } public Marker cloneMarkerType(ObjectFactory objFactory, Marker marker) throws JAXBException { @@ -4837,7 +4368,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nMarker.setDataHeader(marker.getDataHeader()); nMarker.setMarkerColor(marker.getMarkerColor()); return nMarker; - } // cloneDashboardType + } public ChartDrillFormfield cloneChartDrillFormfield(ObjectFactory objFactory, ChartDrillFormfield chartDrillFormfield) @@ -4845,7 +4376,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ChartDrillFormfield nChartDrillFormfield = objFactory.createChartDrillFormfield(); nChartDrillFormfield.setFormfield(chartDrillFormfield.getFormfield()); return nChartDrillFormfield; - } // cloneDashboardType + } public boolean isChartDrillDownContainsName(String name) { for (Iterator iter = getChartDrillOptions().getTargetFormfield().iterator(); iter @@ -4868,16 +4399,16 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nfft.setFieldType(fft.getFieldType()); if (nvl(fft.getVisible()).length() > 0) nfft.setVisible(fft.getVisible()); - if (nvl(fft.getValidationType()).length() > 0) + if (nvl(fft.getValidationType()).length() > 0 || (fft.getValidationType() != null && fft.getValidationType().isEmpty())) nfft.setValidationType(fft.getValidationType()); if (nvl(fft.getMandatory()).length() > 0) nfft.setMandatory(fft.getMandatory()); - if (nvl(fft.getDefaultValue()).length() > 0) + if (nvl(fft.getDefaultValue()).length() > 0 || (fft.getDefaultValue() != null && fft.getDefaultValue().isEmpty())) nfft.setDefaultValue(fft.getDefaultValue()); nfft.setOrderBySeq(fft.getOrderBySeq()); - if (nvl(fft.getFieldSQL()).length() > 0) + if (nvl(fft.getFieldSQL()).length() > 0 || (fft.getFieldSQL() != null && fft.getFieldSQL().isEmpty())) nfft.setFieldSQL(fft.getFieldSQL()); - if (nvl(fft.getFieldDefaultSQL()).length() > 0) + if (nvl(fft.getFieldDefaultSQL()).length() > 0 || (fft.getFieldDefaultSQL() != null && fft.getFieldDefaultSQL().isEmpty())) nfft.setFieldDefaultSQL(fft.getFieldDefaultSQL()); if (fft.getRangeStartDate() != null) nfft.setRangeStartDate(fft.getRangeStartDate()); @@ -4898,7 +4429,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter .hasNext();) predefinedValueList.getPredefinedValue().add(new String((String) iter.next())); - } // if + } if (nvl(fft.getDependsOn()).length() > 0) nfft.setDependsOn(fft.getDependsOn()); @@ -4909,7 +4440,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { nfft.setFieldId(fft.getFieldId()); return nfft; - } // cloneFormFieldType + } public JavascriptItemType cloneJavascriptType(ObjectFactory objFactory, JavascriptItemType jit) throws JAXBException { @@ -4919,7 +4450,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { njit.setFieldId(jit.getFieldId()); njit.setCallText(jit.getCallText()); return njit; - } // cloneJavascriptType + } public ColFilterType cloneColFilterType(ObjectFactory objFactory, ColFilterType cft) throws JAXBException { @@ -4941,7 +4472,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ncft.setComment(cft.getComment()); return ncft; - } // cloneColFilterType + } public DataColumnType cloneDataColumnType(ObjectFactory objFactory, DataColumnType dct) throws JAXBException { @@ -5022,7 +4553,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { .hasNext();) colFilterList.getColFilter().add( cloneColFilterType(objFactory, (ColFilterType) iter.next())); - } // if + } if (nvl(dct.getSemaphoreId()).length() > 0) ndct.setSemaphoreId(dct.getSemaphoreId()); @@ -5055,11 +4586,8 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ndct.setColId(dct.getColId()); - // ndct.setSemaphoreId(nvl(dct.getSemaphoreId())); - // if(nvl(dct.getDbColType()).length()>0) - // ndct.setDbColType(dct.getDbColType()); return ndct; - } // cloneDataColumnType + } public DataSourceType cloneDataSourceType(ObjectFactory objFactory, DataSourceType dst) throws JAXBException { @@ -5084,21 +4612,20 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ndst.setTableId(dst.getTableId()); return ndst; - } // cloneDataSourceType + } public CustomReportType cloneCustomReport() throws RaptorException { ObjectFactory objFactory = new ObjectFactory(); CustomReportType ncr = objFactory.createCustomReportType(); - - // CustomReport ncr = null; try { - // ncr = (CustomReport) objFactory.createCustomReport(customReportType); ncr.setReportName(cr.getReportName()); ncr.setReportDescr(cr.getReportDescr()); if (nvl(cr.getNumDashCols()).length() > 0) ncr.setNumDashCols(cr.getNumDashCols()); if (nvl(cr.getDashboardLayoutHTML()).length() > 0) ncr.setDashboardLayoutHTML(cr.getDashboardLayoutHTML()); + if (nvl(cr.getDashboardLayoutJSON()).length() > 0) + ncr.setDashboardLayoutJSON(cr.getDashboardLayoutJSON()); if (nvl(cr.getDbInfo()).length() > 0) ncr.setDbInfo(cr.getDbInfo()); ncr.setChartType(cr.getChartType()); @@ -5137,31 +4664,17 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ncr.setWidthNoColumn(cr.getWidthNoColumn()); if (nvl(cr.getDataGridAlign()).length() > 0) ncr.setDataGridAlign(cr.getDataGridAlign()); - -// if (nvl(cr.getReportFooter()).length() > 0) ncr.setReportFooter(cr.getReportFooter()); -// if (nvl(cr.getNumFormCols()).length() > 0) ncr.setNumFormCols(cr.getNumFormCols()); -// if (nvl(cr.getDisplayOptions()).length() > 0) ncr.setDisplayOptions(cr.getDisplayOptions()); -// if (nvl(cr.getDataContainerHeight()).length() > 0) ncr.setDataContainerHeight(cr.getDataContainerHeight()); -// if (nvl(cr.getDataContainerWidth()).length() > 0) ncr.setDataContainerWidth(cr.getDataContainerWidth()); -// if (nvl(cr.getAllowSchedule()).length() > 0) ncr.setAllowSchedule(cr.getAllowSchedule()); -// if (nvl(cr.getTopDown()).length() > 0) ncr.setTopDown(cr.getTopDown()); -// if (nvl(cr.getSizedByContent()).length() > 0) ncr.setSizedByContent(cr.getSizedByContent()); -// if (nvl(cr.getComment()).length() > 0) ncr.setComment(cr.getComment()); -// if (nvl(cr.getDashboardOptions()).length() > 0) ncr.setDashboardOptions(cr.getDashboardOptions()); - -// if (cr.isDashboardType() != null) ncr.setDashboardType(cr.isDashboardType()); -// if (cr.isReportInNewWindow() != null) ncr.setReportInNewWindow(cr.isReportInNewWindow()); ncr.setDisplayFolderTree(cr.isDisplayFolderTree()); if (cr.getDashBoardReports() == null) { @@ -5176,23 +4689,16 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ncr.setDrillURLInPoPUpPresent( (cr.isDrillURLInPoPUpPresent() != null && cr.isDrillURLInPoPUpPresent().booleanValue()) ? true : false); - -// if (nvl(cr.getIsOneTimeScheduleAllowed()).length() > 0) ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed()); -// if (nvl(cr.getIsHourlyScheduleAllowed()).length() > 0) ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed()); -// if (nvl(cr.getIsDailyScheduleAllowed()).length() > 0) ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed()); -// if (nvl(cr.getIsDailyMFScheduleAllowed()).length() > 0) ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed()); -// if (nvl(cr.getIsWeeklyScheduleAllowed()).length() > 0) ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed()); -// if (nvl(cr.getIsMonthlyScheduleAllowed()).length() > 0) ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed()); ncr.setPageSize(cr.getPageSize()); ncr.setReportType(cr.getReportType()); - + ncr.setFormFieldGroupsJSON(cr.getFormFieldGroupsJSON()); DataSourceList dataSourceList = objFactory.createDataSourceList(); ncr.setDataSourceList(dataSourceList); @@ -5211,7 +4717,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { formFieldList.getFormField().add( cloneFormFieldType(objFactory, (FormFieldType) iter.next())); formFieldList.setComment(cr.getFormFieldList().getComment()); - } // if + } if (cr.getJavascriptList() != null) { JavascriptList javascriptList = objFactory.createJavascriptList(); @@ -5221,7 +4727,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { .hasNext();) javascriptList.getJavascriptItem().add( cloneJavascriptType(objFactory, (JavascriptItemType) iter.next())); - } // if + } if (cr.getSemaphoreList() != null) { SemaphoreList semaphoreList = objFactory.createSemaphoreList(); @@ -5232,7 +4738,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { semaphoreList.getSemaphore().add( cloneSemaphoreType(objFactory, (SemaphoreType) iter.next())); } - } // if + } if (nvl(cr.getDashboardOptions()).length() > 0) ncr.setDashboardOptions(cr.getDashboardOptions()); @@ -5255,7 +4761,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { dashboardReports.getReportsList().add( cloneDashboardType(objFactory, (Reports) iter.next())); } - } // if + } if (cr.getChartAdditionalOptions() != null) { ChartAdditionalOptions chartAdditionalOptions = objFactory.createChartAdditionalOptions(); @@ -5362,7 +4868,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { : new Integer(60)); ncr.setChartAdditionalOptions(chartAdditionalOptions); - } // if + } if (nvl(cr.getJavascriptElement()).length() > 0) ncr.setJavascriptElement(cr.getJavascriptElement()); @@ -5391,18 +4897,11 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ncr.setChartDrillOptions(chartDrillOptions); } - -// if (nvl(cr.getIsOneTimeScheduleAllowed()).length() > 0) ncr.setIsOneTimeScheduleAllowed(cr.getIsOneTimeScheduleAllowed()); -// if (nvl(cr.getIsHourlyScheduleAllowed()).length() > 0) ncr.setIsHourlyScheduleAllowed(cr.getIsHourlyScheduleAllowed()); -// if (nvl(cr.getIsDailyScheduleAllowed()).length() > 0) ncr.setIsDailyScheduleAllowed(cr.getIsDailyScheduleAllowed()); -// if (nvl(cr.getIsDailyMFScheduleAllowed()).length() > 0) ncr.setIsDailyMFScheduleAllowed(cr.getIsDailyMFScheduleAllowed()); -// if (nvl(cr.getIsWeeklyScheduleAllowed()).length() > 0) ncr.setIsWeeklyScheduleAllowed(cr.getIsWeeklyScheduleAllowed()); -// if (nvl(cr.getIsMonthlyScheduleAllowed()).length() > 0) ncr.setIsMonthlyScheduleAllowed(cr.getIsMonthlyScheduleAllowed()); ncr.setPageSize(cr.getPageSize()); @@ -5447,194 +4946,15 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { ncr.setReportMap(repMap); } - } catch (JAXBException ex) { // try + } catch (JAXBException ex) { logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in cloneCustomReport ", ex); throw new RaptorException(ex.getMessage(), ex.getCause()); } return ncr; - } // cloneCustomReport + } - /** - * ************************************************************************************************* - */ - // public void printFormatType(FormatType ft) { - // System.out.println("------------------------------------------------"); - // System.out.println("Semaphore Col Format"); - // System.out.println("------------------------------------------------"); - // System.out.println("FormatId: [" + ft.getFormatId() + "]"); - // System.out.println("LessThanValue: [" + ft.getLessThanValue() + "]"); - // System.out.println("Expression: [" + ft.getExpression() + "]"); - // System.out.println("Bold: [" + ft.isBold() + "]"); - // System.out.println("Italic: [" + ft.isItalic() + "]"); - // System.out.println("Underline: [" + ft.isUnderline() + "]"); - // System.out.println("BgColor: [" + ft.getBgColor() + "]"); - // System.out.println("FontColor: [" + ft.getFontColor() + "]"); - // System.out.println("FontFace: [" + ft.getFontFace() + "]"); - // System.out.println("FontSize: [" + ft.getFontSize() + "]"); - // System.out.println("Alignment: [" + ft.getAlignment() + "]"); - // System.out.println("Comment: [" + ft.getComment() + "]"); - // System.out.println("------------------------------------------------"); - // } // printFormatType - - // public void printSemaphoreType(SemaphoreType st) { - // System.out.println("------------------------------------------------"); - // System.out.println("Semaphore"); - // System.out.println("------------------------------------------------"); - // System.out.println("SemaphoreId: [" + st.getSemaphoreId() + "]"); - // System.out.println("SemaphoreName: [" + st.getSemaphoreName() + "]"); - // System.out.println("SemaphoreType: [" + st.getSemaphoreType() + "]"); - // System.out.println("Comment: [" + st.getComment() + "]"); - // - // if (st.getFormatList() != null) - // for (Iterator iter = st.getFormatList().getFormat().iterator(); iter.hasNext();) - // printFormatType((FormatType) iter.next()); - // - // System.out.println("------------------------------------------------"); - // } // printSemaphoreType - - // public void printFormFieldType(FormFieldType fft) { - // System.out.println("------------------------------------------------"); - // System.out.println("Form Field"); - // System.out.println("------------------------------------------------"); - // System.out.println("FieldId: [" + fft.getFieldId() + "]"); - // System.out.println("ColId: [" + fft.getColId() + "]"); - // System.out.println("FieldName: [" + fft.getFieldName() + "]"); - // System.out.println("FieldType: [" + fft.getFieldType() + "]"); - // System.out.println("ValidationType: [" + fft.getValidationType() + "]"); - // System.out.println("Mandatory: [" + fft.getMandatory() + "]"); - // System.out.println("DefaultValue: [" + fft.getDefaultValue() + "]"); - // System.out.println("OrderBySeq: [" + fft.getOrderBySeq() + "]"); - // System.out.println("FieldSQL: [" + fft.getFieldSQL() + "]"); - // System.out.println("Comment: [" + fft.getComment() + "]"); - // if (fft.getPredefinedValueList() != null) - // for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue().iterator(); iter - // .hasNext();) - // System.out.println("PredefinedValues: [" + ((String) iter.next()) + "]"); - // - // System.out.println("------------------------------------------------"); - // } // printFormFieldType - - // public void printColFilterType(ColFilterType cft) { - // System.out.println("------------------------------------------------"); - // System.out.println("Col Filter"); - // System.out.println("------------------------------------------------"); - // System.out.println("ColId: [" + cft.getColId() + "]"); - // System.out.println("FilterSeq: [" + cft.getFilterSeq() + "]"); - // System.out.println("JoinCondition: [" + cft.getJoinCondition() + "]"); - // System.out.println("OpenBrackets: [" + cft.getOpenBrackets() + "]"); - // System.out.println("Expression: [" + cft.getExpression() + "]"); - // System.out.println("ArgType: [" + cft.getArgType() + "]"); - // System.out.println("ArgValue: [" + cft.getArgValue() + "]"); - // System.out.println("CloseBrackets: [" + cft.getCloseBrackets() + "]"); - // System.out.println("Comment: [" + cft.getComment() + "]"); - // System.out.println("------------------------------------------------"); - // } // printColFilterType - - // public void printDataColumnType(DataColumnType dct) { - // System.out.println("------------------------------------------------"); - // System.out.println("Data Column"); - // System.out.println("------------------------------------------------"); - // System.out.println("ColId: [" + dct.getColId() + "]"); - // System.out.println("TableId: [" + dct.getTableId() + "]"); - // System.out.println("DbColName: [" + dct.getDbColName() + "]"); - // System.out.println("CrossTabValue: [" + dct.getCrossTabValue() + "]"); - // System.out.println("ColName: [" + dct.getColName() + "]"); - // System.out.println("DisplayName: [" + dct.getDisplayName() + "]"); - // System.out.println("DisplayWidth: [" + dct.getDisplayWidth() + "]"); - // System.out.println("DisplayAlignment: [" + dct.getDisplayAlignment() + "]"); - // System.out.println("DisplayHeaderAlignment: [" + dct.getDisplayHeaderAlignment() + "]"); - // System.out.println("OrderSeq(): [" + dct.getOrderSeq() + "]"); - // System.out.println("Visible: [" + dct.isVisible() + "]"); - // System.out.println("Calculated: [" + dct.isCalculated() + "]"); - // System.out.println("ColType: [" + dct.getColType() + "]"); - // System.out.println("ColFormat: [" + dct.getColFormat() + "]"); - // System.out.println("GroupBreak: [" + dct.isGroupBreak() + "]"); - // System.out.println("OrderBySeq: [" + dct.getOrderBySeq() + "]"); - // System.out.println("OrderByAscDesc: [" + dct.getOrderByAscDesc() + "]"); - // System.out.println("DisplayTotal: [" + dct.getDisplayTotal() + "]"); - // System.out.println("ColOnChart: [" + dct.getColOnChart() + "]"); - // System.out.println("ChartSeq: [" + dct.getChartSeq() + "]"); - // System.out.println("ChartColor: [" + dct.getChartColor() + "]"); - // System.out.println("DrillDownType: [" + dct.getDrillDownType() + "]"); - // System.out.println("DrillDownURL: [" + dct.getDrillDownURL() + "]"); - // System.out.println("DrillDownParams: [" + dct.getDrillDownParams() + "]"); - // System.out.println("Comment: [" + dct.getComment() + "]"); - // - // if (dct.getColFilterList() != null) - // for (Iterator iter = dct.getColFilterList().getColFilter().iterator(); iter - // .hasNext();) - // printColFilterType((ColFilterType) iter.next()); - // - // System.out.println("SemaphoreId: [" + dct.getSemaphoreId() + "]"); - // System.out.println("DbColType: [" + dct.getDbColType() + "]"); - // System.out.println("------------------------------------------------"); - // } // printDataColumnType - - // public void printDataSourceType(DataSourceType dst) { - // System.out.println("------------------------------------------------"); - // System.out.println("Data Source"); - // System.out.println("------------------------------------------------"); - // System.out.println("TableId: [" + dst.getTableId() + "]"); - // System.out.println("TableName: [" + dst.getTableName() + "]"); - // System.out.println("TablePK: [" + dst.getTablePK() + "]"); - // System.out.println("DisplayName: [" + dst.getDisplayName() + "]"); - // System.out.println("RefTableId: [" + dst.getRefTableId() + "]"); - // System.out.println("RefDefinition: [" + dst.getRefDefinition() + "]"); - // System.out.println("Comment: [" + dst.getComment() + "]"); - // - // for (Iterator iter = dst.getDataColumnList().getDataColumn().iterator(); iter - // .hasNext();) - // printDataColumnType((DataColumnType) iter.next()); - // - // System.out.println("------------------------------------------------"); - // } // printDataSourceType - - // public void print() { - // System.out.println("------------------------------------------------"); - // System.out.println("ReportWrapper object"); - // System.out.println("------------------------------------------------"); - // System.out.println("PageSize: [" + getPageSize() + "]"); - // System.out.println("ReportType: [" + getReportType() + "]"); - // System.out.println("ReportName: [" + getReportName() + "]"); - // System.out.println("ReportDescr: [" + getReportDescr() + "]"); - // System.out.println("ChartType: [" + getChartType() + "]"); - // System.out.println("ChartTypeFixed: [" + getChartTypeFixed() + "]"); - // //System.out.println("ChartLeftAxisLabel: [" + getChartLeftAxisLabel() + "]"); - // //System.out.println("ChartRightAxisLabel: [" + getChartRightAxisLabel() + "]"); - // System.out.println("ChartWidth: [" + getChartWidth() + "]"); - // System.out.println("ChartHeight: [" + getChartHeight() + "]"); - // System.out.println("Public: [" + isPublic() + "]"); - // System.out.println("CreateId: NOT USED ANYMORE[" + /* getCreateId()+ */"]"); - // System.out.println("CreateDate: NOT USED ANYMORE[" + /* getCreateDate()+ */"]"); - // System.out.println("ReportSQL: [" + getReportSQL() + "]"); - // System.out.println("ReportTitle: [" + getReportTitle() + "]"); - // System.out.println("DbInfo: [" + getDBInfo() + "]"); - // System.out.println("ReportSubTitle: [" + getReportSubTitle() + "]"); - // System.out.println("ReportHeader: [" + getReportHeader() + "]"); - // System.out.println("ReportFooter: [" + getReportFooter() + "]"); - // System.out.println("NumFormCols: [" + getNumFormCols() + "]"); - // System.out.println("DisplayOptions: [" + getDisplayOptions() + "]"); - // System.out.println("Comment: [" + getComment() + "]"); - // - // for (Iterator iter = cr.getDataSourceList().getDataSource().iterator(); iter.hasNext();) - // printDataSourceType((DataSourceType) iter.next()); - // - // if (cr.getFormFieldList() != null) - // for (Iterator iter = cr.getFormFieldList().getFormField().iterator(); iter - // .hasNext();) - // printFormFieldType((FormFieldType) iter.next()); - // - // if (cr.getSemaphoreList() != null) - // for (Iterator iter = cr.getSemaphoreList().getSemaphore().iterator(); iter - // .hasNext();) - // printSemaphoreType((SemaphoreType) iter.next()); - // - // System.out.println("------------------------------------------------"); - // System.out.println("ReportWrapper object end"); - // System.out.println("------------------------------------------------"); - // } // print private int getIntValue(String value, int defaultValue) { int iValue = defaultValue; @@ -5645,58 +4965,41 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } return iValue; - } // getIntValue + } public static String replaceNewLine(String strSource, String strFind, String chrReplace) { - // buffer to hold the target string after replacement is done. StringBuffer sbfTemp = new StringBuffer(); try { - // for each occurrence of strFind in strSource, replace it with chrReplace. int intIndex = strSource.indexOf(strFind, 0); - - // check if there is any instace of strFind in strSource if (intIndex >= 0) { - // holds the index from where the search is supposed to happen. int intStart = 0; - // size of the source string int intTotalSize = strSource.length(); while (intStart < intTotalSize && ((intIndex = strSource.indexOf(strFind, intStart)) >= 0)) { - // check if strFind is at the beginning... i.e., at index intStart if (intIndex == intStart) { - /* - * starts with strFind...just append chrReplace to the target - */ sbfTemp.append(chrReplace); } else { - // append the sub-string...plus chrReplace sbfTemp.append(strSource.substring(intStart, intIndex)); sbfTemp.append(chrReplace); } - - // advance string index intStart = intIndex + strFind.length(); } - - // append the last portion of the source string. sbfTemp.append(strSource.substring(intStart)); } else { - // strFind not found... just copy the text as it is. sbfTemp.append(strSource); } } catch (Exception expGeneral) { logger.error(EELFLoggerDelegate.debugLogger, "Exception occured in replaceNewLine ", expGeneral); - // in case of any exception, return the source string as it is. sbfTemp = new StringBuffer(strSource); } return sbfTemp.toString(); } - /* folder id */ + public String getFolderId() { return nvl(cr.getFolderId()).length() > 0 ? cr.getFolderId() : "NULL"; } @@ -5801,8 +5104,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return flag; } - /* Datamining Getter Setter */ - public String getClassifier() { return (cr.getDataminingOptions() != null ? cr.getDataminingOptions().getClassifier() : ""); } @@ -5879,7 +5180,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { this.reportSQLWithRowNum = reportSQLWithRowNum; } - // used for Zk sort public void setReportSQLOnlyFirstPart(String reportSQLOnlyFirstPart) { this.reportSQLOnlyFirstPart = reportSQLOnlyFirstPart; } @@ -5912,7 +5212,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } public void setDrillReportIdForChart(String reportId) { - // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():""; cr.getChartDrillOptions().setDrillReportId(reportId); } @@ -5921,7 +5220,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } public void setDrillXAxisFormField(String formField) { - // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():""; cr.getChartDrillOptions().setDrillXAxisFormField(formField); } @@ -5930,7 +5228,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } public void setDrillYAxisFormField(String formField) { - // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():""; cr.getChartDrillOptions().setDrillYAxisFormField(formField); } @@ -5939,7 +5236,6 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { } public void setDrillSeriesFormField(String formField) { - // (cr.getChartDrillOptions()!=null)?cr.getChartDrillOptions().setDrillReportId():""; cr.getChartDrillOptions().setDrillSeriesFormField(formField); } @@ -5954,7 +5250,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (dc.isEnhancedPagination() != null && dc.isEnhancedPagination().booleanValue()) return true; - } // for + } return false; } @@ -5965,7 +5261,7 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { DataColumnType dc = (DataColumnType) iter.next(); if (dc.isEnhancedPagination() != null && dc.isEnhancedPagination().booleanValue()) return dc; - } // for + } return null; } @@ -5993,4 +5289,4 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { return wholeSQL; } -} // ReportWrapper +} 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 e51913e4..11adb35b 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 @@ -73,6 +73,7 @@ import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.xmlobj.ChartAdditionalOptions; import org.onap.portalsdk.analytics.xmlobj.ChartDrillOptions; @@ -91,6 +92,8 @@ import org.onap.portalsdk.analytics.xmlobj.ObjectFactory; import org.onap.portalsdk.analytics.xmlobj.PredefinedValueList; import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /**<HR/> * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/> @@ -110,10 +113,19 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; * */ +@Component public class ReportDefinition extends ReportWrapper implements Serializable { private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportDefinition.class); + protected static RemDbInfo remDbInfo; + + @SuppressWarnings("static-access") + @Autowired + public void setRemDbInfo(RemDbInfo remDbInfo) { + this.remDbInfo = remDbInfo; + } + private ReportSchedule reportSchedule = null; private WizardSequence wizardSequence = null; @@ -124,6 +136,10 @@ public class ReportDefinition extends ReportWrapper implements Serializable { // when persisting report on // each step + public ReportDefinition() { + super(); + } + private ReportDefinition(CustomReportType crType, String reportID, String ownerID, String createID, String createDate, String updateID, String updateDate, String menuID, boolean menuApproved, HttpServletRequest request) throws RaptorException { @@ -214,7 +230,7 @@ public class ReportDefinition extends ReportWrapper implements Serializable { private boolean canPersistDashboard() { - return nvl(getDashboardLayoutHTML()).length() > 0; + return nvl(getDashboardLayoutJSON()).length() > 0; } //canPersistDashboard private boolean canPersistLinearReport() { @@ -1272,7 +1288,6 @@ public class ReportDefinition extends ReportWrapper implements Serializable { boolean isCYMBALScript = false; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); String dbType = remDbInfo.getDBType(dbInfo); if (dbType.equals("DAYTONA") && !(nextToken.toUpperCase().equals("SELECT"))) { isCYMBALScript = true; @@ -1419,7 +1434,6 @@ public class ReportDefinition extends ReportWrapper implements Serializable { boolean isCYMBALScript = false; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); String dbType = remDbInfo.getDBType(dbInfo); if (dbType.equals("DAYTONA") && !(nextToken.toUpperCase().equals("SELECT"))) { isCYMBALScript = true; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java index 5db298b8..dbc68008 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java @@ -72,12 +72,16 @@ import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component public class ReportSchedule extends RaptorObject implements Serializable{ /** @@ -87,6 +91,14 @@ public class ReportSchedule extends RaptorObject implements Serializable{ private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportSchedule.class); + private static RemDbInfo remDbInfo; + + @SuppressWarnings("static-access") + @Autowired + public void setRemDbInfo(RemDbInfo remDbInfo) { + this.remDbInfo = remDbInfo; + } + private String reportID = null; private String scheduleUserID = null; @@ -135,6 +147,10 @@ public class ReportSchedule extends RaptorObject implements Serializable{ private Vector emailToRoles = new Vector(); + public ReportSchedule() { + super(); + } + public ReportSchedule(String reportID, String scheduleUserID, boolean loadData, HttpServletRequest request) { super(); @@ -539,7 +555,6 @@ public class ReportSchedule extends RaptorObject implements Serializable{ int posAnd = 0; if (!isNull(dbInfo) && (!dbInfo.equals(AppConstants.DB_LOCAL))) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); dbType = remDbInfo.getDBType(dbInfo); } catch (Exception ex) { throw new RaptorException(ex); @@ -1321,7 +1336,7 @@ public class ReportSchedule extends RaptorObject implements Serializable{ stmt = connection.prepareStatement(sql); stmt.setString(1,scheduleId); rs = stmt.executeQuery(); - //Writer out = null; + Writer out = null; /*if(Globals.isWeblogicServer()) { java.sql.Clob clob = null; if (rs.next()) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java index 3281eee7..af7e6e8c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSON.java @@ -37,6 +37,8 @@ */ package org.onap.portalsdk.analytics.model.definition.wizard; +import org.onap.portalsdk.analytics.xmlobj.SemaphoreList; + public class ColumnEditJSON implements WizardJSON { private String tabId; @@ -69,7 +71,22 @@ public class ColumnEditJSON implements WizardJSON { private Integer colspan; private String displayName; private String displayTotal; + private SemaphoreList semaphoreList; + private String semaphoreId; + + public SemaphoreList getSemaphoreList() { + return semaphoreList; + } + public void setSemaphoreList(SemaphoreList semaphoreList) { + this.semaphoreList = semaphoreList; + } + public String getSemaphoreId() { + return semaphoreId; + } + public void setSemaphoreId(String semaphoreId) { + this.semaphoreId = semaphoreId; + } public String getTabId() { return tabId; } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java index e8238534..b7ddc3b8 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSON.java @@ -49,6 +49,8 @@ public class FormEditJSON implements WizardJSON { private String fieldType; private boolean visible; private boolean groupFormField; + private String lastUpdatedFieldId; + private String defaultValue; private String fieldDefaultSQL; private String fieldSQL; @@ -160,5 +162,12 @@ public class FormEditJSON implements WizardJSON { } + public String getLastUpdatedFieldId() { + return lastUpdatedFieldId; + } + public void setLastUpdatedFieldId(String lastUpdatedFieldId) { + this.lastUpdatedFieldId = lastUpdatedFieldId; + } + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java index 72769e3f..ff8094fd 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -59,10 +59,10 @@ import java.util.TimeZone; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; - import org.apache.commons.lang.time.DateUtils; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.model.base.ChartSeqComparator; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java index 24c46180..f670da40 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntime.java @@ -41,6 +41,7 @@ public class ErrorJSONRuntime { private String errormessage; private String stacktrace; + private boolean allowEdit; public String getErrormessage() { return errormessage; @@ -54,8 +55,12 @@ public class ErrorJSONRuntime { public void setStacktrace(String stacktrace) { this.stacktrace = stacktrace; } - - + public boolean isAllowEdit() { + return allowEdit; + } + public void setAllowEdit(boolean allowEdit) { + this.allowEdit = allowEdit; + } } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java index 3af59e56..f3633a67 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java @@ -70,7 +70,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.regex.Pattern; import org.onap.portalsdk.analytics.error.RaptorRuntimeException; import org.onap.portalsdk.analytics.error.UserDefinedException; @@ -80,6 +80,7 @@ import org.onap.portalsdk.analytics.model.base.IdNameSql; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.ExecuteQuery; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.DataSet; import org.onap.portalsdk.analytics.util.Utils; @@ -139,7 +140,10 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme public static final String FFT_TEXT = "TEXT"; - public static final String FFT_TEXTAREA = "TEXTAREA"; + public static final String FFT_TEXTAREA = "TEXT"; + +// Changed to "TEXT" +// public static final String FFT_TEXTAREA = "TEXTAREA"; public static final String FFT_COMBO_BOX = "COMBO_BOX"; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java index 916791e1..d3d44ac3 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportJSONRuntime.java @@ -544,6 +544,8 @@ public class ReportJSONRuntime { private String formfield_comments; private ArrayList<ColumnHeader> reportDataColumns; private ArrayList<Map<String,Object>> reportDataRows; + private ArrayList<ColumnHeader> reportTotalDataColumns; + private ArrayList<Map<String,Object>> reportTotalDataRows; private int totalRows; private int pageSize; private String sqlWhole; @@ -712,8 +714,18 @@ public class ReportJSONRuntime { public void setHideFormFieldsAfterRun(boolean hideFormFieldsAfterRun) { this.hideFormFieldsAfterRun = hideFormFieldsAfterRun; } - - + public ArrayList<ColumnHeader> getReportTotalDataColumns() { + return reportTotalDataColumns; + } + public void setReportTotalDataColumns(ArrayList<ColumnHeader> reportTotalDataColumns) { + this.reportTotalDataColumns = reportTotalDataColumns; + } + public ArrayList<Map<String, Object>> getReportTotalDataRows() { + return reportTotalDataRows; + } + public void setReportTotalDataRows(ArrayList<Map<String, Object>> reportTotalDataRows) { + this.reportTotalDataRows = reportTotalDataRows; + } } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java index 209ffea1..9f32eeba 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java @@ -51,7 +51,15 @@ public class SearchResultField extends org.onap.portalsdk.analytics.RaptorObject private String confirmationText = null; + private boolean isAuthorized = false; + public boolean isAuthorized() { + return isAuthorized; + } + + public void setAuthorized(boolean isAuthorized) { + this.isAuthorized = isAuthorized; + } public String getConfirmationText() { return confirmationText; @@ -82,13 +90,12 @@ public class SearchResultField extends org.onap.portalsdk.analytics.RaptorObject setColumnId(column.getColumnId()); setDisplayValue(displayValue); setAlignment(column.getAlignment()); + setAuthorized(isAuthorized); if(column.getColumnId().equals("edit")) { -// setDrillDownLink("report_wizard.htm?action=report.edit&c_master="+linkIdValue); setDrillDownLink("report#/report_wizard/"+linkIdValue); setDrillDownImage(column.getLinkImg()); setConfirmationText(null); } else if(column.getColumnId().equals("copy")) { -// setDrillDownLink("report_wizard.htm?action=report.copy&c_master="+linkIdValue); setDrillDownLink("report#/report_wizard/copy/"+linkIdValue); setDrillDownImage(column.getLinkImg()); setConfirmationText(column.getLinkConfirmMsg()); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java index 3a761d84..c13e2ba7 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java @@ -86,11 +86,7 @@ public class SendNotifications { while (rs.next()) { final int v_schedule_id = rs.getInt("schedule_id"); final int offset = get_report_sched_offset(rs.getInt("rep_id"), v_schedule_id); - - if (offset >= p_time_interval) { - continue; - } - + if (offset >= p_time_interval) { continue; } final Date v_touch_date = (Date) schedulerUtil.getSingleResult( "select touch_date from cr_report_email_sent_log where schedule_id = " + v_schedule_id + " and log_id = (select max(log_id) from cr_report_email_sent_log where schedule_id = " @@ -149,13 +145,9 @@ public class SendNotifications { } else { v_formfields = strip_formfields(v_schedule_id, rs.getString("initial_formfields")); } - - final String v_url = - p_system_url + "&r_action=" + v_r_action + "&log_id=" + v_id + "&user_id=" + rs - .getString("user_id") - + "&pdfAttachmentKey=" + v_gen_key + "&download_limit=" + rs.getInt("max_row") - + v_formfields; - + final String v_url = p_system_url + "&r_action=" + v_r_action + "&log_id=" + + v_id + "&user_id=" + rs .getString("user_id") + "&pdfAttachmentKey=" + + v_gen_key + "&download_limit=" + rs.getInt("max_row") + v_formfields; final boolean v_attach_email_yn = shouldSendAttachmentInEmail(v_schedule_id); final String v_email_msg = diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java index 6f55037b..b64f8e07 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java @@ -82,6 +82,7 @@ import org.onap.portalsdk.analytics.model.runtime.ReportFormFields; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.ExcelColorDef; +import org.onap.portalsdk.analytics.util.RemDbInfo; import org.onap.portalsdk.analytics.util.Scheduler; import org.onap.portalsdk.analytics.util.Utils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -358,6 +359,7 @@ public class Globals extends org.onap.portalsdk.analytics.RaptorObject { dbUtils.initializeDbUtils(servletContext); if(!Globals.getSystemType().equals(Globals.ST_GENERIC)) { + RemDbInfo.load(); rdbUtils = (RDbUtils) Class.forName( ANALYTIC_SYSTEM + systemType.toLowerCase() + ".RemoteDbUtils") .newInstance(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java index fcff3183..a3659bab 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java @@ -44,13 +44,23 @@ import javax.servlet.ServletContext; import org.onap.portalsdk.analytics.system.RDbUtils; import org.onap.portalsdk.analytics.system.fusion.adapter.RaptorAdapter; import org.onap.portalsdk.analytics.system.fusion.adapter.SpringContext; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; - +@Component public class RemoteDbUtils implements RDbUtils{ private RaptorAdapter raptorAdapter; + private static RemDbInfo remDbInfo; + + @SuppressWarnings("static-access") + @Autowired + public void setRemDbInfo(RemDbInfo remDbInfo) { + this.remDbInfo = remDbInfo; + } public void initializeDbUtils(ServletContext servletContext) { raptorAdapter = (RaptorAdapter)SpringContext.getApplicationContext().getBean("raptorAdapter"); @@ -59,7 +69,6 @@ public class RemoteDbUtils implements RDbUtils{ public Connection getRemoteConnection(String dbKey) { try { - org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); return remDbInfo.getDBConnection(dbKey); } catch (Exception ex) { ex.printStackTrace(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java index c0f25892..1921d857 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/DateUtils.java @@ -45,13 +45,18 @@ import java.util.Date; import java.util.List; import java.util.TimeZone; +import org.bouncycastle.asn1.dvcs.Data; import org.onap.portalsdk.core.domain.FusionObject; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.portalsdk.core.web.support.AppUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; - +@Component public class DateUtils implements Serializable, FusionObject{ public static final String US_PACIFIC = "US/Pacific"; @@ -67,14 +72,21 @@ public class DateUtils implements Serializable, FusionObject{ private static final String DB_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; private static final String GET_CURRENT_DATE = "getCurrentDate"; + + //@Autowired private static DataAccessService dataAccessService; - public static DataAccessService getDataAccessService() { - return dataAccessService; - } - - public void setDataAccessService(DataAccessService dataAccessService) { - this.dataAccessService = dataAccessService; +// public static DataAccessService getDataAccessService() { +// return dataAccessService; +// } +// +// public void setDataAccessService(DataAccessService dataAccessService) { +// DateUtils.dataAccessService = dataAccessService; +// } + + @Autowired + public DateUtils(DataAccessService dataAccessService) { + DateUtils.dataAccessService = dataAccessService; } /** @@ -124,7 +136,8 @@ public class DateUtils implements Serializable, FusionObject{ * */ public static Date parseUserDate(String dateValue, String inPattern, Long userId) throws Exception{ - User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); +// User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + User user = (User)dataAccessService.getDomainObject(User.class, userId, null); String userTimeZone = null; Long timezoneId = user.getTimeZoneId(); @@ -230,8 +243,8 @@ public class DateUtils implements Serializable, FusionObject{ * */ public static String formatUserDate(String dateValue,String inPattern, Long userId,String outPattern,String requiredTimeZone) throws Exception{ - User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); - + //User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + User user = (User)dataAccessService.getDomainObject(User.class, userId, null); String userTimeZone = null; Long timezoneId = user.getTimeZoneId(); @@ -255,7 +268,8 @@ public class DateUtils implements Serializable, FusionObject{ * */ public static String formatUserDateForDBTimeZone(String dateValue,String inPattern, Long userId,String outPattern) throws Exception{ - User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); +// User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + User user = (User)dataAccessService.getDomainObject(User.class, userId, null); String userTimeZone = null; Long timezoneId = user.getTimeZoneId(); @@ -275,8 +289,11 @@ public class DateUtils implements Serializable, FusionObject{ */ public static Date getCurrentDBDate()throws Exception{ String dbTimeZone = SystemProperties.getProperty(SystemProperties.DATABASE_TIME_ZONE); - List results = (List)getDataAccessService().executeNamedQuery(GET_CURRENT_DATE, null, null); - return parseDate(((Object[])results.get(0))[0]+" "+((Object[])results.get(0))[1],DB_DATE_FORMAT,dbTimeZone); + //List results = (List)getDataAccessService().executeNamedQuery(GET_CURRENT_DATE, null, null); + List results = (List) dataAccessService.executeNamedQuery(GET_CURRENT_DATE, null, null); + /*Object[] currentDate = (Object[]) results.get(0) ; + System.out.println(currentDate[0]);*/ + return parseDate((String)results.get(0),DB_DATE_FORMAT,dbTimeZone); } /** @@ -288,7 +305,8 @@ public class DateUtils implements Serializable, FusionObject{ * @throws Exception */ public static String getCurrentDBDateForUser(String outPattern,Long userId)throws Exception{ - User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + //User user = (User)getDataAccessService().getDomainObject(User.class, userId, null); + User user = (User)dataAccessService.getDomainObject(User.class, userId, null); String userTimeZone = null; Long timezoneId = user.getTimeZoneId(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java index 354d72bc..9791080f 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java @@ -65,12 +65,11 @@ import org.onap.portalsdk.core.web.support.UserUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -@Service("raptorAdapter") +@Service public class RaptorAdapter extends FusionAdapter { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorAdapter.class); - @Autowired private static DataAccessService dataAccessService; public static final int RAPTOR_USER_ID = 20000; // RAPTOR system user id (for auditing purposes) @@ -373,12 +372,13 @@ public class RaptorAdapter extends FusionAdapter { public static DataAccessService getDataAccessService() { - return org.onap.portalsdk.core.web.support.AppUtils.getDataAccessService(); + return dataAccessService; } - public static void setDataAccessService(DataAccessService dataAccessService) { - dataAccessService = dataAccessService; + @Autowired + public void setDataAccessService(DataAccessService dataAccessService) { + this.dataAccessService = dataAccessService; } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index bf7ef0bb..ae9d39a1 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -108,6 +108,7 @@ import org.onap.portalsdk.analytics.xmlobj.DataColumnType; import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.onap.portalsdk.analytics.xmlobj.ObjectFactory; import org.onap.portalsdk.analytics.xmlobj.PredefinedValueList; +import org.onap.portalsdk.analytics.xmlobj.SemaphoreList; import org.onap.portalsdk.core.controller.RestrictedBaseController; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; @@ -115,6 +116,7 @@ import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.onap.portalsdk.core.web.support.UserUtils; import org.owasp.esapi.ESAPI; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -145,7 +147,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { HttpSession session = request.getSession(); User user = UserUtils.getUserSession(request); - + boolean isPageDownload = Boolean.valueOf(request.getParameter(AppConstants.PAGE_DOWNLOAD)); if ("report.download.excel2007.session".equals(actionKey) || "report.download.csv.session".equals(actionKey) || "report.download.excel.session".equals(actionKey) || "report.download.pdf.session".equals(actionKey)) { @@ -193,24 +195,27 @@ public class RaptorControllerAsync extends RestrictedBaseController { : Globals.getDownloadLimit(); if ("report.csv.download".equals(actionKey)) downloadLimit = Globals.getCSVDownloadLimit(); - if(rr != null) { - String sqlWhole = rr.getReportDataSQL(userId, downloadLimit, request); - request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole); + + final boolean isDashboard = (session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID) != null) && + (((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID())); + + if(!isDashboard) + { + String sql_whole = rr.getReportDataSQL(userId, downloadLimit, request); + request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole); } try { OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream()); - + if(rr != null) + //rr.setSinglePageDownload(isPageDownload); if ("report.download.pdf.session".equals(actionKey)) { new PdfReportHandler().createPdfFileContent(request, response, 3); } else if ("report.download.csv.session".equals(actionKey)) { (new ReportHandler()).createCSVFileContent(out, rd, rr, request, response); } else if ("report.download.excel.session".equals(actionKey)) { - new ReportHandler().createExcelFileContent(out, rd, rr, request, response, userId, 3); // 3 - // whole + new ReportHandler().createExcelFileContent(out, rd, rr, request, response, userId, 3); } else { - - new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, userId, 3); // 3 - // whole + new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, userId, 3); } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, @@ -526,6 +531,17 @@ public class RaptorControllerAsync extends RestrictedBaseController { return formFieldGroupsJSON; } + @RequestMapping(value = "report/wizard/clearSession", method = RequestMethod.GET) + public @ResponseBody MessageJSON clearSession(HttpServletRequest request, HttpServletResponse response) { + MessageJSON messageJSON = new MessageJSON(); + removeVariablesFromSession(request); + request.getSession().setAttribute("COPY_REPORT_EVENT", ""); + messageJSON.setMessage("CopyReport Cancelled"); + return messageJSON; + + } + + @RequestMapping(value = "report/wizard/save_formfield_groups_data", method = RequestMethod.POST) public @ResponseBody MessageJSON saveFFGroupsData(@RequestBody FormFieldGroupsJSON formFieldGroupsJSON, HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException { @@ -573,9 +589,18 @@ public class RaptorControllerAsync extends RestrictedBaseController { String fieldId = formEditJSON.getFieldId(); + boolean lastUpdateIdFlag = false; + if (rdef.getFormFieldList() != null) { + + +// fft.getlastUpdatedFieldId() + for (FormFieldType fft : rdef.getFormFieldList().getFormField()) { - if (fft.getFieldId().equals(fieldId)) { + + System.out.println(fft.getFieldId() + " " + fft.getFieldName() + " " + fft.getlastUpdatedFieldId() + " " + formEditJSON.getLastUpdatedFieldId() ); + if (fft.getFieldId().equals(fieldId) && !lastUpdateIdFlag) { + fft.setFieldId(formEditJSON.getLastUpdatedFieldId() != null ? formEditJSON.getLastUpdatedFieldId() : fft.getFieldId()); fft.setFieldName(formEditJSON.getFieldName()); fft.setFieldType(formEditJSON.getFieldType()); fft.setVisible(formEditJSON.isVisible() ? "Y" : "N"); @@ -589,15 +614,35 @@ public class RaptorControllerAsync extends RestrictedBaseController { PredefinedValueList predefinedValueList = new ObjectFactory().createPredefinedValueList(); fft.setPredefinedValueList(predefinedValueList); + fft.setlastUpdatedFieldId("Y"); + lastUpdateIdFlag = true; + List<IdNameBooleanJSON> predefList = formEditJSON.getPredefinedValueList(); if (predefList != null && predefList.size() > 0) { for (IdNameBooleanJSON item : predefList) { fft.getPredefinedValueList().getPredefinedValue().add(item.getId()); } } + int cnt=0; + for (FormFieldType fft1 : rdef.getFormFieldList().getFormField()) { + + if(fft1.getlastUpdatedFieldId().equals("Y")) + { + cnt++; + } + + if(cnt >= 2) + { + for (FormFieldType fft2 : rdef.getFormFieldList().getFormField()) { + fft2.setlastUpdatedFieldId("N"); + } + cnt = 0; + } } } + System.out.println(fft.getFieldId() + " " + fft.getFieldName() + " " + fft.getlastUpdatedFieldId() + " " + formEditJSON.getLastUpdatedFieldId() ); + } } persistReportDefinition(request, rdef); @@ -634,7 +679,18 @@ public class RaptorControllerAsync extends RestrictedBaseController { if(rdef.getFormFieldList()==null || rdef.getFormFieldList().getFormField()==null || rdef.getFormFieldList().getFormField().size()==0) fieldId = "ff1"; else - fieldId = "ff"+(rdef.getFormFieldList().getFormField().size()+1); + { + int maxFormFieldSeq = 0; + for(FormFieldType ffType : rdef.getFormFieldList().getFormField()) + { + if(Integer.parseInt(ffType.getFieldId().substring(2)) > maxFormFieldSeq) + { + maxFormFieldSeq = Integer.parseInt(ffType.getFieldId().substring(2)); + } + } + maxFormFieldSeq++; + fieldId = "ff"+ maxFormFieldSeq; + } FormFieldType currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",""); currField.setFieldId(fieldId); currField.setFieldName(formEditJSON.getFieldName()); @@ -676,6 +732,8 @@ public class RaptorControllerAsync extends RestrictedBaseController { if (rdef != null) { String colId = columnEditJSON.getColId(); List<DataColumnType> reportColumnList = rdef.getAllColumns(); + rdef.setSemaphoreList(columnEditJSON.getSemaphoreList()); + for (DataColumnType reportColumnType : reportColumnList) { @@ -702,6 +760,8 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType()); if(columnEditJSON.getDisplayTotal()!=null) reportColumnType.setDisplayTotal(columnEditJSON.getDisplayTotal()); + reportColumnType.setSemaphoreId(columnEditJSON.getSemaphoreId()); + } @@ -745,6 +805,9 @@ public class RaptorControllerAsync extends RestrictedBaseController { newReport = true; System.out.println("&&&&&&&&&&&&&&&&&&&&&& CHECK Report Type " + (AppUtils.nvl(rdef.getReportType()).length() <= 0)); + + rdef.setReportType(definitionJSON.getReportType()); + if (AppUtils.nvl(rdef.getReportType()).length() <= 0) { rdef.setReportType(AppConstants.RT_LINEAR); System.out.println("&&&&&&&&&&&&&&&&&&&&&& ADDED Report Type in session "); @@ -899,6 +962,16 @@ public class RaptorControllerAsync extends RestrictedBaseController { messageJSON.setAnyStacktrace((newReport ? " New Report info is added to Session " : rdef.getReportID() + "- is Modified and added to session and DB.")); + if(rdef.getReportType() != null) { + if(rdef.getReportType().equals("Dashboard") && id.equals("Create")) { + messageJSON.setAnyStacktrace(rdef.getReportID() + "- is Modified and added to session and DB."); + } + } + if(request.getSession().getAttribute("COPY_REPORT_EVENT") == "true" || (rdef.getReportType().equals("Dashboard") && id.equals("Create")) ) { + removeVariablesFromSession(request); + request.getSession().setAttribute("COPY_REPORT_EVENT", ""); + } + } catch (Exception ex) { messageJSON.setMessage("Error occured while saving definition Tab"); messageJSON.setAnyStacktrace(getStackTrace(ex)); @@ -1015,6 +1088,10 @@ public class RaptorControllerAsync extends RestrictedBaseController { Globals.initializeSystem(servletContext); } if (rdef != null) { + if(rdef.getSemaphoreList() != null) { + wizardJSON.setSemaphoreList(rdef.getSemaphoreList()); + }else { wizardJSON.setSemaphoreList(new SemaphoreList()); } + wizardJSON.setTabId("ColEdit"); wizardJSON.setTabName("Column Edit"); @@ -1049,6 +1126,8 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setColspan(reportColumnType.getColspan()==null?null:reportColumnType.getColspan()); wizardJSON.setDisplayName(reportColumnType.getDisplayName()); wizardJSON.setDisplayTotal(reportColumnType.getDisplayTotal()); + wizardJSON.setSemaphoreId(reportColumnType.getSemaphoreId()); + } } } else { @@ -1673,7 +1752,9 @@ public class RaptorControllerAsync extends RestrictedBaseController { QueryResultJSON queryResultJSON = new QueryResultJSON(); queryResultJSON.setQuery(queryJSON.getQuery()); String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery()); + if(validate) { rdef.parseReportSQL(query,validate); + } queryResultJSON.setQuery(query); queryResultJSON.setTotalRows(ds.getRowCount()); @@ -1796,7 +1877,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { @RequestMapping(value = "save_chart", method = RequestMethod.POST) public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request, - HttpServletResponse response) throws IOException { + HttpServletResponse response) { //ReportRuntime reportRuntime; //reportRuntime = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); // changing ReportDefinition reportDefn; @@ -1828,7 +1909,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { List<DataColumnType> reportCols = reportDefn.getAllColumns(); for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) { - DataColumnType dct = (DataColumnType) iter.next(); + DataColumnType dct = iter.next(); if (dct.getColId().equals(domainAxis)) { dct.setColOnChart(AppConstants.GC_LEGEND); } else { @@ -1837,14 +1918,14 @@ public class RaptorControllerAsync extends RestrictedBaseController { } CategoryAxisJSON categoryAxisJSON = chartJSON.getCategoryAxisJSON(); - String categoryAxis = null; + String categoryAxis; categoryAxis = (categoryAxisJSON != null ? categoryAxisJSON.getValue() : ""); reportCols = reportDefn.getAllColumns(); for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) { - DataColumnType dct = (DataColumnType) iter.next(); + DataColumnType dct = iter.next(); if (dct.getColId().equals(categoryAxis)) { dct.setChartSeries(true); } else { @@ -1867,7 +1948,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { String rangeLineType = AppUtils.nvl(rangeAxisJSON.getRangeLineType()); rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) { - DataColumnType dct = (DataColumnType) iterator.next(); + DataColumnType dct = iterator.next(); if (dct.getColId().equals(rangeAxis)) { if(removeRangeAxisMap.contains(rangeAxis)) dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included @@ -1947,7 +2028,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportDefn.setRightMargin(chartJSON.getCommonChartOptions().getRightMargin()); for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) { - DataColumnType dct = (DataColumnType) iterator.next(); + DataColumnType dct = iterator.next(); if (!(AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND) || (dct.getChartSeq() != null && dct.getChartSeq() > 0) || dct.isChartSeries())) { dct.setChartSeq(-1); @@ -1970,7 +2051,6 @@ public class RaptorControllerAsync extends RestrictedBaseController { } } - public String getViewName() { return viewName; } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/AppConstants.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/AppConstants.java index cd3fdd39..dc90de77 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/AppConstants.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/AppConstants.java @@ -625,6 +625,7 @@ public class AppConstants { public static final String MYSQL = "mysql"; public static final String ORACLE = "oracle"; public static final String POSTGRESQL = "postgresql"; + public static final String PAGE_DOWNLOAD = "page_download"; // COLORS to be used in Excel public static String Aqua = "#00FFFF"; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/CachingUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/CachingUtils.java new file mode 100644 index 00000000..66bfb697 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/CachingUtils.java @@ -0,0 +1,96 @@ + +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.util; + +import org.apache.commons.collections4.map.LRUMap; + +public class CachingUtils { + + private static LRUMap<String, String> pageSQLCahce; + private static LRUMap<String, String> reportSqlCache; + private static LRUMap<String, Integer> totalRowsCount; + + public static String getPageSql(String sql) { + return pageSQLCahce.get(sql); + + } + + public static void putPageSql(String sql, String pageSql) { + if (pageSQLCahce == null) { + pageSQLCahce = new LRUMap<>(); + } + pageSQLCahce.put(sql, pageSql); + } + + public static void putReportSql(String sql, String reportSql) { + if (reportSqlCache == null) { + reportSqlCache = new LRUMap<>(); + } + reportSqlCache.put(sql, reportSql); + } + + public static String getReportSql(String sql) { + return reportSqlCache.get(sql); + } + + public static boolean isReportSqlExists(String sql) { + if(reportSqlCache != null) { + return reportSqlCache.containsKey(sql); + } + return false; + } + + public static int getTotalRowsCount(String sql) { + return totalRowsCount.get(sql); + } + + public static void cacheTotalRowCount(String sql, int count) { + if (totalRowsCount == null) { + totalRowsCount = new LRUMap<>(); + } + totalRowsCount.put(sql, count); + } + + public static boolean isTotalCountAvailable(String sql) { + if (totalRowsCount != null) { + return totalRowsCount.containsKey(sql); + } + return false; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/EmailUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/EmailUtils.java new file mode 100644 index 00000000..61ac90c2 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/EmailUtils.java @@ -0,0 +1,183 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.mail.javamail.MimeMessagePreparator; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.core.io.FileSystemResource; + + +public class EmailUtils { + + public EmailUtils(){ + super(); + mailSender = new JavaMailSenderImpl(); + mailSender.setProtocol("smtp"); + mailSender.setHost(SystemProperties.getProperty(SystemProperties.MAIL_SERVER_HOST)); + mailSender.setPort(Integer.parseInt(SystemProperties.getProperty(SystemProperties.MAIL_SERVER_PORT))); + } + + private JavaMailSenderImpl mailSender; + + public void sendEmailWithAttachment(String subj, String mesg, String[] toList, String[] ccList, String[] filePathAndName) throws RaptorException { + String from = AppUtils.getDefaultEmailSender(); + List<MailAttachment> mailAttachList = new ArrayList<MailAttachment>(); + + for (int i = 0; i < filePathAndName.length; i++) { + MailAttachment mailAttachment = new MailAttachment(); + mailAttachment.setAttachmentType(MailAttachment.FILE_ATTACHMENT); + + String fileName = filePathAndName[i].substring(filePathAndName[i].lastIndexOf("/") + 1); + mailAttachment.setFileName(fileName); + mailAttachment.setFilePathName(filePathAndName[i]); + + mailAttachList.add(mailAttachment); + } + + notifyWithAttachments(mesg, toList, from, subj, ccList, null, mailAttachList, true); + + } + + public void sendEmailNoAttachment(String subj, String mesg, String[] toList, String[] ccList) throws RaptorException{ + String from = AppUtils.getDefaultEmailSender(); + notify(mesg, toList, from, subj, ccList, null, true); + } + + + public void notify(String message, String to, String from, boolean contentTypeHtml) { + notify(message, to, from, null, null, null, contentTypeHtml); + } + + public void notify(String message, String to, String from, String subject, boolean contentTypeHtml) { + notify(message, to, from, subject, null, null, contentTypeHtml); + } + + public void notify(String message, String to, String from, String subject, String cc, String bcc, boolean contentTypeHtml) { + String[] toList = new String[1]; + String[] ccList = null; + String[] bccList = null; + if (cc != null) { + ccList = new String[1]; + ccList[0] = cc; + } + if (bcc != null) { + bccList = new String[1]; + bccList[0] = bcc; + } + toList[0] = to; + notify(message, toList, from, subject, ccList, bccList, contentTypeHtml); + } + + public void notify(String message, String[] to, String from, String subject, String[] cc, String[] bcc, boolean contentTypeHtml) { + final MimeMessagePreparator messagePreparator = getMessagePreparator(message, to, from, subject, cc, bcc, null, contentTypeHtml); + Thread mailerThread = new Thread() { + public void run() { + getMailSender().send(messagePreparator); + } + }; + mailerThread.start(); + } + + public void notifyWithAttachments(String message, String[] to, String from, String subject, String[] cc, + String[] bcc, List mailAttachments, boolean contentTypeHtml) { + final MimeMessagePreparator messagePreparator = getMessagePreparator(message, to, from, subject, cc, bcc, + mailAttachments, contentTypeHtml); + Thread mailerThread = new Thread() { + public void run() { + getMailSender().send(messagePreparator); + } + }; + mailerThread.start(); + } + + private static MimeMessagePreparator getMessagePreparator(final String message, final String[] to, final String from, + final String subject, final String[] cc, final String[] bcc, final List mailAttachments, final boolean contentTypeHtml) { + final MimeMessagePreparator messagePreparator = new MimeMessagePreparator() { + public void prepare(MimeMessage mimeMessage) throws MessagingException { + MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); + helper.setFrom(from); + helper.setTo(to); + helper.setText(message, contentTypeHtml); + if (subject != null) { + helper.setSubject(subject); + } + if (cc != null) { + System.out.println(cc); + helper.setCc(cc); + } + if (bcc != null) { + helper.setBcc(bcc); + } + if (mailAttachments != null && mailAttachments.size() > 0) { + for (int i = 0; i < mailAttachments.size(); i++) { + MailAttachment mailAttachment = (MailAttachment) mailAttachments.get(i); + if (mailAttachment.getAttachmentType() == MailAttachment.FILE_ATTACHMENT) { + helper.addAttachment(mailAttachment.getFileName(), new FileSystemResource(new File(mailAttachment + .getFilePathName()))); + } else if (mailAttachment.getAttachmentType() == MailAttachment.INLINE_ATTACHMENT) { + helper.addInline(mailAttachment.getFileName(), new FileSystemResource(new File(mailAttachment + .getFilePathName()))); + } + } + } + } + }; + return messagePreparator; + } + + public JavaMailSenderImpl getMailSender() { + return mailSender; + } + + public void setMailSender(JavaMailSenderImpl mailSender) { + this.mailSender = mailSender; + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/MailAttachment.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/MailAttachment.java new file mode 100644 index 00000000..82fa6ade --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/MailAttachment.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.util; + +public class MailAttachment { + public static int INLINE_ATTACHMENT = 1; + public static int FILE_ATTACHMENT = 2; + + private String fileName; + private String filePathName; + private int attachmentType = 1; + + public MailAttachment() { + super(); + // TODO Auto-generated constructor stub + } + + public int getAttachmentType() { + return attachmentType; + } + + public void setAttachmentType(int attachmentType) { + this.attachmentType = attachmentType; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFilePathName() { + return filePathName; + } + + public void setFilePathName(String filePath) { + this.filePathName = filePath; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/RemDbInfo.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/RemDbInfo.java index 57c1e31d..56e117f3 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/RemDbInfo.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/RemDbInfo.java @@ -39,53 +39,35 @@ package org.onap.portalsdk.analytics.util; import java.sql.Connection; import java.util.HashMap; - -import javax.servlet.ServletContext; - import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; -import org.onap.portalsdk.analytics.system.fusion.adapter.RaptorAdapter; -import org.onap.portalsdk.analytics.system.fusion.adapter.SpringContext; - +import org.springframework.stereotype.Component; import com.mchange.v2.c3p0.ComboPooledDataSource; +@Component public class RemDbInfo { - private HashMap remDbMap = null; - private HashMap remDbTypeMap = null; - private HashMap remDbConnectionMap = null; - - public RemDbInfo() throws Exception { - if (remDbMap == null) { - load(); - } - } + private static HashMap remDbMap = null; + private static HashMap remDbTypeMap = null; + private static HashMap remDbConnectionMap = null; - private RaptorAdapter raptorAdapter; + public static void load() { + if(remDbMap!=null) + return; - - public void initializeDbUtils(ServletContext servletContext) { - raptorAdapter = (RaptorAdapter)SpringContext.getApplicationContext().getBean("raptorAdapter"); - } // initializeDbUtils - - public void load() throws Exception { remDbMap = new HashMap(); remDbTypeMap = new HashMap(); remDbConnectionMap = new HashMap(); try { - //String query = " SELECT a.SCHEMA_ID, a.SCHEMA_DESC, DATASOURCE_TYPE, rownum id FROM SCHEMA_INFO a " + - // " where schema_id = 'local' union " + - // " SELECT a.SCHEMA_ID, a.SCHEMA_DESC, DATASOURCE_TYPE, (rownum+1) id FROM SCHEMA_INFO a " + - // " where schema_id <> 'local' order by id "; String query = Globals.getRemoteDbSchemaSql(); DataSet ds = null; Globals.getDbUtils(); ds = DbUtils.executeQuery(query); - String prefix = "", desc = "", dbType = "", connectionUrl = "", username = "", password = "", driver_class = ""; + String dbId = "", desc = "", dbType = "", connectionUrl = "", username = "", password = "", driver_class = ""; if(ds.getRowCount() > 0) { for (int i = 0; i < ds.getRowCount(); i++) { - prefix = ds.getItem(i, 0); + dbId = ds.getItem(i, 0); desc = ds.getItem(i, 1); dbType = ds.getItem(i, 2); connectionUrl = ds.getItem(i, 3); @@ -98,44 +80,40 @@ public class RemDbInfo { cpds.setJdbcUrl( connectionUrl); cpds.setUser(username); cpds.setPassword(password); - - - - - remDbMap.put(prefix, desc); - remDbTypeMap.put(prefix, dbType); - remDbConnectionMap.put(prefix, cpds); - } - } else { - remDbMap.put("local", "local"); - remDbTypeMap.put("local", Globals.getDBType()); - remDbConnectionMap.put("local", raptorAdapter.getConnection()); + cpds.setMinPoolSize(Integer.parseInt(ds.getItem(i, 7))); + cpds.setMaxPoolSize(Integer.parseInt(ds.getItem(i, 8))); + cpds.setIdleConnectionTestPeriod(Integer.parseInt(ds.getItem(i, 9))); + + remDbMap.put(dbId, desc); + remDbTypeMap.put(dbId, dbType); + remDbConnectionMap.put(dbId, cpds); + } } } catch (Exception e) {} } - public String getDesc(String prefix) { - if ((remDbMap != null) && (remDbMap.containsKey(prefix))) { - return (String) remDbMap.get(prefix); + public String getDesc(String dbId) { + if ((remDbMap != null) && (remDbMap.containsKey(dbId))) { + return (String) remDbMap.get(dbId); } return ""; } - public String getDBType(String prefix) { - if ((remDbTypeMap != null) && (remDbTypeMap.containsKey(prefix))) { - return (String) remDbTypeMap.get(prefix); + public String getDBType(String dbId) { + if ((remDbTypeMap != null) && (remDbTypeMap.containsKey(dbId))) { + return (String) remDbTypeMap.get(dbId); } return ""; } - public Connection getDBConnection(String prefix) { - if ((remDbConnectionMap != null) && (remDbConnectionMap.containsKey(prefix))) { + public Connection getDBConnection(String dbId) { + if ((remDbConnectionMap != null) && (remDbConnectionMap.containsKey(dbId))) { try { - return ((ComboPooledDataSource) remDbConnectionMap.get(prefix)).getConnection(); + return ((ComboPooledDataSource) remDbConnectionMap.get(dbId)).getConnection(); } catch (Exception ex) { ex.printStackTrace(); return null; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/HtmlFormatter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/HtmlFormatter.java index ed5276b7..7b5f548b 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/HtmlFormatter.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/HtmlFormatter.java @@ -37,8 +37,11 @@ */ package org.onap.portalsdk.analytics.view; +import org.json.JSONObject; import org.onap.portalsdk.analytics.RaptorObject; +import com.google.gson.JsonObject; + public class HtmlFormatter extends RaptorObject { private boolean bold = false; @@ -173,6 +176,28 @@ public class HtmlFormatter extends RaptorObject { return sb.toString(); } // generateStyleHtml + + public String generateJsonHtmlStyle() { + JSONObject style = new JSONObject(); + if (isBold()) + style.put("font-weight", "bold"); + if (isItalic()) + style.put("font-style", "italic"); + if (isUnderline()) + style.put("text-decoration", "underline"); + if(getBgColor().length()>0) + style.put("background-color", getBgColor()); + if (getFontColor().length() > 0) + style.put("color", getFontColor()); + if (getFontFace().length() > 0) + style.put("font-family", getFontFace()); + if (getFontSize().length() > 0) + style.put("font-size", getFontSize() + "px"); + if (getAlignment().length() > 0) + style.put("text-align",getAlignment()); + return style.toString(); + } + public String generateStyleForZK() { StringBuffer sb = new StringBuffer(); @@ -197,9 +222,9 @@ public class HtmlFormatter extends RaptorObject { } // generateStyleHtml public String formatValue(String value) { - String style = generateStyleHtml(); + String style = generateJsonHtmlStyle(); if (style.length() > 0) - return "<font" + style + ">" + value + "</font>"; + return style; else return value; } // formatValue diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/xmlobj/FormFieldType.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/xmlobj/FormFieldType.java index 79e6994d..86693bd6 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/xmlobj/FormFieldType.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/xmlobj/FormFieldType.java @@ -83,6 +83,7 @@ import javax.xml.datatype.XMLGregorianCalendar; * <element name="dependsOn" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="groupFormField" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/> * <element name="multiSelectListSize" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="lastUpdatedFieldId" type="{http://www.w3.org/2001/XMLSchema}string minOccurs="0"/> * </sequence> * <attribute name="fieldId" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> @@ -112,7 +113,8 @@ import javax.xml.datatype.XMLGregorianCalendar; "predefinedValueList", "dependsOn", "groupFormField", - "multiSelectListSize" + "multiSelectListSize", + "lastUpdatedFieldId" }) public class FormFieldType { @@ -127,6 +129,10 @@ public class FormFieldType { protected String mandatory; protected String defaultValue; protected Integer orderBySeq; + @XmlElement(defaultValue = "ff0") + protected String lastUpdatedFieldId = "N"; + + protected String fieldSQL; protected String fieldDefaultSQL; @XmlSchemaType(name = "date") @@ -624,5 +630,14 @@ public class FormFieldType { public void setFieldId(String value) { this.fieldId = value; } + + + public String getlastUpdatedFieldId() { + return lastUpdatedFieldId; + } + + public void setlastUpdatedFieldId(String lastUpdatedFieldId) { + this.lastUpdatedFieldId = lastUpdatedFieldId; + } } |