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============================================
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.ReportLoader;
70 import org.onap.portalsdk.analytics.model.base.IdNameList;
71 import org.onap.portalsdk.analytics.model.base.IdNameValue;
72 import org.onap.portalsdk.analytics.model.base.ReportUserRole;
73 import org.onap.portalsdk.analytics.model.definition.DrillDownParamDef;
74 import org.onap.portalsdk.analytics.model.definition.ReportDefinition;
75 import org.onap.portalsdk.analytics.model.definition.ReportLogEntry;
76 import org.onap.portalsdk.analytics.model.definition.SecurityEntry;
77 import org.onap.portalsdk.analytics.model.definition.wizard.ColumnEditJSON;
78 import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON;
79 import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON;
80 import org.onap.portalsdk.analytics.model.definition.wizard.FormEditJSON;
81 import org.onap.portalsdk.analytics.model.definition.wizard.FormFieldGroupsJSON;
82 import org.onap.portalsdk.analytics.model.definition.wizard.IdNameBooleanJSON;
83 import org.onap.portalsdk.analytics.model.definition.wizard.ImportJSON;
84 import org.onap.portalsdk.analytics.model.definition.wizard.MessageJSON;
85 import org.onap.portalsdk.analytics.model.definition.wizard.NameBooleanJSON;
86 import org.onap.portalsdk.analytics.model.definition.wizard.QueryJSON;
87 import org.onap.portalsdk.analytics.model.definition.wizard.QueryResultJSON;
88 import org.onap.portalsdk.analytics.model.definition.wizard.RaptorResponse;
89 import org.onap.portalsdk.analytics.model.definition.wizard.SearchFieldJSON;
90 import org.onap.portalsdk.analytics.model.pdf.PdfReportHandler;
91 import org.onap.portalsdk.analytics.model.runtime.CategoryAxisJSON;
92 import org.onap.portalsdk.analytics.model.runtime.ChartJSON;
93 import org.onap.portalsdk.analytics.model.runtime.ErrorJSONRuntime;
94 import org.onap.portalsdk.analytics.model.runtime.FormField;
95 import org.onap.portalsdk.analytics.model.runtime.RangeAxisJSON;
96 import org.onap.portalsdk.analytics.model.runtime.ReportFormFields;
97 import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
98 import org.onap.portalsdk.analytics.system.AppUtils;
99 import org.onap.portalsdk.analytics.system.ConnectionUtils;
100 import org.onap.portalsdk.analytics.system.DbUtils;
101 import org.onap.portalsdk.analytics.system.Globals;
102 import org.onap.portalsdk.analytics.util.AppConstants;
103 import org.onap.portalsdk.analytics.util.DataSet;
104 import org.onap.portalsdk.analytics.util.Utils;
105 import org.onap.portalsdk.analytics.util.XSSFilter;
106 import org.onap.portalsdk.analytics.view.ReportData;
107 import org.onap.portalsdk.analytics.xmlobj.DataColumnType;
108 import org.onap.portalsdk.analytics.xmlobj.FormFieldType;
109 import org.onap.portalsdk.analytics.xmlobj.ObjectFactory;
110 import org.onap.portalsdk.analytics.xmlobj.PredefinedValueList;
111 import org.onap.portalsdk.analytics.xmlobj.SemaphoreList;
112 import org.onap.portalsdk.core.controller.RestrictedBaseController;
113 import org.onap.portalsdk.core.domain.User;
114 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
115 import org.onap.portalsdk.core.util.SecurityCodecUtil;
116 import org.onap.portalsdk.core.web.support.UserUtils;
117 import org.owasp.esapi.ESAPI;
118 import org.springframework.stereotype.Controller;
119 import org.springframework.web.bind.annotation.CrossOrigin;
120 import org.springframework.web.bind.annotation.PathVariable;
121 import org.springframework.web.bind.annotation.RequestBody;
122 import org.springframework.web.bind.annotation.RequestMapping;
123 import org.springframework.web.bind.annotation.RequestMethod;
124 import org.springframework.web.bind.annotation.ResponseBody;
126 import com.fasterxml.jackson.databind.DeserializationFeature;
127 import com.fasterxml.jackson.databind.ObjectMapper;
128 import com.fasterxml.jackson.databind.SerializationFeature;
132 public class RaptorControllerAsync extends RestrictedBaseController {
134 private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorControllerAsync.class);
135 private static final String INVALID_ACTION = "[Controller.processRequest]Invalid raptor action [";
136 private static final String UNABLE_INSTANTIATE = "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: ";
138 private String viewName;
140 @RequestMapping(value = { "/raptor.htm" }, method = RequestMethod.GET)
141 public void RaptorSearch(HttpServletRequest request, HttpServletResponse response)
142 throws IOException, RaptorException {
145 String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
146 actionKey = nvl(actionKey, "report.run");
148 HttpSession session = request.getSession();
149 User user = UserUtils.getUserSession(request);
150 boolean isPageDownload = Boolean.valueOf(request.getParameter(AppConstants.PAGE_DOWNLOAD));
151 if ("report.download.excel2007.session".equals(actionKey) || "report.download.csv.session".equals(actionKey)
152 || "report.download.excel.session".equals(actionKey)
153 || "report.download.pdf.session".equals(actionKey)) {
154 if (session != null && user != null) {
155 ServletContext servletContext = request.getSession().getServletContext();
156 if (!Globals.isSystemInitialized()) {
157 Globals.initializeSystem(servletContext);
159 ReportRuntime rr = null;
160 ReportData rd = null;
163 if (!"N".equals(nvl(request.getParameter("parent"), "")))
164 parent = nvl(request.getParameter("parent"), "");
165 if (parent.startsWith("parent_"))
167 if (parentFlag == 1) {
168 rr = (ReportRuntime) request.getSession().getAttribute(parent + "_rr");
169 rd = (ReportData) request.getSession().getAttribute(parent + "_rd");
172 boolean isEmbedded = false;
173 Object temp = request.getSession().getAttribute("isEmbedded");
175 isEmbedded = (boolean) temp;
178 String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID);
180 rr = (ReportRuntime) ((HashMap) request.getSession()
181 .getAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP)).get(reportID);
183 rd = (ReportData) ((HashMap) request.getSession()
184 .getAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP)).get(reportID);
187 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
189 rd = (ReportData) request.getSession().getAttribute(AppConstants.RI_REPORT_DATA);
191 String userId = AppUtils.getUserID(request);
192 int downloadLimit = 0;
194 downloadLimit = (rr.getMaxRowsInExcelDownload() > 0) ? rr.getMaxRowsInExcelDownload()
195 : Globals.getDownloadLimit();
196 if ("report.csv.download".equals(actionKey))
197 downloadLimit = Globals.getCSVDownloadLimit();
199 final boolean isDashboard = (session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID) != null) &&
200 (((String) session.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).equals(rr.getReportID()));
204 String sql_whole = rr.getReportDataSQL(userId, downloadLimit, request);
205 request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole);
208 OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream());
210 //rr.setSinglePageDownload(isPageDownload);
211 if ("report.download.pdf.session".equals(actionKey)) {
212 new PdfReportHandler().createPdfFileContent(request, response, 3);
213 } else if ("report.download.csv.session".equals(actionKey)) {
214 (new ReportHandler()).createCSVFileContent(out, rd, rr, request, response);
215 } else if ("report.download.excel.session".equals(actionKey)) {
216 new ReportHandler().createExcelFileContent(out, rd, rr, request, response, userId, 3);
218 new ReportHandler().createExcel2007FileContent(out, rd, rr, request, response, userId, 3);
220 } catch (Exception e) {
221 logger.error(EELFLoggerDelegate.errorLogger,
222 INVALID_ACTION + actionKey + "].", e);
225 response.sendRedirect("login.htm");
228 if (session != null && user != null) {
229 Action action = null;
230 ServletContext servletContext = request.getSession().getServletContext();
231 if (!Globals.isSystemInitialized()) {
232 Globals.initializeSystem(servletContext);
235 action = Globals.getRaptorActionMapping().getAction(actionKey);
237 throw new RaptorRuntimeException("Action not found");
238 } catch (RaptorException e) {
239 logger.error(EELFLoggerDelegate.errorLogger,
240 INVALID_ACTION + actionKey + "].", e);
242 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
243 new RaptorRuntimeException(INVALID_ACTION + actionKey
244 + "]. Exception: " + e.getMessage()));
248 Class[] paramTypes = new Class[2];
249 paramTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
250 paramTypes[1] = Class.forName("java.lang.String");
252 Class handlerClass = Class.forName(action.getControllerClass());
253 Object handler = handlerClass.newInstance();
254 Method handlerMethod = handlerClass.getMethod(action.getControllerMethod(), paramTypes);
256 Object[] paramValues = new Object[2];
257 paramValues[0] = request;
258 paramValues[1] = action.getJspName();
261 viewName = (String) handlerMethod.invoke(handler, paramValues);
262 if (!"chart.run".equals(actionKey))
263 response.setContentType("application/json");
265 response.setContentType("text/html");
267 } catch (ClassNotFoundException e) {
268 logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
269 + actionKey + "]. ClassNotFoundException: " + e.getMessage()));
270 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
271 new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
272 } catch (IllegalAccessException e) {
273 logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
274 + actionKey + "]. IllegalAccessException: " + e.getMessage()));
275 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
276 new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
277 } catch (InstantiationException e) {
278 logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
279 + actionKey + "]. InstantiationException: " + e.getMessage()));
280 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
281 new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
282 } catch (NoSuchMethodException e) {
283 logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
284 + actionKey + "]. NoSuchMethodException: " + e.getMessage()));
285 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
286 new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
287 } catch (InvocationTargetException e) {
288 logger.debug(EELFLoggerDelegate.debugLogger, (INVALID_ACTION
289 + actionKey + "]. InvocationTargetException: " + e.getMessage()));
290 viewName = (new ErrorHandler()).processFatalErrorJSON(request,
291 new RaptorRuntimeException(UNABLE_INSTANTIATE + e.getMessage()));
293 PrintWriter out = response.getWriter();
297 PrintWriter out = response.getWriter();
298 out.write("session has timed out for user");
304 @RequestMapping(value = "/report/wizard/drill_down_param/{parameter}", method = RequestMethod.GET, produces = "application/json")
305 public @ResponseBody List<DrillDownParamDef> getDrillDownParamDef (@PathVariable("parameter") String parameter, HttpServletRequest request, HttpServletResponse response)
307 List<DrillDownParamDef> list = new ArrayList<>();
308 String[] tmepArray = null;
310 tmepArray = parameter.split("&");
312 for(String str:tmepArray){
313 list.add(new DrillDownParamDef(str));
318 @RequestMapping(value = "/report/wizard/list_columns", method = RequestMethod.GET, produces = "application/json")
319 public @ResponseBody ArrayList<ColumnJSON> listColumns(HttpServletRequest request, HttpServletResponse response)
321 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
322 List<DataColumnType> reportColumnList = rdef.getAllColumns();
323 ArrayList<ColumnJSON> listJSON = new ArrayList<>();
324 ColumnJSON columnJSON;
326 for (DataColumnType reportColumnType : reportColumnList) {
327 columnJSON = new ColumnJSON();
328 columnJSON.setId(reportColumnType.getColId());
329 columnJSON.setName(reportColumnType.getDisplayName());
330 listJSON.add(columnJSON);
335 @RequestMapping(value = "/report/wizard/list_drilldown_reports", method = RequestMethod.GET, produces = "application/json")
336 public @ResponseBody ArrayList<ColumnJSON> list_drilldown_reports(HttpServletRequest request,
337 HttpServletResponse response) throws RaptorException {
338 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
339 Vector<IdNameValue> publicReportIdNames = DataCache.getPublicReportIdNames();
340 Vector groupReportIdNames = DataCache.getGroupAccessibleReportIdNames(AppUtils.getUserID(request),
341 AppUtils.getUserRoles(request));
342 Vector privateReportIdNames = DataCache.getPrivateAccessibleReportIdNames(AppUtils.getUserID(request),
343 AppUtils.getUserRoles(request));
345 ArrayList<ColumnJSON> listJSON = new ArrayList<>();
346 ColumnJSON columnJSON;
348 ServletContext servletContext = request.getSession().getServletContext();
349 if (!Globals.isSystemInitialized()) {
350 Globals.initializeSystem(servletContext);
353 for (int i = 0; i < publicReportIdNames.size(); i++) {
354 IdNameValue reportIdName = publicReportIdNames.get(i);
355 columnJSON = new ColumnJSON();
356 columnJSON.setId(reportIdName.getId());
357 columnJSON.setName("Public Report: " + reportIdName.getName());
358 if (!rdef.getReportID().equals(reportIdName.getId()))
359 listJSON.add(columnJSON);
362 for (int i = 0; i < groupReportIdNames.size(); i++) {
363 IdNameValue reportIdName = (IdNameValue) groupReportIdNames.get(i);
364 columnJSON = new ColumnJSON();
365 columnJSON.setId(reportIdName.getId());
366 columnJSON.setName("Group Report: " + reportIdName.getName());
367 if (!rdef.getReportID().equals(reportIdName.getId()))
368 listJSON.add(columnJSON);
371 for (int i = 0; i < privateReportIdNames.size(); i++) {
372 IdNameValue reportIdName = (IdNameValue) privateReportIdNames.get(i);
373 columnJSON = new ColumnJSON();
374 columnJSON.setId(reportIdName.getId());
375 columnJSON.setName("Private Report: " + reportIdName.getName());
376 if (!rdef.getReportID().equals(reportIdName.getId()))
377 listJSON.add(columnJSON);
383 @RequestMapping(value = "/report/wizard/list_formfields", method = RequestMethod.GET, produces = "application/json")
384 public @ResponseBody ArrayList<SearchFieldJSON> listFormFields(HttpServletRequest request,
385 HttpServletResponse response) {
386 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
387 ArrayList<SearchFieldJSON> listJSON = new ArrayList<>();
388 SearchFieldJSON fieldJSON;
389 if (rdef.getFormFieldList() != null) {
390 for (Iterator iter = rdef.getFormFieldList().getFormField().iterator(); iter.hasNext();) {
391 fieldJSON = new SearchFieldJSON();
392 FormFieldType fft = (FormFieldType) iter.next();
393 String fieldId = fft.getFieldId();
394 String fieldDisplay = fft.getFieldName();
395 fieldJSON.setId(fieldId);
396 fieldJSON.setName(fieldDisplay);
397 fieldJSON.setOrderSeq(fft.getOrderBySeq());
398 listJSON.add(fieldJSON);
405 @RequestMapping(value = "/report/wizard/list_child_report_col/{reportID}", method = RequestMethod.GET, produces = "application/json")
406 public @ResponseBody ArrayList<ColumnJSON> listChildReportCols(@PathVariable("reportID") String reportID,
407 HttpServletRequest request, HttpServletResponse response) throws RaptorException {
408 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
410 List<DataColumnType> reportColumnList = ddRr.getAllColumns();
411 ArrayList<ColumnJSON> listJSON = new ArrayList<>();
412 ColumnJSON columnJSON;
414 for (DataColumnType reportColumnType : reportColumnList) {
415 columnJSON = new ColumnJSON();
416 columnJSON.setId(reportColumnType.getColId());
417 columnJSON.setName(reportColumnType.getColName());
418 listJSON.add(columnJSON);
423 @RequestMapping(value = "/report/wizard/list_child_report_ff/{reportID}", method = RequestMethod.GET, produces = "application/json")
424 public @ResponseBody ArrayList<SearchFieldJSON> listChildReportFormFields(@PathVariable("reportID") String reportID,
425 HttpServletRequest request, HttpServletResponse response) throws RaptorException {
426 ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, reportID, false);
427 ArrayList<SearchFieldJSON> listJSON = new ArrayList<>();
428 SearchFieldJSON fieldJSON;
430 ReportFormFields ddReportFormFields = ddRr.getReportFormFields();
431 if (ddReportFormFields != null) {
432 for (ddReportFormFields.resetNext(); ddReportFormFields.hasNext();) {
433 FormField ff = ddReportFormFields.getNext();
434 if (!ff.getFieldType().equals(FormField.FFT_BLANK)) {
435 fieldJSON = new SearchFieldJSON();
436 fieldJSON.setId(ff.getFieldName());
437 fieldJSON.setName(ff.getFieldDisplayName());
438 listJSON.add(fieldJSON);
445 @RequestMapping(value = "report/wizard/copy_report/{reportID}", method = RequestMethod.GET, produces = "application/json")
446 public @ResponseBody MessageJSON copyReport(@PathVariable("reportID") String reportID, HttpServletRequest request,
447 HttpServletResponse response){
448 MessageJSON messageJSON = new MessageJSON();
451 ReportHandler rh = new ReportHandler();
452 ReportDefinition rdef = rh.loadReportDefinition(request, reportID);
453 rdef.setAsCopy(request);
454 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
455 request.getSession().setAttribute("COPY_REPORT_EVENT", "true");
456 messageJSON.setMessage("Success- Report Copied.");
457 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
459 } catch (RaptorException e) {
460 request.setAttribute("error_extra_msg", "While copying report " + reportID);
461 messageJSON.setMessage("Failed - While copying report " + reportID);
462 messageJSON.setAnyStacktrace(getStackTrace(e));
463 logger.debug(EELFLoggerDelegate.debugLogger,
464 ("[Controller.processRequest]Invalid raptor action [copyReport]. RaptorException: "
472 @RequestMapping(value = "report/wizard/import_report", method = RequestMethod.POST, consumes = "application/json")
473 public @ResponseBody MessageJSON importReport(@RequestBody ImportJSON importJSON, HttpServletRequest request,
474 HttpServletResponse response) {
475 MessageJSON messageJSON = new MessageJSON();
477 String reportXML = importJSON.getReportXML();
479 ReportHandler rh = new ReportHandler();
480 ReportDefinition rdef = rh.createReportDefinition(request, "-1", reportXML);
481 rdef.updateReportDefType();
482 rdef.generateWizardSequence(request);
483 rdef.setReportName("Import: " + rdef.getReportName());
484 rdef.clearAllDrillDowns();
486 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
488 messageJSON.setMessage("Success- Report imported.");
489 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
491 } catch (RaptorException e) {
492 request.setAttribute("error_extra_msg", "Unable to parse XML. Nested error: ");
493 messageJSON.setMessage("Unable to parse XML. Nested error: ");
494 messageJSON.setAnyStacktrace(getStackTrace(e));
503 @RequestMapping(value = "report/wizard/get_formfield_groups_data/{id}", method = RequestMethod.GET)
504 public @ResponseBody FormFieldGroupsJSON getFFGroupsData(@PathVariable Map<String, String> pathVariables,
505 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
507 FormFieldGroupsJSON formFieldGroupsJSON = new FormFieldGroupsJSON();
508 if (pathVariables.containsKey("id")) {
509 formFieldGroupsJSON.setReportId(pathVariables.get("id"));
510 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
511 ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
513 if (rdef != null && !rdef.getReportID().equals(formFieldGroupsJSON.getReportId())) {
514 removeVariablesFromSession(request);
515 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
516 } else if (rr != null && !rr.getReportID().equals(formFieldGroupsJSON.getReportId())) {
517 removeVariablesFromSession(request);
518 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
519 } else if (rdef == null) {
520 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
523 formFieldGroupsJSON.setFormFieldGroupsJSON(rdef.getCustomReport().getFormFieldGroupsJSON());
524 formFieldGroupsJSON.setMessage("Success");
526 formFieldGroupsJSON.setErrorMessage("Unable to load report definition for Report ID:"+formFieldGroupsJSON.getReportId());
529 formFieldGroupsJSON.setErrorMessage("Report ID missing in the URL");
531 return formFieldGroupsJSON;
534 @RequestMapping(value = "report/wizard/clearSession", method = RequestMethod.GET)
535 public @ResponseBody MessageJSON clearSession(HttpServletRequest request, HttpServletResponse response) {
536 MessageJSON messageJSON = new MessageJSON();
537 removeVariablesFromSession(request);
538 request.getSession().setAttribute("COPY_REPORT_EVENT", "");
539 messageJSON.setMessage("CopyReport Cancelled");
545 @RequestMapping(value = "report/wizard/save_formfield_groups_data", method = RequestMethod.POST)
546 public @ResponseBody MessageJSON saveFFGroupsData(@RequestBody FormFieldGroupsJSON formFieldGroupsJSON,
547 HttpServletRequest request, HttpServletResponse response) throws IOException, RaptorException {
549 MessageJSON messageJSON = new MessageJSON();
550 if(formFieldGroupsJSON != null && formFieldGroupsJSON.getReportId() != null) {
551 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
552 ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
553 if (rdef != null && !rdef.getReportID().equals(formFieldGroupsJSON.getReportId())) {
554 removeVariablesFromSession(request);
555 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
556 } else if (rr != null && !rr.getReportID().equals(formFieldGroupsJSON.getReportId())) {
557 removeVariablesFromSession(request);
558 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
559 } else if (rdef == null) {
560 rdef = (new ReportHandler()).loadReportDefinition(request, formFieldGroupsJSON.getReportId());
563 rdef.getCustomReport().setFormFieldGroupsJSON(formFieldGroupsJSON.getFormFieldGroupsJSON());
565 persistReportDefinition(request, rdef);
566 messageJSON.setMessage("Success: formfield groups have been updated for report ID:"+rdef.getReportID() +" and added to session and DB.");
567 } catch (Exception ex) {
568 messageJSON.setMessage("Error occured while saving formfield groups data");
569 messageJSON.setAnyStacktrace(getStackTrace(ex));
572 messageJSON.setMessage("Unable to load report definition for Report ID:"+formFieldGroupsJSON.getReportId());
575 messageJSON.setMessage("Report ID missing in the request body.");
580 @RequestMapping(value = "report/wizard/save_formfield_tab_data", method = RequestMethod.POST)
581 public @ResponseBody MessageJSON saveFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
582 HttpServletRequest request, HttpServletResponse response) {
583 ReportDefinition rdef = null;
584 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
586 MessageJSON messageJSON = new MessageJSON();
590 String fieldId = formEditJSON.getFieldId();
592 boolean lastUpdateIdFlag = false;
594 if (rdef.getFormFieldList() != null) {
597 // fft.getlastUpdatedFieldId()
599 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
601 System.out.println(fft.getFieldId() + " " + fft.getFieldName() + " " + fft.getlastUpdatedFieldId() + " " + formEditJSON.getLastUpdatedFieldId() );
602 if (fft.getFieldId().equals(fieldId) && !lastUpdateIdFlag) {
603 fft.setFieldId(formEditJSON.getLastUpdatedFieldId() != null ? formEditJSON.getLastUpdatedFieldId() : fft.getFieldId());
604 fft.setFieldName(formEditJSON.getFieldName());
605 fft.setFieldType(formEditJSON.getFieldType());
606 fft.setVisible(formEditJSON.isVisible() ? "Y" : "N");
607 fft.setDefaultValue(formEditJSON.getDefaultValue());
608 fft.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL());
609 fft.setFieldSQL(formEditJSON.getFieldSQL());
610 fft.setValidationType(formEditJSON.getValidationType());
611 fft.setGroupFormField(formEditJSON.isGroupFormField());
612 fft.setOrderBySeq(formEditJSON.getOrderSeq());
613 // clear predefined value
614 PredefinedValueList predefinedValueList = new ObjectFactory().createPredefinedValueList();
615 fft.setPredefinedValueList(predefinedValueList);
617 fft.setlastUpdatedFieldId("Y");
618 lastUpdateIdFlag = true;
620 List<IdNameBooleanJSON> predefList = formEditJSON.getPredefinedValueList();
621 if (predefList != null && predefList.size() > 0) {
622 for (IdNameBooleanJSON item : predefList) {
623 fft.getPredefinedValueList().getPredefinedValue().add(item.getId());
627 for (FormFieldType fft1 : rdef.getFormFieldList().getFormField()) {
629 if(fft1.getlastUpdatedFieldId().equals("Y"))
636 for (FormFieldType fft2 : rdef.getFormFieldList().getFormField()) {
637 fft2.setlastUpdatedFieldId("N");
644 System.out.println(fft.getFieldId() + " " + fft.getFieldName() + " " + fft.getlastUpdatedFieldId() + " " + formEditJSON.getLastUpdatedFieldId() );
648 persistReportDefinition(request, rdef);
649 messageJSON.setMessage("Success formfield Details of given report is saved in session.");
650 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
653 messageJSON.setMessage("Report Definition is not in session");
654 messageJSON.setAnyStacktrace("Report Definition is not in session");
657 } catch (Exception ex) {
658 messageJSON.setMessage("Error occured while formfield details Tab");
659 messageJSON.setAnyStacktrace(getStackTrace(ex));
666 @RequestMapping(value = "report/wizard/add_formfield_tab_data", method = RequestMethod.POST)
667 public @ResponseBody MessageJSON addFFTabWiseData(@RequestBody FormEditJSON formEditJSON,
668 HttpServletRequest request, HttpServletResponse response) {
669 ReportDefinition rdef;
670 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
672 MessageJSON messageJSON = new MessageJSON();
675 FormEditJSON wizardJSON = new FormEditJSON();
676 wizardJSON.setTabId("FormEdit");
677 wizardJSON.setTabName("Form Edit");
679 if(rdef.getFormFieldList()==null || rdef.getFormFieldList().getFormField()==null || rdef.getFormFieldList().getFormField().size()==0)
683 int maxFormFieldSeq = 0;
684 for(FormFieldType ffType : rdef.getFormFieldList().getFormField())
686 if(Integer.parseInt(ffType.getFieldId().substring(2)) > maxFormFieldSeq)
688 maxFormFieldSeq = Integer.parseInt(ffType.getFieldId().substring(2));
692 fieldId = "ff"+ maxFormFieldSeq;
694 FormFieldType currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "","");
695 currField.setFieldId(fieldId);
696 currField.setFieldName(formEditJSON.getFieldName());
697 currField.setFieldType(formEditJSON.getFieldType()==null?null:formEditJSON.getFieldType());
698 currField.setVisible(formEditJSON.isVisible()?"Y":"N");
699 currField.setDefaultValue(formEditJSON.getDefaultValue());
700 currField.setFieldDefaultSQL(formEditJSON.getFieldDefaultSQL());
701 currField.setFieldSQL(formEditJSON.getFieldSQL());
702 currField.setValidationType(formEditJSON.getValidationType());
703 currField.setGroupFormField(formEditJSON.isGroupFormField());
704 persistReportDefinition(request, rdef);
706 messageJSON.setMessage("Success formfield Details of given report is saved in session.");
707 messageJSON.setAnyStacktrace(rdef.getReportID() + " is added to session and DB.");
710 messageJSON.setMessage("Report Definition is not in session");
711 messageJSON.setAnyStacktrace("Report Definition is not in session");
714 } catch (Exception ex) {
715 messageJSON.setMessage("Error occured while formfield details Tab");
716 messageJSON.setAnyStacktrace(getStackTrace(ex));
723 @RequestMapping(value = "report/wizard/save_col_tab_data", method = RequestMethod.POST)
724 public @ResponseBody MessageJSON saveColTabWiseData(@RequestBody ColumnEditJSON columnEditJSON,
725 HttpServletRequest request, HttpServletResponse response) {
726 ReportDefinition rdef;
727 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
729 MessageJSON messageJSON = new MessageJSON();
733 String colId = columnEditJSON.getColId();
734 List<DataColumnType> reportColumnList = rdef.getAllColumns();
735 rdef.setSemaphoreList(columnEditJSON.getSemaphoreList());
738 for (DataColumnType reportColumnType : reportColumnList) {
740 if (reportColumnType.getColId().equals(colId)) {
741 reportColumnType.setColName(columnEditJSON.getColName());
742 reportColumnType.setDependsOnFormField(columnEditJSON.getDepeondsOnForField()==null?"":columnEditJSON.getDepeondsOnForField());
743 reportColumnType.setColType(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType());
744 reportColumnType.setDbColName(columnEditJSON.getDataType()==null?"":columnEditJSON.getDataType());
745 reportColumnType.setGroupByPos(columnEditJSON.getGroupByPos());
746 reportColumnType.setSubTotalCustomText(columnEditJSON.getSubTotalCustomText());
747 reportColumnType.setHideRepeatedKey(columnEditJSON.isHideRepeatedKey());
748 reportColumnType.setLevel(columnEditJSON.getLevel());
749 reportColumnType.setColspan(columnEditJSON.getColspan());
750 reportColumnType.setDisplayName(columnEditJSON.getDisplayName());
751 reportColumnType.setDisplayWidthInPxls(columnEditJSON.getDisplayWidthInPixel()==null?null:String.valueOf(columnEditJSON.getDisplayWidthInPixel()));
752 reportColumnType.setNowrap(columnEditJSON.getNoWrap());
753 reportColumnType.setIndentation(columnEditJSON.getIndentation());
754 reportColumnType.setDisplayAlignment(columnEditJSON.getDisplayAlignment());
755 reportColumnType.setDisplayHeaderAlignment(columnEditJSON.getDisplayHeaderAlignment());
756 reportColumnType.setIsSortable(columnEditJSON.isSortable());
757 reportColumnType.setVisible(columnEditJSON.isVisible());
758 reportColumnType.setDrillDownURL(columnEditJSON.getDrilldownURL());
759 reportColumnType.setDrillDownParams(columnEditJSON.getDrilldownParams());
760 reportColumnType.setDrillDownType(columnEditJSON.getDrilldownType());
761 if(columnEditJSON.getDisplayTotal()!=null)
762 reportColumnType.setDisplayTotal(columnEditJSON.getDisplayTotal());
763 reportColumnType.setSemaphoreId(columnEditJSON.getSemaphoreId());
769 persistReportDefinition(request, rdef);
770 messageJSON.setMessage("Success Column Details of given report is saved in session.");
771 messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB.");
774 messageJSON.setMessage("Report Definition is not in session");
775 messageJSON.setAnyStacktrace("");
778 } catch (Exception ex) {
779 messageJSON.setMessage("Error occured while saving column details Tab");
780 messageJSON.setAnyStacktrace(getStackTrace(ex));
788 @RequestMapping(value = "report/wizard/save_def_tab_data/{id}", method = RequestMethod.POST)
789 public @ResponseBody MessageJSON saveDefTabWiseData(@PathVariable("id") String id,
790 @RequestBody DefinitionJSON definitionJSON, HttpServletRequest request, HttpServletResponse response)
792 ReportDefinition rdef;
795 MessageJSON messageJSON = new MessageJSON();
797 String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT");
798 if (id.equals("InSession") || "true".equals(copyReportEvent)) {
799 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
802 } else if (id.equals("Create")) {
803 removeVariablesFromSession(request);
804 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
806 System.out.println("&&&&&&&&&&&&&&&&&&&&&& CHECK Report Type "
807 + (AppUtils.nvl(rdef.getReportType()).length() <= 0));
809 rdef.setReportType(definitionJSON.getReportType());
811 if (AppUtils.nvl(rdef.getReportType()).length() <= 0) {
812 rdef.setReportType(AppConstants.RT_LINEAR);
813 System.out.println("&&&&&&&&&&&&&&&&&&&&&& ADDED Report Type in session ");
816 } else if (AppUtils.nvl(id).length() > 0) {
817 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
818 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
820 if (rdef != null && !rdef.getReportID().equals(id)) {
821 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
822 removeVariablesFromSession(request);
823 rdef = (new ReportHandler()).loadReportDefinition(request, id);
824 } else if (rr != null && !rr.getReportID().equals(id)) {
825 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
826 removeVariablesFromSession(request);
827 rdef = (new ReportHandler()).loadReportDefinition(request, id);
828 } else if (rdef == null) {
829 rdef = (new ReportHandler()).loadReportDefinition(request, id);
834 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
840 String reportName = definitionJSON.getReportName();
841 String errorString = "";
842 if (AppUtils.nvl(reportName).length() <= 0)
843 errorString = "ReportName cannot be null;";
844 rdef.setReportName(reportName);
845 rdef.setReportDescr(definitionJSON.getReportDescr());
846 rdef.setReportType(definitionJSON.getReportType());
847 rdef.setDataContainerHeight(definitionJSON.getDataContainerHeight());
848 rdef.setDataContainerWidth(definitionJSON.getDataContainerWidth());
849 if(definitionJSON.getAllowScheduler()!=null)
850 rdef.setAllowSchedule(definitionJSON.getAllowScheduler().equals("Y")?"Y":"N");
853 if(rdef.getReportType().equals(AppConstants.RT_DASHBOARD)){
854 rdef.setDashboardLayoutHTML(definitionJSON.getDashboardLayoutHTML());
855 rdef.getCustomReport().setDashboardLayoutJSON(definitionJSON.getDashboardLayoutJSON());
856 rdef.getCustomReport().setDashBoardReports(definitionJSON.getDashboardReports());
858 String dbInfo = definitionJSON.getDbInfo();
859 rdef.setDBInfo(dbInfo);
861 String schemaSql = Globals.getRemoteDbSchemaSqlWithWhereClause();
862 schemaSql = schemaSql.replace("[schema_id]", dbInfo);
863 String dbType = null;
866 ds = DbUtils.executeQuery(schemaSql);
868 String prefix = "", desc = "";
870 for (int i = 0; i < ds.getRowCount(); i++) {
871 dbType = ds.getItem(i, 2);
874 catch (Exception e) {}
875 rdef.setDBType(dbType);
877 String formHelpText = definitionJSON.getFormHelpText();
878 rdef.setFormHelpText(formHelpText);
880 Integer pageSize = definitionJSON.getPageSize();
882 rdef.setPageSize(pageSize);
884 List<IdNameBooleanJSON> menuIds = definitionJSON.getDisplayArea();
886 for (IdNameBooleanJSON menuId : menuIds) {
887 if (menuId.isSelected()) {
888 rdef.setMenuID(menuId.getName());
895 Boolean hideFormFieldsAfterRun = definitionJSON.getHideFormFieldsAfterRun();
896 rdef.setHideFormFieldAfterRun(hideFormFieldsAfterRun==null?false:hideFormFieldsAfterRun);
897 Integer maxRowsInExcelCSVDownload = definitionJSON.getMaxRowsInExcelCSVDownload();
898 if(maxRowsInExcelCSVDownload!=null)
899 rdef.setMaxRowsInExcelDownload(maxRowsInExcelCSVDownload);
900 Integer frozenColumns = definitionJSON.getFrozenColumns();
901 if(frozenColumns!=null)
902 rdef.setFrozenColumns(frozenColumns);
903 String dataGridAlign = definitionJSON.getDataGridAlign();
904 rdef.setDataGridAlign(dataGridAlign);
905 String emptyMessage = definitionJSON.getEmptyMessage();
906 rdef.setEmptyMessage(emptyMessage);
907 Boolean runtimeColSortDisabled = definitionJSON.getRuntimeColSortDisabled();
908 rdef.setRuntimeColSortDisabled(runtimeColSortDisabled==null?false:runtimeColSortDisabled);
909 Integer numFormCols = definitionJSON.getNumFormCols();
910 if(numFormCols!=null)
911 rdef.setNumFormCols(Integer.toString(numFormCols));
912 String reportTitle = definitionJSON.getReportTitle();
913 rdef.setReportTitle(reportTitle);
914 String reportSubTitle = definitionJSON.getReportSubTitle();
915 rdef.setReportSubTitle(reportSubTitle);
917 List<NameBooleanJSON> displayOptions = definitionJSON.getDisplayOptions();
918 StringBuffer displayOptionStr = new StringBuffer("NNNNNNN");
919 if(displayOptions!=null){
920 for (NameBooleanJSON displayOption : displayOptions) {
921 if (displayOption.isSelected()) {
922 if (displayOption.getName().equals("HideFormFields")) {
923 displayOptionStr.setCharAt(0, 'Y');
924 } else if (displayOption.getName().equals("HideChart")) {
925 displayOptionStr.setCharAt(1, 'Y');
926 } else if (displayOption.getName().equals("HideReportData")) {
927 displayOptionStr.setCharAt(2, 'Y');
928 } else if (displayOption.getName().equals("HideExcel")) {
929 displayOptionStr.setCharAt(5, 'Y');
930 } else if (displayOption.getName().equals("HidePdf")) {
931 displayOptionStr.setCharAt(6, 'Y');
938 if(displayOptionStr!=null)
939 rdef.setDisplayOptions(displayOptionStr.toString());
941 if(definitionJSON.getSizedByContent()!=null)
942 rdef.setSizedByContent(definitionJSON.getSizedByContent().equals("Y")?"Y":"N");
943 if(definitionJSON.getOneTimeRec()!=null)
944 rdef.setIsOneTimeScheduleAllowed(definitionJSON.getOneTimeRec().equals("true")?"Y":"N");
945 if(definitionJSON.getHourlyRec()!=null)
946 rdef.setIsHourlyScheduleAllowed(definitionJSON.getHourlyRec().equals("true")?"Y":"N");
947 if(definitionJSON.getDailyRec()!=null)
948 rdef.setIsDailyScheduleAllowed(definitionJSON.getDailyRec().equals("true")?"Y":"N");
949 if(definitionJSON.getDailyMFRec()!=null)
950 rdef.setIsDailyMFScheduleAllowed(definitionJSON.getDailyMFRec().equals("true")?"Y":"N");
951 if(definitionJSON.getWeeklyRec()!=null)
952 rdef.setIsWeeklyScheduleAllowed(definitionJSON.getWeeklyRec().equals("true")?"Y":"N");
953 if(definitionJSON.getMonthlyRec()!=null)
954 rdef.setIsMonthlyScheduleAllowed(definitionJSON.getMonthlyRec().equals("true")?"Y":"N");
957 if (id.equals("Create")) {
958 rdef.persistReport(request);
960 persistReportDefinition(request, rdef);
961 messageJSON.setMessage("Success Definition of given report is saved in session.");
962 messageJSON.setAnyStacktrace((newReport ? " New Report info is added to Session "
963 : rdef.getReportID() + "- is Modified and added to session and DB."));
965 if(rdef.getReportType() != null) {
966 if(rdef.getReportType().equals("Dashboard") && id.equals("Create")) {
967 messageJSON.setAnyStacktrace(rdef.getReportID() + "- is Modified and added to session and DB.");
970 if(request.getSession().getAttribute("COPY_REPORT_EVENT") == "true" || (rdef.getReportType().equals("Dashboard") && id.equals("Create")) ) {
971 removeVariablesFromSession(request);
972 request.getSession().setAttribute("COPY_REPORT_EVENT", "");
975 } catch (Exception ex) {
976 messageJSON.setMessage("Error occured while saving definition Tab");
977 messageJSON.setAnyStacktrace(getStackTrace(ex));
978 logger.error(EELFLoggerDelegate.errorLogger,
979 "[Controller.processRequest]Invalid raptor action [retrieveTabWiseData].", ex);
986 @RequestMapping(value = { "/report/wizard/retrieve_form_tab_wise_data/{id}",
987 "/report/wizard/retrieve_form_tab_wise_data/{id}/{action}" }, method = RequestMethod.GET)
988 public @ResponseBody FormEditJSON retrieveFormTabWiseData(@PathVariable Map<String, String> pathVariables,
989 HttpServletRequest request, HttpServletResponse response) {
990 ReportDefinition rdef;
993 String detailId = "";
994 FormEditJSON wizardJSON = new FormEditJSON();
995 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
997 if (pathVariables.containsKey("id")) {
998 id = pathVariables.get("id");
1000 if (pathVariables.containsKey("action")) {
1001 action = pathVariables.get("action");
1004 ServletContext servletContext = request.getSession().getServletContext();
1005 if (!Globals.isSystemInitialized()) {
1006 Globals.initializeSystem(servletContext);
1008 wizardJSON.setTabId("FormEdit");
1009 wizardJSON.setTabName("Form Edit");
1010 FormFieldType currField = null;
1012 if (id.equals("add")) {
1014 currField = rdef.addFormFieldType(new ObjectFactory(), "", "", "", "", "", "", "", "", null, null, "",
1016 wizardJSON.setFieldId(currField.getFieldId());
1017 wizardJSON.setFieldName(currField.getFieldName());
1018 wizardJSON.setFieldType(currField.getFieldType());
1019 wizardJSON.setVisible(AppUtils.nvls(currField.getVisible(), "Y").toUpperCase().startsWith("Y"));
1020 wizardJSON.setDefaultValue(currField.getDefaultValue());
1021 wizardJSON.setFieldDefaultSQL(currField.getFieldDefaultSQL());
1022 wizardJSON.setFieldSQL(currField.getFieldSQL());
1023 wizardJSON.setValidationType(currField.getValidationType());
1024 persistReportDefinition(request, rdef);
1026 } else if (action.equals("delete")) {
1027 rdef.deleteFormField(id);
1028 persistReportDefinition(request, rdef);
1029 wizardJSON.setMessage("Formfield " + detailId + " Deleted");
1031 if (rdef.getFormFieldList() != null) {
1032 for (FormFieldType fft : rdef.getFormFieldList().getFormField()) {
1033 if (fft.getFieldId().equals(id)) {
1034 wizardJSON.setFieldId(fft.getFieldId());
1035 wizardJSON.setFieldName(fft.getFieldName());
1036 wizardJSON.setFieldType(fft.getFieldType());
1037 wizardJSON.setVisible(fft.getVisible().toUpperCase().startsWith("Y"));
1038 wizardJSON.setDefaultValue(fft.getDefaultValue());
1039 wizardJSON.setFieldDefaultSQL(fft.getFieldDefaultSQL());
1040 wizardJSON.setFieldSQL(fft.getFieldSQL());
1041 wizardJSON.setValidationType(fft.getValidationType());
1042 wizardJSON.setGroupFormField(fft.isGroupFormField());
1043 wizardJSON.setOrderSeq(fft.getOrderBySeq());
1044 PredefinedValueList preDefined = fft.getPredefinedValueList();
1046 if (preDefined != null) {
1047 List<IdNameBooleanJSON> preDefinedList = new ArrayList<>();
1048 IdNameBooleanJSON idNameBooleanJSON;
1050 for (String v : preDefined.getPredefinedValue()) {
1051 idNameBooleanJSON = new IdNameBooleanJSON();
1052 idNameBooleanJSON.setId(v);
1053 idNameBooleanJSON.setName(v);
1054 preDefinedList.add(idNameBooleanJSON);
1056 wizardJSON.setPredefinedValueList(preDefinedList);
1061 } catch (Exception ex) {
1062 logger.error(EELFLoggerDelegate.errorLogger,
1063 "[Controller.processRequest]Invalid raptor action [retrieveFormTabWiseData].", ex);
1064 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1065 errorJSONRuntime.setErrormessage("Error occured while retreiving formedit definition Tab");
1066 errorJSONRuntime.setStacktrace(getStackTrace(ex));
1067 wizardJSON.setErrorMessage("Error occured while retreiving formedit definition Tab");
1068 wizardJSON.setErrorStackTrace(getStackTrace(ex));
1075 @RequestMapping(value = { "/report/wizard/retrieve_col_tab_wise_data/{id}" }, method = RequestMethod.GET)
1076 public @ResponseBody ColumnEditJSON retrieveColTabWiseData(@PathVariable Map<String, String> pathVariables,
1077 HttpServletRequest request, HttpServletResponse response) {
1078 ReportDefinition rdef;
1080 ColumnEditJSON wizardJSON = new ColumnEditJSON();
1081 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1083 if (pathVariables.containsKey("id")) {
1084 id = pathVariables.get("id");
1086 ServletContext servletContext = request.getSession().getServletContext();
1087 if (!Globals.isSystemInitialized()) {
1088 Globals.initializeSystem(servletContext);
1091 if(rdef.getSemaphoreList() != null) {
1092 wizardJSON.setSemaphoreList(rdef.getSemaphoreList());
1093 }else { wizardJSON.setSemaphoreList(new SemaphoreList()); }
1095 wizardJSON.setTabId("ColEdit");
1096 wizardJSON.setTabName("Column Edit");
1098 List<DataColumnType> reportColumnList = rdef.getAllColumns();
1100 for (DataColumnType reportColumnType : reportColumnList) {
1101 if (reportColumnType.getColId().equals(id)) {
1102 wizardJSON.setColId(reportColumnType.getColId());
1103 wizardJSON.setColName(reportColumnType.getColName());
1104 wizardJSON.setDisplayAlignment(reportColumnType.getDisplayAlignment());
1105 wizardJSON.setDisplayHeaderAlignment(reportColumnType.getDisplayHeaderAlignment());
1106 wizardJSON.setSortable(
1107 reportColumnType.isIsSortable() == null ? false : reportColumnType.isIsSortable());
1108 wizardJSON.setVisible(reportColumnType.isVisible());
1109 wizardJSON.setDrilldownURL(
1110 reportColumnType.getDrillDownURL() == null ? "" : reportColumnType.getDrillDownURL());
1111 wizardJSON.setDrilldownParams(
1112 reportColumnType.getDrillDownParams() == null ? "" : reportColumnType.getDrillDownParams());
1113 wizardJSON.setDrilldownType(
1114 reportColumnType.getDrillDownType() == null ? "" : reportColumnType.getDrillDownType());
1115 wizardJSON.setDataType(reportColumnType.getDbColType() == null ? "" :reportColumnType.getDbColType());
1116 wizardJSON.setGroupByPos(reportColumnType.getGroupByPos());
1117 wizardJSON.setLevel(reportColumnType.getLevel());
1118 wizardJSON.setDisplayWidth(reportColumnType.getDisplayWidth());
1119 wizardJSON.setNoWrap(reportColumnType.getNowrap() == null ? "" : reportColumnType.getNowrap());
1120 wizardJSON.setIndentation(reportColumnType.getIndentation());
1122 wizardJSON.setDepeondsOnForField(reportColumnType.getDependsOnFormField() ==null?"":reportColumnType.getDependsOnFormField());
1123 wizardJSON.setSubTotalCustomText(reportColumnType.getSubTotalCustomText()==null?"":reportColumnType.getSubTotalCustomText());
1125 wizardJSON.setHideRepeatedKey(reportColumnType.isHideRepeatedKey()==null?false:reportColumnType.isHideRepeatedKey());
1126 wizardJSON.setColspan(reportColumnType.getColspan()==null?null:reportColumnType.getColspan());
1127 wizardJSON.setDisplayName(reportColumnType.getDisplayName());
1128 wizardJSON.setDisplayTotal(reportColumnType.getDisplayTotal());
1129 wizardJSON.setSemaphoreId(reportColumnType.getSemaphoreId());
1134 wizardJSON.setErrorMessage("Report is not in session");
1140 @RequestMapping(value = { "/report/wizard/retrieve_sql_tab_wise_data/{id}",
1141 "/report/wizard/retrieve_sql_tab_wise_data/" }, method = RequestMethod.GET)
1142 public @ResponseBody QueryJSON retrieveSqlTabWiseData(@PathVariable Map<String, String> pathVariables,
1143 HttpServletRequest request, HttpServletResponse response) throws RaptorException {
1144 ReportDefinition rdef = null;
1147 QueryJSON wizardJSON = new QueryJSON();
1149 if (pathVariables.containsKey("id")) {
1150 id = pathVariables.get("id");
1152 ServletContext servletContext = request.getSession().getServletContext();
1153 if (!Globals.isSystemInitialized()) {
1154 Globals.initializeSystem(servletContext);
1156 if (id.equals("InSession") || AppUtils.nvl(id).length() <= 0) {
1157 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1158 } else if (AppUtils.nvl(id).length() > 0) {
1159 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1160 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1162 if (rdef != null && !rdef.getReportID().equals(id)) {
1163 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1164 removeVariablesFromSession(request);
1165 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1166 } else if (rr != null && !rr.getReportID().equals(id)) {
1167 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1168 removeVariablesFromSession(request);
1169 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1170 } else if (rdef == null) {
1171 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1177 wizardJSON.setTabId("Sql");
1178 wizardJSON.setTabName("Sql");
1179 wizardJSON.setQuery(rdef.getReportSQL());
1184 @RequestMapping(value = { "/report/wizard/retrieveTotalForTheColList" }, method = RequestMethod.GET)
1185 public @ResponseBody List<IdNameValue> getTotalForTheCol(HttpServletRequest request)
1187 IdNameList idNameList = AppConstants.TOTAL_FUNCTIONS;
1188 List<IdNameValue> list = new ArrayList<>();
1189 for(int i=0; i<idNameList.getCount(); i++)
1190 list.add(idNameList.getValue(i));
1195 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList" }, method = RequestMethod.GET)
1196 public @ResponseBody List<SecurityEntry> getReportUserList(HttpServletRequest request)
1197 throws RaptorException {
1198 List<SecurityEntry> reportUserList = new ArrayList<>();
1199 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1200 Vector reportUsers = rdef.getReportUsers(request);
1201 for(Iterator iter=reportUsers.iterator(); iter.hasNext();) {
1202 SecurityEntry rUser = (SecurityEntry) iter.next();
1203 reportUserList.add(rUser);
1205 return reportUserList;
1208 @RequestMapping(value = { "/report/wizard/security/retrieveReportRoleList" }, method = RequestMethod.GET)
1209 public @ResponseBody List<IdNameValue> getReportRoleList(HttpServletRequest request)
1210 throws RaptorException {
1211 List<IdNameValue> reportRoleList = new ArrayList<>();
1212 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1213 Vector reportRoles = rdef.getReportRoles(request);
1214 Vector remainingRoles = Utils.getRolesNotInList(reportRoles,request);
1215 for(int i=0; i<remainingRoles.size(); i++) {
1216 IdNameValue role = (IdNameValue) remainingRoles.get(i);
1217 reportRoleList.add(role);
1219 return reportRoleList;
1222 @RequestMapping(value = { "/report/wizard/security/retrieveReportUserList_query" }, method = RequestMethod.GET)
1223 public @ResponseBody List<Map<String, String>> getReportUserListQuery(HttpServletRequest request)
1225 List<Map<String, String>> reportUserList = new ArrayList();
1226 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1227 String reportId = rdef.getReportID();
1228 Map<String, Object> params = new HashMap<>();
1229 params.put("report_id", new Long(reportId));
1230 List<ReportUserRole> queriedUserList = getDataAccessService().executeNamedQuery("getReportSecurityUsers", params, null);
1231 for (int i=0; i<queriedUserList.size();i++){
1232 Map<String, String> reportUser = new HashMap<>();
1233 reportUser.put("rep_id", queriedUserList.get(i).toString());
1234 reportUser.put("order_no", queriedUserList.get(i).getOrderNo().toString());
1235 reportUser.put("user_id", queriedUserList.get(i).getUserId().toString());
1236 reportUser.put("role_id", queriedUserList.get(i).getRoleId().toString());
1237 reportUser.put("read_only_yn", queriedUserList.get(i).getReadOnlyYn());
1238 reportUserList.add(reportUser);
1240 return reportUserList;
1245 @RequestMapping(value = "/report/security/addReportUser", method = RequestMethod.POST)
1246 public @ResponseBody Map<String,String> addSelectedReportUser(
1247 @RequestBody String userIdToAdd, HttpServletRequest request, HttpServletResponse response)
1249 Map<String, String> JsonResponse = new HashMap<>();
1250 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1252 JsonResponse.put("status","success");
1253 JsonResponse.put("userId",userIdToAdd);
1254 String action = "Add User";
1255 rdef.getReportSecurity().addUserAccess(userIdToAdd, "Y");
1256 WizardSequence ws = rdef.getWizardSequence();
1257 ws.performAction(action,rdef);
1258 return JsonResponse;
1259 } catch (Exception ex) {
1260 logger.error(EELFLoggerDelegate.errorLogger,
1261 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1266 @RequestMapping(value = "/report/security/removeReportUser", method = RequestMethod.POST)
1267 public @ResponseBody Map<String,String> removeSelectedReportUser(
1268 @RequestBody String userIdToRemove, HttpServletRequest request, HttpServletResponse response)
1270 Map<String, String> JsonResponse = new HashMap<>();
1271 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1273 JsonResponse.put("status","success");
1274 JsonResponse.put("userId",userIdToRemove);
1275 String action = "Delete User";
1276 rdef.getReportSecurity().removeUserAccess(userIdToRemove);
1277 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1278 WizardSequence ws = rdef.getWizardSequence();
1279 ws.performAction(action,rdef);
1280 return JsonResponse;
1281 } catch (Exception ex) {
1282 logger.error(EELFLoggerDelegate.errorLogger,
1283 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1288 @RequestMapping(value = "/report/security/addReportRole", method = RequestMethod.POST)
1289 public @ResponseBody Map<String,String> addSelectedReportRole(
1290 @RequestBody String roleIdToAdd, HttpServletRequest request, HttpServletResponse response) {
1291 Map<String, String> JsonResponse = new HashMap<>();
1292 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1294 JsonResponse.put("status","success");
1295 JsonResponse.put("roleId",roleIdToAdd);
1296 String action = "Add Role";
1297 rdef.getReportSecurity().addRoleAccess(roleIdToAdd, "Y");
1298 WizardSequence ws = rdef.getWizardSequence();
1299 ws.performAction(action,rdef);
1300 return JsonResponse;
1301 } catch (Exception ex) {
1302 logger.error(EELFLoggerDelegate.errorLogger,
1303 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1308 @RequestMapping(value = "/report/security/removeReportRole", method = RequestMethod.POST)
1309 public @ResponseBody Map<String,String> removeSelectedReportRole(
1310 @RequestBody String roleIdToRemove, HttpServletRequest request, HttpServletResponse response)
1312 Map<String, String> JsonResponse = new HashMap<>();
1313 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1315 JsonResponse.put("status","success");
1316 JsonResponse.put("roleId",roleIdToRemove);
1317 String action = "Delete Role";
1318 rdef.getReportSecurity().removeRoleAccess(roleIdToRemove);
1319 WizardSequence ws = rdef.getWizardSequence();
1320 ws.performAction(action,rdef);
1321 return JsonResponse;
1322 } catch (Exception ex) {
1323 logger.error(EELFLoggerDelegate.errorLogger,
1324 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1329 @RequestMapping(value = "/report/security/updateReportSecurityInfo", method = RequestMethod.POST)
1330 public @ResponseBody Map<String,String> updateReportSecurityInfo(
1331 @RequestBody Map<String,String> securityInfo, HttpServletRequest request, HttpServletResponse response)
1334 Map<String, String> JsonResponse = new HashMap<>();
1335 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1337 JsonResponse.put("status","success");
1338 String OwnerUserId = securityInfo.get("userId");
1339 String isPublic = securityInfo.get("isPublic");
1340 boolean rPublic = isPublic.equals("true");
1341 rdef.getReportSecurity().setOwnerID(OwnerUserId);
1342 rdef.setPublic(rPublic);
1343 persistReportDefinition(request, rdef);
1344 return JsonResponse;
1346 } catch (Exception ex) {
1347 logger.error(EELFLoggerDelegate.errorLogger,
1348 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1353 @RequestMapping(value = "/report/security/toggleUserEditAccess/{userID}", method = RequestMethod.POST)
1354 public @ResponseBody Map<String,String> toggleUserEditAccess(
1355 @PathVariable("userID") String userId,
1356 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1358 Map<String, String> JsonResponse = new HashMap<>();
1359 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1362 JsonResponse.put("status","success");
1363 if (readOnly.equals("N")) {
1364 action = "Grant User Access";
1366 action = "Revoke User Access";
1368 rdef.getReportSecurity().updateUserAccess(userId, readOnly);
1369 WizardSequence ws = rdef.getWizardSequence();
1370 ws.performAction(action,rdef);
1372 return JsonResponse;
1373 } catch (Exception ex) {
1374 logger.error(EELFLoggerDelegate.errorLogger,
1375 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1380 @RequestMapping(value = "/report/security/toggleRoleEditAccess/{roleID}", method = RequestMethod.POST)
1381 public @ResponseBody Map<String,String> toggleRoleEditAccess(
1382 @PathVariable("roleID") String roleId,
1383 @RequestBody String readOnly, HttpServletRequest request, HttpServletResponse response)
1385 Map<String, String> JsonResponse = new HashMap<>();
1386 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1389 JsonResponse.put("status","success");
1390 if (readOnly.equals("N")) {
1391 action = "Grant Role Access";
1393 action = "Revoke Role Access";
1395 rdef.getReportSecurity().updateRoleAccess(roleId, readOnly);
1396 WizardSequence ws = rdef.getWizardSequence();
1397 ws.performAction(action,rdef);
1399 return JsonResponse;
1400 } catch (Exception ex) {
1401 logger.error(EELFLoggerDelegate.errorLogger,
1402 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1407 @RequestMapping(value = { "/report/wizard/security/retrieveReportOwner" }, method = RequestMethod.GET)
1408 public @ResponseBody List<IdNameValue> getReportOwnerInList(HttpServletRequest request)
1409 throws RaptorException {
1410 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1412 List<IdNameValue> UserList = new ArrayList<>();
1413 List excludeValues = new java.util.ArrayList();
1414 HttpSession session = request.getSession();
1415 String query = Globals.getCustomizedScheduleQueryForUsers();
1416 session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request));
1417 String userId = AppUtils.getUserID(request);
1418 session.setAttribute("LOGGED_USERID", userId);
1419 String[] sessionParameters = Globals.getSessionParams().split(",");
1421 for (int i = 0; i < sessionParameters.length; i++) {
1422 param = (String) session.getAttribute(sessionParameters[0]);
1423 query = Utils.replaceInString(query, "[" + sessionParameters[i].toUpperCase() + "]",
1424 (String) session.getAttribute(sessionParameters[i]));
1426 boolean isAdmin = AppUtils.isAdminUser(request);
1427 Vector allUsers = AppUtils.getAllUsers(query, param, isAdmin);
1429 for (Iterator iter = allUsers.iterator(); iter.hasNext();) {
1430 IdNameValue value = (IdNameValue) iter.next();
1432 boolean exclude = false;
1433 for (Iterator iterE = excludeValues.iterator(); iterE.hasNext();)
1434 if (((IdNameValue) iterE.next()).getId().equals(value.getId())) {
1440 UserList.add(value);
1446 @RequestMapping(value = { "/report/wizard/security/getReportSecurityInfo" }, method = RequestMethod.GET)
1447 public @ResponseBody Map<String,String> getReportSecurityInfo(HttpServletRequest request)
1449 Map<String, String> securityInfoMap = new HashMap<>();
1450 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1451 String isPublic = Boolean.toString(rdef.isPublic());
1452 String createUser = AppUtils.getUserName(rdef.getCreateID());
1453 String createDate = rdef.getCreateDate();
1454 String updateUser = AppUtils.getUserName(rdef.getUpdateID());
1455 String updateDate = rdef.getUpdateDate();
1456 String ownerId = rdef.getOwnerID();
1458 securityInfoMap.put("isPublic",isPublic);
1459 securityInfoMap.put("createdUser",createUser);
1460 securityInfoMap.put("createdDate",createDate);
1461 securityInfoMap.put("updateUser",updateUser);
1462 securityInfoMap.put("updatedDate",updateDate);
1463 securityInfoMap.put("ownerId",ownerId);
1465 return securityInfoMap;
1468 @RequestMapping(value = { "/report/wizard/security/getReportSecurityUsers" }, method = RequestMethod.GET)
1469 public @ResponseBody List<SecurityEntry> getReportSecurityUsers(HttpServletRequest request)
1470 throws RaptorException {
1472 List<SecurityEntry> reportUserMapList = new ArrayList<>();
1473 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1474 Vector reportUsers = rdef.getReportUsers(request);
1477 for(Iterator iter=reportUsers.iterator(); iter.hasNext(); iCount++) {
1478 Map<String, String> reportUserMap = new HashMap<>();
1479 SecurityEntry rUser = (SecurityEntry) iter.next();
1480 reportUserMapList.add(rUser);
1483 return reportUserMapList;
1487 @RequestMapping(value = { "/report/wizard/security/getReportSecurityRoles" }, method = RequestMethod.GET)
1488 public @ResponseBody List<SecurityEntry> getReportSecurityRoles(HttpServletRequest request)
1489 throws RaptorException {
1491 List<SecurityEntry> reportRoleList = new ArrayList<>();
1492 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1493 Vector reportRoles = rdef.getReportRoles(request);
1495 for(Iterator iter=reportRoles.iterator(); iter.hasNext(); ) {
1496 SecurityEntry rRole = (SecurityEntry) iter.next();
1497 reportRoleList.add(rRole);
1500 return reportRoleList;
1504 @RequestMapping(value = { "/report/wizard/retrieve_def_tab_wise_data/{id}",
1505 "/report/wizard/retrieve_def_tab_wise_data/{id}/{detailId}" }, method = RequestMethod.GET)
1506 public @ResponseBody DefinitionJSON retrieveDefTabWiseData(@PathVariable Map<String, String> pathVariables,
1507 HttpServletRequest request, HttpServletResponse response) throws RaptorException {
1508 ReportDefinition rdef;
1510 String tabId = "Def";
1513 if (pathVariables.containsKey("id")) {
1514 id = pathVariables.get("id");
1517 ServletContext servletContext = request.getSession().getServletContext();
1518 if (!Globals.isSystemInitialized()) {
1519 Globals.initializeSystem(servletContext);
1521 String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT");
1522 if (tabId.equals("Def") && id.equals("InSession") || "true".equals(copyReportEvent)) {
1523 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1525 } else if (tabId.equals("Def") && id.equals("Create")) {
1526 removeVariablesFromSession(request);
1527 rdef = (new ReportHandler()).loadReportDefinition(request, "-1");
1528 rdef.setReportType(AppConstants.RT_LINEAR);
1530 } else if (tabId.equals("Def") && AppUtils.nvl(id).length() > 0) {
1531 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1532 rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
1534 if (rdef != null && !rdef.getReportID().equals(id)) {
1535 request.getSession().removeAttribute(AppConstants.SI_REPORT_DEFINITION);
1536 removeVariablesFromSession(request);
1537 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1538 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1539 } else if (rr != null && !rr.getReportID().equals(id)) {
1540 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
1541 removeVariablesFromSession(request);
1542 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1543 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1544 } else if (rdef == null) {
1545 rdef = (new ReportHandler()).loadReportDefinition(request, id);
1546 request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef);
1550 rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1552 DefinitionJSON wizardJSON = new DefinitionJSON();
1553 if (tabId.equals("Def")) {
1554 wizardJSON.setTabId("Def");
1555 wizardJSON.setTabName("Definition");
1557 wizardJSON.setReportId((rdef != null) ? rdef.getReportID() + "" : "");
1558 wizardJSON.setReportName((rdef != null) ? rdef.getReportName() : "");
1559 wizardJSON.setReportDescr((rdef != null) ? rdef.getReportDescr() : "");
1560 wizardJSON.setReportType((rdef != null) ? rdef.getReportType() : AppConstants.RT_LINEAR);
1561 wizardJSON.setDataContainerHeight((rdef != null) ? rdef.getDataContainerHeight() : "600");
1562 wizardJSON.setDataContainerWidth((rdef != null) ? rdef.getDataContainerWidth() : "900");
1563 wizardJSON.setAllowScheduler((rdef != null) ? rdef.getAllowSchedule() : "false");
1565 if(wizardJSON.getReportType().equals(AppConstants.RT_LINEAR)) {
1566 wizardJSON.setDbInfo((rdef != null) ? rdef.getDBInfo() : "");
1567 wizardJSON.setFormHelpText((rdef != null) ? rdef.getFormHelpText() : "");
1568 wizardJSON.setPageSize((rdef != null) ? rdef.getPageSize() : 50);
1569 List<IdNameBooleanJSON> displayArea = new ArrayList<>();
1570 IdNameBooleanJSON idNameJSON = new IdNameBooleanJSON();
1572 for (int i = 0; i < AppUtils.getQuickLinksMenuIDs().size(); i++) {
1573 idNameJSON = new IdNameBooleanJSON();
1574 qMenu = (String) AppUtils.getQuickLinksMenuIDs().get(i);
1575 idNameJSON.setId(qMenu);
1576 idNameJSON.setName(qMenu);
1577 if (rdef != null && (rdef.getMenuID().equals(qMenu))) {
1578 idNameJSON.setSelected(true);
1580 displayArea.add(idNameJSON);
1582 wizardJSON.setDisplayArea(displayArea);
1583 wizardJSON.setHideFormFieldsAfterRun((rdef != null) ? rdef.isHideFormFieldAfterRun() : false);
1584 wizardJSON.setMaxRowsInExcelCSVDownload((rdef != null) ? rdef.getMaxRowsInExcelDownload() : 500);
1585 wizardJSON.setFrozenColumns((rdef != null) ? rdef.getFrozenColumns() : 0);
1586 wizardJSON.setDataGridAlign((rdef != null) ? rdef.getDataGridAlign() : "left");
1587 wizardJSON.setEmptyMessage((rdef != null) ? rdef.getEmptyMessage() : "No records found");
1588 List<NameBooleanJSON> displayOptions = new ArrayList<>();
1589 NameBooleanJSON nameBooleanJSON = new NameBooleanJSON();
1590 nameBooleanJSON.setName("HideFormFields");
1591 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideForm() : false);
1592 displayOptions.add(nameBooleanJSON);
1594 nameBooleanJSON = new NameBooleanJSON();
1595 nameBooleanJSON.setName("HideChart");
1596 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideChart() : false);
1597 displayOptions.add(nameBooleanJSON);
1599 nameBooleanJSON = new NameBooleanJSON();
1600 nameBooleanJSON.setName("HideReportData");
1601 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideData() : false);
1602 displayOptions.add(nameBooleanJSON);
1604 nameBooleanJSON = new NameBooleanJSON();
1605 nameBooleanJSON.setName("HideExcel");
1606 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHideExcelIcons() : false);
1607 displayOptions.add(nameBooleanJSON);
1609 nameBooleanJSON = new NameBooleanJSON();
1610 nameBooleanJSON.setName("HidePdf");
1611 nameBooleanJSON.setSelected((rdef != null) ? rdef.isDisplayOptionHidePDFIcons() : false);
1612 displayOptions.add(nameBooleanJSON);
1614 wizardJSON.setDisplayOptions(displayOptions);
1616 wizardJSON.setRuntimeColSortDisabled((rdef != null) ? rdef.isRuntimeColSortDisabled() : false);
1617 wizardJSON.setNumFormCols((rdef != null) ? rdef.getNumFormColsAsInt() : 1);
1618 wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : "");
1619 wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : "");
1622 String schemaSql = Globals.getRemoteDbSchemaSql();
1624 ArrayList<IdNameBooleanJSON> dbInfoList = new ArrayList<>();
1626 ds = DbUtils.executeQuery(schemaSql);
1628 String prefix = "", desc = "";
1630 for (int i = 0; i < ds.getRowCount(); i++) {
1631 IdNameBooleanJSON dBNameJSON = new IdNameBooleanJSON();
1632 dBNameJSON.setId(ds.getItem(i, 0));
1633 dBNameJSON.setName(ds.getItem(i, 0));
1634 dBNameJSON.setSelected(false);
1635 dbInfoList.add(dBNameJSON);
1638 catch (Exception e) {}
1639 wizardJSON.setDbInfoList(dbInfoList);
1642 wizardJSON.setOneTimeRec((rdef != null) ? rdef.getIsOneTimeScheduleAllowed() : "false");
1643 wizardJSON.setHourlyRec((rdef != null) ? rdef.getIsHourlyScheduleAllowed() : "false");
1644 wizardJSON.setDailyRec((rdef != null) ? rdef.getIsDailyScheduleAllowed() : "false");
1645 wizardJSON.setDailyMFRec((rdef != null) ? rdef.getIsDailyMFScheduleAllowed() : "false");
1646 wizardJSON.setWeeklyRec((rdef != null) ? rdef.getIsWeeklyScheduleAllowed() : "false");
1647 wizardJSON.setMonthlyRec((rdef != null) ? rdef.getIsMonthlyScheduleAllowed() : "false");
1648 wizardJSON.setSizedByContent((rdef != null) ? rdef.getSizedByContentOption() : "false");
1649 wizardJSON.setRepDefType(rdef.getReportDefType());
1650 } else if(wizardJSON.getReportType().equals(AppConstants.RT_DASHBOARD)){
1651 wizardJSON.setDashboardLayoutHTML((rdef != null) ? rdef.getCustomReport().getDashboardLayoutHTML() : null);
1652 wizardJSON.setDashboardLayoutJSON((rdef != null) ? rdef.getCustomReport().getDashboardLayoutJSON() : null);
1653 wizardJSON.setDashboardReports((rdef != null) ? rdef.getCustomReport().getDashBoardReports() : null);
1657 ObjectMapper mapper = new ObjectMapper();
1658 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1659 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1665 @RequestMapping(value = "/report/wizard/retrieve_data/{validate}", method = RequestMethod.POST)
1666 public @ResponseBody RaptorResponse retrieveDataForGivenQuery(@PathVariable("validate") boolean validate,
1667 @RequestBody QueryJSON queryJSON, HttpServletRequest request, HttpServletResponse response)
1668 throws RaptorException {
1669 RaptorResponse raptorResponse = new RaptorResponse();
1670 String sql = queryJSON.getQuery();
1671 String jsonInString = "";
1673 ServletContext servletContext = request.getSession().getServletContext();
1674 if (!Globals.isSystemInitialized()) {
1675 Globals.initializeSystem(servletContext);
1678 ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION);
1680 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1681 errorJSONRuntime.setErrormessage("Report Definition is not in session;");
1682 errorJSONRuntime.setStacktrace("");
1684 ObjectMapper mapper = new ObjectMapper();
1685 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1686 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1689 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1690 raptorResponse.data().put("elements", jsonInString);
1691 return raptorResponse;
1692 } catch (Exception ex1) {
1693 logger.error(EELFLoggerDelegate.errorLogger,
1694 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1697 if (!sql.trim().toUpperCase().startsWith("SELECT")) {
1698 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1699 errorJSONRuntime.setErrormessage("Invalid statement - the SQL must start with the keyword SELECT");
1700 errorJSONRuntime.setStacktrace("SQL Error");
1701 ObjectMapper mapper = new ObjectMapper();
1702 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1703 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1706 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1707 raptorResponse.data().put("elements", jsonInString);
1708 return raptorResponse;
1710 } catch (Exception ex) {
1711 logger.error(EELFLoggerDelegate.errorLogger,
1712 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex);
1716 String remoteDb = request.getParameter("remoteDbPrefix");
1717 // comment below two lines to test
1718 String remoteDbPrefix = (remoteDb != null && !remoteDb.equalsIgnoreCase("null")) ? remoteDb
1720 String userId = AppUtils.getUserID(request);
1722 sql = Utils.replaceInString(sql, "[LOGGED_USERID]", userId);
1723 sql = Utils.replaceInString(sql, "[USERID]", userId);
1724 String[] reqParameters = Globals.getRequestParams().split(",");
1725 String[] sessionParameters = Globals.getSessionParams().split(",");
1726 javax.servlet.http.HttpSession session = request.getSession();
1727 logger.debug(EELFLoggerDelegate.debugLogger, ("B4 testRunSQL " + sql));
1728 if (request != null) {
1729 for (int i = 0; i < reqParameters.length; i++) {
1730 if (!reqParameters[i].startsWith("ff"))
1731 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1732 ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),request.getParameter(reqParameters[i].toUpperCase())));
1734 sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase() + "]",
1735 ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),request.getParameter(reqParameters[i])));
1738 if (session != null) {
1739 for (int i = 0; i < sessionParameters.length; i++) {
1740 logger.debug(EELFLoggerDelegate.debugLogger, (" Session " + " sessionParameters[i] "
1741 + sessionParameters[i] + " " + (String) session.getAttribute(sessionParameters[i])));
1742 sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase() + "]",
1743 (String) session.getAttribute(sessionParameters[i]));
1746 logger.debug(EELFLoggerDelegate.debugLogger, ("After testRunSQL " + sql));
1749 response.setContentType("application/json");
1750 ds = ConnectionUtils.getDataSet(sql, rdef.getDBInfo(), true);
1752 QueryResultJSON queryResultJSON = new QueryResultJSON();
1753 queryResultJSON.setQuery(queryJSON.getQuery());
1754 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1756 rdef.parseReportSQL(query,validate);
1758 queryResultJSON.setQuery(query);
1760 queryResultJSON.setTotalRows(ds.getRowCount());
1762 Map<String, String> dvJSON;
1763 ArrayList<String> colList = new ArrayList<>();
1764 ArrayList<Map<String, String>> reportDataRows = new ArrayList<>();
1765 if (!ds.isEmpty()) {
1767 for (int i = 0; i < ds.getColumnCount(); i++) {
1768 colList.add(ds.getColumnName(i));
1770 queryResultJSON.setReportDataColumns(colList);
1771 if (queryResultJSON.getTotalRows() > 0) {
1772 for (int r = 0; r < Math.min(ds.getRowCount(), 100); r++) {
1773 dvJSON = new HashMap<>();
1774 for (int c = 0; c < ds.getColumnCount(); c++) {
1776 dvJSON.put(ds.getColumnName(c), ds.getString(r, c));
1777 } catch (Exception ex) {
1778 logger.error(EELFLoggerDelegate.errorLogger,
1779 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].",
1783 reportDataRows.add(dvJSON);
1789 queryResultJSON.setReportDataRows(reportDataRows);
1790 ObjectMapper mapper = new ObjectMapper();
1791 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1792 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1794 query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1795 request.setAttribute("sqlValidated", "N");
1796 rdef.parseReportSQL(query);
1797 request.setAttribute("sqlValidated", "Y");
1798 persistReportDefinition(request, rdef);
1802 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(queryResultJSON);
1803 raptorResponse.data().put("elements", jsonInString);
1804 return raptorResponse;
1806 } catch (Exception ex) {
1807 logger.error(EELFLoggerDelegate.errorLogger,
1808 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery]. RaptorException: ",
1811 } catch (ReportSQLException ex) {
1812 ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
1813 if (sql.contains("[")) {
1814 errorJSONRuntime.setErrormessage(
1815 "Formfield information is present in the query, hence couldn't execute");
1817 .setStacktrace("Formfield information is present in the query, hence couldn't execute");
1819 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1820 request.setAttribute("sqlValidated", "N");
1821 rdef.parseReportSQL(query);
1822 request.setAttribute("sqlValidated", "Y");
1823 persistReportDefinition(request, rdef);
1828 errorJSONRuntime.setErrormessage(ex.getMessage());
1829 errorJSONRuntime.setStacktrace(getStackTrace(ex));
1831 ObjectMapper mapper = new ObjectMapper();
1832 mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
1833 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1836 jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
1837 raptorResponse.data().put("elements", jsonInString);
1838 return raptorResponse;
1840 } catch (Exception ex1) {
1841 logger.error(EELFLoggerDelegate.errorLogger,
1842 "[Controller.processRequest]Invalid raptor action [retrieveDataForGivenQuery].", ex1);
1846 String query = XSSFilter.filterRequestOnlyScript(queryJSON.getQuery());
1847 request.setAttribute("sqlValidated", "N");
1848 rdef.parseReportSQL(query);
1849 request.setAttribute("sqlValidated", "Y");
1850 persistReportDefinition(request, rdef);
1856 raptorResponse.data().put("elements", jsonInString);
1857 return raptorResponse;
1862 @RequestMapping(value = "/report/wizard/get_report_log/{reportID}", method = RequestMethod.GET)
1863 public @ResponseBody ArrayList<ReportLogEntry> getLogs(@PathVariable("reportID") String reportId, HttpServletRequest request,
1864 HttpServletResponse ReportLogEntry) {
1865 ArrayList<ReportLogEntry> arrayList = new ArrayList<>();
1867 Vector<ReportLogEntry> v = ReportLoader.loadReportLogEntries(reportId);
1868 for(ReportLogEntry r:v ){
1871 } catch (RaptorException e) {
1872 logger.error(EELFLoggerDelegate.errorLogger,
1873 "RaptorControllerAsync getLogs.", e);
1878 @RequestMapping(value = "save_chart", method = RequestMethod.POST)
1879 public void reportChartReceive(@RequestBody ChartJSON chartJSON, HttpServletRequest request,
1880 HttpServletResponse response) {
1881 //ReportRuntime reportRuntime;
1882 //reportRuntime = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); // changing
1883 ReportDefinition reportDefn;
1884 reportDefn = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); // session
1887 String reportID = request.getParameter("c_master");
1888 /* if (reportRuntime == null && AppUtils.nvl(reportID).length() > 0) {
1890 ReportHandler rh = new ReportHandler();
1891 reportRuntime = rh.loadReportRuntime(request, reportID);
1892 } catch (RaptorException ex) {
1893 logger.error(EELFLoggerDelegate.errorLogger,
1894 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
1898 if (reportDefn != null) {
1899 String chartType = chartJSON.getChartType();
1900 reportDefn.setChartType(chartJSON.getChartType());
1901 reportDefn.setChartAnimate(chartJSON.isAnimation());
1902 reportDefn.setChartWidth(chartJSON.getWidth());
1903 reportDefn.setChartHeight(chartJSON.getHeight());
1904 reportDefn.setShowChartTitle(chartJSON.isShowTitle());
1906 String domainAxis = null;
1907 domainAxis = chartJSON.getDomainAxis();
1909 List<DataColumnType> reportCols = reportDefn.getAllColumns();
1911 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1912 DataColumnType dct = iter.next();
1913 if (dct.getColId().equals(domainAxis)) {
1914 dct.setColOnChart(AppConstants.GC_LEGEND);
1916 dct.setColOnChart(null);
1920 CategoryAxisJSON categoryAxisJSON = chartJSON.getCategoryAxisJSON();
1921 String categoryAxis;
1923 categoryAxis = (categoryAxisJSON != null ? categoryAxisJSON.getValue() : "");
1925 reportCols = reportDefn.getAllColumns();
1927 for (Iterator<DataColumnType> iter = reportCols.iterator(); iter.hasNext();) {
1928 DataColumnType dct = iter.next();
1929 if (dct.getColId().equals(categoryAxis)) {
1930 dct.setChartSeries(true);
1932 dct.setChartSeries(false);
1936 ArrayList<RangeAxisJSON> rangeAxisList = chartJSON.getRangeAxisList();
1938 HashSet<String> removeRangeAxisMap = new HashSet<>();
1939 for(RangeAxisJSON rangeAxis:chartJSON.getRangeAxisRemoveList()){
1940 removeRangeAxisMap.add(rangeAxis.getRangeAxis());
1942 for (int i = 0; i < rangeAxisList.size(); i++) {
1943 RangeAxisJSON rangeAxisJSON = rangeAxisList.get(i);
1944 String rangeAxis = rangeAxisJSON.getRangeAxis();
1945 String rangeYAxis = AppUtils.nvl(rangeAxisJSON.getRangeYAxis());
1946 String rangeChartGroup = AppUtils.nvl(rangeAxisJSON.getRangeChartGroup());
1947 String rangeColor = AppUtils.nvl(rangeAxisJSON.getRangeColor());
1948 String rangeLineType = AppUtils.nvl(rangeAxisJSON.getRangeLineType());
1950 rangefor: for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
1951 DataColumnType dct = iterator.next();
1952 if (dct.getColId().equals(rangeAxis)) {
1953 if(removeRangeAxisMap.contains(rangeAxis))
1954 dct.setChartSeq(-1); // if we set it to -1, means this range axis will not be included
1956 dct.setChartSeq(++r);
1958 if (!dct.getColId().equals(domainAxis)) {
1959 dct.setColOnChart("0");
1961 dct.setChartSeq(-1);
1963 dct.setYAxis(rangeYAxis); // +"|"+dct.getColId());
1964 dct.setChartGroup(rangeChartGroup); // +"|"+dct.getColId());
1965 dct.setChartColor(rangeColor);
1966 dct.setChartLineType(rangeLineType);
1968 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1969 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1970 if (rangeAxisJSON.isShowAsArea()) {
1971 dct.setIsRangeAxisFilled(true);
1973 dct.setIsRangeAxisFilled(false);
1981 reportDefn.setChartLeftAxisLabel(chartJSON.getPrimaryAxisLabel());
1982 reportDefn.setChartRightAxisLabel(chartJSON.getSecondaryAxisLabel());
1984 reportDefn.setRangeAxisLowerLimit(chartJSON.getMinRange());
1985 reportDefn.setRangeAxisUpperLimit(chartJSON.getMaxRange());
1987 if (chartType.equals(AppConstants.GT_ANNOTATION_CHART)
1988 || chartType.equals(AppConstants.GT_FLEX_TIME_CHARTS)) {
1989 if (chartJSON.getFlexTimeSeriesChartOptions() != null) {
1990 reportDefn.setZoomIn(chartJSON.getFlexTimeSeriesChartOptions().getZoomIn());
1991 reportDefn.setTimeAxisType(chartJSON.getFlexTimeSeriesChartOptions().getTimeAxisType());
1996 if (chartType.equals(AppConstants.GT_TIME_SERIES)) {
1997 if (chartJSON.getTimeSeriesChartOptions() != null) {
1998 reportDefn.setTimeSeriesRender(chartJSON.getTimeSeriesChartOptions().getLineChartRenderer());
1999 reportDefn.setShowXAxisLabel(chartJSON.getTimeSeriesChartOptions().isShowXAxisLabel());
2000 reportDefn.setAddXAxisTickers(chartJSON.getTimeSeriesChartOptions().isAddXAxisTicker());
2001 reportDefn.setTimeAxis(chartJSON.getTimeSeriesChartOptions().isNonTimeAxis());
2002 reportDefn.setMultiSeries(chartJSON.getTimeSeriesChartOptions().isMultiSeries());
2007 if (chartType.equals(AppConstants.GT_BAR_3D)) {
2008 if (chartJSON.getBarChartOptions() != null) {
2009 reportDefn.setChartOrientation(
2010 chartJSON.getBarChartOptions().isVerticalOrientation() ? "vertical" : "horizontal");
2011 reportDefn.setChartStacked(chartJSON.getBarChartOptions().isStackedChart());
2012 reportDefn.setBarControls(chartJSON.getBarChartOptions().isDisplayBarControls());
2013 reportDefn.setXAxisDateType(chartJSON.getBarChartOptions().isxAxisDateType());
2014 reportDefn.setLessXaxisTickers(chartJSON.getBarChartOptions().isMinimizeXAxisTickers());
2015 reportDefn.setTimeAxis(chartJSON.getBarChartOptions().isTimeAxis());
2016 reportDefn.setLogScale(chartJSON.getBarChartOptions().isyAxisLogScale());
2020 reportDefn.setLegendLabelAngle(chartJSON.getCommonChartOptions().getLegendLabelAngle());
2021 reportDefn.setLegendPosition(chartJSON.getCommonChartOptions().getLegendPosition());
2022 reportDefn.setChartLegendDisplay(chartJSON.getCommonChartOptions().isHideLegend() ? "Y" : "N");
2023 reportDefn.setAnimateAnimatedChart(chartJSON.getCommonChartOptions().isAnimateAnimatedChart());
2025 reportDefn.setTopMargin(chartJSON.getCommonChartOptions().getTopMargin());
2026 reportDefn.setBottomMargin(chartJSON.getCommonChartOptions().getBottomMargin());
2027 reportDefn.setLeftMargin(chartJSON.getCommonChartOptions().getLeftMargin());
2028 reportDefn.setRightMargin(chartJSON.getCommonChartOptions().getRightMargin());
2030 for (Iterator<DataColumnType> iterator = reportCols.iterator(); iterator.hasNext();) {
2031 DataColumnType dct = iterator.next();
2032 if (!(AppUtils.nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND)
2033 || (dct.getChartSeq() != null && dct.getChartSeq() > 0) || dct.isChartSeries())) {
2034 dct.setChartSeq(-1);
2035 dct.setChartColor(null);
2036 dct.setColOnChart(null);
2037 dct.setCreateInNewChart(false);
2038 dct.setChartGroup(null);
2044 //reportRuntime.persistLinearReport(request);
2045 //reportRuntime.persistReport(request);
2046 persistReportDefinition(request, reportDefn);
2047 } catch (Exception ex) {
2048 logger.error(EELFLoggerDelegate.errorLogger,
2049 "[Controller.processRequest]Invalid raptor action [reportChartReceive].", ex);
2054 public String getViewName() {
2058 public void setViewName(String viewName) {
2059 this.viewName = viewName;
2062 public String nvl(String s) {
2063 return (s == null) ? "" : s;
2066 public String nvl(String s, String sDefault) {
2067 return nvl(s).equals("") ? sDefault : s;
2070 public static String getStackTrace(Throwable aThrowable) {
2071 Writer result = new StringWriter();
2072 PrintWriter printWriter = new PrintWriter(result);
2073 aThrowable.printStackTrace(printWriter);
2074 return result.toString();
2077 public void persistReportDefinition(HttpServletRequest request, ReportDefinition rdef) throws RaptorException {
2078 ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
2079 if (rr != null && rr.getReportID().equals(rdef.getReportID()))
2080 request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);
2081 rdef.persistReport(request);
2082 } // persistReportDefinition
2084 // Remove from session
2085 private void removeVariablesFromSession(HttpServletRequest request) {
2086 HttpSession session = request.getSession();
2087 session.removeAttribute(AppConstants.DRILLDOWN_REPORTS_LIST);
2088 session.removeAttribute(AppConstants.DRILLDOWN_INDEX);
2089 session.removeAttribute(AppConstants.FORM_DRILLDOWN_INDEX);
2090 session.removeAttribute(AppConstants.SI_BACKUP_FOR_REP_ID);
2091 session.removeAttribute(AppConstants.SI_COLUMN_LOOKUP);
2092 session.removeAttribute(AppConstants.SI_DASHBOARD_REP_ID);
2093 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP);
2094 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME);
2095 session.removeAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP);
2096 session.removeAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP);
2097 session.removeAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP);
2098 session.removeAttribute(AppConstants.SI_DATA_SIZE_FOR_TEXTFIELD_POPUP);
2099 session.removeAttribute(AppConstants.SI_MAP);
2100 session.removeAttribute(AppConstants.SI_MAP_OBJECT);
2101 session.removeAttribute(AppConstants.SI_REPORT_DEFINITION);
2102 session.removeAttribute(AppConstants.SI_REPORT_RUNTIME);
2103 session.removeAttribute(AppConstants.SI_REPORT_RUN_BACKUP);
2104 session.removeAttribute(AppConstants.SI_REPORT_SCHEDULE);
2105 session.removeAttribute(AppConstants.RI_REPORT_DATA);
2106 session.removeAttribute(AppConstants.RI_CHART_DATA);
2107 session.removeAttribute(AppConstants.SI_FORMFIELD_INFO);
2108 session.removeAttribute(AppConstants.SI_FORMFIELD_DOWNLOAD_INFO);
2109 session.removeAttribute(AppConstants.EMBEDDED_REPORTRUNTIME_MAP);
2110 session.removeAttribute(AppConstants.EMBEDDED_REPORTDATA_MAP);
2111 Enumeration<String> enum1 = session.getAttributeNames();
2112 String attributeName = "";
2113 while (enum1.hasMoreElements()) {
2114 attributeName = enum1.nextElement();
2115 if (attributeName.startsWith("parent_")) {
2116 session.removeAttribute(attributeName);