2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalsdk.analytics.system.fusion.web;
22 import java.io.IOException;
23 import java.io.OutputStreamWriter;
24 import java.io.PrintWriter;
25 import java.io.StringWriter;
26 import java.io.Writer;
27 import java.lang.reflect.InvocationTargetException;
28 import java.lang.reflect.Method;
29 import java.util.ArrayList;
30 import java.util.Enumeration;
31 import java.util.HashMap;
32 import java.util.HashSet;
33 import java.util.Iterator;
34 import java.util.List;
36 import java.util.Vector;
38 import javax.servlet.ServletContext;
39 import javax.servlet.http.HttpServletRequest;
40 import javax.servlet.http.HttpServletResponse;
41 import javax.servlet.http.HttpSession;
43 import org.openecomp.portalsdk.analytics.controller.Action;
44 import org.openecomp.portalsdk.analytics.controller.ErrorHandler;
45 import org.openecomp.portalsdk.analytics.controller.WizardSequence;
46 import org.openecomp.portalsdk.analytics.error.RaptorException;
47 import org.openecomp.portalsdk.analytics.error.RaptorRuntimeException;
48 import org.openecomp.portalsdk.analytics.error.ReportSQLException;
49 import org.openecomp.portalsdk.analytics.model.DataCache;
50 import org.openecomp.portalsdk.analytics.model.ReportHandler;
51 import org.openecomp.portalsdk.analytics.model.base.IdNameValue;
52 import org.openecomp.portalsdk.analytics.model.base.ReportUserRole;
53 import org.openecomp.portalsdk.analytics.model.definition.ReportDefinition;
54 import org.openecomp.portalsdk.analytics.model.definition.SecurityEntry;
55 import org.openecomp.portalsdk.analytics.model.definition.wizard.ColumnEditJSON;
56 import org.openecomp.portalsdk.analytics.model.definition.wizard.ColumnJSON;
57 import org.openecomp.portalsdk.analytics.model.definition.wizard.DefinitionJSON;
58 import org.openecomp.portalsdk.analytics.model.definition.wizard.FormEditJSON;
59 import org.openecomp.portalsdk.analytics.model.definition.wizard.IdNameBooleanJSON;
60 import org.openecomp.portalsdk.analytics.model.definition.wizard.ImportJSON;
61 import org.openecomp.portalsdk.analytics.model.definition.wizard.MessageJSON;
62 import org.openecomp.portalsdk.analytics.model.definition.wizard.NameBooleanJSON;
63 import org.openecomp.portalsdk.analytics.model.definition.wizard.QueryJSON;
64 import org.openecomp.portalsdk.analytics.model.definition.wizard.QueryResultJSON;
65 import org.openecomp.portalsdk.analytics.model.definition.wizard.RaptorResponse;
66 import org.openecomp.portalsdk.analytics.model.definition.wizard.SearchFieldJSON;
67 import org.openecomp.portalsdk.analytics.model.definition.wizard.WizardJSON;
68 import org.openecomp.portalsdk.analytics.model.pdf.PdfReportHandler;
69 import org.openecomp.portalsdk.analytics.model.runtime.CategoryAxisJSON;
70 import org.openecomp.portalsdk.analytics.model.runtime.ChartJSON;
71 import org.openecomp.portalsdk.analytics.model.runtime.ErrorJSONRuntime;
72 import org.openecomp.portalsdk.analytics.model.runtime.FormField;
73 import org.openecomp.portalsdk.analytics.model.runtime.RangeAxisJSON;
74 import org.openecomp.portalsdk.analytics.model.runtime.ReportFormFields;
75 import org.openecomp.portalsdk.analytics.model.runtime.ReportRuntime;
76 import org.openecomp.portalsdk.analytics.system.AppUtils;
77 import org.openecomp.portalsdk.analytics.system.ConnectionUtils;
78 import org.openecomp.portalsdk.analytics.system.Globals;
79 import org.openecomp.portalsdk.analytics.system.fusion.adapter.Item;
80 import org.openecomp.portalsdk.analytics.util.AppConstants;
81 import org.openecomp.portalsdk.analytics.util.DataSet;
82 import org.openecomp.portalsdk.analytics.util.Utils;
83 import org.openecomp.portalsdk.analytics.util.XSSFilter;
84 import org.openecomp.portalsdk.analytics.view.ReportData;
85 import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType;
86 import org.openecomp.portalsdk.analytics.xmlobj.FormFieldType;
87 import org.openecomp.portalsdk.analytics.xmlobj.ObjectFactory;
88 import org.openecomp.portalsdk.analytics.xmlobj.PredefinedValueList;
89 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
90 import org.openecomp.portalsdk.core.domain.User;
91 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
92 import org.openecomp.portalsdk.core.web.support.UserUtils;
93 import org.springframework.stereotype.Controller;
94 import org.springframework.web.bind.annotation.PathVariable;
95 import org.springframework.web.bind.annotation.RequestBody;
96 import org.springframework.web.bind.annotation.RequestMapping;
97 import org.springframework.web.bind.annotation.RequestMethod;
98 import org.springframework.web.bind.annotation.ResponseBody;
99 import org.springframework.web.context.request.async.DeferredResult;
101 import com.fasterxml.jackson.core.JsonFactory;
102 import com.fasterxml.jackson.core.JsonParser;
103 import com.fasterxml.jackson.databind.DeserializationFeature;
104 import com.fasterxml.jackson.databind.JsonNode;
105 import com.fasterxml.jackson.databind.ObjectMapper;
106 import com.fasterxml.jackson.databind.SerializationFeature;
110 public class RaptorControllerAsync extends RestrictedBaseController {
112 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorControllerAsync.class);
114 private String viewName;
116 @RequestMapping(value = { "/raptor.htm" }, method = RequestMethod.GET)
117 public void RaptorSearch(HttpServletRequest request, HttpServletResponse response)
118 throws IOException, RaptorException {
121 String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
122 actionKey = nvl(actionKey, "report.run");
124 HttpSession session = request.getSession();
125 User user = UserUtils.getUserSession(request);
127 if (actionKey.equals("report.download.excel2007.session") || actionKey.equals("report.download.csv.session")
128 || actionKey.equals("report.download.excel.session")
129 || actionKey.equals("report.download.pdf.session")) {
130 if (session != null && user != null) {
131 ServletContext servletContext = request.getSession().getServletContext();
132 if (!Globals.isSystemInitialized()) {
133 Globals.initializeSystem(servletContext);
135 ReportRuntime rr = null;
136 ReportData rd = null;
139 if (!nvl(request.getParameter("parent"), "").equals("N"))
140 parent = nvl(request.getParameter("parent"), "");
141 if (parent.startsWith("parent_"))
143 if (parentFlag == 1) {
144 rr = (ReportRuntime) request.getSession().getAttribute(parent + "_rr");
145 rd = (ReportData) request.getSession().getAttribute(parent + "_rd");
148 boolean isEmbedded = false;
149 Object temp = request.getSession().getAttribute("isEmbedded");
151 isEmbedded = (boolean) temp;
154 String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID);
156 rr = (ReportRuntime) ((HashMap) request.getSession()
157 .getAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP)).get(reportID);
159 rd = (ReportData) ((HashMap) request.getSession()
160 .getAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP)).get(reportID);
163 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
165 rd = (ReportData) request.getSession().getAttribute(AppConstants.RI_REPORT_DATA);
167 String user_id = AppUtils.getUserID(request);
168 int downloadLimit = 0;
170 downloadLimit = (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload()
171 : Globals.getDownloadLimit();
172 if (actionKey.equals("report.csv.download"))
173 downloadLimit = Globals.getCSVDownloadLimit();
174 String sql_whole = rr.getReportDataSQL(user_id, downloadLimit, request);
175 request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole);
177 OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
179 if (actionKey.equals("report.download.pdf.session")) {
180 new PdfReportHandler().createPdfFileContent(request, response, 3);
181 } else if (actionKey.equals("report.download.csv.session")) {
182 (new ReportHandler()).createCSVFileContent(out, rd, rr, request, response);
183 } else if (actionKey.equals("report.download.excel.session")) {
184 new ReportHandler().createExcelFileContent(out, rd, rr, request, response, user_id, 3); // 3
188 new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, user_id, 3); // 3
191 } catch (Exception e) {
192 logger.error(EELFLoggerDelegate.errorLogger,
193 "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
196 response.sendRedirect("login.htm");
199 if (session != null && user != null) {
200 Action action = null;
201 ServletContext servletContext = request.getSession().getServletContext();
202 if (!Globals.isSystemInitialized()) {
203 Globals.initializeSystem(servletContext);
206 action = Globals.getRaptorActionMapping().getAction(actionKey);
208 throw new RaptorRuntimeException("Action not found");
209 } catch (RaptorException e) {
210 logger.error(EELFLoggerDelegate.errorLogger,
211 "[Controller.processRequest]Invalid raptor action [" + actionKey + "].", e);
213 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
214 new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
215 + "]. Exception: " + e.getMessage()));
219 Class[] paramTypes = new Class[2];
220 paramTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
221 paramTypes[1] = Class.forName("java.lang.String");
223 Class handlerClass = Class.forName(action.getControllerClass());
224 Object handler = handlerClass.newInstance();
225 Method handlerMethod = handlerClass.getMethod(action.getControllerMethod(), paramTypes);
227 Object[] paramValues = new Object[2];
228 paramValues[0] = request;
229 paramValues[1] = action.getJspName();
232 viewName = (String) handlerMethod.invoke(handler, paramValues);
233 if (!actionKey.equals("chart.run"))
234 response.setContentType("application/json");
236 response.setContentType("text/html");
238 } catch (ClassNotFoundException e) {
239 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
240 + actionKey + "]. ClassNotFoundException: " + e.getMessage()));
241 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
242 new RaptorRuntimeException(
243 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
245 } catch (IllegalAccessException e) {
246 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
247 + actionKey + "]. IllegalAccessException: " + e.getMessage()));
248 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
249 new RaptorRuntimeException(
250 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
252 } catch (InstantiationException e) {
253 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
254 + actionKey + "]. InstantiationException: " + e.getMessage()));
255 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
256 new RaptorRuntimeException(
257 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
259 } catch (NoSuchMethodException e) {
260 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
261 + actionKey + "]. NoSuchMethodException: " + e.getMessage()));
262 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
263 new RaptorRuntimeException(
264 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
266 } catch (InvocationTargetException e) {
267 logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
268 + actionKey + "]. InvocationTargetException: " + e.getMessage()));
269 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
270 new RaptorRuntimeException(
271 "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
274 PrintWriter out = response.getWriter();
278 PrintWriter out = response.getWriter();
279 out.write("session has timed out for user");
285 @RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json")
286 public @ResponseBody ArrayList<ColumnJSON> listColumns(HttpServletRequest request, HttpServletResponse response)
287 throws IOException, RaptorException {
288 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
289 List<DataColumnType> reportColumnList = rdef.getAllColumns();
290 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
291 ColumnJSON columnJSON = new ColumnJSON();
293 for (DataColumnType reportColumnType : reportColumnList) {
294 columnJSON = new ColumnJSON();
295 columnJSON.setId(reportColumnType.getColId());
296 columnJSON.setName(reportColumnType.getColName());
297 listJSON.add(columnJSON);
302 @RequestMapping(value = "/report/wizard/list_drilldown_reports", method = RequestMethod.GET, produces = "application/json")
303 public @ResponseBody ArrayList<ColumnJSON> list_drilldown_reports(HttpServletRequest request,
304 HttpServletResponse response) throws IOException, RaptorException {
305 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
306 Vector<IdNameValue> publicReportIdNames = DataCache.getPublicReportIdNames();
307 Vector groupReportIdNames = DataCache.getGroupAccessibleReportIdNames(AppUtils.getUserID(request),
308 AppUtils.getUserRoles(request));
309 Vector privateReportIdNames = DataCache.getPrivateAccessibleReportIdNames(AppUtils.getUserID(request),
310 AppUtils.getUserRoles(request));
312 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
313 ColumnJSON columnJSON = new ColumnJSON();
315 ServletContext servletContext = request.getSession().getServletContext();
316 if (!Globals.isSystemInitialized()) {
317 Globals.initializeSystem(servletContext);
320 for (int i = 0; i < publicReportIdNames.size(); i++) {
321 IdNameValue reportIdName = (IdNameValue) publicReportIdNames.get(i);
322 columnJSON = new ColumnJSON();
323 columnJSON.setId(reportIdName.getId());
324 columnJSON.setName("Public Report: " + reportIdName.getName());
325 if (!rdef.getReportID().equals(reportIdName.getId()))
326 listJSON.add(columnJSON);
329 for (int i = 0; i < groupReportIdNames.size(); i++) {
330 IdNameValue reportIdName = (IdNameValue) groupReportIdNames.get(i);
331 columnJSON = new ColumnJSON();
332 columnJSON.setId(reportIdName.getId());
333 columnJSON.setName("Group Report: " + reportIdName.getName());
334 if (!rdef.getReportID().equals(reportIdName.getId()))
335 listJSON.add(columnJSON);
338 for (int i = 0; i < privateReportIdNames.size(); i++) {
339 IdNameValue reportIdName = (IdNameValue) privateReportIdNames.get(i);
340 columnJSON = new ColumnJSON();
341 columnJSON.setId(reportIdName.getId());
342 columnJSON.setName("Private Report: " + reportIdName.getName());
343 if (!rdef.getReportID().equals(reportIdName.getId()))
344 listJSON.add(columnJSON);
350 @RequestMapping(value = "/report/wizard/list_formfields", method = RequestMethod.GET, produces = "application/json")
351 public @ResponseBody ArrayList<SearchFieldJSON> listFormFields(HttpServletRequest request,
352 HttpServletResponse response) throws IOException, RaptorException {
353 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
354 ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
355 SearchFieldJSON fieldJSON = new SearchFieldJSON();
356 if (rdef.getFormFieldList() != null) {
357 for (Iterator iter = rdef.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
358 fieldJSON = new SearchFieldJSON();
359 FormFieldType fft = (FormFieldType) iter.next();
360 String fieldId = fft.getFieldId();
361 String fieldDisplay = fft.getFieldName();
362 fieldJSON.setId(fieldId);
363 fieldJSON.setName(fieldDisplay);
364 listJSON.add(fieldJSON);
371 @RequestMapping(value = "/report/wizard/list_child_report_col/{reportID}", method = RequestMethod.GET, produces = "application/json")
372 public @ResponseBody ArrayList<ColumnJSON> listChildReportCols(@PathVariable("reportID") String reportID,
373 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
374 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
376 List<DataColumnType> reportColumnList = ddRr.getAllColumns();
377 ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>();
378 ColumnJSON columnJSON = new ColumnJSON();
380 for (DataColumnType reportColumnType : reportColumnList) {
381 columnJSON = new ColumnJSON();
382 columnJSON.setId(reportColumnType.getColId());
383 columnJSON.setName(reportColumnType.getColName());
384 listJSON.add(columnJSON);
389 @RequestMapping(value = "/report/wizard/list_child_report_ff/{reportID}", method = RequestMethod.GET, produces = "application/json")
390 public @ResponseBody ArrayList<SearchFieldJSON> listChildReportFormFields(@PathVariable("reportID") String reportID,
391 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
392 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
393 ArrayList<SearchFieldJSON> listJSON = new ArrayList<SearchFieldJSON>();
394 SearchFieldJSON fieldJSON = new SearchFieldJSON();
396 ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
397 if (ddReportFormFields != null) {
398 for (ddReportFormFields.resetNext(); ddReportFormFields.hasNext();) {
399 FormField ff = ddReportFormFields.getNext();
400 if (!ff.getFieldType().equals(FormField.FFT_BLANK)) {
401 fieldJSON = new SearchFieldJSON();
402 fieldJSON.setId(ff.getFieldName());
403 fieldJSON.setName(ff.getFieldDisplayName());
404 listJSON.add(fieldJSON);
411 @RequestMapping(value = "report/wizard/copy_report/{reportID}", method = RequestMethod.GET, produces = "application/json")
412 public @ResponseBody MessageJSON copyReport(@PathVariable("reportID") String reportID, HttpServletRequest request,
413 HttpServletResponse response) throws IOException, RaptorException {
414 MessageJSON messageJSON = new MessageJSON();
417 ReportHandler rh = new ReportHandler();
418 ReportDefinition rdef = rh.loadReportDefinition(request, reportID);
419 rdef.setAsCopy(request);
420 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
421 messageJSON.setMessage("Success- Report Copied.");
422 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
424 } catch (RaptorException e) {
425 request.setAttribute("error_extra_msg", "While copying report " + reportID);
426 messageJSON.setMessage("Failed - While copying report " + reportID);
427 messageJSON.setAnyStacktrace(getStackTrace(e));
428 logger.debug(EELFLoggerDelegate.debugLogger,
429 ("[Controller.processRequest]Invalid raptor action [copyReport]. RaptorException: "
437 @RequestMapping(value = "report/wizard/import_report", method = RequestMethod.POST, consumes = "application/json")
438 public @ResponseBody MessageJSON importReport(@RequestBody ImportJSON importJSON, HttpServletRequest request,
439 HttpServletResponse response) throws IOException, RaptorException {
440 MessageJSON messageJSON = new MessageJSON();
442 String reportXML = importJSON.getReportXML();
444 ReportHandler rh = new ReportHandler();
445 ReportDefinition rdef = rh.createReportDefinition(request, "-1", reportXML);
446 rdef.updateReportDefType();
447 rdef.generateWizardSequence(request);
448 rdef.setReportName("Import: " + rdef.getReportName());
449 rdef.clearAllDrillDowns();
451 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
453 messageJSON.setMessage("Success- Report imported.");
454 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
456 } catch (RaptorException e) {
457 request.setAttribute("error_extra_msg", "Unable to parse XML. Nested error: ");
458 messageJSON.setMessage("Unable to parse XML. Nested error: ");
459 messageJSON.setAnyStacktrace(getStackTrace(e));
468 @RequestMapping(value = "report/wizard/save_formfield_tab_data", method = RequestMethod.POST)
469 public @ResponseBody MessageJSON saveFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
470 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
471 ReportDefinition rdef = null;
472 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
474 MessageJSON messageJSON = new MessageJSON();
478 String fieldId = formEditJSON.getFieldId();
480 if (rdef.getFormFieldList() != null) {
481 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
482 if (fft.getFieldId().equals(fieldId)) {
483 fft.setFieldName(formEditJSON.getFieldName());
484 fft.setFieldType(formEditJSON.getFieldType());
485 fft.setVisible(formEditJSON.isVisible() ? "Y" : "N");
486 fft.setDefaultValue(formEditJSON.getDefaultValue());
487 fft.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL());
488 fft.setFieldSQL(formEditJSON.getFieldSQL());
489 fft.setValidationType(formEditJSON.getValidationType());
491 // clear predefined value
492 if (fft.getPredefinedValueList() != null) {
493 for (Iterator<String> iter = fft.getPredefinedValueList().getPredefinedValue()
494 .iterator(); iter.hasNext();)
498 List<IdNameBooleanJSON> predefList = formEditJSON.getPredefinedValueList();
499 if (predefList != null && predefList.size() > 0) {
500 for (IdNameBooleanJSON item : predefList) {
501 PredefinedValueList predefinedValueList = new ObjectFactory()
502 .createPredefinedValueList();
503 fft.setPredefinedValueList(predefinedValueList);
504 fft.getPredefinedValueList().getPredefinedValue().add(item.getId());
512 persistReportDefinition(request, rdef);
513 messageJSON.setMessage("Success formfield Details of given report is saved in session.");
514 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
517 messageJSON.setMessage("Report Definition is not in session");
518 messageJSON.setAnyStacktrace("Report Definition is not in session");
521 } catch (Exception ex) {
522 messageJSON.setMessage("Error occured while formfield details Tab");
523 messageJSON.setAnyStacktrace(getStackTrace(ex));
530 @RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST)
531 public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON,
532 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
533 ReportDefinition rdef = null;
534 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
536 MessageJSON messageJSON = new MessageJSON();
540 String colId = columnEditJSON.getColId();
541 List<DataColumnType> reportColumnList = rdef.getAllColumns();
543 for (DataColumnType reportColumnType : reportColumnList) {
544 // columnJSON = new ColumnJSON();
545 if (reportColumnType.getColId().equals(colId)) {
546 reportColumnType.setColName(columnEditJSON.getColName());
547 reportColumnType.setDisplayAlignment(columnEditJSON.getDisplayAlignment());
548 reportColumnType.setDisplayHeaderAlignment(columnEditJSON.getDisplayHeaderAlignment());
549 reportColumnType.setIsSortable(columnEditJSON.isSortable());
550 reportColumnType.setVisible(columnEditJSON.isVisible());
551 reportColumnType.setDrillDownURL(columnEditJSON.getDrilldownURL());
552 reportColumnType.setDrillDownParams(columnEditJSON.getDrilldownParams());
553 reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType());
558 persistReportDefinition(request, rdef);
559 messageJSON.setMessage("Success Column Details of given report is saved in session.");
560 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
563 messageJSON.setMessage("Report Definition is not in session");
564 messageJSON.setAnyStacktrace("");
567 } catch (Exception ex) {
568 messageJSON.setMessage("Error occured while saving column details Tab");
569 messageJSON.setAnyStacktrace(getStackTrace(ex));
577 @RequestMapping(value = "report/wizard/save_def_tab_data/{id}", method = RequestMethod.POST)
578 public @ResponseBody MessageJSON saveDefTabWiseData(@PathVariable("id") String id,
579 @RequestBody DefinitionJSON definitionJSON, HttpServletRequest request, HttpServletResponse response)
580 throws IOException, RaptorException {
581 ReportDefinition rdef = null;
582 ReportRuntime rr = null;
583 boolean newReport = false;
584 MessageJSON messageJSON = new MessageJSON();
587 if (id.equals("InSession")) {
588 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
591 } else if (id.equals("Create")) {
592 removeVariablesFromSession(request);
593 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
595 System.out.println("&&&&&&&&&&&&&&&&&&&&&& CHECK Report Type "
596 + (AppUtils.nvl(rdef.getReportType()).length() <= 0));
597 if (AppUtils.nvl(rdef.getReportType()).length() <= 0) {
598 rdef.setReportType(AppConstants.RT_LINEAR);
599 System.out.println("&&&&&&&&&&&&&&&&&&&&&& ADDED Report Type in session ");
602 } else if (AppUtils.nvl(id).length() > 0) {
603 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
604 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
606 if (rdef != null && !rdef.getReportID().equals(id)) {
607 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
608 removeVariablesFromSession(request);
609 rdef = (new ReportHandler()).loadReportDefinition(request, id);
610 } else if (rr != null && !rr.getReportID().equals(id)) {
611 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
612 removeVariablesFromSession(request);
613 rdef = (new ReportHandler()).loadReportDefinition(request, id);
614 } else if (rdef == null) {
615 rdef = (new ReportHandler()).loadReportDefinition(request, id);
620 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
626 String reportName = definitionJSON.getReportName();
627 String errorString = "";
628 if (AppUtils.nvl(reportName).length() <= 0)
629 errorString = "ReportName cannot be null;";
630 rdef.setReportName(reportName);
632 String reportDescr = definitionJSON.getReportDescr();
633 rdef.setReportDescr(reportDescr);
635 String formHelpText = definitionJSON.getFormHelpText();
636 rdef.setFormHelpText(formHelpText);
638 Integer pageSize = definitionJSON.getPageSize();
639 rdef.setPageSize(pageSize);
641 List<IdNameBooleanJSON> menuIds = definitionJSON.getDisplayArea();
642 for (IdNameBooleanJSON menuId : menuIds) {
643 if (menuId.isSelected()) {
644 rdef.setMenuID(menuId.getName());
649 Boolean hideFormFieldsAfterRun = definitionJSON.getHideFormFieldsAfterRun();
650 rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun);
651 Integer maxRowsInExcelCSVDownload = definitionJSON.getMaxRowsInExcelCSVDownload();
652 rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload);
653 Integer frozenColumns = definitionJSON.getFrozenColumns();
654 rdef.setFrozenColumns(frozenColumns);
655 String dataGridAlign = definitionJSON.getDataGridAlign();
656 rdef.setDataGridAlign(dataGridAlign);
657 String emptyMessage = definitionJSON.getEmptyMessage();
658 rdef.setEmptyMessage(emptyMessage);
659 String dataContainerHeight = definitionJSON.getDataContainerHeight();
660 rdef.setDataContainerHeight(dataContainerHeight);
661 String dataContainerWidth = definitionJSON.getDataContainerWidth();
662 rdef.setDataContainerWidth(dataContainerWidth);
663 boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled();
664 rdef.setRuntimeColSortDisabled(runtimeColSortDisabled);
665 Integer numFormCols = definitionJSON.getNumFormCols();
666 rdef.setNumFormCols(Integer.toString(numFormCols));
667 String reportTitle = definitionJSON.getReportTitle();
668 rdef.setReportTitle(reportTitle);
669 String reportSubTitle = definitionJSON.getReportSubTitle();
670 rdef.setReportSubTitle(reportSubTitle);
672 List<NameBooleanJSON> displayOptions = definitionJSON.getDisplayOptions();
673 StringBuffer displayOptionStr = new StringBuffer("NNNNNNN");
674 for (NameBooleanJSON displayOption : displayOptions) {
675 if (displayOption.isSelected()) {
676 if (displayOption.getName().equals("HideFormFields")) {
677 displayOptionStr.setCharAt(0, 'Y');
678 } else if (displayOption.getName().equals("HideChart")) {
679 displayOptionStr.setCharAt(1, 'Y');
680 } else if (displayOption.getName().equals("HideReportData")) {
681 displayOptionStr.setCharAt(2, 'Y');
682 } else if (displayOption.getName().equals("HideExcel")) {
683 displayOptionStr.setCharAt(5, 'Y');
684 } else if (displayOption.getName().equals("HidePdf")) {
685 displayOptionStr.setCharAt(6, 'Y');
691 rdef.setDisplayOptions(displayOptionStr.toString());
693 if (id.equals("Create")) {
694 rdef.persistReport(request);
696 persistReportDefinition(request, rdef);
697 messageJSON.setMessage("Success Definition of given report is saved in session.");
698 messageJSON.setAnyStacktrace((newReport ? " New Report info is added to Session "
699 : rdef.getReportID() + " is Modified and added to session and DB."));
701 } catch (Exception ex) {
702 messageJSON.setMessage("Error occured while saving definition Tab");
703 messageJSON.setAnyStacktrace(getStackTrace(ex));
704 logger.error(EELFLoggerDelegate.errorLogger,
705 "[Controller.processRequest]Invalid raptor action [retrieveTabWiseData].", ex);
712 @RequestMapping(value = { "/report/wizard/retrieve_form_tab_wise_data/{id}",
713 "/report/wizard/retrieve_form_tab_wise_data/{id}/{action}" }, method = RequestMethod.GET)
714 public @ResponseBody FormEditJSON retrieveFormTabWiseData(@PathVariable Map<String, String> pathVariables,
715 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
716 ReportDefinition rdef = null;
719 String detailId = "";
720 FormEditJSON wizardJSON = new FormEditJSON();
721 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
723 if (pathVariables.containsKey("id")) {
724 id = pathVariables.get("id");
726 if (pathVariables.containsKey("action")) {
727 action = pathVariables.get("action");
730 ServletContext servletContext = request.getSession().getServletContext();
731 if (!Globals.isSystemInitialized()) {
732 Globals.initializeSystem(servletContext);
734 wizardJSON.setTabId("FormEdit");
735 wizardJSON.setTabName("Form Edit");
736 FormFieldType currField = null;
738 if (id.equals("add")) {
740 currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",
742 wizardJSON.setFieldId(currField.getFieldId());
743 wizardJSON.setFieldName(currField.getFieldName());
744 wizardJSON.setFieldType(currField.getFieldType());
745 wizardJSON.setVisible(AppUtils.nvls(currField.getVisible(), "Y").toUpperCase().startsWith("Y"));
746 wizardJSON.setDefaultValue(currField.getDefaultValue());
747 wizardJSON.setFieldDefaultSQL(currField.getFieldDefaultSQL());
748 wizardJSON.setFieldSQL(currField.getFieldSQL());
749 wizardJSON.setValidationType(currField.getValidationType());
750 persistReportDefinition(request, rdef);
752 } else if (action.equals("delete")) {
753 rdef.deleteFormField(id);
754 persistReportDefinition(request, rdef);
755 wizardJSON.setMessage("Formfield " + detailId + " Deleted");
757 if (rdef.getFormFieldList() != null) {
758 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
759 if (fft.getFieldId().equals(id)) {
760 wizardJSON.setFieldId(fft.getFieldId());
761 wizardJSON.setFieldName(fft.getFieldName());
762 wizardJSON.setFieldType(fft.getFieldType());
763 wizardJSON.setVisible(fft.getVisible().toUpperCase().startsWith("Y"));
764 wizardJSON.setDefaultValue(fft.getDefaultValue());
765 wizardJSON.setFieldDefaultSQL(fft.getFieldDefaultSQL());
766 wizardJSON.setFieldSQL(fft.getFieldSQL());
767 wizardJSON.setValidationType(fft.getValidationType());
769 PredefinedValueList preDefined = fft.getPredefinedValueList();
771 if (preDefined != null) {
772 List<IdNameBooleanJSON> preDefinedList = new ArrayList<IdNameBooleanJSON>();
773 IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON();
775 for (String v : preDefined.getPredefinedValue()) {
776 idNameBooleanJSON = new IdNameBooleanJSON();
777 idNameBooleanJSON.setId(v);
778 idNameBooleanJSON.setName(v);
779 preDefinedList.add(idNameBooleanJSON);
781 wizardJSON.setPredefinedValueList(preDefinedList);
786 } catch (Exception ex) {
787 logger.error(EELFLoggerDelegate.errorLogger,
788 "[Controller.processRequest]Invalid raptor action [retrieveFormTabWiseData].", ex);
789 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
790 errorJSONRuntime.setErrormessage("Error occured while retreiving formedit definition Tab");
791 errorJSONRuntime.setStacktrace(getStackTrace(ex));
792 wizardJSON.setErrorMessage("Error occured while retreiving formedit definition Tab");
793 wizardJSON.setErrorStackTrace(getStackTrace(ex));
800 @RequestMapping(value = { "/report/wizard/retrieve_col_tab_wise_data/{id}" }, method = RequestMethod.GET)
801 public @ResponseBody ColumnEditJSON retrieveColTabWiseData(@PathVariable Map<String, String> pathVariables,
802 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
803 ReportDefinition rdef = null;
805 ColumnEditJSON wizardJSON = new ColumnEditJSON();
806 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
808 if (pathVariables.containsKey("id")) {
809 id = pathVariables.get("id");
811 ServletContext servletContext = request.getSession().getServletContext();
812 if (!Globals.isSystemInitialized()) {
813 Globals.initializeSystem(servletContext);
816 wizardJSON.setTabId("ColEdit");
817 wizardJSON.setTabName("Column Edit");
819 List<DataColumnType> reportColumnList = rdef.getAllColumns();
821 for (DataColumnType reportColumnType : reportColumnList) {
822 if (reportColumnType.getColId().equals(id)) {
823 wizardJSON.setColId(reportColumnType.getColId());
824 wizardJSON.setColName(reportColumnType.getColName());
825 wizardJSON.setDisplayAlignment(reportColumnType.getDisplayAlignment());
826 wizardJSON.setDisplayHeaderAlignment(reportColumnType.getDisplayHeaderAlignment());
827 wizardJSON.setSortable(
828 reportColumnType.isIsSortable() == null ? false : reportColumnType.isIsSortable());
829 wizardJSON.setVisible(reportColumnType.isVisible());
830 wizardJSON.setDrilldownURL(
831 reportColumnType.getDrillDownURL() == null ? "" : reportColumnType.getDrillDownURL());
832 wizardJSON.setDrilldownParams(
833 reportColumnType.getDrillDownParams() == null ? "" : reportColumnType.getDrillDownParams());
834 wizardJSON.setDrilldownType(
835 reportColumnType.getDrillDownType() == null ? "" : reportColumnType.getDrillDownType());
840 wizardJSON.setErrorMessage("Report is not in session");
846 @RequestMapping(value = { "/report/wizard/retrieve_sql_tab_wise_data/{id}",
847 "/report/wizard/retrieve_sql_tab_wise_data/" }, method = RequestMethod.GET)
848 public @ResponseBody QueryJSON retrieveSqlTabWiseData(@PathVariable Map<String, String> pathVariables,
849 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
850 ReportDefinition rdef = null;
851 ReportRuntime rr = null;
853 String detailId = "";
854 QueryJSON wizardJSON = new QueryJSON();
856 if (pathVariables.containsKey("id")) {
857 id = pathVariables.get("id");
859 if (pathVariables.containsKey("detailId")) {
860 detailId = pathVariables.get("detailId");
862 ServletContext servletContext = request.getSession().getServletContext();
863 if (!Globals.isSystemInitialized()) {
864 Globals.initializeSystem(servletContext);
866 if (id.equals("InSession") || AppUtils.nvl(id).length() <= 0) {
867 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
868 } else if (AppUtils.nvl(id).length() > 0) {
869 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
870 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
872 if (rdef != null && !rdef.getReportID().equals(id)) {
873 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
874 removeVariablesFromSession(request);
875 rdef = (new ReportHandler()).loadReportDefinition(request, id);
876 } else if (rr != null && !rr.getReportID().equals(id)) {
877 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
878 removeVariablesFromSession(request);
879 rdef = (new ReportHandler()).loadReportDefinition(request, id);
880 } else if (rdef == null) {
881 rdef = (new ReportHandler()).loadReportDefinition(request, id);
887 wizardJSON.setTabId("Sql");
888 wizardJSON.setTabName("Sql");
889 wizardJSON.setQuery(rdef.getReportSQL());
894 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList" }, method = RequestMethod.GET)
895 public @ResponseBody List<SecurityEntry> getReportUserList(HttpServletRequest request)
896 throws IOException, RaptorException {
897 List<SecurityEntry> reportUserList = new ArrayList<SecurityEntry>();
898 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
899 Vector reportUsers = rdef.getReportUsers(request);
900 for(Iterator iter=reportUsers.iterator(); iter.hasNext();) {
901 SecurityEntry rUser = (SecurityEntry) iter.next();
902 reportUserList.add(rUser);
904 return reportUserList;
907 @RequestMapping(value = { "/report/wizard/security/retrieveReportRoleList" }, method = RequestMethod.GET)
908 public @ResponseBody List<IdNameValue> getReportRoleList(HttpServletRequest request)
909 throws IOException, RaptorException {
910 List<IdNameValue> reportRoleList = new ArrayList<IdNameValue>();
911 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
912 Vector reportRoles = rdef.getReportRoles(request);
913 Vector remainingRoles = Utils.getRolesNotInList(reportRoles,request);
914 for(int i=0; i<remainingRoles.size(); i++) {
915 IdNameValue role = (IdNameValue) remainingRoles.get(i);
916 reportRoleList.add(role);
918 return reportRoleList;
921 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList_query" }, method = RequestMethod.GET)
922 public @ResponseBody List<Map<String, String>> getReportUserListQuery(HttpServletRequest request)
923 throws IOException, RaptorException {
924 List<Map<String, String>> reportUserList = new ArrayList();
925 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
926 String reportId = rdef.getReportID();
927 Map<String, Object> params = new HashMap<String, Object>();
928 params.put("report_id", new Long(reportId));
929 List<ReportUserRole> queriedUserList = getDataAccessService().executeNamedQuery("getReportSecurityUsers", params, null);
930 for (int i=0; i<queriedUserList.size();i++){
931 Map<String, String> reportUser = new HashMap<String, String>();
932 Object tmp = queriedUserList.get(i);
933 reportUser.put("rep_id", queriedUserList.get(i).toString());
934 reportUser.put("order_no", queriedUserList.get(i).getOrderNo().toString());
935 reportUser.put("user_id", queriedUserList.get(i).getUserId().toString());
936 reportUser.put("role_id", queriedUserList.get(i).getRoleId().toString());
937 reportUser.put("read_only_yn", queriedUserList.get(i).getReadOnlyYn());
938 reportUserList.add(reportUser);
940 return reportUserList;
945 @RequestMapping(value = "/report/security/addReportUser", method = RequestMethod.POST)
946 public @ResponseBody Map<String,String> addSelectedReportUser(
947 @RequestBody String userIdToAdd, HttpServletRequest request, HttpServletResponse response)
948 throws IOException, RaptorException {
949 Map<String, String> JsonResponse = new HashMap<String, String>();
950 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
952 JsonResponse.put("status","success");
953 JsonResponse.put("userId",userIdToAdd);
954 String action = "Add User";
955 rdef.getReportSecurity().addUserAccess(userIdToAdd, "Y");
956 WizardSequence ws = rdef.getWizardSequence();
957 ws.performAction(action,rdef);
959 } catch (Exception ex) {
960 logger.error(EELFLoggerDelegate.errorLogger,
961 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
966 @RequestMapping(value = "/report/security/removeReportUser", method = RequestMethod.POST)
967 public @ResponseBody Map<String,String> removeSelectedReportUser(
968 @RequestBody String userIdToRemove, HttpServletRequest request, HttpServletResponse response)
969 throws IOException, RaptorException {
970 Map<String, String> JsonResponse = new HashMap<String, String>();
971 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
973 JsonResponse.put("status","success");
974 JsonResponse.put("userId",userIdToRemove);
975 String action = "Delete User";
976 rdef.getReportSecurity().removeUserAccess(userIdToRemove);
977 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
978 WizardSequence ws = rdef.getWizardSequence();
979 ws.performAction(action,rdef);
981 } catch (Exception ex) {
982 logger.error(EELFLoggerDelegate.errorLogger,
983 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
988 @RequestMapping(value = "/report/security/addReportRole", method = RequestMethod.POST)
989 public @ResponseBody Map<String,String> addSelectedReportRole(
990 @RequestBody String roleIdToAdd, HttpServletRequest request, HttpServletResponse response)
991 throws IOException, RaptorException {
992 Map<String, String> JsonResponse = new HashMap<String, String>();
993 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
995 JsonResponse.put("status","success");
996 JsonResponse.put("roleId",roleIdToAdd);
997 String action = "Add Role";
998 rdef.getReportSecurity().addRoleAccess(roleIdToAdd, "Y");
999 WizardSequence ws = rdef.getWizardSequence();
1000 ws.performAction(action,rdef);
1001 return JsonResponse;
1002 } catch (Exception ex) {
1003 logger.error(EELFLoggerDelegate.errorLogger,
1004 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1009 @RequestMapping(value = "/report/security/removeReportRole", method = RequestMethod.POST)
1010 public @ResponseBody Map<String,String> removeSelectedReportRole(
1011 @RequestBody String roleIdToRemove, HttpServletRequest request, HttpServletResponse response)
1012 throws IOException, RaptorException {
1013 Map<String, String> JsonResponse = new HashMap<String, String>();
1014 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1016 JsonResponse.put("status","success");
1017 JsonResponse.put("roleId",roleIdToRemove);
1018 String action = "Delete Role";
1019 rdef.getReportSecurity().removeRoleAccess(roleIdToRemove);
1020 WizardSequence ws = rdef.getWizardSequence();
1021 ws.performAction(action,rdef);
1022 return JsonResponse;
1023 } catch (Exception ex) {
1024 logger.error(EELFLoggerDelegate.errorLogger,
1025 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1030 @RequestMapping(value = "/report/security/updateReportSecurityInfo", method = RequestMethod.POST)
1031 public @ResponseBody Map<String,String> updateReportSecurityInfo(
1032 @RequestBody Map<String,String> securityInfo, HttpServletRequest request, HttpServletResponse response)
1033 throws IOException, RaptorException {
1035 Map<String, String> JsonResponse = new HashMap<String, String>();
1036 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1038 JsonResponse.put("status","success");
1039 String OwnerUserId = securityInfo.get("userId");
1040 String isPublic = securityInfo.get("isPublic");
1041 boolean rPublic = isPublic.equals("true");
1042 rdef.getReportSecurity().setOwnerID(OwnerUserId);
1043 rdef.setPublic(rPublic);
1044 persistReportDefinition(request, rdef);
1045 return JsonResponse;
1047 } catch (Exception ex) {
1048 logger.error(EELFLoggerDelegate.errorLogger,
1049 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1054 @RequestMapping(value = "/report/security/toggleUserEditAccess/{userID}", method = RequestMethod.POST)
1055 public @ResponseBody Map<String,String> toggleUserEditAccess(
1056 @PathVariable("userID") String userId,
1057 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1058 throws IOException, RaptorException {
1059 Map<String, String> JsonResponse = new HashMap<String, String>();
1060 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1063 JsonResponse.put("status","success");
1064 if (readOnly.equals("N")) {
1065 action = "Grant User Access";
1067 action = "Revoke User Access";
1069 rdef.getReportSecurity().updateUserAccess(userId, readOnly);
1070 WizardSequence ws = rdef.getWizardSequence();
1071 ws.performAction(action,rdef);
1073 return JsonResponse;
1074 } catch (Exception ex) {
1075 logger.error(EELFLoggerDelegate.errorLogger,
1076 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1081 @RequestMapping(value = "/report/security/toggleRoleEditAccess/{roleID}", method = RequestMethod.POST)
1082 public @ResponseBody Map<String,String> toggleRoleEditAccess(
1083 @PathVariable("roleID") String roleId,
1084 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1085 throws IOException, RaptorException {
1086 Map<String, String> JsonResponse = new HashMap<String, String>();
1087 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1090 JsonResponse.put("status","success");
1091 if (readOnly.equals("N")) {
1092 action = "Grant Role Access";
1094 action = "Revoke Role Access";
1096 rdef.getReportSecurity().updateRoleAccess(roleId, readOnly);
1097 WizardSequence ws = rdef.getWizardSequence();
1098 ws.performAction(action,rdef);
1100 return JsonResponse;
1101 } catch (Exception ex) {
1102 logger.error(EELFLoggerDelegate.errorLogger,
1103 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1108 @RequestMapping(value = { "/report/wizard/security/retrieveReportOwner" }, method = RequestMethod.GET)
1109 public @ResponseBody List<IdNameValue> getReportOwnerInList(HttpServletRequest request)
1110 throws IOException, RaptorException {
1111 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1113 List<IdNameValue> UserList = new ArrayList<IdNameValue>();
1114 List excludeValues = new java.util.ArrayList();
1115 HttpSession session = request.getSession();
1116 String query = Globals.getCustomizedScheduleQueryForUsers();
1117 session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
1118 String userId = AppUtils.getUserID(request);
1119 session.setAttribute("LOGGED_USERID", userId);
1120 String[] sessionParameters = Globals.getSessionParams().split(",");
1122 for (int i = 0; i < sessionParameters.length; i++) {
1123 param = (String) session.getAttribute(sessionParameters[0]);
1124 query = Utils.replaceInString(query, "[" + sessionParameters[i].toUpperCase() + "]",
1125 (String) session.getAttribute(sessionParameters[i]));
1127 boolean isAdmin = AppUtils.isAdminUser(request);
1128 Vector allUsers = AppUtils.getAllUsers(query, param, isAdmin);
1129 Vector result = new Vector(allUsers.size());
1131 for (Iterator iter = allUsers.iterator(); iter.hasNext();) {
1132 IdNameValue value = (IdNameValue) iter.next();
1134 boolean exclude = false;
1135 for (Iterator iterE = excludeValues.iterator(); iterE.hasNext();)
1136 if (((IdNameValue) iterE.next()).getId().equals(value.getId())) {
1142 UserList.add(value);
1148 @RequestMapping(value = { "/report/wizard/security/getReportSecurityInfo" }, method = RequestMethod.GET)
1149 public @ResponseBody Map<String,String> getReportSecurityInfo(HttpServletRequest request)
1150 throws IOException, RaptorException {
1151 Map<String, String> securityInfoMap = new HashMap<String,String>();
1152 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1153 String isPublic = Boolean.toString(rdef.isPublic());
1154 String createUser = AppUtils.getUserName(rdef.getCreateID());
1155 String createDate = rdef.getCreateDate();
1156 String updateUser = AppUtils.getUserName(rdef.getUpdateID());
1157 String updateDate = rdef.getUpdateDate();
1158 String ownerId = rdef.getOwnerID();
1160 securityInfoMap.put("isPublic",isPublic);
1161 securityInfoMap.put("createdUser",createUser);
1162 securityInfoMap.put("createdDate",createDate);
1163 securityInfoMap.put("updateUser",updateUser);
1164 securityInfoMap.put("updatedDate",updateDate);
1165 securityInfoMap.put("ownerId",ownerId);
1167 return securityInfoMap;
1170 @RequestMapping(value = { "/report/wizard/security/getReportSecurityUsers" }, method = RequestMethod.GET)
1171 public @ResponseBody List<SecurityEntry> getReportSecurityUsers(HttpServletRequest request)
1172 throws IOException, RaptorException {
1174 List<SecurityEntry> reportUserMapList = new ArrayList<SecurityEntry>();
1175 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1176 Vector reportUsers = rdef.getReportUsers(request);
1179 for(Iterator iter=reportUsers.iterator(); iter.hasNext(); iCount++) {
1180 Map<String, String> reportUserMap = new HashMap<String,String>();
1181 SecurityEntry rUser = (SecurityEntry) iter.next();
1182 reportUserMapList.add(rUser);
1185 return reportUserMapList;
1189 @RequestMapping(value = { "/report/wizard/security/getReportSecurityRoles" }, method = RequestMethod.GET)
1190 public @ResponseBody List<SecurityEntry> getReportSecurityRoles(HttpServletRequest request)
1191 throws IOException, RaptorException {
1193 List<SecurityEntry> reportRoleList = new ArrayList<SecurityEntry>();
1194 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1195 Vector reportRoles = rdef.getReportRoles(request);
1198 for(Iterator iter=reportRoles.iterator(); iter.hasNext(); iCount++) {
1199 SecurityEntry rRole = (SecurityEntry) iter.next();
1200 reportRoleList.add(rRole);
1203 return reportRoleList;
1207 @RequestMapping(value = { "/report/wizard/retrieve_def_tab_wise_data/{id}",
1208 "/report/wizard/retrieve_def_tab_wise_data/{id}/{detailId}" }, method = RequestMethod.GET)
1209 public @ResponseBody DefinitionJSON retrieveDefTabWiseData(@PathVariable Map<String, String> pathVariables,
1210 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
1211 ReportDefinition rdef = null;
1212 ReportRuntime rr = null;
1213 boolean newReport = false;
1214 String tabId = "Def";
1217 if (pathVariables.containsKey("id")) {
1218 id = pathVariables.get("id");
1220 String detailId = "";
1221 if (pathVariables.containsKey("detailId")) {
1222 detailId = pathVariables.get("detailId");
1225 ServletContext servletContext = request.getSession().getServletContext();
1226 if (!Globals.isSystemInitialized()) {
1227 Globals.initializeSystem(servletContext);
1230 if (tabId.equals("Def") && id.equals("InSession")) {
1231 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1234 } else if (tabId.equals("Def") && id.equals("Create")) {
1235 removeVariablesFromSession(request);
1236 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
1237 rdef.setReportType(AppConstants.RT_LINEAR);
1240 } else if (tabId.equals("Def") && AppUtils.nvl(id).length() > 0) {
1241 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1242 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1244 if (rdef != null && !rdef.getReportID().equals(id)) {
1245 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1246 removeVariablesFromSession(request);
1247 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1248 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1249 } else if (rr != null && !rr.getReportID().equals(id)) {
1250 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1251 removeVariablesFromSession(request);
1252 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1253 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1254 } else if (rdef == null) {
1255 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1256 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1261 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1263 DefinitionJSON wizardJSON = new DefinitionJSON();
1264 if (tabId.equals("Def")) {
1265 wizardJSON.setTabId("Def");
1266 wizardJSON.setTabName("Definition");
1268 wizardJSON.setReportId((rdef != null) ? rdef.getReportID() + "" : "");
1269 wizardJSON.setReportName((rdef != null) ? rdef.getReportName() : "");
1270 wizardJSON.setReportDescr((rdef != null) ? rdef.getReportDescr() : "");
1271 wizardJSON.setReportType((rdef != null) ? rdef.getReportType() : AppConstants.RT_LINEAR);
1272 wizardJSON.setDbInfo((rdef != null) ? rdef.getDBInfo() : "");
1273 wizardJSON.setFormHelpText((rdef != null) ? rdef.getFormHelpText() : "");
1274 wizardJSON.setPageSize((rdef != null) ? rdef.getPageSize() : 50);
1275 List<IdNameBooleanJSON> displayArea = new ArrayList<IdNameBooleanJSON>();
1276 IdNameBooleanJSON idNameJSON = new IdNameBooleanJSON();
1278 for (int i = 0; i < AppUtils.getQuickLinksMenuIDs().size(); i++) {
1279 idNameJSON = new IdNameBooleanJSON();
1280 qMenu = (String) AppUtils.getQuickLinksMenuIDs().get(i);
1281 idNameJSON.setId(qMenu);
1282 idNameJSON.setName(qMenu);
1283 if (rdef != null && (rdef.getMenuID().equals(qMenu))) {
1284 idNameJSON.setSelected(true);
1286 displayArea.add(idNameJSON);
1288 wizardJSON.setDisplayArea(displayArea);
1289 wizardJSON.setHideFormFieldsAfterRun((rdef != null) ? rdef.isHideFormFieldAfterRun() : false);
1290 wizardJSON.setMaxRowsInExcelCSVDownload((rdef != null) ? rdef.getMaxRowsInExcelDownload() : 500);
1291 wizardJSON.setFrozenColumns((rdef != null) ? rdef.getFrozenColumns() : 0);
1292 wizardJSON.setDataGridAlign((rdef != null) ? rdef.getDataGridAlign() : "left");
1293 wizardJSON.setEmptyMessage((rdef != null) ? rdef.getEmptyMessage() : "No records found");
1294 wizardJSON.setDataContainerHeight((rdef != null) ? rdef.getDataContainerHeight() : "600");
1295 wizardJSON.setDataContainerWidth((rdef != null) ? rdef.getDataContainerWidth() : "900");
1296 List<NameBooleanJSON> displayOptions = new ArrayList<NameBooleanJSON>();
1297 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
1298 nameBooleanJSON.setName("HideFormFields");
1299 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideForm() : false);
1300 displayOptions.add(nameBooleanJSON);
1302 nameBooleanJSON = new NameBooleanJSON();
1303 nameBooleanJSON.setName("HideChart");
1304 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideChart() : false);
1305 displayOptions.add(nameBooleanJSON);
1307 nameBooleanJSON = new NameBooleanJSON();
1308 nameBooleanJSON.setName("HideReportData");
1309 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideData() : false);
1310 displayOptions.add(nameBooleanJSON);
1312 nameBooleanJSON = new NameBooleanJSON();
1313 nameBooleanJSON.setName("HideExcel");
1314 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideExcelIcons() : false);
1315 displayOptions.add(nameBooleanJSON);
1317 nameBooleanJSON = new NameBooleanJSON();
1318 nameBooleanJSON.setName("HidePdf");
1319 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHidePDFIcons() : false);
1320 displayOptions.add(nameBooleanJSON);
1322 wizardJSON.setDisplayOptions(displayOptions);
1324 wizardJSON.setRuntimeColSortDisabled((rdef != null) ? rdef.isRuntimeColSortDisabled() : false);
1325 wizardJSON.setNumFormCols((rdef != null) ? rdef.getNumFormColsAsInt() : 1);
1326 wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : "");
1327 wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : "");
1331 ObjectMapper mapper = new ObjectMapper();
1332 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1333 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1339 @RequestMapping(value = "/report/wizard/retrieve_data/{validate}", method = RequestMethod.POST)
1340 public @ResponseBody RaptorResponse retrieveDataForGivenQuery(@PathVariable("validate") boolean validate,
1341 @RequestBody QueryJSON queryJSON, HttpServletRequest request, HttpServletResponse response)
1342 throws IOException, RaptorException {
1343 RaptorResponse raptorResponse = new RaptorResponse();
1344 String sql = queryJSON.getQuery();
1345 String jsonInString = "";
1347 ServletContext servletContext = request.getSession().getServletContext();
1348 if (!Globals.isSystemInitialized()) {
1349 Globals.initializeSystem(servletContext);
1352 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1354 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1355 errorJSONRuntime.setErrormessage("Report Definition is not in session;");
1356 errorJSONRuntime.setStacktrace("");
1358 ObjectMapper mapper = new ObjectMapper();
1359 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1360 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1363 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1364 raptorResponse.data().put("elements", jsonInString);
1365 return raptorResponse;
1366 } catch (Exception ex1) {
1367 logger.error(EELFLoggerDelegate.errorLogger,
1368 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1371 if (!sql.trim().toUpperCase().startsWith("SELECT")) {
1372 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1373 errorJSONRuntime.setErrormessage("Invalid statement - the SQL must start with the keyword SELECT");
1374 errorJSONRuntime.setStacktrace("SQL Error");
1375 ObjectMapper mapper = new ObjectMapper();
1376 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1377 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1380 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1381 raptorResponse.data().put("elements", jsonInString);
1382 return raptorResponse;
1384 } catch (Exception ex) {
1385 logger.error(EELFLoggerDelegate.errorLogger,
1386 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1390 String remoteDb = request.getParameter("remoteDbPrefix");
1391 // comment below two lines to test
1392 String remoteDbPrefix = (remoteDb != null && !remoteDb.equalsIgnoreCase("null")) ? remoteDb
1394 String userId = AppUtils.getUserID(request);
1395 // String userId = "1";
1396 sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
1397 sql = Utils.replaceInString(sql, "[USERID]", userId);
1398 String[] reqParameters = Globals.getRequestParams().split(",");
1399 String[] sessionParameters = Globals.getSessionParams().split(",");
1400 javax.servlet.http.HttpSession session = request.getSession();
1401 logger.debug(EELFLoggerDelegate.debugLogger, ("B4 testRunSQL " + sql));
1402 if (request != null) {
1403 for (int i = 0; i < reqParameters.length; i++) {
1404 if (!reqParameters[i].startsWith("ff"))
1405 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1406 request.getParameter(reqParameters[i].toUpperCase()));
1408 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1409 request.getParameter(reqParameters[i]));
1412 if (session != null) {
1413 for (int i = 0; i < sessionParameters.length; i++) {
1414 logger.debug(EELFLoggerDelegate.debugLogger, (" Session " + " sessionParameters[i] "
1415 + sessionParameters[i] + " " + (String) session.getAttribute(sessionParameters[i])));
1416 sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]",
1417 (String) session.getAttribute(sessionParameters[i]));
1420 logger.debug(EELFLoggerDelegate.debugLogger, ("After testRunSQL " + sql));
1423 response.setContentType("application/json");
1424 ds = ConnectionUtils.getDataSet(sql, "local", true);
1426 QueryResultJSON queryResultJSON = new QueryResultJSON();
1427 queryResultJSON.setQuery(queryJSON.getQuery());
1428 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1429 rdef.parseReportSQL(query);
1430 queryResultJSON.setQuery(query);
1432 int numColumns = ds.getColumnCount();
1433 queryResultJSON.setTotalRows(ds.getRowCount());
1436 Map<String, String> dvJSON = null;
1437 ArrayList<String> colList = new ArrayList<String>();
1438 ArrayList<Map<String, String>> reportDataRows = new ArrayList<Map<String, String>>();
1439 if (!ds.isEmpty()) {
1442 for (int i = 0; i < ds.getColumnCount(); i++) {
1443 colList.add(ds.getColumnName(i));
1445 queryResultJSON.setReportDataColumns(colList);
1446 if (queryResultJSON.getTotalRows() > 0) {
1448 dvJSON = new HashMap<String, String>();
1449 for (int r = 0; r < Math.min(ds.getRowCount(), 100); r++) {
1450 dvJSON = new HashMap<String, String>();
1451 for (int c = 0; c < ds.getColumnCount(); c++) {
1453 dvJSON.put(ds.getColumnName(c), ds.getString(r, c));
1454 } catch (Exception ex) {
1455 logger.error(EELFLoggerDelegate.errorLogger,
1456 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].",
1460 reportDataRows.add(dvJSON);
1466 queryResultJSON.setReportDataRows(reportDataRows);
1467 ObjectMapper mapper = new ObjectMapper();
1468 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1469 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1471 query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1472 request.setAttribute("sqlValidated", "N");
1473 rdef.parseReportSQL(query);
1474 request.setAttribute("sqlValidated", "Y");
1475 persistReportDefinition(request, rdef);
1479 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(queryResultJSON);
1480 raptorResponse.data().put("elements", jsonInString);
1481 return raptorResponse;
1483 } catch (Exception ex) {
1484 logger.error(EELFLoggerDelegate.errorLogger,
1485 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery]. RaptorException: ",
1488 } catch (ReportSQLException ex) {
1489 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1490 if (sql.contains("[")) {
1491 errorJSONRuntime.setErrormessage(
1492 "Formfield information is present in the query, hence couldn't execute");
1494 .setStacktrace("Formfield information is present in the query, hence couldn't execute");
1496 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1497 request.setAttribute("sqlValidated", "N");
1498 rdef.parseReportSQL(query);
1499 request.setAttribute("sqlValidated", "Y");
1500 persistReportDefinition(request, rdef);
1505 errorJSONRuntime.setErrormessage(ex.getMessage());
1506 errorJSONRuntime.setStacktrace(getStackTrace(ex));
1508 ObjectMapper mapper = new ObjectMapper();
1509 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1510 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1513 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1514 raptorResponse.data().put("elements", jsonInString);
1515 return raptorResponse;
1517 } catch (Exception ex1) {
1518 logger.error(EELFLoggerDelegate.errorLogger,
1519 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1523 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1524 request.setAttribute("sqlValidated", "N");
1525 rdef.parseReportSQL(query);
1526 request.setAttribute("sqlValidated", "Y");
1527 persistReportDefinition(request, rdef);
1533 raptorResponse.data().put("elements", jsonInString);
1534 return raptorResponse;
1538 @RequestMapping(value = "save_chart", method = RequestMethod.POST)
1539 public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request,
1540 HttpServletResponse response) throws IOException {
1541 ReportRuntime reportRuntime;
1542 reportRuntime = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); // changing
1546 String reportID = request.getParameter("c_master");
1547 if (reportRuntime == null && AppUtils.nvl(reportID).length() > 0) {
1549 ReportHandler rh = new ReportHandler();
1550 reportRuntime = rh.loadReportRuntime(request, reportID);
1551 } catch (RaptorException ex) {
1552 logger.error(EELFLoggerDelegate.errorLogger,
1553 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
1557 if (reportRuntime != null) {
1558 String chartType = chartJSON.getChartType();
1559 reportRuntime.setChartType(chartJSON.getChartType());
1560 reportRuntime.setChartAnimate(chartJSON.isAnimation());
1561 reportRuntime.setChartWidth(chartJSON.getWidth());
1562 reportRuntime.setChartHeight(chartJSON.getHeight());
1563 reportRuntime.setShowChartTitle(chartJSON.isShowTitle());
1565 String domainAxis = null;
1566 domainAxis = chartJSON.getDomainAxis();
1568 List<DataColumnType> reportCols = reportRuntime.getAllColumns();
1570 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1571 DataColumnType dct = (DataColumnType) iter.next();
1572 if (dct.getColId().equals(domainAxis)) {
1573 dct.setColOnChart(AppConstants.GC_LEGEND);
1575 dct.setColOnChart(null);
1579 CategoryAxisJSON categoryAxisJSON = chartJSON.getCategoryAxisJSON();
1580 String categoryAxis = null;
1582 categoryAxis = (categoryAxisJSON != null ? categoryAxisJSON.getValue() : "");
1584 reportCols = reportRuntime.getAllColumns();
1586 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1587 DataColumnType dct = (DataColumnType) iter.next();
1588 if (dct.getColId().equals(categoryAxis)) {
1589 dct.setChartSeries(true);
1591 dct.setChartSeries(false);
1595 ArrayList<RangeAxisJSON> rangeAxisList = chartJSON.getRangeAxisList();
1597 HashSet<String> removeRangeAxisMap = new HashSet<>();
1598 for(RangeAxisJSON rangeAxis:chartJSON.getRangeAxisRemoveList()){
1599 removeRangeAxisMap.add(rangeAxis.getRangeAxis());
1601 for (int i = 0; i < rangeAxisList.size(); i++) {
1602 RangeAxisJSON rangeAxisJSON = rangeAxisList.get(i);
1603 String rangeAxis = rangeAxisJSON.getRangeAxis();
1604 String rangeYAxis = AppUtils.nvl(rangeAxisJSON.getRangeYAxis());
1605 String rangeChartGroup = AppUtils.nvl(rangeAxisJSON.getRangeChartGroup());
1606 String rangeColor = AppUtils.nvl(rangeAxisJSON.getRangeColor());
1607 String rangeLineType = AppUtils.nvl(rangeAxisJSON.getRangeLineType());
1609 rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
1610 DataColumnType dct = (DataColumnType) iterator.next();
1611 if (dct.getColId().equals(rangeAxis)) {
1612 if(removeRangeAxisMap.contains(rangeAxis))
1613 dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included
1615 dct.setChartSeq(++r);
1616 dct.setColOnChart("0");
1617 dct.setYAxis(rangeYAxis); // +"|"+dct.getColId());
1618 dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId());
1619 dct.setChartColor(rangeColor);
1620 dct.setChartLineType(rangeLineType);
1622 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1623 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1624 if (rangeAxisJSON.isShowAsArea()) {
1625 dct.setIsRangeAxisFilled(true);
1627 dct.setIsRangeAxisFilled(false);
1636 reportRuntime.setChartLeftAxisLabel(chartJSON.getPrimaryAxisLabel());
1637 reportRuntime.setChartRightAxisLabel(chartJSON.getSecondaryAxisLabel());
1639 reportRuntime.setRangeAxisLowerLimit(chartJSON.getMinRange());
1640 reportRuntime.setRangeAxisUpperLimit(chartJSON.getMaxRange());
1642 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1643 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1644 if (chartJSON.getFlexTimeSeriesChartOptions() != null) {
1645 reportRuntime.setZoomIn(chartJSON.getFlexTimeSeriesChartOptions().getZoomIn());
1646 reportRuntime.setTimeAxisType(chartJSON.getFlexTimeSeriesChartOptions().getTimeAxisType());
1651 if (chartType.equals(AppConstants.GT_TIME_SERIES)) {
1652 if (chartJSON.getTimeSeriesChartOptions() != null) {
1653 reportRuntime.setTimeSeriesRender(chartJSON.getTimeSeriesChartOptions().getLineChartRenderer());
1654 reportRuntime.setShowXAxisLabel(chartJSON.getTimeSeriesChartOptions().isShowXAxisLabel());
1655 reportRuntime.setAddXAxisTickers(chartJSON.getTimeSeriesChartOptions().isAddXAxisTicker());
1656 reportRuntime.setTimeAxis(chartJSON.getTimeSeriesChartOptions().isNonTimeAxis());
1657 reportRuntime.setMultiSeries(chartJSON.getTimeSeriesChartOptions().isMultiSeries());
1662 if (chartType.equals(AppConstants.GT_BAR_3D)) {
1663 if (chartJSON.getBarChartOptions() != null) {
1664 reportRuntime.setChartOrientation(
1665 chartJSON.getBarChartOptions().isVerticalOrientation() ? "vertical" : "horizontal");
1666 reportRuntime.setChartStacked(chartJSON.getBarChartOptions().isStackedChart());
1667 reportRuntime.setBarControls(chartJSON.getBarChartOptions().isDisplayBarControls());
1668 reportRuntime.setXAxisDateType(chartJSON.getBarChartOptions().isxAxisDateType());
1669 reportRuntime.setLessXaxisTickers(chartJSON.getBarChartOptions().isMinimizeXAxisTickers());
1670 reportRuntime.setTimeAxis(chartJSON.getBarChartOptions().isTimeAxis());
1671 reportRuntime.setLogScale(chartJSON.getBarChartOptions().isyAxisLogScale());
1675 reportRuntime.setLegendLabelAngle(chartJSON.getCommonChartOptions().getLegendLabelAngle());
1676 reportRuntime.setLegendPosition(chartJSON.getCommonChartOptions().getLegendPosition());
1677 reportRuntime.setChartLegendDisplay(chartJSON.getCommonChartOptions().isHideLegend() ? "Y" : "N");
1678 reportRuntime.setAnimateAnimatedChart(chartJSON.getCommonChartOptions().isAnimateAnimatedChart());
1680 reportRuntime.setTopMargin(chartJSON.getCommonChartOptions().getTopMargin());
1681 reportRuntime.setBottomMargin(chartJSON.getCommonChartOptions().getBottomMargin());
1682 reportRuntime.setLeftMargin(chartJSON.getCommonChartOptions().getLeftMargin());
1683 reportRuntime.setRightMargin(chartJSON.getCommonChartOptions().getRightMargin());
1685 for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
1686 DataColumnType dct = (DataColumnType) iterator.next();
1687 if (!(AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)
1688 || (dct.getChartSeq() != null && dct.getChartSeq() > 0) || dct.isChartSeries())) {
1689 dct.setChartSeq(-1);
1690 dct.setChartColor(null);
1691 dct.setColOnChart(null);
1692 dct.setCreateInNewChart(false);
1693 dct.setChartGroup(null);
1699 reportRuntime.persistLinearReport(request);
1700 } catch (Exception ex) {
1701 logger.error(EELFLoggerDelegate.errorLogger,
1702 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
1708 public String getViewName() {
1712 public void setViewName(String viewName) {
1713 this.viewName = viewName;
1716 public String nvl(String s) {
1717 return (s == null) ? "" : s;
1720 public String nvl(String s, String sDefault) {
1721 return nvl(s).equals("") ? sDefault : s;
1724 public static String getStackTrace(Throwable aThrowable) {
1725 Writer result = new StringWriter();
1726 PrintWriter printWriter = new PrintWriter(result);
1727 aThrowable.printStackTrace(printWriter);
1728 return result.toString();
1731 public void persistReportDefinition(HttpServletRequest request, ReportDefinition rdef) throws RaptorException {
1732 ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1733 if (rr != null && rr.getReportID().equals(rdef.getReportID()))
1734 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1735 rdef.persistReport(request);
1736 } // persistReportDefinition
1738 // Remove from session
1739 private void removeVariablesFromSession(HttpServletRequest request) {
1740 HttpSession session = request.getSession();
1741 session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
1742 session.removeAttribute(AppConstants.DRILLDOWN_INDEX);
1743 session.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
1744 session.removeAttribute(AppConstants.SI_BACKUP_FOR_REP_ID);
1745 session.removeAttribute(AppConstants.SI_COLUMN_LOOKUP);
1746 session.removeAttribute(AppConstants.SI_DASHBOARD_REP_ID);
1747 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
1748 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME);
1749 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
1750 session.removeAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP);
1751 session.removeAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP);
1752 session.removeAttribute(AppConstants.SI_DATA_SIZE_FOR_TEXTFIELD_POPUP);
1753 session.removeAttribute(AppConstants.SI_MAP);
1754 session.removeAttribute(AppConstants.SI_MAP_OBJECT);
1755 session.removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1756 session.removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1757 session.removeAttribute(AppConstants.SI_REPORT_RUN_BACKUP);
1758 session.removeAttribute(AppConstants.SI_REPORT_SCHEDULE);
1759 session.removeAttribute(AppConstants.RI_REPORT_DATA);
1760 session.removeAttribute(AppConstants.RI_CHART_DATA);
1761 session.removeAttribute(AppConstants.SI_FORMFIELD_INFO);
1762 session.removeAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
1763 session.removeAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP);
1764 session.removeAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP);
1765 Enumeration<String> enum1 = session.getAttributeNames();
1766 String attributeName = "";
1767 while (enum1.hasMoreElements()) {
1768 attributeName = enum1.nextElement();
1769 if (attributeName.startsWith("parent_")) {
1770 session.removeAttribute(attributeName);