diff options
author | 2019-12-16 15:37:23 -0500 | |
---|---|---|
committer | 2020-01-14 10:02:31 -0500 | |
commit | 28af72fc23a1e0cb67e1ac1b5fac6b6d9020270a (patch) | |
tree | 490dc3652bccb7e8752ed8a761fcc6950acb91fe /ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime | |
parent | b51640fc222a61869c26c9fc9a5fe5034f6f39b4 (diff) |
Resolved null-pointer-exception while running raptor test cases
Issue-ID: PORTAL-725
Change-Id: I31b57e200b98e616f32f73e1b6a14682555fca94
Signed-off-by: mravula <mr257h@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime')
2 files changed, 136 insertions, 259 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/DashboardRunJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/DashboardRunJSON.java new file mode 100644 index 00000000..a645f6d5 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/DashboardRunJSON.java @@ -0,0 +1,103 @@ +/* + * ============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.runtime; + +import java.util.TreeMap; + +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; + +public class DashboardRunJSON { + + private String reportId; + private FormFieldList formFieldList; + private String formFieldGroupsJSON; + private String dashboardLayoutJSON; + private TreeMap reportsFromDashBoardHTML; + private String message; + private String errorMessage; + private String errorStackTrace; + + public String getReportId() { + return reportId; + } + public void setReportId(String reportId) { + this.reportId = reportId; + } + public FormFieldList getFormFieldList() { + return formFieldList; + } + public void setFormFieldList(FormFieldList formFieldList) { + this.formFieldList = formFieldList; + } + public String getFormFieldGroupsJSON() { + return formFieldGroupsJSON; + } + public void setFormFieldGroupsJSON(String formFieldGroupsJSON) { + this.formFieldGroupsJSON = formFieldGroupsJSON; + } + public String getDashboardLayoutJSON() { + return dashboardLayoutJSON; + } + public void setDashboardLayoutJSON(String dashboardLayoutJSON) { + this.dashboardLayoutJSON = dashboardLayoutJSON; + } + public TreeMap getReportsFromDashBoardHTML() { + return reportsFromDashBoardHTML; + } + public void setReportsFromDashBoardHTML(TreeMap reportsFromDashBoardHTML) { + this.reportsFromDashBoardHTML = reportsFromDashBoardHTML; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public String getErrorMessage() { + return errorMessage; + } + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + public String getErrorStackTrace() { + return errorStackTrace; + } + public void setErrorStackTrace(String errorStackTrace) { + this.errorStackTrace = errorStackTrace; + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index 4b72502f..73387b20 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -645,6 +645,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(isGoBackAction && rd!=null) return rd; if (rd == null) { // Commented So that Data is refreshed from DB again if (getReportDataSize() < 0) + if (pageNo > 0) + pageNo = 0; + if (getReportType().equals(AppConstants.RT_CROSSTAB)) rd = loadCrossTabReportData(pageNo, userId, downloadLimit, request, download); else if (getReportType().equals(AppConstants.RT_LINEAR)) @@ -2088,66 +2091,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return this.cr.getDbInfo(); } -// private String fixSQL(StringBuffer sql) { -// int pos = 0; -// int pos_f_format = 0; -// int pos_t_format = 0; -// int pos_alias = 0; -// String format = ""; -// String alias = null; -// if(sql.indexOf("SELECT", 7)!= -1) { -// pos = sql.indexOf("SELECT", 7); -// if(sql.indexOf("TO_CHAR", pos)!= -1){ -// pos = sql.indexOf("TO_CHAR", pos); -// if(sql.indexOf("999",pos)!= -1) { -// pos = sql.indexOf("999",pos); -// pos_f_format = sql.lastIndexOf(", '", pos); -// if(pos_f_format == -1 || (pos - pos_f_format > 10)) { -// pos_f_format = sql.lastIndexOf(",'", pos); -// pos_f_format -= 1; -// } -// pos = pos_f_format; -// if(sql.indexOf("')", pos)!= -1) { -// pos_t_format = sql.indexOf("')", pos); -// //debugLogger.debug("pos_t - " + pos_t_format + " " + pos); -// if(pos_t_format == -1 || (pos_t_format - pos > 20)) { -// pos_t_format = sql.indexOf("' )", pos); -// pos_t_format += 3; -// } -// else if (pos_t_format != -1) -// pos_t_format += 2; -// format = sql.substring(pos_f_format+3, pos_t_format); -// //alias = sql.substring(pos_t_format+3, pos_t_format+6); -// pos_alias = sql.indexOf(" ", pos_t_format); -// alias = sql.substring(pos_alias+1, pos_alias+4); -// } -// } -// } -// -// if(sql.indexOf(alias)!=-1) { -// pos = sql.indexOf(alias); -// //debugLogger.debug(pos + " " + alias.length()+1 + "\n" + sql); -// sql.delete(pos,pos+4); -// sql.insert(pos, "TO_NUMBER("+alias+", '"+format+"')),'"+ format + "')"); -// pos = sql.lastIndexOf("SUM", pos); -// if(pos==-1) -// pos = sql.lastIndexOf("AVG", pos); -// else if (pos==-1) -// pos = sql.lastIndexOf("COUNT", pos); -// else if (pos == -1) -// pos = sql.lastIndexOf("STDDEV", pos); -// else if (pos == -1) -// pos = sql.lastIndexOf("VARIANCE", pos); -// sql.insert(pos, "TO_CHAR ("); -// } -// -// } -// -// //debugLogger.debug("Alias|" + alias + "| Format " + format); -// //debugLogger.debug(sql.toString()); -// return sql.toString(); -// } // FixSQL - public String parseReportSQL(String sql) throws RaptorException { StringBuffer parsedSQL = new StringBuffer(); @@ -3009,210 +2952,41 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } - private String parseAndFillOtherFormfieldValues(HttpServletRequest request, String SQL, String userId, ArrayList<FormFieldJSON> formFieldJSONList) { + private String parseAndFillOtherFormfieldValues(HttpServletRequest request, String SQL, String userId, + ArrayList<FormFieldJSON> formFieldJSONList) { ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>(); - String selectedValue = ""; - String displayName = ""; - for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { - FormFieldJSON ffJSON = (FormFieldJSON) iter1.next(); - displayName = ffJSON.getFieldDisplayName(); - ArrayList<IdNameValue> formfieldvalues = ffJSON.getFormFieldValues(); - for (int i = 0; i< formfieldvalues.size(); i++) { - IdNameValue formfieldItem = formfieldvalues.get(i); - if(formfieldItem.isDefaultValue()) { - selectedValue = formfieldItem.getId(); - } + String selectedValue = ""; + String displayName = ""; + for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { + FormFieldJSON ffJSON = (FormFieldJSON) iter1.next(); + String fieldId = ffJSON.getFieldId(); + displayName = ffJSON.getFieldDisplayName(); + if (request.getParameter(fieldId) != null && request.getParameter(fieldId).length() > 0) { + if (ffJSON.getFieldType().equals(FormField.FFT_LIST_MULTI) + || ffJSON.getFieldType().equals(FormField.FFT_CHECK_BOX)) { + try { + selectedValue = formatListValue(displayName, Utils.oracleSafe(request.getParameter(fieldId)), + null, false, true, null, null); + } catch (RaptorException e) { + e.printStackTrace(); } - SQL = Utils.replaceInString(SQL, "["+displayName+"]", selectedValue); + } else { + selectedValue = "'" + request.getParameter(fieldId) + "'"; } - return SQL; - + } else { + ArrayList<IdNameValue> formfieldvalues = ffJSON.getFormFieldValues(); + for (int i = 0; i < formfieldvalues.size(); i++) { + IdNameValue formfieldItem = formfieldvalues.get(i); + if (formfieldItem.isDefaultValue()) { + selectedValue = formfieldItem.getId(); + } + } + } + SQL = Utils.replaceInString(SQL, "[" + displayName + "]", selectedValue); + } + return SQL; } -// private void refreshFormFieldsWithLatestValue(HttpServletRequest request, String userId, FormField ff_src, ArrayList<FormFieldJSON> formFieldJSONList) { -// ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>(); -// List<String> requestValueList = null; -// IdNameList lookup = null; -// lookup = ff_src.getLookupList(); -// IdNameSql lu = (IdNameSql) lookup; -// String SQL = "" ; -// String oldSQL = ""; -// String oldDefaultSQL = ""; -// String defaultSQL = ""; -// IdNameList lookupList = null; -// if(lu != null) { -// SQL = lu.getSql(); -// oldSQL = lu.getSql(); -// oldDefaultSQL = lu.getDefaultSQL(); -// defaultSQL = lu.getDefaultSQL(); -// } -// boolean readOnly = false; -// for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { -// FormFieldJSON ffJSON = (FormFieldJSON) iter1.next(); -// if((ffJSON.getFieldId().equals(ff_src.getFieldName())) && ffJSON.isVisible()) { -// for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) { -// formFieldValues = new ArrayList<IdNameValue>(); -// FormField ff = (FormField) iter.next(); -// if(!ff.getFieldName().equals(ff_src.getFieldName())) { -// //IdNameList lookup = null; -// //lookup = ff.getLookupList(); -// String selectedValue = ""; -// -// -// -// String [] requestParam = request.getParameterValues(ff.getFieldName()); -// if(requestParam != null) { -// requestValueList = Arrays.asList(request.getParameterValues(ff.getFieldName())); -// -// } else { -// requestValueList = new ArrayList<String>(); -// } -// -// -// if(nvl(ff_src.getBaseSQL()).length()>0 && ff_src.getBaseSQL().indexOf("["+ff.getFieldDisplayName() +"]")!= -1) { -// if(lookup!=null) { -// try { -// if(!ff_src.hasPredefinedList) { -// String formatSelected = null; -// if(ff_src.getFieldType().equals(FormField.FFT_LIST_MULTI) || ff_src.getFieldType().equals(FormField.FFT_CHECK_BOX)) { -// formatSelected = formatSelectedItems(requestValueList, ff_src.getFieldType()); -// } else -// formatSelected = requestValueList.size()>0?requestValueList.get(0):""; -// SQL = Utils.replaceInString(SQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected); -// defaultSQL = Utils.replaceInString(defaultSQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected); -// defaultSQL = parseAndFillWithCurrentValues(request, defaultSQL, ff_src); -// defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId); -// SQL = parseAndFillReq_Session_UserValues(request, SQL, userId); -// SQL = parseAndFillWithCurrentValues(request, SQL, ff_src); -// -// } -// } catch (Exception ex) { -// ex.printStackTrace(); -// } -// -// } -// -// } -// } -// } -// -// if(nvl(ff_src.getBaseSQL()).length()>0) { -// lookup = new IdNameSql(-1,SQL,defaultSQL); -// lookupList = lookup; -// try { -// lookup.loadUserData(0, "", ff_src.getDbInfo(), ff_src.getUserId()); -// } catch (Exception e ){ -// e.printStackTrace(); //throw new RaptorRuntimeException(e); -// } -// if(!ff_src.hasPredefinedList) { -// lookup.trimToSize(); -// for (lookup.resetNext(); lookup.hasNext();) { -// IdNameValue value = lookup.getNext(); -// readOnly = value.isReadOnly(); -// formFieldValues.add(value); -// } -// } -// ffJSON.setFormFieldValues(formFieldValues); -// } -// if(!ff_src.hasPredefinedList) { -// if(oldSQL != null && !oldSQL.equals("")) { -// ((IdNameSql)lookup).setSQL(oldSQL); -// } -// if(oldDefaultSQL != null && !oldDefaultSQL.equals("")) { -// ((IdNameSql)lookup).setDefaultSQL(oldDefaultSQL); -// } -// } -// -// } -// } -// -// } - - -// private void triggerOtherFormFieldsWithThisValue(HttpServletRequest request, String userId, FormField ff_src, ArrayList<String> requestValueList, ArrayList<FormFieldJSON> formFieldJSONList) { -// ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>(); -// //ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>(); -// for (Iterator iter = reportFormFields.iterator(); iter.hasNext();) { -// formFieldValues = new ArrayList<IdNameValue>(); -// FormField ff = (FormField) iter.next(); -// if(!ff_src.getFieldName().equals(ff.getFieldName())) { -// for (Iterator iter1 = formFieldJSONList.iterator(); iter1.hasNext();) { -// FormFieldJSON ffJSON = (FormFieldJSON) iter1.next(); -// if(ffJSON.getFieldId().equals(ff.getFieldName()) && ffJSON.isVisible()) { -// if(nvl(ff.getBaseSQL()).length()>0 && ff.getBaseSQL().indexOf("["+ff_src.getFieldDisplayName() +"]")!= -1) { -// IdNameList lookup = null; -// lookup = ff.getLookupList(); -// String selectedValue = ""; -// String oldSQL = ""; -// String oldDefaultSQL = ""; -// IdNameList lookupList = null; -// boolean readOnly = false; -// if(lookup!=null) { -// try { -// if(!ff.hasPredefinedList) { -// IdNameSql lu = (IdNameSql) lookup; -// String SQL = lu.getSql(); -// oldSQL = lu.getSql(); -// oldDefaultSQL = lu.getDefaultSQL(); -// String defaultSQL = lu.getDefaultSQL(); -// String formatSelected = null; -// if(ff_src.getFieldType().equals(FormField.FFT_LIST_MULTI) || ff_src.getFieldType().equals(FormField.FFT_CHECK_BOX)) { -// formatSelected = formatSelectedItems(requestValueList, ff.getFieldType()); -// } -// else -// formatSelected = requestValueList.size()>0?requestValueList.get(0):""; -// SQL = Utils.replaceInString(SQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected); -// defaultSQL = Utils.replaceInString(defaultSQL, "["+ff_src.getFieldDisplayName()+"]", formatSelected); -// defaultSQL = parseAndFillWithCurrentValues(request, defaultSQL, ff_src); -// defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId); -// SQL = parseAndFillReq_Session_UserValues(request, SQL, userId); -// SQL = parseAndFillWithCurrentValues(request, SQL, ff_src); -// lookup = new IdNameSql(-1,SQL,defaultSQL); -// lookupList = lookup; -// try { -// lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId()); -// } catch (Exception e ){ -// e.printStackTrace(); //throw new RaptorRuntimeException(e); -// } -// } -// lookup.trimToSize(); -// -// -// -// for (lookup.resetNext(); lookup.hasNext();) { -// IdNameValue value = lookup.getNext(); -// readOnly = value.isReadOnly(); -//// if(nvl(requestValue).length()>0) { -//// if(value.getId().equals(requestValue)) -//// value.setDefaultValue(true); -//// } -// formFieldValues.add(value); -// //break; -// } -// -// ffJSON.setFormFieldValues(formFieldValues); -// -// if(!ff.hasPredefinedList) { -// if(oldSQL != null && !oldSQL.equals("")) { -// ((IdNameSql)lookup).setSQL(oldSQL); -// } -// if(oldDefaultSQL != null && !oldDefaultSQL.equals("")) { -// ((IdNameSql)lookup).setDefaultSQL(oldDefaultSQL); -// } -// } -// } catch (Exception ex) { -// ex.printStackTrace(); -// } -// } -// -// } //ff baseSQL -// } -// } -// } -// } -// -// } - public String formatSelectedItems(List selectedItems, String type) { StringBuffer value = new StringBuffer(""); int count = 0; |