From f51a3e2b128f0b96bc9ed67dfc3081f4b41d1303 Mon Sep 17 00:00:00 2001 From: "Kishore Reddy, Gujja (kg811t)" Date: Fri, 8 Jun 2018 16:40:16 -0400 Subject: Junit Test Cases & Raptors Issue-ID: PORTAL-273. PORTAL-301 Covered JUNITS for sdk modules and RAPTOR reports fixes Change-Id: Ifaf3bf06f0ec123051a791cc8e7f10662f97a525 Signed-off-by: Kishore Reddy, Gujja (kg811t) --- .../system/fusion/web/RaptorControllerAsync.java | 248 +++++++++++++++++---- 1 file changed, 203 insertions(+), 45 deletions(-) (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index b2ce1b7d..e06a1765 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -66,9 +66,13 @@ import org.onap.portalsdk.analytics.error.RaptorRuntimeException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; +import org.onap.portalsdk.analytics.model.ReportLoader; +import org.onap.portalsdk.analytics.model.base.IdNameList; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.model.base.ReportUserRole; +import org.onap.portalsdk.analytics.model.definition.DrillDownParamDef; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.definition.ReportLogEntry; import org.onap.portalsdk.analytics.model.definition.SecurityEntry; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnEditJSON; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON; @@ -296,6 +300,20 @@ public class RaptorControllerAsync extends RestrictedBaseController { } } + @RequestMapping(value = "/report/wizard/drill_down_param/{parameter}", method = RequestMethod.GET, produces = "application/json") + public @ResponseBody List getDrillDownParamDef (@PathVariable("parameter") String parameter, HttpServletRequest request, HttpServletResponse response) + throws IOException, RaptorException { + List list = new ArrayList<>(); + String[] tmepArray = null; + if(parameter!=null){ + tmepArray = parameter.split("&"); + } + for(String str:tmepArray){ + list.add(new DrillDownParamDef(str)); + } + return list; + } + @RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json") public @ResponseBody ArrayList listColumns(HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException { @@ -307,7 +325,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { for (DataColumnType reportColumnType : reportColumnList) { columnJSON = new ColumnJSON(); columnJSON.setId(reportColumnType.getColId()); - columnJSON.setName(reportColumnType.getColName()); + columnJSON.setName(reportColumnType.getDisplayName()); listJSON.add(columnJSON); } return listJSON; @@ -375,6 +393,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { String fieldDisplay = fft.getFieldName(); fieldJSON.setId(fieldId); fieldJSON.setName(fieldDisplay); + fieldJSON.setOrderSeq(fft.getOrderBySeq()); listJSON.add(fieldJSON); } } @@ -501,20 +520,15 @@ public class RaptorControllerAsync extends RestrictedBaseController { fft.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL()); fft.setFieldSQL(formEditJSON.getFieldSQL()); fft.setValidationType(formEditJSON.getValidationType()); - + fft.setGroupFormField(formEditJSON.isGroupFormField()); + fft.setOrderBySeq(formEditJSON.getOrderSeq()); // clear predefined value - if (fft.getPredefinedValueList() != null) { - for (Iterator iter = fft.getPredefinedValueList().getPredefinedValue() - .iterator(); iter.hasNext();) - iter.remove(); - } - + PredefinedValueList predefinedValueList = new ObjectFactory().createPredefinedValueList(); + fft.setPredefinedValueList(predefinedValueList); + List predefList = formEditJSON.getPredefinedValueList(); if (predefList != null && predefList.size() > 0) { for (IdNameBooleanJSON item : predefList) { - PredefinedValueList predefinedValueList = new ObjectFactory() - .createPredefinedValueList(); - fft.setPredefinedValueList(predefinedValueList); fft.getPredefinedValueList().getPredefinedValue().add(item.getId()); } } @@ -540,6 +554,52 @@ public class RaptorControllerAsync extends RestrictedBaseController { return messageJSON; } + + @RequestMapping(value = "report/wizard/add_formfield_tab_data", method = RequestMethod.POST) + public @ResponseBody MessageJSON addFFTabWiseData(@RequestBody FormEditJSON formEditJSON, + HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException { + ReportDefinition rdef = null; + rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); + + MessageJSON messageJSON = new MessageJSON(); + try { + if (rdef != null) { + FormEditJSON wizardJSON = new FormEditJSON(); + wizardJSON.setTabId("FormEdit"); + wizardJSON.setTabName("Form Edit"); + String fieldId =""; + if(rdef.getFormFieldList()==null || rdef.getFormFieldList().getFormField()==null || rdef.getFormFieldList().getFormField().size()==0) + fieldId = "ff1"; + else + fieldId = "ff"+(rdef.getFormFieldList().getFormField().size()+1); + FormFieldType currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",""); + currField.setFieldId(fieldId); + currField.setFieldName(formEditJSON.getFieldName()); + currField.setFieldType(formEditJSON.getFieldType()==null?null:formEditJSON.getFieldType()); + currField.setVisible(formEditJSON.isVisible()?"Y":"N"); + currField.setDefaultValue(formEditJSON.getDefaultValue()); + currField.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL()); + currField.setFieldSQL(formEditJSON.getFieldSQL()); + currField.setValidationType(formEditJSON.getValidationType()); + currField.setGroupFormField(formEditJSON.isGroupFormField()); + persistReportDefinition(request, rdef); + + messageJSON.setMessage("Success formfield Details of given report is saved in session."); + messageJSON.setAnyStacktrace(rdef.getReportID() + " is added to session and DB."); + + } else { + messageJSON.setMessage("Report Definition is not in session"); + messageJSON.setAnyStacktrace("Report Definition is not in session"); + + } + } catch (Exception ex) { + messageJSON.setMessage("Error occured while formfield details Tab"); + messageJSON.setAnyStacktrace(getStackTrace(ex)); + return messageJSON; + } + + return messageJSON; + } @RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST) public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON, @@ -558,6 +618,18 @@ public class RaptorControllerAsync extends RestrictedBaseController { // columnJSON = new ColumnJSON(); if (reportColumnType.getColId().equals(colId)) { reportColumnType.setColName(columnEditJSON.getColName()); + reportColumnType.setDependsOnFormField(columnEditJSON.getDepeondsOnForField()==null?"":columnEditJSON.getDepeondsOnForField()); + reportColumnType.setColType(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType()); + reportColumnType.setDbColName(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType()); + reportColumnType.setGroupByPos(columnEditJSON.getGroupByPos()); + reportColumnType.setSubTotalCustomText(columnEditJSON.getSubTotalCustomText()); + reportColumnType.setHideRepeatedKey(columnEditJSON.isHideRepeatedKey()); + reportColumnType.setLevel(columnEditJSON.getLevel()); + reportColumnType.setColspan(columnEditJSON.getColspan()); + reportColumnType.setDisplayName(columnEditJSON.getDisplayName()); + reportColumnType.setDisplayWidthInPxls(columnEditJSON.getDisplayWidthInPixel()==null?null:String.valueOf(columnEditJSON.getDisplayWidthInPixel())); + reportColumnType.setNowrap(columnEditJSON.getNoWrap()); + reportColumnType.setIndentation(columnEditJSON.getIndentation()); reportColumnType.setDisplayAlignment(columnEditJSON.getDisplayAlignment()); reportColumnType.setDisplayHeaderAlignment(columnEditJSON.getDisplayHeaderAlignment()); reportColumnType.setIsSortable(columnEditJSON.isSortable()); @@ -565,7 +637,9 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportColumnType.setDrillDownURL(columnEditJSON.getDrilldownURL()); reportColumnType.setDrillDownParams(columnEditJSON.getDrilldownParams()); reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType()); - + if(columnEditJSON.getDisplayTotal()!=null) + reportColumnType.setDisplayTotal(columnEditJSON.getDisplayTotal()); + } } @@ -650,22 +724,28 @@ public class RaptorControllerAsync extends RestrictedBaseController { rdef.setFormHelpText(formHelpText); Integer pageSize = definitionJSON.getPageSize(); - rdef.setPageSize(pageSize); + if(pageSize!=null) + rdef.setPageSize(pageSize); List menuIds = definitionJSON.getDisplayArea(); - for (IdNameBooleanJSON menuId : menuIds) { - if (menuId.isSelected()) { - rdef.setMenuID(menuId.getName()); - } + if(menuIds!=null){ + for (IdNameBooleanJSON menuId : menuIds) { + if (menuId.isSelected()) { + rdef.setMenuID(menuId.getName()); + } + } } + Boolean hideFormFieldsAfterRun = definitionJSON.getHideFormFieldsAfterRun(); - rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun); + rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun==null?false:hideFormFieldsAfterRun); Integer maxRowsInExcelCSVDownload = definitionJSON.getMaxRowsInExcelCSVDownload(); - rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload); + if(maxRowsInExcelCSVDownload!=null) + rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload); Integer frozenColumns = definitionJSON.getFrozenColumns(); - rdef.setFrozenColumns(frozenColumns); + if(frozenColumns!=null) + rdef.setFrozenColumns(frozenColumns); String dataGridAlign = definitionJSON.getDataGridAlign(); rdef.setDataGridAlign(dataGridAlign); String emptyMessage = definitionJSON.getEmptyMessage(); @@ -674,10 +754,11 @@ public class RaptorControllerAsync extends RestrictedBaseController { rdef.setDataContainerHeight(dataContainerHeight); String dataContainerWidth = definitionJSON.getDataContainerWidth(); rdef.setDataContainerWidth(dataContainerWidth); - boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled(); - rdef.setRuntimeColSortDisabled(runtimeColSortDisabled); + Boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled(); + rdef.setRuntimeColSortDisabled(runtimeColSortDisabled==null?false:runtimeColSortDisabled); Integer numFormCols = definitionJSON.getNumFormCols(); - rdef.setNumFormCols(Integer.toString(numFormCols)); + if(numFormCols!=null) + rdef.setNumFormCols(Integer.toString(numFormCols)); String reportTitle = definitionJSON.getReportTitle(); rdef.setReportTitle(reportTitle); String reportSubTitle = definitionJSON.getReportSubTitle(); @@ -685,24 +766,45 @@ public class RaptorControllerAsync extends RestrictedBaseController { List displayOptions = definitionJSON.getDisplayOptions(); StringBuffer displayOptionStr = new StringBuffer("NNNNNNN"); - for (NameBooleanJSON displayOption : displayOptions) { - if (displayOption.isSelected()) { - if (displayOption.getName().equals("HideFormFields")) { - displayOptionStr.setCharAt(0, 'Y'); - } else if (displayOption.getName().equals("HideChart")) { - displayOptionStr.setCharAt(1, 'Y'); - } else if (displayOption.getName().equals("HideReportData")) { - displayOptionStr.setCharAt(2, 'Y'); - } else if (displayOption.getName().equals("HideExcel")) { - displayOptionStr.setCharAt(5, 'Y'); - } else if (displayOption.getName().equals("HidePdf")) { - displayOptionStr.setCharAt(6, 'Y'); + if(displayOptions!=null){ + for (NameBooleanJSON displayOption : displayOptions) { + if (displayOption.isSelected()) { + if (displayOption.getName().equals("HideFormFields")) { + displayOptionStr.setCharAt(0, 'Y'); + } else if (displayOption.getName().equals("HideChart")) { + displayOptionStr.setCharAt(1, 'Y'); + } else if (displayOption.getName().equals("HideReportData")) { + displayOptionStr.setCharAt(2, 'Y'); + } else if (displayOption.getName().equals("HideExcel")) { + displayOptionStr.setCharAt(5, 'Y'); + } else if (displayOption.getName().equals("HidePdf")) { + displayOptionStr.setCharAt(6, 'Y'); + } } - } + } } - - rdef.setDisplayOptions(displayOptionStr.toString()); + + if(displayOptionStr!=null) + rdef.setDisplayOptions(displayOptionStr.toString()); + + if(definitionJSON.getAllowScheduler()!=null) + rdef.setAllowSchedule(definitionJSON.getAllowScheduler().equals("true")?"Y":"N"); + if(definitionJSON.getSizedByContent()!=null) + rdef.setSizedByContent(definitionJSON.getSizedByContent().equals("true")?"Y":"N"); + if(definitionJSON.getOneTimeRec()!=null) + rdef.setIsOneTimeScheduleAllowed(definitionJSON.getOneTimeRec().equals("true")?"Y":"N"); + if(definitionJSON.getHourlyRec()!=null) + rdef.setIsHourlyScheduleAllowed(definitionJSON.getHourlyRec().equals("true")?"Y":"N"); + if(definitionJSON.getDailyRec()!=null) + rdef.setIsDailyScheduleAllowed(definitionJSON.getDailyRec().equals("true")?"Y":"N"); + if(definitionJSON.getDailyMFRec()!=null) + rdef.setIsDailyMFScheduleAllowed(definitionJSON.getDailyMFRec().equals("true")?"Y":"N"); + if(definitionJSON.getWeeklyRec()!=null) + rdef.setIsWeeklyScheduleAllowed(definitionJSON.getWeeklyRec().equals("true")?"Y":"N"); + if(definitionJSON.getMonthlyRec()!=null) + rdef.setIsMonthlyScheduleAllowed(definitionJSON.getMonthlyRec().equals("true")?"Y":"N"); + } if (id.equals("Create")) { rdef.persistReport(request); @@ -779,7 +881,8 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setFieldDefaultSQL(fft.getFieldDefaultSQL()); wizardJSON.setFieldSQL(fft.getFieldSQL()); wizardJSON.setValidationType(fft.getValidationType()); - + wizardJSON.setGroupFormField(fft.isGroupFormField()); + wizardJSON.setOrderSeq(fft.getOrderBySeq()); PredefinedValueList preDefined = fft.getPredefinedValueList(); if (preDefined != null) { @@ -847,7 +950,20 @@ public class RaptorControllerAsync extends RestrictedBaseController { reportColumnType.getDrillDownParams() == null ? "" : reportColumnType.getDrillDownParams()); wizardJSON.setDrilldownType( reportColumnType.getDrillDownType() == null ? "" : reportColumnType.getDrillDownType()); - + wizardJSON.setDataType(reportColumnType.getDbColType() == null ? "" :reportColumnType.getDbColType()); + wizardJSON.setGroupByPos(reportColumnType.getGroupByPos()); + wizardJSON.setLevel(reportColumnType.getLevel()); + wizardJSON.setDisplayWidth(reportColumnType.getDisplayWidth()); + wizardJSON.setNoWrap(reportColumnType.getNowrap() == null ? "" : reportColumnType.getNowrap()); + wizardJSON.setIndentation(reportColumnType.getIndentation()); + + wizardJSON.setDepeondsOnForField(reportColumnType.getDependsOnFormField() ==null?"":reportColumnType.getDependsOnFormField()); + wizardJSON.setSubTotalCustomText(reportColumnType.getSubTotalCustomText()==null?"":reportColumnType.getSubTotalCustomText()); + + wizardJSON.setHideRepeatedKey(reportColumnType.isHideRepeatedKey()==null?false:reportColumnType.isHideRepeatedKey()); + wizardJSON.setColspan(reportColumnType.getColspan()==null?null:reportColumnType.getColspan()); + wizardJSON.setDisplayName(reportColumnType.getDisplayName()); + wizardJSON.setDisplayTotal(reportColumnType.getDisplayTotal()); } } } else { @@ -905,6 +1021,17 @@ public class RaptorControllerAsync extends RestrictedBaseController { return wizardJSON; } + @RequestMapping(value = { "/report/wizard/retrieveTotalForTheColList" }, method = RequestMethod.GET) + public @ResponseBody List getTotalForTheCol(HttpServletRequest request) + throws IOException, RaptorException { + IdNameList idNameList = AppConstants.TOTAL_FUNCTIONS; + List list = new ArrayList<>(); + for(int i=0; i getReportUserList(HttpServletRequest request) throws IOException, RaptorException { @@ -1339,7 +1466,17 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setNumFormCols((rdef != null) ? rdef.getNumFormColsAsInt() : 1); wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : ""); wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : ""); - + + /*Robert add*/ + wizardJSON.setOneTimeRec((rdef != null) ? rdef.getIsOneTimeScheduleAllowed() : "false"); + wizardJSON.setHourlyRec((rdef != null) ? rdef.getIsHourlyScheduleAllowed() : "false"); + wizardJSON.setDailyRec((rdef != null) ? rdef.getIsDailyScheduleAllowed() : "false"); + wizardJSON.setDailyMFRec((rdef != null) ? rdef.getIsDailyMFScheduleAllowed() : "false"); + wizardJSON.setWeeklyRec((rdef != null) ? rdef.getIsWeeklyScheduleAllowed() : "false"); + wizardJSON.setMonthlyRec((rdef != null) ? rdef.getIsMonthlyScheduleAllowed() : "false"); + wizardJSON.setAllowScheduler((rdef != null) ? rdef.getAllowSchedule() : "false"); + wizardJSON.setSizedByContent((rdef != null) ? rdef.getSizedByContentOption() : "false"); + wizardJSON.setRepDefType(rdef.getReportDefType()); } ObjectMapper mapper = new ObjectMapper(); @@ -1357,7 +1494,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { RaptorResponse raptorResponse = new RaptorResponse(); String sql = queryJSON.getQuery(); String jsonInString = ""; - + ServletContext servletContext = request.getSession().getServletContext(); if (!Globals.isSystemInitialized()) { Globals.initializeSystem(servletContext); @@ -1440,7 +1577,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { QueryResultJSON queryResultJSON = new QueryResultJSON(); queryResultJSON.setQuery(queryJSON.getQuery()); String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery()); - rdef.parseReportSQL(query); + rdef.parseReportSQL(query,validate); queryResultJSON.setQuery(query); int numColumns = ds.getColumnCount(); @@ -1548,6 +1685,23 @@ public class RaptorControllerAsync extends RestrictedBaseController { return raptorResponse; } + + + @RequestMapping(value = "/report/wizard/get_report_log/{reportID}", method = RequestMethod.GET) + public @ResponseBody ArrayList getLogs(@PathVariable("reportID") String reportId, HttpServletRequest request, + HttpServletResponse ReportLogEntry) throws IOException { + ArrayList arrayList = new ArrayList<>(); + try { + Vector v = ReportLoader.loadReportLogEntries(reportId); + for(ReportLogEntry r:v ){ + arrayList.add(r); + } + } catch (RaptorException e) { + logger.error(EELFLoggerDelegate.errorLogger, + "RaptorControllerAsync getLogs.", e); + } + return arrayList; + } @RequestMapping(value = "save_chart", method = RequestMethod.POST) public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request, @@ -1627,7 +1781,12 @@ public class RaptorControllerAsync extends RestrictedBaseController { dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included else dct.setChartSeq(++r); - dct.setColOnChart("0"); + + if (!dct.getColId().equals(domainAxis)) { + dct.setColOnChart("0"); + }else{ + dct.setChartSeq(-1); + } dct.setYAxis(rangeYAxis); // +"|"+dct.getColId()); dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId()); dct.setChartColor(rangeColor); @@ -1646,7 +1805,6 @@ public class RaptorControllerAsync extends RestrictedBaseController { } } - reportRuntime.setChartLeftAxisLabel(chartJSON.getPrimaryAxisLabel()); reportRuntime.setChartRightAxisLabel(chartJSON.getSecondaryAxisLabel()); -- cgit 1.2.3-korg