diff options
author | 2020-05-20 14:50:39 +0000 | |
---|---|---|
committer | 2020-05-20 14:50:39 +0000 | |
commit | d17ef055f03f5957bf192fbdb464c21a402be9f1 (patch) | |
tree | f001c4b7477e696875eaadad857e1fbd6b90e830 /ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime | |
parent | 848ab89ed4ef881ec913a16324a5a4d6654d7659 (diff) | |
parent | 8c9c19f430ee91b72955b7cb48d9cf5c48da22ff (diff) |
Merge "enabled analytics test cases and resolved conflicts"
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java | 786 |
1 files changed, 251 insertions, 535 deletions
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 29c5f3c1..d10826af 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 @@ -55,7 +55,8 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; - +import org.apache.commons.lang.StringUtils; +import org.apache.jcs.engine.CacheUtils; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; @@ -70,7 +71,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.Utils; import org.onap.portalsdk.analytics.view.ColumnHeader; import org.onap.portalsdk.analytics.view.ColumnHeaderRow; @@ -85,9 +88,11 @@ 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.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.objectcache.jcs.JCSCacheManager; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; - +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -108,11 +113,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; * */ +@Component public class ReportRuntime extends ReportWrapper implements Cloneable, Serializable { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportRuntime.class); - //TODO DELETE IF PARSE SQL is not working private int curSQLParsePos = 0; private String xmlFileURL = null; @@ -131,10 +136,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private boolean displayContent = true; - private boolean reportRunLogged = false; // Used to avoid multiple - // entries in the report log - // when executing with different - // params or going to next page + private boolean reportRunLogged = false; private DataSet chartDataCache = null; @@ -142,11 +144,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private int cachedPageNo = -1; - private String cachedSQL = null; // For display purposes only + private String cachedSQL = null; - private String wholeSQL = null; // For display purposes only + private String wholeSQL = null; - private String totalSql = null; // For display purposes only + private String totalSql = null; + + private boolean isSinglePageDownload = false; private ReportParamValues reportParamValues = null; @@ -184,53 +188,51 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa private int DATE_OPTION = -1; + public boolean isSinglePageDownload() { + return isSinglePageDownload; + } + + public void setSinglePageDownload(boolean isSinglePageDownload) { + this.isSinglePageDownload = isSinglePageDownload; + } + public void setReportFormFields(ReportFormFields reportFormFields) { this.reportFormFields = reportFormFields; } + public ReportRuntime() { + super(); + } - /* - * private ReportRuntime(CustomReport cr, String reportID, - * HttpServletRequest request) { super(cr, reportID); - * - * reportParamValues = new ReportParamValues(this); reportFormFields = new - * ReportFormFields(this); - * - * if(request!=null) setParamValues(request); } // ReportRuntime - */ private ReportRuntime(CustomReportType crType, String reportID, HttpServletRequest request, String ownerID, String createID, String createDate, String updateID, String updateDate, String menuID, boolean menuApproved) throws RaptorException { super(crType, reportID, ownerID, createID, createDate, updateID, updateDate, menuID, menuApproved); initializeReportRuntime(request); - } // ReportRuntime + } public ReportRuntime(ReportWrapper rw) throws RaptorException { this(rw, null); - } // ReportRuntime + } public ReportRuntime(ReportWrapper rw, HttpServletRequest request)throws RaptorException { super(rw); initializeReportRuntime(request); - } // ReportRuntime + } private void initializeReportRuntime(HttpServletRequest request) throws RaptorException { reportFormFields = new ReportFormFields(this, request); setParamValues(request, true, true); visualManager = new VisualManager(); - } // initializeReportRuntime + } -// public void setReportFormFields(HttpServletRequest request) { -// reportFormFields = new ReportFormFields(this, request); -// setParamValues(request, true, true); -// } public static ReportRuntime unmarshal(String reportXML, String reportID) throws RaptorException { return unmarshal(reportXML, reportID, null); - } // unmarshal + } public static ReportRuntime unmarshal(String reportXML, String reportID, HttpServletRequest request) throws RaptorException { @@ -242,7 +244,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return new ReportRuntime(crType, reportID, request, null, null, null, null, null, null, false); - } // unmarshal + } public String getXmlFileURL() { return xmlFileURL; @@ -339,8 +341,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa setDisplayForm(false); else setDisplayForm(true); - } // else - } // setDisplayFlags + } + } public void logReportRun(String userID, String executionTime, String formFields) throws RaptorException { if (reportRunLogged) @@ -348,7 +350,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ReportLoader.createReportLogEntry(null, reportID, userID, AppConstants.RLA_RUN,executionTime,formFields ); reportRunLogged = true; - } // logReportRun + } public void logReportExecutionTime(String userId, String executionTime, String action, String formFields) throws RaptorException { ReportLoader.createReportLogEntryForExecutionTime(null, reportID, userId,executionTime , action, formFields); @@ -367,7 +369,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (pageDataCache != null) pageDataCache.resetVisualSettings(); - } // resetVisualSettings + } /** ************** ReportParamValues processing *************** */ @@ -385,7 +387,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } else if (request != null) { paramsUpdated = reportParamValues.setParamValues(request,refresh); } - // This is called even in the wizard page. Hence this condition. + if((ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null) { if(reportParamValuesFPE!=null) reportParamValuesFPE.setParamValues(request,refresh); else { @@ -394,15 +396,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } else { reportFormFields = new ReportFormFields(this, request); - //added below two lines for dashboard default value reportParamValues = new ReportParamValues(reportFormFields, getReportDefType()); reportParamValues.setParamValues(request,refresh); - //End reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType()); reportParamValuesFPE.setParamValues(request,refresh); } -// } if (paramsUpdated) { setReportDataSize(-1); chartDataCache = null; @@ -417,35 +416,32 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa grandTotalCrosstab = null; if(!refresh) resetVisualSettings(); - } // if + } displayChart = (request.getParameter(AppConstants.RI_DISPLAY_CHART) == null) ? !isDisplayOptionHideChart() : request.getParameter("display_chart") .equals("Y"); return paramsUpdated; - } // setParamValues + } public String getParamValue(String key) { - //reportParamValues.printValues(); return reportParamValues.getParamValue(key); - } // getParamValue + } - public String getParamDisplayValue(String key) { - //reportParamValues.printValues(); + public String getParamDisplayValue(String key) {; return reportParamValues.getParamDisplayValue(key); - } // getParamValue - + } public Enumeration getParamKeys() { return reportParamValues.keys(); - } // getParamKeys + } public Enumeration getParamKeysForPDFExcel() { return reportParamValuesFPE.keys(); - } // getParamKeys + } public String getParamValueForPDFExcel(String key) { return reportParamValuesFPE.getParamValue(key); - } // getParamValue + } public ArrayList getParamNameValuePairs() { ArrayList paramList = new ArrayList(getReportFormFields().size()); @@ -453,9 +449,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa FormField ff = (FormField) iter.next(); paramList.add(new IdNameValue(ff.getFieldDisplayName(), reportParamValues .getParamDisplayValue(ff.getFieldName()))); - } // for + } return paramList; - } // getParamNameValuePairs + } public ArrayList getParamNameValuePairsforPDFExcel(HttpServletRequest request, int type /*excel =1; pdf=2*/) { javax.servlet.http.HttpSession session = request.getSession(); @@ -465,7 +461,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(paramList!=null && paramList.size()>0) return paramList; } - //System.out.println(" getParamNamePairs type " + type + " " + Globals.customizeFormFieldInfo()); if ( reportParamValuesFPE == null) { reportParamValuesFPE = new ReportParamValuesForPDFExcel(reportFormFields, getReportDefType()); reportParamValuesFPE.setParamValues(request,true); @@ -474,7 +469,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String valueString = ""; for (Iterator iter = getReportFormFields().iterator(); iter.hasNext();) { FormField ff = (FormField) iter.next(); - if(ff.isVisible() && /*!ff.getFieldType().equals(FormField.FFT_HIDDEN) &&*/ type == 1){ + if(ff.isVisible() && type == 1){ valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName()); } else if(ff.isVisible() && type != 1) { valueString = reportParamValuesFPE.getParamDisplayValue(ff.getFieldName()); @@ -482,8 +477,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(valueString.equalsIgnoreCase("NULL")) valueString=""; paramList.add(new IdNameValue(ff.getFieldDisplayName(), valueString)); -// } - } // for + } String pdfAttachmentKey = AppUtils.getRequestValue(request, "pdfAttachmentKey"); boolean isSchedule = false; @@ -501,10 +495,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if(isSchedule) { - //debugLogger.debug("Globals " + Globals.getSessionParamsForScheduling()); String[] scheduleSessionParam = Globals.getSessionParamsForScheduling().split(","); for (int i = 0; i < scheduleSessionParam.length; i++) { - //debugLogger.debug(" scheduleSessionParam[i] " + scheduleSessionParam[i] + " " + request.getParameter(scheduleSessionParam[i]) ); if(request.getParameter(scheduleSessionParam[i])!=null) paramList.add(new IdNameValue(ESAPI.encoder().canonicalize(scheduleSessionParam[i].toUpperCase()), ESAPI.encoder().canonicalize(request.getParameter(scheduleSessionParam[i])))); } @@ -518,7 +510,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } catch(Exception ex) {} } else { - //System.out.println(" In Else getParamNamePairs type " + type); String[] sessionDisplayParameters = Globals.getDisplaySessionParamInPDFEXCEL().split(","); if(session != null && !isSchedule ) { session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request)); @@ -526,7 +517,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String sessionDispParam = sessionDisplayParameters[i]; if(nvl(sessionDispParam).length()>0) { String sessionDispParamArr[] = sessionDispParam.split(";"); - //System.out.println("Session " + sessionDispParamArr[1] + " " + (String)session.getAttribute(sessionDispParamArr[0])); paramList.add(new IdNameValue(sessionDispParamArr[1], nvl((String)session.getAttribute(sessionDispParamArr[0]),""))); } } @@ -555,9 +545,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String name = value.getName().replaceAll(",","~"); value.setName(name); } - //request.getSession().setAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO, paramList); return paramList; - } // getParamNameValuePairs + } /** ************** ReportFormFields processing *************** */ @@ -570,7 +559,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(comment.length()>0) { al = getParamNameValuePairsforPDFExcel(request, 2); if(al!=null) { - //st = new StringBuffer(comment); for (int i=0; i < al.size(); i++) { IdNameValue idNameValue = (IdNameValue)al.get(i); if(nvl(idNameValue.getId()).equals("DATE")) @@ -591,15 +579,15 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa public boolean needFormInput() { return reportFormFields.getFieldCount() > 0; - } // needFormInput + } public FormField getFormField(String fieldName) { return reportFormFields.getFormField(fieldName); - } // getFormField + } public ReportFormFields getReportFormFields() { return reportFormFields; - } // getReportFormFields + } public void setChartDataCache(DataSet chartDataCache) { this.chartDataCache = chartDataCache; @@ -621,10 +609,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ds = ConnectionUtils.getDataSet(sql, dbInfo); if (Globals.getCacheChartData()) chartDataCache = ds; - } // if + } return ds; - } // loadChartData + } public String getReportDataSQL(String userId, int downloadLimit, HttpServletRequest request) throws RaptorException { String reportSQL = ""; @@ -643,11 +631,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd = pageDataCache; 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 (rd == null) { if (getReportType().equals(AppConstants.RT_CROSSTAB)) rd = loadCrossTabReportData(pageNo, userId, downloadLimit, request, download); else if (getReportType().equals(AppConstants.RT_LINEAR)) @@ -661,10 +645,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa pageDataCache = rd; cachedPageNo = pageNo; } - } // if // Commented So that Data is refreshed from DB again + } return rd; - } // loadReportData + } private ReportData loadCrossTabReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException { String reportSQL = generateSQL(reportParamValues, userId, request); @@ -672,13 +656,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa cachedSQL = reportSQL; wholeSQL = reportSQL; List reportCols = getAllColumns(); - // replace the request parameter specified in the drill down DataColumnType dataColumnRequest = getCrossTabValueColumn(); reportSQL = parseReportSQLForDrillDownParams(reportSQL, dataColumnRequest, request); DataSet ds = null; - // try { String dbInfo = getDBInfo(); StringBuffer colNames = new StringBuffer(); StringBuffer colExtraIdNames = new StringBuffer(); @@ -687,24 +669,18 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa 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) { System.out.println("Drilldown URL " + dc.getDrillDownURL()); } - } // for + } if (reportSQL.toUpperCase().indexOf("GROUP BY ") < 0) colNames.append(colExtraIdNames.toString()); colNames.append(colExtraDateNames.toString()); - //reportSQL = " SELECT ROWNUM rnum, " - // + colNames.toString() + " FROM (" + reportSQL + ") "; String rSQL = Globals.getLoadCrosstabReportData(); rSQL = rSQL.replace("[colNames.toString()]", colNames.toString()); @@ -769,8 +745,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_ROW)) { RowHeaderCol rhc = new RowHeaderCol(); rhc.setColumnTitle(dct.getDisplayName()); - // rhc.setColumnWidth("10%"); - //rhc.setColumnWidth(dct.getDisplayWidth() + "%"); if(nvl(dct.getDisplayWidthInPxls()).length()<=0) { dct.setDisplayWidthInPxls("100px"); } @@ -805,29 +779,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd.reportRowHeaderCols.addRowHeaderCol(rhc); } } - } // for - - //int dataColumnIdx = getCrossTabValueColumnIndex(); + } FormatProcessor formatProcessor = new FormatProcessor(getSemaphoreById(dataColumn .getSemaphoreId()), getReportDefType().equals(AppConstants.RD_SQL_BASED) ? AppConstants.CT_NUMBER : dataColumn.getColType(), dataColumn.getColFormat(), false); List dataList = new ArrayList(); - /* //fillup all rows based on rowheaders - Vector rowHeaders = crossTabOrderManager.getRowHeaderValues(); - CrossTabColumnValues crossTabRowValues; - int size = 0; - for (int i = 0; i < rowHeaders.size(); i++) { - if((i+1)==rowHeaders.size()) { - crossTabRowValues = (CrossTabColumnValues) rowHeaders.get(i); - size = crossTabRowValues.getValuesCount(); - } - } - - for (int i = 0; i < size; i++) { - dataList.add(new DataRow()); - }*/ - for (int i = 0; i < ds.getRowCount(); i++) { Vector rValues = new Vector(); Vector cValues = new Vector(); @@ -865,41 +822,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setDisplayName(dataColumn.getDisplayName()); dv.setColId(dataColumn.getColId()); dv.setNowrap(nvl(dataColumn.getNowrap(),"null").equals("false")?"null":nvl(dataColumn.getNowrap(),"null")); - /*StringBuffer indentation = new StringBuffer(""); - if(dataColumn.getIndentation()!=null && dataColumn.getIndentation().intValue()>0) { - for (int indent=0; indent < dataColumn.getIndentation(); indent++) { - indentation.append("\t"); - } - dv.setNowrap("true"); - } - dv.setIndentation(indentation.toString());*/ - if (nvl(dataColumn.getDrillDownURL()).length() > 0) { if(dv.getDisplayValue().length() > 0) { dv.setDrillDownURL(parseDrillDownURL(i, /* dataColumnIdx, */ds, dataColumn,request, childReportFormFields)); dv.setDrillDowninPoPUp(dataColumn.isDrillinPoPUp()!=null?dataColumn.isDrillinPoPUp():false); } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } - } // if + } rd.setDataValue(rValues, cValues, cValuesSort.size()==0?null:cValuesSort, dv, formatProcessor, crossTabOrderManager, dataList); - } // for + } rd.setReportDataList(dataList); - /*if (getReportDataSize() < 0) - setReportDataSize(rd.getDataRowCount());*/ - - /*if (pageNo >= 0) - rd.truncateData(pageNo * getPageSize(), (pageNo + 1) * getPageSize() - 1); - else { - if( downloadLimit != -1) - rd.truncateData(0, downloadLimit - 1); - else - rd.truncateData(0, -1); - }*/ - if (colDataTotalsCrosstab == null) colDataTotalsCrosstab = generateDataTotalsCrossTab(AppConstants.CV_COLUMN, userId,request); if (displayColTotals && colDataTotalsCrosstab != null) @@ -926,13 +861,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa rd.setGrandTotalCrossTab(Utils.truncateTotalDecimals(grandTotalCrosstab), dataColumn.getDisplayAlignment(), getCrossTabDisplayTotal(AppConstants.CV_COLUMN), dataList); - } // if + } rd.consolidateColumnHeaders(visualManager); - //if (Globals.getMergeCrosstabRowHeadings()) - // rd.consolidateRowHeaders(); - //rd.addRowNumbers(pageNo, dataList); - if (displayColTotals && colDataTotalsCrosstab != null) { String totalLabel = "Total"; String colDisplayTotal = getCrossTabDisplayTotal(AppConstants.CV_COLUMN); @@ -942,11 +873,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (getReportDataSize() > getPageSize()) totalLabel += "_nl_(for all pages)"; - //rd.setCrossTabColumnTotalLabel(totalLabel); - } // if - //rd.applyVisibility(); - //Collections.sort((List)dataList, new DataRowComparable()); + } DataRow drInFor1 = null; Vector<DataValue> v1= null, v2 = null; ArrayList<String> temp = new ArrayList<>(); @@ -957,9 +885,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa v1 = drInFor1.getRowValues(); if(i<dataList.size()-1) { v2 = ((DataRow)dataList.get(i+1)).getRowValues(); - } /*else { - v2 = ((DataRow)dataList.get(i-1)).getRowValues(); - }*/ + } for (int j = 0; j < v1.size(); j++) { if(j==0) { if(v1.get(j).getDisplayValue().length()>0) { // another ArrayList @@ -975,13 +901,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } rd.setReportDataList(dataList); if (getReportDataSize() < 0) { - //setReportDataSize(rd.getDataRowCount()); setReportDataSize(rd.getReportDataList().size()); } return rd; - } // loadCrossTabReportData - + } public DataValue addDataValue(DataColumnType dataColumn, String columnValue) { DataValue dv = new DataValue(); @@ -998,7 +922,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } - /*private*/ public boolean doesReportContainsGroupFormField() { + public boolean doesReportContainsGroupFormField() { int flag = 0; if(getFormFieldList()!=null) { for (Iterator iter = getFormFieldList().getFormField().iterator(); iter.hasNext();) { @@ -1013,10 +937,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } private ReportData loadLinearReportData(int pageNo, String userId, int downloadLimit, HttpServletRequest request, boolean download) throws RaptorException { + long startTime = System.currentTimeMillis(); + logger.info("Session ID: " + request.getSession().getId()); + boolean isSameSession = false; + String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));; - String reportSQL = ""; - if(action.endsWith("session")) { reportSQL = getWholeSQL(); wholeSQL = reportSQL; @@ -1028,11 +954,24 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } DataSet ds = null; String dbInfo = getDBInfo(); - ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo); - setReportDataSize(ds.getRowCount()); - //wholeSQL = reportSQL; + long runWHoleSqlStart = System.currentTimeMillis(); + String SQLForCount = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x "; + boolean isPageDowload = Boolean.valueOf(request.getParameter(AppConstants.PAGE_DOWNLOAD)); + if(download) { + if(isPageDowload) { + ds = ConnectionUtils.getDataSet(cachedSQL, dbInfo); + } + else { + String downloadAll = generateSubsetSQL(0, downloadLimit, userId, request, true, null); + ds = ConnectionUtils.getDataSet(downloadAll, dbInfo); + } + } + long runWHoleSqlEnd = System.currentTimeMillis(); + logger.info("Run whole sql to set reportDataSize took:"+ (runWHoleSqlEnd - runWHoleSqlStart)/1000F + "Seconds"); + long hibernateSessionTimeStart = System.currentTimeMillis(); HttpSession session = request.getSession(); - //debugLogger.debug(" ******** Download Limit ********* " + downloadLimit + " %%%%%%%%%%PAGE " + pageNo ); + long hibernateSessionTimeEnd = System.currentTimeMillis(); + logger.info("Hibernate session time : " + (hibernateSessionTimeEnd - hibernateSessionTimeStart)/1000F + " Seconds"); List reportCols = null; StringBuffer colNames = new StringBuffer(); @@ -1049,12 +988,18 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } else { - String pagedSQL = null; // reportSQL; + String pagedSQL = null; + long genaratePageSqlStart = System.currentTimeMillis(); + boolean getColumnNamesFromReportSQL = false; + if(Globals.getDBType().equals(AppConstants.ORACLE)) { + getColumnNamesFromReportSQL = true; + } if (pageNo >= 0) - pagedSQL = generatePagedSQL(pageNo, userId, request, false, null); + pagedSQL = generatePagedSQL(pageNo, userId, request, getColumnNamesFromReportSQL, null); else - pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, false, null); - // replace the request parameter specified in the drill down + pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, getColumnNamesFromReportSQL, null); + long genaratePageSqlend = System.currentTimeMillis(); + logger.info("generate paged sql took : " + (genaratePageSqlend - genaratePageSqlStart)/1000F + " Seconds"); reportCols = getAllColumns(); colNames = new StringBuffer(); for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1072,18 +1017,30 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa cachedSQL = pagedSQL; - // try { + if(doesReportContainsGroupFormField()) { if (pageNo >= 0) - pagedSQL = generatePagedSQL(pageNo, userId, request, true, reportParamValues); + pagedSQL = generatePagedSQL(pageNo, userId, request, getColumnNamesFromReportSQL, reportParamValues); else - pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, true, reportParamValues); + pagedSQL = generateSubsetSQL(0, downloadLimit, userId, request, getColumnNamesFromReportSQL, reportParamValues); } - //check for Group formfield - //if groupformfield get columns from sql - + long start = System.currentTimeMillis(); ds = ConnectionUtils.getDataSet(pagedSQL, dbInfo); - + long end = System.currentTimeMillis(); + float sec = (end - start) / 1000F; + logger.info("Get page data : "+sec + " seconds"); + if (ds.getRowCount() < getPageSize() && pageNo == 0) { + setReportDataSize(ds.getRowCount()); + } else { + if (CachingUtils.isTotalCountAvailable(request.getSession().getId() + wholeSQL) && !download) { + setReportDataSize(CachingUtils.getTotalRowsCount(request.getSession().getId() + wholeSQL)); + } else { + DataSet countData = null; + countData = ConnectionUtils.getDataSet(SQLForCount, dbInfo); + setReportDataSize(countData.getInt(0, 0)); + CachingUtils.cacheTotalRowCount(request.getSession().getId() + wholeSQL, countData.getInt(0, 0)); + } + } if(doesReportContainsGroupFormField()) { List reportCols1 = getAllColumns(); reportCols = new Vector(); @@ -1120,20 +1077,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } - - // if ( (remDbInfo!=null) && (!remDbInfo.equals(AppConstants.DB_LOCAL))) - // { - // Globals.getRDbUtils().setDBPrefix(remDbInfo); - // ds = RemDbUtils.executeQuery(pagedSQL); - // } - // else - // ds = DbUtils.executeQuery(pagedSQL); - /* - * } catch(SQLException e) { throw new - * ReportSQLException("[ReportRuntime.loadLinearReportData] - * "+e.getMessage(), pagedSQL); } - */ - if (getReportDataSize() < 0) if (pageNo < 0) setReportDataSize(ds.getRowCount()); @@ -1141,30 +1084,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa setReportDataSize(ds.getRowCount()); else { - /*Pattern re1 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]", Pattern.DOTALL); - Pattern re2 = Pattern.compile("[Oo][Rr][Dd][Ee][Rr](.*?[^\r\n]*)[Bb][Yy]((.*?[^\r\n]*)|[\\s]|[^0-9a-zA-Z])\\)", Pattern.DOTALL); - Matcher matcher = re1.matcher(reportSQL); - Matcher matcher2 = null; - int startPoint = reportSQL.length()-30; - String startReportSQL = ""; - String endReportSQL = ""; - while(reportSQL.indexOf("xid", startPoint)!=-1)startPoint++; - if (matcher.find(startPoint)) { - startReportSQL = reportSQL.substring(0, reportSQL.indexOf(matcher.group())); - endReportSQL = reportSQL.substring(reportSQL.indexOf(matcher.group())); - matcher2 = re2.matcher(endReportSQL); - if(matcher2.find()) - endReportSQL = endReportSQL.substring(matcher.group().length()-1); - else - endReportSQL = ""; - reportSQL = startReportSQL + endReportSQL; - }*/ String countSQL = "SELECT count(*) FROM (" + reportSQL + ")"+ (Globals.isPostgreSQL() || Globals.isMySQL()?" AS ":"") +" x "; String dbType = ""; 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); if (dbType.equals("DAYTONA") && reportSQL.trim().toUpperCase().startsWith("SELECT")) { Pattern re1 = Pattern.compile("order(.*?[^\r\n]*)by", Pattern.DOTALL); @@ -1185,9 +1109,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } DataSet ds2 = null; - // try { if(reportSQL.trim().toUpperCase().startsWith("SELECT")) { + long start1 = System.currentTimeMillis(); ds2 = ConnectionUtils.getDataSet(countSQL, dbInfo); + long end1 = System.currentTimeMillis(); + float sec1 = (end1 - start1) / 1000F; System.out.println("Get count data : "+sec1 + " seconds"); if (ds2.getRowCount() > 0) setReportDataSize(ds2.getInt(0, 0)); else @@ -1195,26 +1121,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa "[ReportRuntime.loadLinearReportData] Unable to load report data size"); } else setReportDataSize(50); - // if ( (remDbInfo!=null) && - // (!remDbInfo.equals(AppConstants.DB_LOCAL))){ - // Globals.getRDbUtils().setDBPrefix(remDbInfo); - // ds2 = RemDbUtils.executeQuery(countSQL); - // } - // else - // ds2 = DbUtils.executeQuery(countSQL); - /* - * } catch(SQLException e) { throw new - * ReportSQLException("[ReportRuntime.loadLinearReportData size] - * "+e.getMessage(), countSQL); } - */ - - - } // else + + + } } ReportData rd = new ReportData(pageNo, true); - - // Already defined changed for modifying request parameters - //List reportCols = getAllColumns(); Vector visibleCols = new Vector(reportCols.size()); Vector formatProcessors = new Vector(reportCols.size()); @@ -1222,8 +1133,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa // rd.reportColumnHeaderRows.addColumnHeaderRow(chr); // chr.setRowHeight("30"); int count =0 ; - - /* ADDED */ ReportFormFields rff = getReportFormFields(); ReportFormFields childReportFormFields = null; String fieldDisplayName = ""; @@ -1236,7 +1145,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa for(int i = 0 ; i < rff.size(); i++) { fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]"; fieldValue = ""; - //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName()); if (dct.getDependsOnFormField().equals(fieldDisplayName)) { fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName())); @@ -1253,8 +1161,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } } - - /* ADDED */ String displayName = ""; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1266,11 +1172,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa AppConstants.RD_SQL_BASED))); if (nvl(dc.getDrillDownURL()).length() > 0) { + if(!dc.getDrillDownURL().contains("c_master")) { childReportFormFields = getChildReportFormFields(request,AppUtils.getDrillActionURL()+""+dc.getDrillDownURL()); + }else { + childReportFormFields = getChildReportFormFields(request,dc.getDrillDownURL()); + } } if (dc.isVisible()) { visibleCols.add(count,dc); - //if(dc.getColId().startsWith("group")) { for (int d = 0; d < reportCols.size(); d++) { if(reportCols.get(d)!=null) { DataColumnType dct1 = (DataColumnType) reportCols.get(d); @@ -1295,43 +1204,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa visualManager.isColumnVisible(dc.getColId()), visualManager .getSortByColId().equals(dc.getColId()) ? visualManager .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); - // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(), - // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%"))); - } // if + } else { visibleCols.add(count,null); rd.createColumn(dc.getColId(), AppConstants.HIDDEN, dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(), true, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); -// formatProcessors.add(count,null); } count++; - } // for + } if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && pageNo ==0) { - /*Vector v = null; - try { - v = addForecastData(reportSQL); - } catch (Exception ex) { - ex.printStackTrace(); - throw new RaptorException (ex); - } - session.setAttribute("FORECASTED_DATA", v); - DataSet dsWhole = ConnectionUtils.getDataSet(wholeSQL, dbInfo); - dsWhole.addAll(v); - session.setAttribute(AppConstants.RI_CHART_FORECAST_DATA, dsWhole); - } - if(getReportDefType().equals(AppConstants.RD_SQL_BASED_DATAMIN) && session.getAttribute("FORECASTED_DATA")!=null) { - Vector vForecastedData = (Vector)session.getAttribute("FORECASTED_DATA"); - if(vForecastedData.size() > 0) - ds.addAll(vForecastedData);*/ } - - // Utils._assert(chr.size()==ds.getColumnCount(), - // "[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 for (int r = 0; r < Math.min(ds.getRowCount(), ((pageNo < 0) ? (downloadLimit == -1?Globals.getFlatFileUpperLimit():Globals.getDownloadLimit() ) : getPageSize())); r++) { DataRow dr = new DataRow(); rd.reportDataRows.addDataRow(dr); @@ -1341,6 +1226,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa DataColumnType dct = (DataColumnType) reportCols.get(c); DataValue dv = new DataValue(); dr.addDataValue(dv); + String reverseDispalyValue = reverseDisplayValue(ds.getString(r, ds.getColumnIndex(dct.getColId()))); + reverseDispalyValue = StringUtils.substringBefore(reverseDispalyValue, ","); + if(download) + dv.setDisplayValue(reverseDispalyValue); + else dv.setDisplayValue(ds.getString(r, ds.getColumnIndex(dct.getColId()))); dv.setColName(dct.getColName()); dv.setColId(dct.getColId()); @@ -1368,7 +1258,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } } // if @@ -1377,20 +1266,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setVisible(false); dv.setHidden(true); } - //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - if(dr.getFormatId()!=null) ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true); else ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false); + } + } + } - //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - } // if reportCols - } // for - } // for - - //Only if rownumber options is needed - //rd.addRowNumbers(pageNo, getPageSize()); if (colDataTotalsLinear == null) { if(!download && !action.endsWith("session")) @@ -1406,12 +1289,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalLabel += "<br><font size=1>(for all pages)</font>"; rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel); - } // if - // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar + } rd.applyVisibility(); - + long endTime = System.currentTimeMillis(); + float totalTime = (endTime - startTime)/1000F; + logger.info("Linearreportdata took: " + totalTime +"Seconds"); return rd; - } // loadLinearReportData + } @@ -1427,16 +1311,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getDisplayTotal()).length() > 0) { displayColTotals = true; break; - } // if - } // if checking dct - } // for + } + } + } DataSet ds = null; if (displayColTotals) { dr = new DataRow(); - // ds = - // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues, - // userId)); ds = ConnectionUtils.getDataSet(reportSQL, dbInfo); @@ -1473,12 +1354,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setVisible(dct.isVisible()); if(dv.isVisible()) dr.addDataValue(dv); - } // dct check - } // for + } + } } return dr; - } // generateColumnDataTotalsLinear + } public ReportData loadHiveLinearReportData(String reportSQL, String userId, int downloadLimit, HttpServletRequest request) throws RaptorException { @@ -1492,7 +1373,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa HttpSession session = request.getSession(); DataSet ds = null; - // try { String dbInfo = getDBInfo(); List reportCols = getAllColumns(); @@ -1508,18 +1388,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa ds = ConnectionUtils.getDataSet(wholeSQL, dbInfo); ReportData rd = new ReportData(0, true); - - // Already defined changed for modifying request parameters - //List reportCols = getAllColumns(); Vector visibleCols = new Vector(reportCols.size()); Vector formatProcessors = new Vector(reportCols.size()); - - // ColumnHeaderRow chr = new ColumnHeaderRow(); - // rd.reportColumnHeaderRows.addColumnHeaderRow(chr); - // chr.setRowHeight("30"); int count =0 ; + - /* ADDED */ ReportFormFields rff = getReportFormFields(); ReportFormFields childReportFormFields = null; String fieldDisplayName = ""; @@ -1532,7 +1405,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa for(int i = 0 ; i < rff.size(); i++) { fieldDisplayName = "["+((FormField)rff.getFormField(i)).getFieldDisplayName()+"]"; fieldValue = ""; - //if(dct.getOriginalDisplayName()==null) dct.setOriginalDisplayName(dct.getDisplayName()); if (dct.getDependsOnFormField().equals(fieldDisplayName)) { fieldValue = nvl(request.getParameter(((FormField)rff.getFormField(i)).getFieldName())); @@ -1550,7 +1422,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } - /* ADDED */ String displayName = ""; for (Iterator iter = reportCols.iterator(); iter.hasNext();) { @@ -1566,7 +1437,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dc.isVisible()) { visibleCols.add(count,dc); - //if(dc.getColId().startsWith("group")) { for (int d = 0; d < reportCols.size(); d++) { if(reportCols.get(d)!=null) { DataColumnType dct1 = (DataColumnType) reportCols.get(d); @@ -1591,17 +1461,15 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa visualManager.isColumnVisible(dc.getColId()), visualManager .getSortByColId().equals(dc.getColId()) ? visualManager .getSortByAscDesc() : null, isRuntimeColSortDisabled(), dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); - // chr.addColumnHeader(new ColumnHeader(dc.getDisplayName(), - // (dc.getDisplayWidth()>100)?"10%":(""+dc.getDisplayWidth()+"%"))); - } // if + + } else { visibleCols.add(count,null); rd.createColumn(dc.getColId(), "", dc.getDisplayWidthInPxls(), dc.getDisplayHeaderAlignment(), true, null,false, dc.getLevel()!=null?dc.getLevel():0, dc.getStart()!=null?dc.getStart():0, dc.getColspan()!=null?dc.getColspan():0, dc.isIsSortable()!=null?dc.isIsSortable():false); -// formatProcessors.add(count,null); } count++; - } // for + } ArrayList reportDataList = new ArrayList(); for (int r = 0; r < ds.getRowCount(); r++) { @@ -1640,30 +1508,24 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if (dv.getDisplayValue().length() == 0) { - //dv.setDisplayValue("[NULL]"); dv.setDisplayValue(""); } - } // if + } } else { dv.setVisible(false); dv.setHidden(true); } - //System.out.println("in Linear report b4" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); if(dr.getFormatId()!=null) ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, true); else ((FormatProcessor) formatProcessors.get(c)).setHtmlFormatters(dv, dr, false); - - //System.out.println("in Linear report After" + dr.getFormatId() + dr.getBgColorHtml() + dv.getDisplayValue()); - } // if reportCols - } // for + } + } reportDataList.add(dr); - } // for + } rd.setReportDataList(reportDataList); - //Only if rownumber options is needed - //rd.addRowNumbers(pageNo, getPageSize()); if (colDataTotalsLinear == null) colDataTotalsLinear = generateColumnDataTotalsLinear(new ArrayList(reportCols), userId, @@ -1674,21 +1536,19 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalLabel += "<br><font size=1>(for all pages)</font>"; rd.setColumnDataTotalsLinear(colDataTotalsLinear, totalLabel); - } // if - // Please note the below function doesn't set the visibility for dv since this is set in this function. - Sundar + } + rd.applyVisibility(); return rd; - } // loadHiveLinearReportData + } + - //For Hive reports public int getHiveReportCount(String sql) throws RaptorException { - //select t from (select count(*) t from (select * from program)x)x1; int count = 0; String countSql = "select t from (select count(*) t from ("+ sql + ")" + (Globals.isPostgreSQL() || Globals.isMySQL() ?" AS ":"") + " x) AS x1"; DataSet ds = null; - // try { String dbInfo = getDBInfo(); System.out.println("SQL getReportCount()- " + countSql); try { @@ -1697,7 +1557,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa String dbType = ""; 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); @@ -1709,10 +1568,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } catch (NumberFormatException ex) {} return count; - } // getReportCount + } - /*private*/ public ReportFormFields getChildReportFormFields( HttpServletRequest request, String URL ) throws RaptorException { + public ReportFormFields getChildReportFormFields( HttpServletRequest request, String URL ) throws RaptorException { String childReportID = getReportID(URL); ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID, @@ -1733,20 +1592,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return reportID; } - /*private*/ public String parseDrillDownURL(int rowIdx, /* int colIdx, */DataSet ds, DataColumnType dct, HttpServletRequest request, ReportFormFields ddReportFormFields) +public String parseDrillDownURL(int rowIdx, /* int colIdx, */DataSet ds, DataColumnType dct, HttpServletRequest request, ReportFormFields ddReportFormFields) throws RaptorException { Vector viewActions = DataCache.getDataViewActions(); javax.servlet.http.HttpSession session = request.getSession(); StringBuffer dUrl = new StringBuffer(); - - //String childReportID = getReportID(dct.getDrillDownURL()); - - //ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, childReportID, - // false, 1); - - //ReportFormFields ddReportFormFields = ddRr.getReportFormFields(); - boolean isViewAction = false; int flag = 0; String requestParam =""; @@ -1755,18 +1606,14 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa AppUtils.getBaseActionURL() + ((String) viewActions.get(k)))) isViewAction = true; if (isViewAction) { - // Drill-down to record details - String param = nvl(dct.getDrillDownParams()); // i.e. - // "c_master=[bo1.RECID$]" + String param = nvl(dct.getDrillDownParams()); param = param.substring(AppUtils.getBaseActionParam().length() + 1, - param.length() - 1); // i.e. "bo1.RECID$" - param = param.replace('.', '_'); // i.e. "bo1.RECID$" + param.length() - 1); + param = param.replace('.', '_'); dUrl.append(AppUtils.getBaseActionParam()); dUrl.append(java.net.URLEncoder.encode(ds.getString(rowIdx, param.toLowerCase()))); } else { - // Drill-down to another report - // Replacing col ids with values String param = nvl(dct.getDrillDownParams()); while (param.indexOf('[') >= 0) { int startIdx = param.indexOf('['); @@ -1782,13 +1629,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa sb.append(param.substring(0, startIdx)); if (param.charAt(startIdx + 1) == '!') { - // Parameter is a form field value String fieldId = param.substring(startIdx + 2, endIdx); String fieldValue = (String) reportParamValues.get(fieldId); sb.append(java.net.URLEncoder.encode(nvl(fieldValue))); - //TODO Add a else if condition to check whether the param is from request Param - //TODO make a unique symbol like # }else if (param.charAt(startIdx + 1) == '#') { flag = 1; String fieldId = param.substring(startIdx + 2, endIdx); @@ -1796,14 +1640,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa sb.append(java.net.URLEncoder.encode(nvl(fieldValue))); }else { - // Parameter is a column value String fieldValue = ""; String colValue = null; String colId = null; if (param.indexOf('!') < 0 || param.indexOf('!') > endIdx) colId = param.substring(startIdx + 1, endIdx); else { - // Need to use NVL(column, form field) colId = param.substring(startIdx + 1, param.indexOf('!')); String fieldId = param.substring(param.indexOf('!') + 1, endIdx); @@ -1812,7 +1654,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa fieldValue = reportParamValues.getParamValueforTextAreaDrilldown(fieldId); } else fieldValue = (String) reportParamValues.get(fieldId); - } // else + } DataColumnType column = getColumnById(colId); String columnName = ""; @@ -1835,39 +1677,29 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if(nvl(dependsOn).length()>0) System.out.println("DependsOn " + dependsOn); if (column != null) { - // if (column.getColType().equals(AppConstants.CT_DATE)) - //if (!nvl(column.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) - // .equals(AppConstants.DEFAULT_DATE_FORMAT)) - // Use extra column instead - //commented out below line usually for Visual - //colId += AppConstants.DD_COL_EXTENSION; colValue = ds.getString(rowIdx, colId.toLowerCase()); - // if SQL-Based and drill-down param is a date, decode - // it to the expected Oracle format **/ if (getReportDefType().equals(AppConstants.RD_SQL_BASED)) if (!getColumnNoParseDateFlag(column)) if (ReportParamDateValueParser.isDateParam(colValue)) colValue = ReportParamDateValueParser .formatDateParamValue(colValue); - } // if + } String suppressValues = "|" + nvl(dct.getDrillDownType()) + "|"; if (suppressValues.length() > 2 && suppressValues.indexOf("|" + colValue + "|") >= 0) - // Parameter value is suppressed and not passed to the - // drill-down report colValue = null; sb.append(java.net.URLEncoder.encode(nvl(colValue, fieldValue))); } else { sb.delete(sb.lastIndexOf("&")+1, sb.length()); } - } // else + } if (endIdx < param.length() - 1) sb.append(param.substring(endIdx + 1)); param = sb.toString(); - } // while + } if(Globals.getPassRequestParamInDrilldown()) { if(param.indexOf('#') < 0) { String[] reqParameters = Globals.getRequestParams().split(","); @@ -1920,28 +1752,16 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } dUrl.append(AppConstants.DRILLDOWN_INDEX); int index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.DRILLDOWN_INDEX), "0")); - /* - int form_index = Integer.parseInt(nvl(AppUtils.getRequestValue(request, AppConstants.FORM_DRILLDOWN_INDEX), "0")); - index = index>0 ? --index : 0; - form_index = form_index>0 ? --form_index : 0;*/ request.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index)); - /*session.setAttribute(AppConstants.DRILLDOWN_INDEX, Integer.toString(index)); - request.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index)); - session.setAttribute(AppConstants.FORM_DRILLDOWN_INDEX, Integer.toString(form_index));*/ - dUrl.append("=" + AppUtils.getRequestNvlValue(request, AppConstants.DRILLDOWN_INDEX)); - - //TODO Add a if condition to check whether the param is request Param - } // if + } if (dUrl.length() > 0) dUrl.insert(0, ((dct.getDrillDownURL()).indexOf('&') > 0) ? '&' : '&'); dUrl.insert(0, AppUtils.getDrillActionURL()+dct.getDrillDownURL()); - //debugLogger.debug(" [[[[[[[[[[[[[[[[ " + dUrl); - return dUrl.toString(); - } // parseDrillDownURL + } /** *********************************************************************************** */ @@ -1957,16 +1777,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (nvl(dct.getDisplayTotal()).length() > 0) { displayColTotals = true; break; - } // if - } // if checking dct - } // for + } + } + } DataSet ds = null; if (displayColTotals) { dr = new DataRow(); - // ds = - // DbUtils.executeQuery(generateTotalSQLLinear(reportParamValues, - // userId)); ds = ConnectionUtils.getDataSet(generateTotalSQLLinear(reportParamValues, userId,request), dbInfo); @@ -1985,6 +1802,9 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa totalValue = nvl(AppConstants.TOTAL_FUNCTIONS.getNameById(dct .getDisplayTotal())) + ": " + totalValue; + if( nvl(dct.getDisplayTotal()).length() > 0 && dct.getDisplayTotal().equals(AppConstants.TOTAL_SUM_ID)){ + totalValue = "Total: "+ totalValue; + } dv.setDisplayValue(Utils.truncateTotalDecimals(totalValue)); dv.setAlignment(dct.getDisplayAlignment()); @@ -2002,12 +1822,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dv.setIndentation(indentation.toString()); dv.setDisplayTotal(dct.getDisplayTotal()); dv.setBold(true); - } // dct check - } // for + } + } } return dr; - } // generateColumnDataTotalsLinear + } private Vector generateDataTotalsCrossTab(String rowColPos, String userId, HttpServletRequest request) throws RaptorException { @@ -2022,9 +1842,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa displayRowTotals = displayTotals; if (displayTotals) { - // DataSet ds = - // DbUtils.executeQuery(generateTotalSQLCrossTab(reportParamValues, - // rowColPos, userId)); String executeSql = generateTotalSQLCrossTab( sql, rowColPos, userId, request, reportParamValues); DataSet ds = ConnectionUtils.getDataSet(executeSql, getDbInfo()); @@ -2044,34 +1861,31 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dataValue.setAlignment("center"); dataValue.setDisplayValue(ds.getString(i, cPos++)); headerValues.add(dataValue); - - //headerValues.add(ds.getString(i, cPos++)); } else if (nvl(dct.getCrossTabValue()).equals(AppConstants.CV_VALUE)) totalValue = ds.getString(i, cPos++); - } // for + } dataTotals.add(new CrossTabTotalValue(headerValues, Utils .truncateTotalDecimals(totalValue))); - } // for - } // if + } + } return dataTotals; - } // generateDataTotalsCrossTab - + } /** *********************************************************************************** */ public void hideColVisual(String colId) { visualManager.hideColumn(colId); if (pageDataCache != null) pageDataCache.columnVisualShowHide(colId, false); - } // hideColVisual + } public void showColVisual(String colId) { visualManager.showColumn(colId); if (pageDataCache != null) pageDataCache.columnVisualShowHide(colId, true); - } // showColVisual + } public void sortColVisual(String colId) { visualManager.setSortByColumn(colId); @@ -2079,13 +1893,13 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa pageDataCache = null; cachedPageNo = -1; - } // sortColVisual + } /** *********************************************************************************** */ public String generateDistinctValuesSQL(DataColumnType dct, String userId, HttpServletRequest request) throws RaptorException { return super.generateDistinctValuesSQL(reportParamValues, dct, userId, request); - } // generateDistinctValuesSQL + } public String getDbInfo() { return this.cr.getDbInfo(); @@ -2102,18 +1916,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa logger.debug(EELFLoggerDelegate.debugLogger, ("Flat File parseReportSQL ******* SQL " + sql)); sql = sql.replaceAll("([\\s]*\\() (?!FROM)", "("); sql = sql.replaceAll("[\\s]*\\)", ")"); - //sql = sql.replaceAll("[dD][eE][cC][oO][dD][eE] ", "decode"); - //sql = sql.replaceAll("[\\s]*\\(", "("); - //sql = replaceNewLine(sql, "decode ", "decode"); - //sql = replaceNewLine(sql, "DECODE ", "decode"); - //sql = replaceNewLine(sql, "Decode ", "decode"); String nextToken = getNextSQLParseToken(sql, true); String dbInfo = getDbInfo(); 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; @@ -2124,9 +1932,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } if ( isCYMBALScript == false ) { while (nextToken.length() > 0) { - //System.out.println("LastToken " + lastToken + " NextToken " + nextToken); - - if (parsedSQL.length() == 0) { if (nextToken.toUpperCase().equals("SELECT")) parsedSQL.append("SELECT "); @@ -2155,9 +1960,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa parsedSQL.append(sql.substring(lastParsePos)); break; } else { - //System.out.println("Next Token " + nextToken); if (nextToken.charAt(nextToken.length() - 1) == ',') { - // The token ends with , nextToken = nextToken.substring(0, nextToken.length() - 1); if (nextToken.length() == 0) { @@ -2165,9 +1968,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa updatedReportCols.add(getParseSQLDataColumn(lastToken, null, parsedSQL, updatedReportCols, false)); lastToken = null; - } // else just comma => ignore it + } } else { - //System.out.println("Next Token " + nextToken + " is Here" + " Last Token " + lastToken); if (lastToken != null) { updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, parsedSQL, updatedReportCols, false)); @@ -2177,28 +1979,25 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa parsedSQL, updatedReportCols, false)); } } else { - // The token doesn't end with , if (lastToken == null) lastToken = nextToken; else { String token = getNextSQLParseToken(sql, false); - //System.out.println(" ********** " + token + " " + lastToken); if (!token.toUpperCase().equals("FROM")) throw new org.onap.portalsdk.analytics.error.ValidationException( "|FROM keyword or a comma expected after [" + nextToken + "]."); - //System.out.println("Next Token " + nextToken); updatedReportCols.add(getParseSQLDataColumn(lastToken, nextToken, parsedSQL, updatedReportCols, false)); lastToken = null; - } // else - } // else - } // else + } + } + } lastParsePos = curSQLParsePos; nextToken = getNextSQLParseToken(sql, true); - } // while - } else { // if CYMBAL Script + } + } else { nextToken = getNextCYMBALSQLParseToken(sql, true); Pattern re = null; Matcher matcher = null; @@ -2207,7 +2006,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (lastToken == null) lastToken = nextToken; if( lastToken.toUpperCase().equals("DO DISPLAY")) { - re = Pattern.compile("each(.*)\\[.(.*?)\\]"); //\\[(.*?)\\] + re = Pattern.compile("each(.*)\\[.(.*?)\\]"); matcher = re.matcher(nextToken); if (matcher.find()) { extracted = matcher.group(); @@ -2238,7 +2037,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa return parsedSQL.toString(); - } // parseReportSQL + } private String getNextCYMBALSQLParseToken(String sql, boolean updateParsePos) { int braketCount = 0; @@ -2250,11 +2049,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (ch!='\n') nextToken.append(ch); else break; - } // for + } return nextToken.toString(); - } // getNextSQLParseToken - + } private String getNextSQLParseToken(String sql, boolean updateParsePos) { int braketCount = 0; boolean isInsideQuote = false; @@ -2283,12 +2081,11 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa braketCount--; else if (ch == '\''/* ||ch=='\"' */) isInsideQuote = (!isInsideQuote); - } // else - } // for + } + } return nextToken.toString(); - } // getNextSQLParseToken - + } private DataColumnType getParseSQLDataColumn(String sqlExpression, String colId, StringBuffer parsedSQL, Vector updatedReportCols, boolean isCYMBALScript) throws RaptorException { DataColumnType dct = null; @@ -2302,7 +2099,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct = getColumnById(colId); } else { - // Getting unique column id + colId = ""; int colIdN = 0; for (int i = 0; (i < sqlExpression.length()) && (colIdN < 2); i++) @@ -2328,10 +2125,10 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa idAlreadyUsed = true; break; } - } // for + } colId += (colIdN - 1); - } // else + } if (dct == null) { dct = (new ObjectFactory()).createDataColumnType(); @@ -2339,7 +2136,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setDisplayWidth(10); dct.setDisplayAlignment("Left"); dct.setVisible(true); - dct.setGroupBreak(false); // ??? + dct.setGroupBreak(false); boolean isValidIdentifier = Character.isLetterOrDigit(sqlExpression.charAt(0)); for (int i = 0; i < sqlExpression.length(); i++) @@ -2353,8 +2150,8 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setDisplayName(sqlExpression); } else { dct.setDisplayName(colId); - } // else - } // if + } + } if(!isCYMBALScript) sqlExpression = sqlExpression.replaceAll(", '", ",'"); dct.setDbColName(sqlExpression); @@ -2362,7 +2159,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa dct.setCalculated(true); dct.setColType(AppConstants.CT_CHAR); dct.setDbColType(AppConstants.CT_CHAR); - adjustColumnType(dct); // ??? + adjustColumnType(dct); if(!isCYMBALScript) { if (parsedSQL.toString().equals("SELECT ") @@ -2376,8 +2173,7 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } return dct; - } // getParseSQLDataColumn - + } private boolean isParseSQLColID(String token) { if (nvl(token).length() == 0) return false; @@ -2390,12 +2186,12 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa if (!(Character.isLetterOrDigit(ch) || ch == '_')) return false; - } // for + } return true; - } // isParseSQLColID + } - /*private*/ public String parseReportSQLForDrillDownParams(String reportSQL, DataColumnType dataColumnRequest, HttpServletRequest request){ + public String parseReportSQLForDrillDownParams(String reportSQL, DataColumnType dataColumnRequest, HttpServletRequest request){ String param = nvl(dataColumnRequest.getDrillDownParams()); String sql = reportSQL; int pos = 0; @@ -2409,7 +2205,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa else break; if (param.charAt(startIdx + 1) == '#') { - // Parameter is a form field value String fieldId = param.substring(startIdx + 2, endIdx); String fieldValue = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(fieldId)); sql = Utils.replaceInString(sql, "[" + fieldId.toUpperCase()+"]", fieldValue ); @@ -2479,7 +2274,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep try { return super.clone(); } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable throw new InternalError("Cloning throws error."); } } @@ -2491,7 +2285,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep public String getReportSQLWithRowNum(String _orderBy, boolean asc) { String sql = getWholeSQL(); int closeBracketPos = 0; - // Added reportSQLOnlyFirstPart which has Column information with Rownum return nvl(getReportSQLOnlyFirstPart()) + " " + sql + ") x "; } @@ -2540,11 +2333,11 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep visibleColExist = true; break; } - } // for - } // if + } + } return visibleColExist; - } // canPersistLinearReport + } public void persistLinearReport(HttpServletRequest request) throws RaptorException { @@ -2557,8 +2350,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep String reportXML = marshal(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID + " XML marshalled succesfully")); - - // Update report verifySQLBasedReportAccess(request); reportSecurity.reportUpdate(request); connection = DbUtils.startTransaction(); @@ -2575,7 +2366,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } finally { DbUtils.clearConnection(connection); } - } // persistLinearReport + } public void persistDashboardReport(HttpServletRequest request) throws RaptorException { @@ -2586,8 +2377,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep String reportXML = marshal(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] Report " + reportID + " XML marshalled succesfully")); - - // Update report verifySQLBasedReportAccess(request); reportSecurity.reportUpdate(request); connection = DbUtils.startTransaction(); @@ -2604,7 +2393,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } finally { DbUtils.clearConnection(connection); } - } // persistDashboardReport + } public String getTotalSql() { return totalSql; } @@ -2663,7 +2452,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ObjectMapper mapper = new ObjectMapper(); ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); reportJSONRuntime.setReportTitle(getReportTitle()); - //reportJSONRuntime.setReportSubTitle(getReportSubTitle()); reportJSONRuntime.setReportID(getReportID()); reportJSONRuntime.setReportDescr(getReportDescr()); reportJSONRuntime.setReportName(getReportName()); @@ -2672,7 +2460,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep reportJSONRuntime.setAllowEdit(isAllowEdit(request)); reportJSONRuntime.setColIdxTobeFreezed(getFrozenColumnId()); reportJSONRuntime.setNumFormCols(getNumFormColsAsInt()); - //back button url reportJSONRuntime.setBackBtnURL(""); String chartType = getChartType(); boolean displayChart = (nvl(chartType).length()>0)&&getDisplayChart(); @@ -2699,7 +2486,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ffJSON.setHelpText(ff.getHelpText()); ffJSON.setValidationType(ff.getValidationType()); ffJSON.setVisible(ff.isVisible()); - //ffJSON.setTriggerOtherFormFields(ff.getDependsOn()); IdNameList lookup = null; lookup = ff.getLookupList(); String selectedValue = ""; @@ -2723,7 +2509,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep lookupList = lookup; try { lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId()); - } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e); + } catch (Exception e ){ e.printStackTrace(); } } lookup.trimToSize(); @@ -2735,7 +2521,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep IdNameValue value = lookup.getNext(); readOnly = value.isReadOnly(); if(requestValue != null && Arrays.asList(requestValue).contains(value.getId())) { - //if(value.getId().equals(requestValue)) value.setDefaultValue(true); } else if (AppUtils.nvl(ff.getDefaultValue()).length()>0) { if(ff.getDefaultValue().equals(value.getId())) { @@ -2749,7 +2534,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) { formFieldValues.add(value); } - //break; + } } else { if(requestValue!=null && requestValue.length>0) { @@ -2783,7 +2568,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } // for } reportJSONRuntime.setFormFieldList(formFieldJSONList); - //reportJSONRuntime.setReportDataColumns(get); int count = 0; Map<String,Object> dvJSON = null; if(rd!=null) { @@ -2834,7 +2618,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } reportJSONRuntime.setReportDataColumns(colList); reportJSONRuntime.setReportDataRows(reportDataRows); - //reportJSONRuntime.setSqlWhole(getWholeSQL()); reportJSONRuntime.setPageSize(getPageSize()); reportJSONRuntime.setReportTotalDataRows(reportTotalDataRows); @@ -2898,16 +2681,14 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep setTriggerThisFormFieldCheck(getReportFormFields(), ff); SQL = parseAndFillReq_Session_UserValues(request, SQL, userId); SQL = parseAndFillOtherFormfieldValues(request, SQL, userId, formFieldJSONList); - //SQL = parseAndFillWithCurrentValues(formGrid,SQL, ff); String defaultSQL = lu.getDefaultSQL(); defaultSQL = parseAndFillReq_Session_UserValues(request, defaultSQL, userId); - //defaultSQL = parseAndFillWithCurrentValues(formGrid,defaultSQL, ff); 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); + }catch (Exception e) { } } lookup.trimToSize(); @@ -2916,10 +2697,6 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ArrayList<String> requestValueList = new ArrayList<>(); requestValueList.add(requestValue); - /*if(ff.isTriggerThisFormfield()) { - refreshFormFieldsWithLatestValue(request, userId, ff, formFieldJSONList); - }*/ - for (lookup.resetNext(); lookup.hasNext();) { IdNameValue value = lookup.getNext(); @@ -2929,7 +2706,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep value.setDefaultValue(true); } formFieldValues.add(value); - //break; + } } else { @@ -2949,21 +2726,17 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep ((IdNameSql)lookup).setSQL(oldSQL); } } - - - //if(!ff.isTriggerThisFormfield()) { ffJSON.setFormFieldValues(formFieldValues); - //} + break; - } //if - } //for - }//for - }//if + } + } + } + } reportJSONRuntime.setFormFieldList(formFieldJSONList); - //reportJSONRuntime.setReportDataColumns(get); return reportJSONRuntime; @@ -3011,16 +2784,12 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep boolean multiple = false; if(type.equals("LIST_MULTI_SELECT")) multiple = true; - //multiple = (selectedItems.size()>1); for(Iterator iter = selectedItems.iterator(); iter.hasNext(); ) { count++; String entry = (String) iter.next(); if(count == 1 && multiple) value.append("("); - //if(type.equals(FormField.FFT_CHECK_BOX)) - /*if(type.equals(FormField.FFT_CHECK_BOX)) - value.append("'"+Utils.oracleSafe(entry)+"'"); - else*/ if (type.equals(FormField.FFT_LIST_MULTI)) + else if (type.equals(FormField.FFT_LIST_MULTI)) value.append("'"+Utils.oracleSafe(entry)+"'"); else if(type.equals(FormField.FFT_LIST_BOX)) value.append(Utils.oracleSafe(entry)); @@ -3047,14 +2816,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s String fieldDisplay = getFormFieldDisplayName(fft); String formfield_value = ""; List<String> selectedItems = new ArrayList<>(); - //Added so that Combo Box in old RAPTOR definition is translated to List box if(fft.getFieldType().equals(FormField.FFT_COMBO_BOX)) { fft.setFieldType(FormField.FFT_LIST_BOX); } if(!fft.getFieldType().equals(FormField.FFT_BLANK)) { - //if(source_Formfield==null || (source_Formfield!=null && !fft.getFieldId().equals(source_Formfield.getFieldName()))) { - // Add oracle safe - // Add param base sql if(fft.getFieldType().equals(FormField.FFT_LIST_MULTI) || fft.getFieldType().equals(FormField.FFT_CHECK_BOX)) { if(request.getParameterValues(fieldId)!=null && request.getParameterValues(fieldId).length > 0) { @@ -3085,73 +2850,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } } else if (fft.getValidationType().equals(FormField.VT_DATE) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - /*if(formGrid.hasFellow(fieldId, true)) { - Datebox tb = (Datebox) formGrid.getFellowIfAny(fieldId, true); - try { - formfield_value = tb.getText(); - } catch (WrongValueException ex) { - formfield_value = ""; - } - if(AppUtils.nvl(formfield_value).length() > 0) { - if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { - if(formGrid.hasFellow(fieldId+"_Hr", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { - if(formGrid.hasFellow(fieldId+"_Min", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(formGrid.hasFellow(fieldId+"_Sec", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue(); - - } - } - } - } else { - formfield_value = ""; - }*/ } else if ((fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC))) { - /*if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)|| - fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_HR)) { - if(formGrid.hasFellow(fieldId+"_Hr", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_MIN)) { - if(formGrid.hasFellow(fieldId+"_Min", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - } - } else if(fft.getValidationType().equals(FormField.VT_TIMESTAMP_SEC)) { - if(formGrid.hasFellow(fieldId+"_Sec", true)) { - Label hiddenLbHr = (Label) formGrid.getFellowIfAny(fieldId+"_Hr", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue(); - Label hiddenLbMin = (Label) formGrid.getFellowIfAny(fieldId+"_Min", true); - //formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue(); - Label hiddenLbSec = (Label) formGrid.getFellowIfAny(fieldId+"_Sec", true); - formfield_value = formfield_value + " " + hiddenLbHr.getValue() + ":" +hiddenLbMin.getValue()+ ":" +hiddenLbSec.getValue(); - - } - } - - } */ } else if (fft.getFieldType().equals(FormField.FFT_TEXT_W_POPUP)) { if(request.getParameter(fieldId)!=null) { formfield_value = request.getParameter(fieldId); @@ -3164,16 +2866,15 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } else { formfield_value = ""; } - //} + } if(nvl(formfield_value).length()>0) { sql = Utils.replaceInString(sql, fieldDisplay, formfield_value); } else { sql = Utils.replaceInString(sql, "'"+fieldDisplay+"'", "null"); sql = Utils.replaceInString(sql, fieldDisplay, "null"); - //sql = Utils.replaceInString(sql, fieldDisplay, "''"); } - } // for + } } } return sql; @@ -3195,7 +2896,6 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } for (int i = 0; i < scheduleSessionParameters.length; i++) { - //debugLogger.debug(" Session " + " scheduleSessionParameters[i] " + scheduleSessionParameters[i].toUpperCase() + " " + request.getParameter(scheduleSessionParameters[i])); if(request.getParameter(scheduleSessionParameters[i])!=null && request.getParameter(scheduleSessionParameters[i]).trim().length()>0 ) sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", request.getParameter(scheduleSessionParameters[i]) ); if(request.getAttribute(scheduleSessionParameters[i])!=null && ((String)request.getAttribute(scheduleSessionParameters[i])).trim().length()>0 ) @@ -3204,14 +2904,10 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s } for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - //fieldSQL = Utils.replaceInString(fieldSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - //else { if (session.getAttribute(sessionParameters[i])!=null && ((String)session.getAttribute(sessionParameters[i])).length() > 0) { - //debugLogger.debug(" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i])); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - // } + } sql = Utils.replaceInString(sql, "[USERID]", user_id); sql = Utils.replaceInString(sql, "[USER_ID]", user_id); @@ -3221,4 +2917,24 @@ public String parseAndFillWithCurrentValues(HttpServletRequest request, String s return sql; } -} // ReportRuntime + private static String reverseDisplayValue(String value) { + int i = value.length() - 1; + int start, end = i + 1; + String result = ""; + while (i >= 0) { + if (value.charAt(i) == ',') { + start = i + 1; + while (start != end) + result += value.charAt(start++); + result += ','; + end = i; + } + i--; + } + start = 0; + while (start != end) + result += value.charAt(start++); + return result; + } + +} |