2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.onap.portalsdk.analytics.system.fusion.web;
40 import java.io.IOException;
41 import java.io.OutputStreamWriter;
42 import java.io.PrintWriter;
43 import java.io.StringWriter;
44 import java.io.Writer;
45 import java.lang.reflect.InvocationTargetException;
46 import java.lang.reflect.Method;
47 import java.util.ArrayList;
48 import java.util.Enumeration;
49 import java.util.HashMap;
50 import java.util.HashSet;
51 import java.util.Iterator;
52 import java.util.List;
54 import java.util.Vector;
56 import javax.servlet.ServletContext;
57 import javax.servlet.http.HttpServletRequest;
58 import javax.servlet.http.HttpServletResponse;
59 import javax.servlet.http.HttpSession;
61 import org.onap.portalsdk.analytics.controller.Action;
62 import org.onap.portalsdk.analytics.controller.ErrorHandler;
63 import org.onap.portalsdk.analytics.controller.WizardSequence;
64 import org.onap.portalsdk.analytics.error.RaptorException;
65 import org.onap.portalsdk.analytics.error.RaptorRuntimeException;
66 import org.onap.portalsdk.analytics.error.ReportSQLException;
67 import org.onap.portalsdk.analytics.model.DataCache;
68 import org.onap.portalsdk.analytics.model.ReportHandler;
69 import org.onap.portalsdk.analytics.model.base.IdNameValue;
70 import org.onap.portalsdk.analytics.model.base.ReportUserRole;
71 import org.onap.portalsdk.analytics.model.definition.ReportDefinition;
72 import org.onap.portalsdk.analytics.model.definition.SecurityEntry;
73 import org.onap.portalsdk.analytics.model.definition.wizard.ColumnEditJSON;
74 import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON;
75 import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON;
76 import org.onap.portalsdk.analytics.model.definition.wizard.FormEditJSON;
77 import org.onap.portalsdk.analytics.model.definition.wizard.IdNameBooleanJSON;
78 import org.onap.portalsdk.analytics.model.definition.wizard.ImportJSON;
79 import org.onap.portalsdk.analytics.model.definition.wizard.MessageJSON;
80 import org.onap.portalsdk.analytics.model.definition.wizard.NameBooleanJSON;
81 import org.onap.portalsdk.analytics.model.definition.wizard.QueryJSON;
82 import org.onap.portalsdk.analytics.model.definition.wizard.QueryResultJSON;
83 import org.onap.portalsdk.analytics.model.definition.wizard.RaptorResponse;
84 import org.onap.portalsdk.analytics.model.definition.wizard.SearchFieldJSON;
85 import org.onap.portalsdk.analytics.model.pdf.PdfReportHandler;
86 import org.onap.portalsdk.analytics.model.runtime.CategoryAxisJSON;
87 import org.onap.portalsdk.analytics.model.runtime.ChartJSON;
88 import org.onap.portalsdk.analytics.model.runtime.ErrorJSONRuntime;
89 import org.onap.portalsdk.analytics.model.runtime.FormField;
90 import org.onap.portalsdk.analytics.model.runtime.RangeAxisJSON;
91 import org.onap.portalsdk.analytics.model.runtime.ReportFormFields;
92 import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
93 import org.onap.portalsdk.analytics.system.AppUtils;
94 import org.onap.portalsdk.analytics.system.ConnectionUtils;
95 import org.onap.portalsdk.analytics.system.Globals;
96 import org.onap.portalsdk.analytics.util.AppConstants;
97 import org.onap.portalsdk.analytics.util.DataSet;
98 import org.onap.portalsdk.analytics.util.Utils;
99 import org.onap.portalsdk.analytics.util.XSSFilter;
100 import org.onap.portalsdk.analytics.view.ReportData;
101 import org.onap.portalsdk.analytics.xmlobj.DataColumnType;
102 import org.onap.portalsdk.analytics.xmlobj.FormFieldType;
103 import org.onap.portalsdk.analytics.xmlobj.ObjectFactory;
104 import org.onap.portalsdk.analytics.xmlobj.PredefinedValueList;
105 import org.onap.portalsdk.core.controller.RestrictedBaseController;
106 import org.onap.portalsdk.core.domain.User;
107 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
108 import org.onap.portalsdk.core.util.SecurityCodecUtil;
109 import org.onap.portalsdk.core.web.support.UserUtils;
110 import org.owasp.esapi.ESAPI;
111 import org.springframework.stereotype.Controller;
112 import org.springframework.web.bind.annotation.PathVariable;
113 import org.springframework.web.bind.annotation.RequestBody;
114 import org.springframework.web.bind.annotation.RequestMapping;
115 import org.springframework.web.bind.annotation.RequestMethod;
116 import org.springframework.web.bind.annotation.ResponseBody;
118 import com.fasterxml.jackson.databind.DeserializationFeature;
119 import com.fasterxml.jackson.databind.ObjectMapper;
120 import com.fasterxml.jackson.databind.SerializationFeature;
124 public class RaptorControllerAsync extends RestrictedBaseController {
126 private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorControllerAsync.class);
128 private String viewName;
130 @RequestMapping(value = { "/raptor.htm" }, method = RequestMethod.GET)
131 public void RaptorSearch(HttpServletRequest request, HttpServletResponse response)
132 throws IOException, RaptorException {
135 String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
136 actionKey = nvl(actionKey, "report.run");
138 HttpSession session = request.getSession();
139 User user = UserUtils.getUserSession(request);
141 if (actionKey.equals("report.download.excel2007.session") || actionKey.equals("report.download.csv.session")
142 || actionKey.equals("report.download.excel.session")
143 || actionKey.equals("report.download.pdf.session")) {
144 if (session != null && user != null) {
145 ServletContext servletContext = request.getSession().getServletContext();
146 if (!Globals.isSystemInitialized()) {
147 Globals.initializeSystem(servletContext);
149 ReportRuntime rr = null;
150 ReportData rd = null;
153 if (!nvl(request.getParameter("parent"), "").equals("N"))
154 parent = nvl(request.getParameter("parent"), "");
155 if (parent.startsWith("parent_"))
157 if (parentFlag == 1) {
158 rr = (ReportRuntime) request.getSession().getAttribute(parent + "_rr");
159 rd = (ReportData) request.getSession().getAttribute(parent + "_rd");
162 boolean isEmbedded = false;
163 Object temp = request.getSession().getAttribute("isEmbedded");
165 isEmbedded = (boolean) temp;
168 String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID);
170 rr = (ReportRuntime) ((HashMap) request.getSession()
171 .getAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP)).get(reportID);
173 rd = (ReportData) ((HashMap) request.getSession()
174 .getAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP)).get(reportID);
177 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
179 rd = (ReportData) request.getSession().getAttribute(AppConstants.RI_REPORT_DATA);
181 String user_id = AppUtils.getUserID(request);
182 int downloadLimit = 0;
184 downloadLimit = (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload()
185 : Globals.getDownloadLimit();
186 if (actionKey.equals("report.csv.download"))
187 downloadLimit = Globals.getCSVDownloadLimit();
188 String sql_whole = rr.getReportDataSQL(user_id, downloadLimit, request);
189 request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole);
191 OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
193 if (actionKey.equals("report.download.pdf.session")) {
194 new PdfReportHandler().createPdfFileContent(request, response, 3);
195 } else if (actionKey.equals("report.download.csv.session")) {
196 (new ReportHandler()).createCSVFileContent(out, rd, rr, request, response);
197 } else if (actionKey.equals("report.download.excel.session")) {
198 new ReportHandler().createExcelFileContent(out, rd, rr, request, response, user_id, 3); // 3
202 new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, user_id, 3); // 3
205 } catch (Exception e) {
206 logger.error(EELFLoggerDelegate.errorLogger,
207 "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
210 response.sendRedirect("login.htm");
213 if (session != null && user != null) {
214 Action action = null;
215 ServletContext servletContext = request.getSession().getServletContext();
216 if (!Globals.isSystemInitialized()) {
217 Globals.initializeSystem(servletContext);
220 action = Globals.getRaptorActionMapping().getAction(actionKey);
222 throw new RaptorRuntimeException("Action not found");
223 } catch (RaptorException e) {
224 logger.error(EELFLoggerDelegate.errorLogger,
225 "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
227 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
228 new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
229 + "]. Exception: " + e.getMessage()));
233 Class[] paramTypes = new Class[2];
234 paramTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
235 paramTypes[1] = Class.forName("java.lang.String");
237 Class handlerClass = Class.forName(action.getControllerClass());
238 Object handler = handlerClass.newInstance();
239 Method handlerMethod = handlerClass.getMethod(action.getControllerMethod(), paramTypes);
241 Object[] paramValues = new Object[2];
242 paramValues[0] = request;
243 paramValues[1] = action.getJspName();
246 viewName = (String) handlerMethod.invoke(handler, paramValues);
247 if (!actionKey.equals("chart.run"))
248 response.setContentType("application/json");
250 response.setContentType("text/html");
252 } catch (ClassNotFoundException e) {
253 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
254 + actionKey + "]. ClassNotFoundException: " + e.getMessage()));
255 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
256 new RaptorRuntimeException(
257 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
259 } catch (IllegalAccessException e) {
260 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
261 + actionKey + "]. IllegalAccessException: " + e.getMessage()));
262 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
263 new RaptorRuntimeException(
264 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
266 } catch (InstantiationException e) {
267 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
268 + actionKey + "]. InstantiationException: " + e.getMessage()));
269 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
270 new RaptorRuntimeException(
271 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
273 } catch (NoSuchMethodException e) {
274 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
275 + actionKey + "]. NoSuchMethodException: " + e.getMessage()));
276 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
277 new RaptorRuntimeException(
278 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
280 } catch (InvocationTargetException e) {
281 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
282 + actionKey + "]. InvocationTargetException: " + e.getMessage()));
283 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
284 new RaptorRuntimeException(
285 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
288 PrintWriter out = response.getWriter();
292 PrintWriter out = response.getWriter();
293 out.write("session has timed out for user");
299 @RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json")
300 public @ResponseBody ArrayList<ColumnJSON> listColumns(HttpServletRequest request, HttpServletResponse response)
301 throws IOException, RaptorException {
302 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
303 List<DataColumnType> reportColumnList = rdef.getAllColumns();
304 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
305 ColumnJSON columnJSON = new ColumnJSON();
307 for (DataColumnType reportColumnType : reportColumnList) {
308 columnJSON = new ColumnJSON();
309 columnJSON.setId(reportColumnType.getColId());
310 columnJSON.setName(reportColumnType.getColName());
311 listJSON.add(columnJSON);
316 @RequestMapping(value = "/report/wizard/list_drilldown_reports", method = RequestMethod.GET, produces = "application/json")
317 public @ResponseBody ArrayList<ColumnJSON> list_drilldown_reports(HttpServletRequest request,
318 HttpServletResponse response) throws IOException, RaptorException {
319 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
320 Vector<IdNameValue> publicReportIdNames = DataCache.getPublicReportIdNames();
321 Vector groupReportIdNames = DataCache.getGroupAccessibleReportIdNames(AppUtils.getUserID(request),
322 AppUtils.getUserRoles(request));
323 Vector privateReportIdNames = DataCache.getPrivateAccessibleReportIdNames(AppUtils.getUserID(request),
324 AppUtils.getUserRoles(request));
326 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
327 ColumnJSON columnJSON = new ColumnJSON();
329 ServletContext servletContext = request.getSession().getServletContext();
330 if (!Globals.isSystemInitialized()) {
331 Globals.initializeSystem(servletContext);
334 for (int i = 0; i < publicReportIdNames.size(); i++) {
335 IdNameValue reportIdName = (IdNameValue) publicReportIdNames.get(i);
336 columnJSON = new ColumnJSON();
337 columnJSON.setId(reportIdName.getId());
338 columnJSON.setName("Public Report: " + reportIdName.getName());
339 if (!rdef.getReportID().equals(reportIdName.getId()))
340 listJSON.add(columnJSON);
343 for (int i = 0; i < groupReportIdNames.size(); i++) {
344 IdNameValue reportIdName = (IdNameValue) groupReportIdNames.get(i);
345 columnJSON = new ColumnJSON();
346 columnJSON.setId(reportIdName.getId());
347 columnJSON.setName("Group Report: " + reportIdName.getName());
348 if (!rdef.getReportID().equals(reportIdName.getId()))
349 listJSON.add(columnJSON);
352 for (int i = 0; i < privateReportIdNames.size(); i++) {
353 IdNameValue reportIdName = (IdNameValue) privateReportIdNames.get(i);
354 columnJSON = new ColumnJSON();
355 columnJSON.setId(reportIdName.getId());
356 columnJSON.setName("Private Report: " + reportIdName.getName());
357 if (!rdef.getReportID().equals(reportIdName.getId()))
358 listJSON.add(columnJSON);
364 @RequestMapping(value = "/report/wizard/list_formfields", method = RequestMethod.GET, produces = "application/json")
365 public @ResponseBody ArrayList<SearchFieldJSON> listFormFields(HttpServletRequest request,
366 HttpServletResponse response) throws IOException, RaptorException {
367 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
368 ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
369 SearchFieldJSON fieldJSON = new SearchFieldJSON();
370 if (rdef.getFormFieldList() != null) {
371 for (Iterator iter = rdef.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
372 fieldJSON = new SearchFieldJSON();
373 FormFieldType fft = (FormFieldType) iter.next();
374 String fieldId = fft.getFieldId();
375 String fieldDisplay = fft.getFieldName();
376 fieldJSON.setId(fieldId);
377 fieldJSON.setName(fieldDisplay);
378 listJSON.add(fieldJSON);
385 @RequestMapping(value = "/report/wizard/list_child_report_col/{reportID}", method = RequestMethod.GET, produces = "application/json")
386 public @ResponseBody ArrayList<ColumnJSON> listChildReportCols(@PathVariable("reportID") String reportID,
387 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
388 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
390 List<DataColumnType> reportColumnList = ddRr.getAllColumns();
391 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
392 ColumnJSON columnJSON = new ColumnJSON();
394 for (DataColumnType reportColumnType : reportColumnList) {
395 columnJSON = new ColumnJSON();
396 columnJSON.setId(reportColumnType.getColId());
397 columnJSON.setName(reportColumnType.getColName());
398 listJSON.add(columnJSON);
403 @RequestMapping(value = "/report/wizard/list_child_report_ff/{reportID}", method = RequestMethod.GET, produces = "application/json")
404 public @ResponseBody ArrayList<SearchFieldJSON> listChildReportFormFields(@PathVariable("reportID") String reportID,
405 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
406 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
407 ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
408 SearchFieldJSON fieldJSON = new SearchFieldJSON();
410 ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
411 if (ddReportFormFields != null) {
412 for (ddReportFormFields.resetNext(); ddReportFormFields.hasNext();) {
413 FormField ff = ddReportFormFields.getNext();
414 if (!ff.getFieldType().equals(FormField.FFT_BLANK)) {
415 fieldJSON = new SearchFieldJSON();
416 fieldJSON.setId(ff.getFieldName());
417 fieldJSON.setName(ff.getFieldDisplayName());
418 listJSON.add(fieldJSON);
425 @RequestMapping(value = "report/wizard/copy_report/{reportID}", method = RequestMethod.GET, produces = "application/json")
426 public @ResponseBody MessageJSON copyReport(@PathVariable("reportID") String reportID, HttpServletRequest request,
427 HttpServletResponse response) throws IOException, RaptorException {
428 MessageJSON messageJSON = new MessageJSON();
431 ReportHandler rh = new ReportHandler();
432 ReportDefinition rdef = rh.loadReportDefinition(request, reportID);
433 rdef.setAsCopy(request);
434 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
435 messageJSON.setMessage("Success- Report Copied.");
436 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
438 } catch (RaptorException e) {
439 request.setAttribute("error_extra_msg", "While copying report " + reportID);
440 messageJSON.setMessage("Failed - While copying report " + reportID);
441 messageJSON.setAnyStacktrace(getStackTrace(e));
442 logger.debug(EELFLoggerDelegate.debugLogger,
443 ("[Controller.processRequest]Invalid raptor action [copyReport]. RaptorException: "
451 @RequestMapping(value = "report/wizard/import_report", method = RequestMethod.POST, consumes = "application/json")
452 public @ResponseBody MessageJSON importReport(@RequestBody ImportJSON importJSON, HttpServletRequest request,
453 HttpServletResponse response) throws IOException, RaptorException {
454 MessageJSON messageJSON = new MessageJSON();
456 String reportXML = importJSON.getReportXML();
458 ReportHandler rh = new ReportHandler();
459 ReportDefinition rdef = rh.createReportDefinition(request, "-1", reportXML);
460 rdef.updateReportDefType();
461 rdef.generateWizardSequence(request);
462 rdef.setReportName("Import: " + rdef.getReportName());
463 rdef.clearAllDrillDowns();
465 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
467 messageJSON.setMessage("Success- Report imported.");
468 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
470 } catch (RaptorException e) {
471 request.setAttribute("error_extra_msg", "Unable to parse XML. Nested error: ");
472 messageJSON.setMessage("Unable to parse XML. Nested error: ");
473 messageJSON.setAnyStacktrace(getStackTrace(e));
482 @RequestMapping(value = "report/wizard/save_formfield_tab_data", method = RequestMethod.POST)
483 public @ResponseBody MessageJSON saveFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
484 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
485 ReportDefinition rdef = null;
486 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
488 MessageJSON messageJSON = new MessageJSON();
492 String fieldId = formEditJSON.getFieldId();
494 if (rdef.getFormFieldList() != null) {
495 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
496 if (fft.getFieldId().equals(fieldId)) {
497 fft.setFieldName(formEditJSON.getFieldName());
498 fft.setFieldType(formEditJSON.getFieldType());
499 fft.setVisible(formEditJSON.isVisible() ? "Y" : "N");
500 fft.setDefaultValue(formEditJSON.getDefaultValue());
501 fft.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL());
502 fft.setFieldSQL(formEditJSON.getFieldSQL());
503 fft.setValidationType(formEditJSON.getValidationType());
505 // clear predefined value
506 if (fft.getPredefinedValueList() != null) {
507 for (Iterator<String> iter = fft.getPredefinedValueList().getPredefinedValue()
508 .iterator(); iter.hasNext();)
512 List<IdNameBooleanJSON> predefList = formEditJSON.getPredefinedValueList();
513 if (predefList != null && predefList.size() > 0) {
514 for (IdNameBooleanJSON item : predefList) {
515 PredefinedValueList predefinedValueList = new ObjectFactory()
516 .createPredefinedValueList();
517 fft.setPredefinedValueList(predefinedValueList);
518 fft.getPredefinedValueList().getPredefinedValue().add(item.getId());
526 persistReportDefinition(request, rdef);
527 messageJSON.setMessage("Success formfield Details of given report is saved in session.");
528 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
531 messageJSON.setMessage("Report Definition is not in session");
532 messageJSON.setAnyStacktrace("Report Definition is not in session");
535 } catch (Exception ex) {
536 messageJSON.setMessage("Error occured while formfield details Tab");
537 messageJSON.setAnyStacktrace(getStackTrace(ex));
544 @RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST)
545 public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON,
546 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
547 ReportDefinition rdef = null;
548 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
550 MessageJSON messageJSON = new MessageJSON();
554 String colId = columnEditJSON.getColId();
555 List<DataColumnType> reportColumnList = rdef.getAllColumns();
557 for (DataColumnType reportColumnType : reportColumnList) {
558 // columnJSON = new ColumnJSON();
559 if (reportColumnType.getColId().equals(colId)) {
560 reportColumnType.setColName(columnEditJSON.getColName());
561 reportColumnType.setDisplayAlignment(columnEditJSON.getDisplayAlignment());
562 reportColumnType.setDisplayHeaderAlignment(columnEditJSON.getDisplayHeaderAlignment());
563 reportColumnType.setIsSortable(columnEditJSON.isSortable());
564 reportColumnType.setVisible(columnEditJSON.isVisible());
565 reportColumnType.setDrillDownURL(columnEditJSON.getDrilldownURL());
566 reportColumnType.setDrillDownParams(columnEditJSON.getDrilldownParams());
567 reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType());
572 persistReportDefinition(request, rdef);
573 messageJSON.setMessage("Success Column Details of given report is saved in session.");
574 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
577 messageJSON.setMessage("Report Definition is not in session");
578 messageJSON.setAnyStacktrace("");
581 } catch (Exception ex) {
582 messageJSON.setMessage("Error occured while saving column details Tab");
583 messageJSON.setAnyStacktrace(getStackTrace(ex));
591 @RequestMapping(value = "report/wizard/save_def_tab_data/{id}", method = RequestMethod.POST)
592 public @ResponseBody MessageJSON saveDefTabWiseData(@PathVariable("id") String id,
593 @RequestBody DefinitionJSON definitionJSON, HttpServletRequest request, HttpServletResponse response)
594 throws IOException, RaptorException {
595 ReportDefinition rdef = null;
596 ReportRuntime rr = null;
597 boolean newReport = false;
598 MessageJSON messageJSON = new MessageJSON();
601 if (id.equals("InSession")) {
602 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
605 } else if (id.equals("Create")) {
606 removeVariablesFromSession(request);
607 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
609 System.out.println("&&&&&&&&&&&&&&&&&&&&&& CHECK Report Type "
610 + (AppUtils.nvl(rdef.getReportType()).length() <= 0));
611 if (AppUtils.nvl(rdef.getReportType()).length() <= 0) {
612 rdef.setReportType(AppConstants.RT_LINEAR);
613 System.out.println("&&&&&&&&&&&&&&&&&&&&&& ADDED Report Type in session ");
616 } else if (AppUtils.nvl(id).length() > 0) {
617 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
618 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
620 if (rdef != null && !rdef.getReportID().equals(id)) {
621 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
622 removeVariablesFromSession(request);
623 rdef = (new ReportHandler()).loadReportDefinition(request, id);
624 } else if (rr != null && !rr.getReportID().equals(id)) {
625 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
626 removeVariablesFromSession(request);
627 rdef = (new ReportHandler()).loadReportDefinition(request, id);
628 } else if (rdef == null) {
629 rdef = (new ReportHandler()).loadReportDefinition(request, id);
634 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
640 String reportName = definitionJSON.getReportName();
641 String errorString = "";
642 if (AppUtils.nvl(reportName).length() <= 0)
643 errorString = "ReportName cannot be null;";
644 rdef.setReportName(reportName);
646 String reportDescr = definitionJSON.getReportDescr();
647 rdef.setReportDescr(reportDescr);
649 String formHelpText = definitionJSON.getFormHelpText();
650 rdef.setFormHelpText(formHelpText);
652 Integer pageSize = definitionJSON.getPageSize();
653 rdef.setPageSize(pageSize);
655 List<IdNameBooleanJSON> menuIds = definitionJSON.getDisplayArea();
656 for (IdNameBooleanJSON menuId : menuIds) {
657 if (menuId.isSelected()) {
658 rdef.setMenuID(menuId.getName());
663 Boolean hideFormFieldsAfterRun = definitionJSON.getHideFormFieldsAfterRun();
664 rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun);
665 Integer maxRowsInExcelCSVDownload = definitionJSON.getMaxRowsInExcelCSVDownload();
666 rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload);
667 Integer frozenColumns = definitionJSON.getFrozenColumns();
668 rdef.setFrozenColumns(frozenColumns);
669 String dataGridAlign = definitionJSON.getDataGridAlign();
670 rdef.setDataGridAlign(dataGridAlign);
671 String emptyMessage = definitionJSON.getEmptyMessage();
672 rdef.setEmptyMessage(emptyMessage);
673 String dataContainerHeight = definitionJSON.getDataContainerHeight();
674 rdef.setDataContainerHeight(dataContainerHeight);
675 String dataContainerWidth = definitionJSON.getDataContainerWidth();
676 rdef.setDataContainerWidth(dataContainerWidth);
677 boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled();
678 rdef.setRuntimeColSortDisabled(runtimeColSortDisabled);
679 Integer numFormCols = definitionJSON.getNumFormCols();
680 rdef.setNumFormCols(Integer.toString(numFormCols));
681 String reportTitle = definitionJSON.getReportTitle();
682 rdef.setReportTitle(reportTitle);
683 String reportSubTitle = definitionJSON.getReportSubTitle();
684 rdef.setReportSubTitle(reportSubTitle);
686 List<NameBooleanJSON> displayOptions = definitionJSON.getDisplayOptions();
687 StringBuffer displayOptionStr = new StringBuffer("NNNNNNN");
688 for (NameBooleanJSON displayOption : displayOptions) {
689 if (displayOption.isSelected()) {
690 if (displayOption.getName().equals("HideFormFields")) {
691 displayOptionStr.setCharAt(0, 'Y');
692 } else if (displayOption.getName().equals("HideChart")) {
693 displayOptionStr.setCharAt(1, 'Y');
694 } else if (displayOption.getName().equals("HideReportData")) {
695 displayOptionStr.setCharAt(2, 'Y');
696 } else if (displayOption.getName().equals("HideExcel")) {
697 displayOptionStr.setCharAt(5, 'Y');
698 } else if (displayOption.getName().equals("HidePdf")) {
699 displayOptionStr.setCharAt(6, 'Y');
705 rdef.setDisplayOptions(displayOptionStr.toString());
707 if (id.equals("Create")) {
708 rdef.persistReport(request);
710 persistReportDefinition(request, rdef);
711 messageJSON.setMessage("Success Definition of given report is saved in session.");
712 messageJSON.setAnyStacktrace((newReport ? " New Report info is added to Session "
713 : rdef.getReportID() + " is Modified and added to session and DB."));
715 } catch (Exception ex) {
716 messageJSON.setMessage("Error occured while saving definition Tab");
717 messageJSON.setAnyStacktrace(getStackTrace(ex));
718 logger.error(EELFLoggerDelegate.errorLogger,
719 "[Controller.processRequest]Invalid raptor action [retrieveTabWiseData].", ex);
726 @RequestMapping(value = { "/report/wizard/retrieve_form_tab_wise_data/{id}",
727 "/report/wizard/retrieve_form_tab_wise_data/{id}/{action}" }, method = RequestMethod.GET)
728 public @ResponseBody FormEditJSON retrieveFormTabWiseData(@PathVariable Map<String, String> pathVariables,
729 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
730 ReportDefinition rdef = null;
733 String detailId = "";
734 FormEditJSON wizardJSON = new FormEditJSON();
735 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
737 if (pathVariables.containsKey("id")) {
738 id = pathVariables.get("id");
740 if (pathVariables.containsKey("action")) {
741 action = pathVariables.get("action");
744 ServletContext servletContext = request.getSession().getServletContext();
745 if (!Globals.isSystemInitialized()) {
746 Globals.initializeSystem(servletContext);
748 wizardJSON.setTabId("FormEdit");
749 wizardJSON.setTabName("Form Edit");
750 FormFieldType currField = null;
752 if (id.equals("add")) {
754 currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",
756 wizardJSON.setFieldId(currField.getFieldId());
757 wizardJSON.setFieldName(currField.getFieldName());
758 wizardJSON.setFieldType(currField.getFieldType());
759 wizardJSON.setVisible(AppUtils.nvls(currField.getVisible(), "Y").toUpperCase().startsWith("Y"));
760 wizardJSON.setDefaultValue(currField.getDefaultValue());
761 wizardJSON.setFieldDefaultSQL(currField.getFieldDefaultSQL());
762 wizardJSON.setFieldSQL(currField.getFieldSQL());
763 wizardJSON.setValidationType(currField.getValidationType());
764 persistReportDefinition(request, rdef);
766 } else if (action.equals("delete")) {
767 rdef.deleteFormField(id);
768 persistReportDefinition(request, rdef);
769 wizardJSON.setMessage("Formfield " + detailId + " Deleted");
771 if (rdef.getFormFieldList() != null) {
772 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
773 if (fft.getFieldId().equals(id)) {
774 wizardJSON.setFieldId(fft.getFieldId());
775 wizardJSON.setFieldName(fft.getFieldName());
776 wizardJSON.setFieldType(fft.getFieldType());
777 wizardJSON.setVisible(fft.getVisible().toUpperCase().startsWith("Y"));
778 wizardJSON.setDefaultValue(fft.getDefaultValue());
779 wizardJSON.setFieldDefaultSQL(fft.getFieldDefaultSQL());
780 wizardJSON.setFieldSQL(fft.getFieldSQL());
781 wizardJSON.setValidationType(fft.getValidationType());
783 PredefinedValueList preDefined = fft.getPredefinedValueList();
785 if (preDefined != null) {
786 List<IdNameBooleanJSON> preDefinedList = new ArrayList<IdNameBooleanJSON>();
787 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
789 for (String v : preDefined.getPredefinedValue()) {
790 idNameBooleanJSON = new IdNameBooleanJSON();
791 idNameBooleanJSON.setId(v);
792 idNameBooleanJSON.setName(v);
793 preDefinedList.add(idNameBooleanJSON);
795 wizardJSON.setPredefinedValueList(preDefinedList);
800 } catch (Exception ex) {
801 logger.error(EELFLoggerDelegate.errorLogger,
802 "[Controller.processRequest]Invalid raptor action [retrieveFormTabWiseData].", ex);
803 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
804 errorJSONRuntime.setErrormessage("Error occured while retreiving formedit definition Tab");
805 errorJSONRuntime.setStacktrace(getStackTrace(ex));
806 wizardJSON.setErrorMessage("Error occured while retreiving formedit definition Tab");
807 wizardJSON.setErrorStackTrace(getStackTrace(ex));
814 @RequestMapping(value = { "/report/wizard/retrieve_col_tab_wise_data/{id}" }, method = RequestMethod.GET)
815 public @ResponseBody ColumnEditJSON retrieveColTabWiseData(@PathVariable Map<String, String> pathVariables,
816 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
817 ReportDefinition rdef = null;
819 ColumnEditJSON wizardJSON = new ColumnEditJSON();
820 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
822 if (pathVariables.containsKey("id")) {
823 id = pathVariables.get("id");
825 ServletContext servletContext = request.getSession().getServletContext();
826 if (!Globals.isSystemInitialized()) {
827 Globals.initializeSystem(servletContext);
830 wizardJSON.setTabId("ColEdit");
831 wizardJSON.setTabName("Column Edit");
833 List<DataColumnType> reportColumnList = rdef.getAllColumns();
835 for (DataColumnType reportColumnType : reportColumnList) {
836 if (reportColumnType.getColId().equals(id)) {
837 wizardJSON.setColId(reportColumnType.getColId());
838 wizardJSON.setColName(reportColumnType.getColName());
839 wizardJSON.setDisplayAlignment(reportColumnType.getDisplayAlignment());
840 wizardJSON.setDisplayHeaderAlignment(reportColumnType.getDisplayHeaderAlignment());
841 wizardJSON.setSortable(
842 reportColumnType.isIsSortable() == null ? false : reportColumnType.isIsSortable());
843 wizardJSON.setVisible(reportColumnType.isVisible());
844 wizardJSON.setDrilldownURL(
845 reportColumnType.getDrillDownURL() == null ? "" : reportColumnType.getDrillDownURL());
846 wizardJSON.setDrilldownParams(
847 reportColumnType.getDrillDownParams() == null ? "" : reportColumnType.getDrillDownParams());
848 wizardJSON.setDrilldownType(
849 reportColumnType.getDrillDownType() == null ? "" : reportColumnType.getDrillDownType());
854 wizardJSON.setErrorMessage("Report is not in session");
860 @RequestMapping(value = { "/report/wizard/retrieve_sql_tab_wise_data/{id}",
861 "/report/wizard/retrieve_sql_tab_wise_data/" }, method = RequestMethod.GET)
862 public @ResponseBody QueryJSON retrieveSqlTabWiseData(@PathVariable Map<String, String> pathVariables,
863 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
864 ReportDefinition rdef = null;
865 ReportRuntime rr = null;
867 String detailId = "";
868 QueryJSON wizardJSON = new QueryJSON();
870 if (pathVariables.containsKey("id")) {
871 id = pathVariables.get("id");
873 if (pathVariables.containsKey("detailId")) {
874 detailId = pathVariables.get("detailId");
876 ServletContext servletContext = request.getSession().getServletContext();
877 if (!Globals.isSystemInitialized()) {
878 Globals.initializeSystem(servletContext);
880 if (id.equals("InSession") || AppUtils.nvl(id).length() <= 0) {
881 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
882 } else if (AppUtils.nvl(id).length() > 0) {
883 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
884 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
886 if (rdef != null && !rdef.getReportID().equals(id)) {
887 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
888 removeVariablesFromSession(request);
889 rdef = (new ReportHandler()).loadReportDefinition(request, id);
890 } else if (rr != null && !rr.getReportID().equals(id)) {
891 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
892 removeVariablesFromSession(request);
893 rdef = (new ReportHandler()).loadReportDefinition(request, id);
894 } else if (rdef == null) {
895 rdef = (new ReportHandler()).loadReportDefinition(request, id);
901 wizardJSON.setTabId("Sql");
902 wizardJSON.setTabName("Sql");
903 wizardJSON.setQuery(rdef.getReportSQL());
908 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList" }, method = RequestMethod.GET)
909 public @ResponseBody List<SecurityEntry> getReportUserList(HttpServletRequest request)
910 throws IOException, RaptorException {
911 List<SecurityEntry> reportUserList = new ArrayList<SecurityEntry>();
912 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
913 Vector reportUsers = rdef.getReportUsers(request);
914 for(Iterator iter=reportUsers.iterator(); iter.hasNext();) {
915 SecurityEntry rUser = (SecurityEntry) iter.next();
916 reportUserList.add(rUser);
918 return reportUserList;
921 @RequestMapping(value = { "/report/wizard/security/retrieveReportRoleList" }, method = RequestMethod.GET)
922 public @ResponseBody List<IdNameValue> getReportRoleList(HttpServletRequest request)
923 throws IOException, RaptorException {
924 List<IdNameValue> reportRoleList = new ArrayList<IdNameValue>();
925 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
926 Vector reportRoles = rdef.getReportRoles(request);
927 Vector remainingRoles = Utils.getRolesNotInList(reportRoles,request);
928 for(int i=0; i<remainingRoles.size(); i++) {
929 IdNameValue role = (IdNameValue) remainingRoles.get(i);
930 reportRoleList.add(role);
932 return reportRoleList;
935 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList_query" }, method = RequestMethod.GET)
936 public @ResponseBody List<Map<String, String>> getReportUserListQuery(HttpServletRequest request)
937 throws IOException, RaptorException {
938 List<Map<String, String>> reportUserList = new ArrayList();
939 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
940 String reportId = rdef.getReportID();
941 Map<String, Object> params = new HashMap<String, Object>();
942 params.put("report_id", new Long(reportId));
943 List<ReportUserRole> queriedUserList = getDataAccessService().executeNamedQuery("getReportSecurityUsers", params, null);
944 for (int i=0; i<queriedUserList.size();i++){
945 Map<String, String> reportUser = new HashMap<String, String>();
946 Object tmp = queriedUserList.get(i);
947 reportUser.put("rep_id", queriedUserList.get(i).toString());
948 reportUser.put("order_no", queriedUserList.get(i).getOrderNo().toString());
949 reportUser.put("user_id", queriedUserList.get(i).getUserId().toString());
950 reportUser.put("role_id", queriedUserList.get(i).getRoleId().toString());
951 reportUser.put("read_only_yn", queriedUserList.get(i).getReadOnlyYn());
952 reportUserList.add(reportUser);
954 return reportUserList;
959 @RequestMapping(value = "/report/security/addReportUser", method = RequestMethod.POST)
960 public @ResponseBody Map<String,String> addSelectedReportUser(
961 @RequestBody String userIdToAdd, HttpServletRequest request, HttpServletResponse response)
962 throws IOException, RaptorException {
963 Map<String, String> JsonResponse = new HashMap<String, String>();
964 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
966 JsonResponse.put("status","success");
967 JsonResponse.put("userId",userIdToAdd);
968 String action = "Add User";
969 rdef.getReportSecurity().addUserAccess(userIdToAdd, "Y");
970 WizardSequence ws = rdef.getWizardSequence();
971 ws.performAction(action,rdef);
973 } catch (Exception ex) {
974 logger.error(EELFLoggerDelegate.errorLogger,
975 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
980 @RequestMapping(value = "/report/security/removeReportUser", method = RequestMethod.POST)
981 public @ResponseBody Map<String,String> removeSelectedReportUser(
982 @RequestBody String userIdToRemove, HttpServletRequest request, HttpServletResponse response)
983 throws IOException, RaptorException {
984 Map<String, String> JsonResponse = new HashMap<String, String>();
985 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
987 JsonResponse.put("status","success");
988 JsonResponse.put("userId",userIdToRemove);
989 String action = "Delete User";
990 rdef.getReportSecurity().removeUserAccess(userIdToRemove);
991 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
992 WizardSequence ws = rdef.getWizardSequence();
993 ws.performAction(action,rdef);
995 } catch (Exception ex) {
996 logger.error(EELFLoggerDelegate.errorLogger,
997 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1002 @RequestMapping(value = "/report/security/addReportRole", method = RequestMethod.POST)
1003 public @ResponseBody Map<String,String> addSelectedReportRole(
1004 @RequestBody String roleIdToAdd, HttpServletRequest request, HttpServletResponse response)
1005 throws IOException, RaptorException {
1006 Map<String, String> JsonResponse = new HashMap<String, String>();
1007 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1009 JsonResponse.put("status","success");
1010 JsonResponse.put("roleId",roleIdToAdd);
1011 String action = "Add Role";
1012 rdef.getReportSecurity().addRoleAccess(roleIdToAdd, "Y");
1013 WizardSequence ws = rdef.getWizardSequence();
1014 ws.performAction(action,rdef);
1015 return JsonResponse;
1016 } catch (Exception ex) {
1017 logger.error(EELFLoggerDelegate.errorLogger,
1018 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1023 @RequestMapping(value = "/report/security/removeReportRole", method = RequestMethod.POST)
1024 public @ResponseBody Map<String,String> removeSelectedReportRole(
1025 @RequestBody String roleIdToRemove, HttpServletRequest request, HttpServletResponse response)
1026 throws IOException, RaptorException {
1027 Map<String, String> JsonResponse = new HashMap<String, String>();
1028 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1030 JsonResponse.put("status","success");
1031 JsonResponse.put("roleId",roleIdToRemove);
1032 String action = "Delete Role";
1033 rdef.getReportSecurity().removeRoleAccess(roleIdToRemove);
1034 WizardSequence ws = rdef.getWizardSequence();
1035 ws.performAction(action,rdef);
1036 return JsonResponse;
1037 } catch (Exception ex) {
1038 logger.error(EELFLoggerDelegate.errorLogger,
1039 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1044 @RequestMapping(value = "/report/security/updateReportSecurityInfo", method = RequestMethod.POST)
1045 public @ResponseBody Map<String,String> updateReportSecurityInfo(
1046 @RequestBody Map<String,String> securityInfo, HttpServletRequest request, HttpServletResponse response)
1047 throws IOException, RaptorException {
1049 Map<String, String> JsonResponse = new HashMap<String, String>();
1050 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1052 JsonResponse.put("status","success");
1053 String OwnerUserId = securityInfo.get("userId");
1054 String isPublic = securityInfo.get("isPublic");
1055 boolean rPublic = isPublic.equals("true");
1056 rdef.getReportSecurity().setOwnerID(OwnerUserId);
1057 rdef.setPublic(rPublic);
1058 persistReportDefinition(request, rdef);
1059 return JsonResponse;
1061 } catch (Exception ex) {
1062 logger.error(EELFLoggerDelegate.errorLogger,
1063 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1068 @RequestMapping(value = "/report/security/toggleUserEditAccess/{userID}", method = RequestMethod.POST)
1069 public @ResponseBody Map<String,String> toggleUserEditAccess(
1070 @PathVariable("userID") String userId,
1071 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1072 throws IOException, RaptorException {
1073 Map<String, String> JsonResponse = new HashMap<String, String>();
1074 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1077 JsonResponse.put("status","success");
1078 if (readOnly.equals("N")) {
1079 action = "Grant User Access";
1081 action = "Revoke User Access";
1083 rdef.getReportSecurity().updateUserAccess(userId, readOnly);
1084 WizardSequence ws = rdef.getWizardSequence();
1085 ws.performAction(action,rdef);
1087 return JsonResponse;
1088 } catch (Exception ex) {
1089 logger.error(EELFLoggerDelegate.errorLogger,
1090 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1095 @RequestMapping(value = "/report/security/toggleRoleEditAccess/{roleID}", method = RequestMethod.POST)
1096 public @ResponseBody Map<String,String> toggleRoleEditAccess(
1097 @PathVariable("roleID") String roleId,
1098 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1099 throws IOException, RaptorException {
1100 Map<String, String> JsonResponse = new HashMap<String, String>();
1101 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1104 JsonResponse.put("status","success");
1105 if (readOnly.equals("N")) {
1106 action = "Grant Role Access";
1108 action = "Revoke Role Access";
1110 rdef.getReportSecurity().updateRoleAccess(roleId, readOnly);
1111 WizardSequence ws = rdef.getWizardSequence();
1112 ws.performAction(action,rdef);
1114 return JsonResponse;
1115 } catch (Exception ex) {
1116 logger.error(EELFLoggerDelegate.errorLogger,
1117 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1122 @RequestMapping(value = { "/report/wizard/security/retrieveReportOwner" }, method = RequestMethod.GET)
1123 public @ResponseBody List<IdNameValue> getReportOwnerInList(HttpServletRequest request)
1124 throws IOException, RaptorException {
1125 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1127 List<IdNameValue> UserList = new ArrayList<IdNameValue>();
1128 List excludeValues = new java.util.ArrayList();
1129 HttpSession session = request.getSession();
1130 String query = Globals.getCustomizedScheduleQueryForUsers();
1131 session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
1132 String userId = AppUtils.getUserID(request);
1133 session.setAttribute("LOGGED_USERID", userId);
1134 String[] sessionParameters = Globals.getSessionParams().split(",");
1136 for (int i = 0; i < sessionParameters.length; i++) {
1137 param = (String) session.getAttribute(sessionParameters[0]);
1138 query = Utils.replaceInString(query, "[" + sessionParameters[i].toUpperCase() + "]",
1139 (String) session.getAttribute(sessionParameters[i]));
1141 boolean isAdmin = AppUtils.isAdminUser(request);
1142 Vector allUsers = AppUtils.getAllUsers(query, param, isAdmin);
1143 Vector result = new Vector(allUsers.size());
1145 for (Iterator iter = allUsers.iterator(); iter.hasNext();) {
1146 IdNameValue value = (IdNameValue) iter.next();
1148 boolean exclude = false;
1149 for (Iterator iterE = excludeValues.iterator(); iterE.hasNext();)
1150 if (((IdNameValue) iterE.next()).getId().equals(value.getId())) {
1156 UserList.add(value);
1162 @RequestMapping(value = { "/report/wizard/security/getReportSecurityInfo" }, method = RequestMethod.GET)
1163 public @ResponseBody Map<String,String> getReportSecurityInfo(HttpServletRequest request)
1164 throws IOException, RaptorException {
1165 Map<String, String> securityInfoMap = new HashMap<String,String>();
1166 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1167 String isPublic = Boolean.toString(rdef.isPublic());
1168 String createUser = AppUtils.getUserName(rdef.getCreateID());
1169 String createDate = rdef.getCreateDate();
1170 String updateUser = AppUtils.getUserName(rdef.getUpdateID());
1171 String updateDate = rdef.getUpdateDate();
1172 String ownerId = rdef.getOwnerID();
1174 securityInfoMap.put("isPublic",isPublic);
1175 securityInfoMap.put("createdUser",createUser);
1176 securityInfoMap.put("createdDate",createDate);
1177 securityInfoMap.put("updateUser",updateUser);
1178 securityInfoMap.put("updatedDate",updateDate);
1179 securityInfoMap.put("ownerId",ownerId);
1181 return securityInfoMap;
1184 @RequestMapping(value = { "/report/wizard/security/getReportSecurityUsers" }, method = RequestMethod.GET)
1185 public @ResponseBody List<SecurityEntry> getReportSecurityUsers(HttpServletRequest request)
1186 throws IOException, RaptorException {
1188 List<SecurityEntry> reportUserMapList = new ArrayList<SecurityEntry>();
1189 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1190 Vector reportUsers = rdef.getReportUsers(request);
1193 for(Iterator iter=reportUsers.iterator(); iter.hasNext(); iCount++) {
1194 Map<String, String> reportUserMap = new HashMap<String,String>();
1195 SecurityEntry rUser = (SecurityEntry) iter.next();
1196 reportUserMapList.add(rUser);
1199 return reportUserMapList;
1203 @RequestMapping(value = { "/report/wizard/security/getReportSecurityRoles" }, method = RequestMethod.GET)
1204 public @ResponseBody List<SecurityEntry> getReportSecurityRoles(HttpServletRequest request)
1205 throws IOException, RaptorException {
1207 List<SecurityEntry> reportRoleList = new ArrayList<SecurityEntry>();
1208 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1209 Vector reportRoles = rdef.getReportRoles(request);
1212 for(Iterator iter=reportRoles.iterator(); iter.hasNext(); iCount++) {
1213 SecurityEntry rRole = (SecurityEntry) iter.next();
1214 reportRoleList.add(rRole);
1217 return reportRoleList;
1221 @RequestMapping(value = { "/report/wizard/retrieve_def_tab_wise_data/{id}",
1222 "/report/wizard/retrieve_def_tab_wise_data/{id}/{detailId}" }, method = RequestMethod.GET)
1223 public @ResponseBody DefinitionJSON retrieveDefTabWiseData(@PathVariable Map<String, String> pathVariables,
1224 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
1225 ReportDefinition rdef = null;
1226 ReportRuntime rr = null;
1227 boolean newReport = false;
1228 String tabId = "Def";
1231 if (pathVariables.containsKey("id")) {
1232 id = pathVariables.get("id");
1234 String detailId = "";
1235 if (pathVariables.containsKey("detailId")) {
1236 detailId = pathVariables.get("detailId");
1239 ServletContext servletContext = request.getSession().getServletContext();
1240 if (!Globals.isSystemInitialized()) {
1241 Globals.initializeSystem(servletContext);
1244 if (tabId.equals("Def") && id.equals("InSession")) {
1245 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1248 } else if (tabId.equals("Def") && id.equals("Create")) {
1249 removeVariablesFromSession(request);
1250 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
1251 rdef.setReportType(AppConstants.RT_LINEAR);
1254 } else if (tabId.equals("Def") && AppUtils.nvl(id).length() > 0) {
1255 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1256 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1258 if (rdef != null && !rdef.getReportID().equals(id)) {
1259 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1260 removeVariablesFromSession(request);
1261 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1262 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1263 } else if (rr != null && !rr.getReportID().equals(id)) {
1264 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1265 removeVariablesFromSession(request);
1266 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1267 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1268 } else if (rdef == null) {
1269 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1270 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1275 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1277 DefinitionJSON wizardJSON = new DefinitionJSON();
1278 if (tabId.equals("Def")) {
1279 wizardJSON.setTabId("Def");
1280 wizardJSON.setTabName("Definition");
1282 wizardJSON.setReportId((rdef != null) ? rdef.getReportID() + "" : "");
1283 wizardJSON.setReportName((rdef != null) ? rdef.getReportName() : "");
1284 wizardJSON.setReportDescr((rdef != null) ? rdef.getReportDescr() : "");
1285 wizardJSON.setReportType((rdef != null) ? rdef.getReportType() : AppConstants.RT_LINEAR);
1286 wizardJSON.setDbInfo((rdef != null) ? rdef.getDBInfo() : "");
1287 wizardJSON.setFormHelpText((rdef != null) ? rdef.getFormHelpText() : "");
1288 wizardJSON.setPageSize((rdef != null) ? rdef.getPageSize() : 50);
1289 List<IdNameBooleanJSON> displayArea = new ArrayList<IdNameBooleanJSON>();
1290 IdNameBooleanJSON idNameJSON = new IdNameBooleanJSON();
1292 for (int i = 0; i < AppUtils.getQuickLinksMenuIDs().size(); i++) {
1293 idNameJSON = new IdNameBooleanJSON();
1294 qMenu = (String) AppUtils.getQuickLinksMenuIDs().get(i);
1295 idNameJSON.setId(qMenu);
1296 idNameJSON.setName(qMenu);
1297 if (rdef != null && (rdef.getMenuID().equals(qMenu))) {
1298 idNameJSON.setSelected(true);
1300 displayArea.add(idNameJSON);
1302 wizardJSON.setDisplayArea(displayArea);
1303 wizardJSON.setHideFormFieldsAfterRun((rdef != null) ? rdef.isHideFormFieldAfterRun() : false);
1304 wizardJSON.setMaxRowsInExcelCSVDownload((rdef != null) ? rdef.getMaxRowsInExcelDownload() : 500);
1305 wizardJSON.setFrozenColumns((rdef != null) ? rdef.getFrozenColumns() : 0);
1306 wizardJSON.setDataGridAlign((rdef != null) ? rdef.getDataGridAlign() : "left");
1307 wizardJSON.setEmptyMessage((rdef != null) ? rdef.getEmptyMessage() : "No records found");
1308 wizardJSON.setDataContainerHeight((rdef != null) ? rdef.getDataContainerHeight() : "600");
1309 wizardJSON.setDataContainerWidth((rdef != null) ? rdef.getDataContainerWidth() : "900");
1310 List<NameBooleanJSON> displayOptions = new ArrayList<NameBooleanJSON>();
1311 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
1312 nameBooleanJSON.setName("HideFormFields");
1313 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideForm() : false);
1314 displayOptions.add(nameBooleanJSON);
1316 nameBooleanJSON = new NameBooleanJSON();
1317 nameBooleanJSON.setName("HideChart");
1318 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideChart() : false);
1319 displayOptions.add(nameBooleanJSON);
1321 nameBooleanJSON = new NameBooleanJSON();
1322 nameBooleanJSON.setName("HideReportData");
1323 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideData() : false);
1324 displayOptions.add(nameBooleanJSON);
1326 nameBooleanJSON = new NameBooleanJSON();
1327 nameBooleanJSON.setName("HideExcel");
1328 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideExcelIcons() : false);
1329 displayOptions.add(nameBooleanJSON);
1331 nameBooleanJSON = new NameBooleanJSON();
1332 nameBooleanJSON.setName("HidePdf");
1333 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHidePDFIcons() : false);
1334 displayOptions.add(nameBooleanJSON);
1336 wizardJSON.setDisplayOptions(displayOptions);
1338 wizardJSON.setRuntimeColSortDisabled((rdef != null) ? rdef.isRuntimeColSortDisabled() : false);
1339 wizardJSON.setNumFormCols((rdef != null) ? rdef.getNumFormColsAsInt() : 1);
1340 wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : "");
1341 wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : "");
1345 ObjectMapper mapper = new ObjectMapper();
1346 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1347 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1353 @RequestMapping(value = "/report/wizard/retrieve_data/{validate}", method = RequestMethod.POST)
1354 public @ResponseBody RaptorResponse retrieveDataForGivenQuery(@PathVariable("validate") boolean validate,
1355 @RequestBody QueryJSON queryJSON, HttpServletRequest request, HttpServletResponse response)
1356 throws IOException, RaptorException {
1357 RaptorResponse raptorResponse = new RaptorResponse();
1358 String sql = queryJSON.getQuery();
1359 String jsonInString = "";
1361 ServletContext servletContext = request.getSession().getServletContext();
1362 if (!Globals.isSystemInitialized()) {
1363 Globals.initializeSystem(servletContext);
1366 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1368 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1369 errorJSONRuntime.setErrormessage("Report Definition is not in session;");
1370 errorJSONRuntime.setStacktrace("");
1372 ObjectMapper mapper = new ObjectMapper();
1373 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1374 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1377 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1378 raptorResponse.data().put("elements", jsonInString);
1379 return raptorResponse;
1380 } catch (Exception ex1) {
1381 logger.error(EELFLoggerDelegate.errorLogger,
1382 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1385 if (!sql.trim().toUpperCase().startsWith("SELECT")) {
1386 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1387 errorJSONRuntime.setErrormessage("Invalid statement - the SQL must start with the keyword SELECT");
1388 errorJSONRuntime.setStacktrace("SQL Error");
1389 ObjectMapper mapper = new ObjectMapper();
1390 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1391 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1394 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1395 raptorResponse.data().put("elements", jsonInString);
1396 return raptorResponse;
1398 } catch (Exception ex) {
1399 logger.error(EELFLoggerDelegate.errorLogger,
1400 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1404 String remoteDb = request.getParameter("remoteDbPrefix");
1405 // comment below two lines to test
1406 String remoteDbPrefix = (remoteDb != null && !remoteDb.equalsIgnoreCase("null")) ? remoteDb
1408 String userId = AppUtils.getUserID(request);
1409 // String userId = "1";
1410 sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
1411 sql = Utils.replaceInString(sql, "[USERID]", userId);
1412 String[] reqParameters = Globals.getRequestParams().split(",");
1413 String[] sessionParameters = Globals.getSessionParams().split(",");
1414 javax.servlet.http.HttpSession session = request.getSession();
1415 logger.debug(EELFLoggerDelegate.debugLogger, ("B4 testRunSQL " + sql));
1416 if (request != null) {
1417 for (int i = 0; i < reqParameters.length; i++) {
1418 if (!reqParameters[i].startsWith("ff"))
1419 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1420 ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),request.getParameter(reqParameters[i].toUpperCase())));
1422 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1423 ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),request.getParameter(reqParameters[i])));
1426 if (session != null) {
1427 for (int i = 0; i < sessionParameters.length; i++) {
1428 logger.debug(EELFLoggerDelegate.debugLogger, (" Session " + " sessionParameters[i] "
1429 + sessionParameters[i] + " " + (String) session.getAttribute(sessionParameters[i])));
1430 sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]",
1431 (String) session.getAttribute(sessionParameters[i]));
1434 logger.debug(EELFLoggerDelegate.debugLogger, ("After testRunSQL " + sql));
1437 response.setContentType("application/json");
1438 ds = ConnectionUtils.getDataSet(sql, "local", true);
1440 QueryResultJSON queryResultJSON = new QueryResultJSON();
1441 queryResultJSON.setQuery(queryJSON.getQuery());
1442 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1443 rdef.parseReportSQL(query);
1444 queryResultJSON.setQuery(query);
1446 int numColumns = ds.getColumnCount();
1447 queryResultJSON.setTotalRows(ds.getRowCount());
1450 Map<String, String> dvJSON = null;
1451 ArrayList<String> colList = new ArrayList<String>();
1452 ArrayList<Map<String, String>> reportDataRows = new ArrayList<Map<String, String>>();
1453 if (!ds.isEmpty()) {
1456 for (int i = 0; i < ds.getColumnCount(); i++) {
1457 colList.add(ds.getColumnName(i));
1459 queryResultJSON.setReportDataColumns(colList);
1460 if (queryResultJSON.getTotalRows() > 0) {
1462 dvJSON = new HashMap<String, String>();
1463 for (int r = 0; r < Math.min(ds.getRowCount(), 100); r++) {
1464 dvJSON = new HashMap<String, String>();
1465 for (int c = 0; c < ds.getColumnCount(); c++) {
1467 dvJSON.put(ds.getColumnName(c), ds.getString(r, c));
1468 } catch (Exception ex) {
1469 logger.error(EELFLoggerDelegate.errorLogger,
1470 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].",
1474 reportDataRows.add(dvJSON);
1480 queryResultJSON.setReportDataRows(reportDataRows);
1481 ObjectMapper mapper = new ObjectMapper();
1482 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1483 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1485 query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1486 request.setAttribute("sqlValidated", "N");
1487 rdef.parseReportSQL(query);
1488 request.setAttribute("sqlValidated", "Y");
1489 persistReportDefinition(request, rdef);
1493 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(queryResultJSON);
1494 raptorResponse.data().put("elements", jsonInString);
1495 return raptorResponse;
1497 } catch (Exception ex) {
1498 logger.error(EELFLoggerDelegate.errorLogger,
1499 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery]. RaptorException: ",
1502 } catch (ReportSQLException ex) {
1503 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1504 if (sql.contains("[")) {
1505 errorJSONRuntime.setErrormessage(
1506 "Formfield information is present in the query, hence couldn't execute");
1508 .setStacktrace("Formfield information is present in the query, hence couldn't execute");
1510 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1511 request.setAttribute("sqlValidated", "N");
1512 rdef.parseReportSQL(query);
1513 request.setAttribute("sqlValidated", "Y");
1514 persistReportDefinition(request, rdef);
1519 errorJSONRuntime.setErrormessage(ex.getMessage());
1520 errorJSONRuntime.setStacktrace(getStackTrace(ex));
1522 ObjectMapper mapper = new ObjectMapper();
1523 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1524 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1527 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1528 raptorResponse.data().put("elements", jsonInString);
1529 return raptorResponse;
1531 } catch (Exception ex1) {
1532 logger.error(EELFLoggerDelegate.errorLogger,
1533 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1537 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1538 request.setAttribute("sqlValidated", "N");
1539 rdef.parseReportSQL(query);
1540 request.setAttribute("sqlValidated", "Y");
1541 persistReportDefinition(request, rdef);
1547 raptorResponse.data().put("elements", jsonInString);
1548 return raptorResponse;
1552 @RequestMapping(value = "save_chart", method = RequestMethod.POST)
1553 public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request,
1554 HttpServletResponse response) throws IOException {
1555 ReportRuntime reportRuntime;
1556 reportRuntime = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); // changing
1560 String reportID = request.getParameter("c_master");
1561 if (reportRuntime == null && AppUtils.nvl(reportID).length() > 0) {
1563 ReportHandler rh = new ReportHandler();
1564 reportRuntime = rh.loadReportRuntime(request, reportID);
1565 } catch (RaptorException ex) {
1566 logger.error(EELFLoggerDelegate.errorLogger,
1567 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
1571 if (reportRuntime != null) {
1572 String chartType = chartJSON.getChartType();
1573 reportRuntime.setChartType(chartJSON.getChartType());
1574 reportRuntime.setChartAnimate(chartJSON.isAnimation());
1575 reportRuntime.setChartWidth(chartJSON.getWidth());
1576 reportRuntime.setChartHeight(chartJSON.getHeight());
1577 reportRuntime.setShowChartTitle(chartJSON.isShowTitle());
1579 String domainAxis = null;
1580 domainAxis = chartJSON.getDomainAxis();
1582 List<DataColumnType> reportCols = reportRuntime.getAllColumns();
1584 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1585 DataColumnType dct = (DataColumnType) iter.next();
1586 if (dct.getColId().equals(domainAxis)) {
1587 dct.setColOnChart(AppConstants.GC_LEGEND);
1589 dct.setColOnChart(null);
1593 CategoryAxisJSON categoryAxisJSON = chartJSON.getCategoryAxisJSON();
1594 String categoryAxis = null;
1596 categoryAxis = (categoryAxisJSON != null ? categoryAxisJSON.getValue() : "");
1598 reportCols = reportRuntime.getAllColumns();
1600 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1601 DataColumnType dct = (DataColumnType) iter.next();
1602 if (dct.getColId().equals(categoryAxis)) {
1603 dct.setChartSeries(true);
1605 dct.setChartSeries(false);
1609 ArrayList<RangeAxisJSON> rangeAxisList = chartJSON.getRangeAxisList();
1611 HashSet<String> removeRangeAxisMap = new HashSet<>();
1612 for(RangeAxisJSON rangeAxis:chartJSON.getRangeAxisRemoveList()){
1613 removeRangeAxisMap.add(rangeAxis.getRangeAxis());
1615 for (int i = 0; i < rangeAxisList.size(); i++) {
1616 RangeAxisJSON rangeAxisJSON = rangeAxisList.get(i);
1617 String rangeAxis = rangeAxisJSON.getRangeAxis();
1618 String rangeYAxis = AppUtils.nvl(rangeAxisJSON.getRangeYAxis());
1619 String rangeChartGroup = AppUtils.nvl(rangeAxisJSON.getRangeChartGroup());
1620 String rangeColor = AppUtils.nvl(rangeAxisJSON.getRangeColor());
1621 String rangeLineType = AppUtils.nvl(rangeAxisJSON.getRangeLineType());
1623 rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
1624 DataColumnType dct = (DataColumnType) iterator.next();
1625 if (dct.getColId().equals(rangeAxis)) {
1626 if(removeRangeAxisMap.contains(rangeAxis))
1627 dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included
1629 dct.setChartSeq(++r);
1630 dct.setColOnChart("0");
1631 dct.setYAxis(rangeYAxis); // +"|"+dct.getColId());
1632 dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId());
1633 dct.setChartColor(rangeColor);
1634 dct.setChartLineType(rangeLineType);
1636 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1637 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1638 if (rangeAxisJSON.isShowAsArea()) {
1639 dct.setIsRangeAxisFilled(true);
1641 dct.setIsRangeAxisFilled(false);
1650 reportRuntime.setChartLeftAxisLabel(chartJSON.getPrimaryAxisLabel());
1651 reportRuntime.setChartRightAxisLabel(chartJSON.getSecondaryAxisLabel());
1653 reportRuntime.setRangeAxisLowerLimit(chartJSON.getMinRange());
1654 reportRuntime.setRangeAxisUpperLimit(chartJSON.getMaxRange());
1656 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1657 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1658 if (chartJSON.getFlexTimeSeriesChartOptions() != null) {
1659 reportRuntime.setZoomIn(chartJSON.getFlexTimeSeriesChartOptions().getZoomIn());
1660 reportRuntime.setTimeAxisType(chartJSON.getFlexTimeSeriesChartOptions().getTimeAxisType());
1665 if (chartType.equals(AppConstants.GT_TIME_SERIES)) {
1666 if (chartJSON.getTimeSeriesChartOptions() != null) {
1667 reportRuntime.setTimeSeriesRender(chartJSON.getTimeSeriesChartOptions().getLineChartRenderer());
1668 reportRuntime.setShowXAxisLabel(chartJSON.getTimeSeriesChartOptions().isShowXAxisLabel());
1669 reportRuntime.setAddXAxisTickers(chartJSON.getTimeSeriesChartOptions().isAddXAxisTicker());
1670 reportRuntime.setTimeAxis(chartJSON.getTimeSeriesChartOptions().isNonTimeAxis());
1671 reportRuntime.setMultiSeries(chartJSON.getTimeSeriesChartOptions().isMultiSeries());
1676 if (chartType.equals(AppConstants.GT_BAR_3D)) {
1677 if (chartJSON.getBarChartOptions() != null) {
1678 reportRuntime.setChartOrientation(
1679 chartJSON.getBarChartOptions().isVerticalOrientation() ? "vertical" : "horizontal");
1680 reportRuntime.setChartStacked(chartJSON.getBarChartOptions().isStackedChart());
1681 reportRuntime.setBarControls(chartJSON.getBarChartOptions().isDisplayBarControls());
1682 reportRuntime.setXAxisDateType(chartJSON.getBarChartOptions().isxAxisDateType());
1683 reportRuntime.setLessXaxisTickers(chartJSON.getBarChartOptions().isMinimizeXAxisTickers());
1684 reportRuntime.setTimeAxis(chartJSON.getBarChartOptions().isTimeAxis());
1685 reportRuntime.setLogScale(chartJSON.getBarChartOptions().isyAxisLogScale());
1689 reportRuntime.setLegendLabelAngle(chartJSON.getCommonChartOptions().getLegendLabelAngle());
1690 reportRuntime.setLegendPosition(chartJSON.getCommonChartOptions().getLegendPosition());
1691 reportRuntime.setChartLegendDisplay(chartJSON.getCommonChartOptions().isHideLegend() ? "Y" : "N");
1692 reportRuntime.setAnimateAnimatedChart(chartJSON.getCommonChartOptions().isAnimateAnimatedChart());
1694 reportRuntime.setTopMargin(chartJSON.getCommonChartOptions().getTopMargin());
1695 reportRuntime.setBottomMargin(chartJSON.getCommonChartOptions().getBottomMargin());
1696 reportRuntime.setLeftMargin(chartJSON.getCommonChartOptions().getLeftMargin());
1697 reportRuntime.setRightMargin(chartJSON.getCommonChartOptions().getRightMargin());
1699 for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
1700 DataColumnType dct = (DataColumnType) iterator.next();
1701 if (!(AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)
1702 || (dct.getChartSeq() != null && dct.getChartSeq() > 0) || dct.isChartSeries())) {
1703 dct.setChartSeq(-1);
1704 dct.setChartColor(null);
1705 dct.setColOnChart(null);
1706 dct.setCreateInNewChart(false);
1707 dct.setChartGroup(null);
1713 reportRuntime.persistLinearReport(request);
1714 } catch (Exception ex) {
1715 logger.error(EELFLoggerDelegate.errorLogger,
1716 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
1722 public String getViewName() {
1726 public void setViewName(String viewName) {
1727 this.viewName = viewName;
1730 public String nvl(String s) {
1731 return (s == null) ? "" : s;
1734 public String nvl(String s, String sDefault) {
1735 return nvl(s).equals("") ? sDefault : s;
1738 public static String getStackTrace(Throwable aThrowable) {
1739 Writer result = new StringWriter();
1740 PrintWriter printWriter = new PrintWriter(result);
1741 aThrowable.printStackTrace(printWriter);
1742 return result.toString();
1745 public void persistReportDefinition(HttpServletRequest request, ReportDefinition rdef) throws RaptorException {
1746 ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1747 if (rr != null && rr.getReportID().equals(rdef.getReportID()))
1748 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1749 rdef.persistReport(request);
1750 } // persistReportDefinition
1752 // Remove from session
1753 private void removeVariablesFromSession(HttpServletRequest request) {
1754 HttpSession session = request.getSession();
1755 session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
1756 session.removeAttribute(AppConstants.DRILLDOWN_INDEX);
1757 session.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
1758 session.removeAttribute(AppConstants.SI_BACKUP_FOR_REP_ID);
1759 session.removeAttribute(AppConstants.SI_COLUMN_LOOKUP);
1760 session.removeAttribute(AppConstants.SI_DASHBOARD_REP_ID);
1761 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
1762 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME);
1763 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
1764 session.removeAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP);
1765 session.removeAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP);
1766 session.removeAttribute(AppConstants.SI_DATA_SIZE_FOR_TEXTFIELD_POPUP);
1767 session.removeAttribute(AppConstants.SI_MAP);
1768 session.removeAttribute(AppConstants.SI_MAP_OBJECT);
1769 session.removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1770 session.removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1771 session.removeAttribute(AppConstants.SI_REPORT_RUN_BACKUP);
1772 session.removeAttribute(AppConstants.SI_REPORT_SCHEDULE);
1773 session.removeAttribute(AppConstants.RI_REPORT_DATA);
1774 session.removeAttribute(AppConstants.RI_CHART_DATA);
1775 session.removeAttribute(AppConstants.SI_FORMFIELD_INFO);
1776 session.removeAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
1777 session.removeAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP);
1778 session.removeAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP);
1779 Enumeration<String> enum1 = session.getAttributeNames();
1780 String attributeName = "";
1781 while (enum1.hasMoreElements()) {
1782 attributeName = enum1.nextElement();
1783 if (attributeName.startsWith("parent_")) {
1784 session.removeAttribute(attributeName);