private ResultSet getQueryResult(
      Connection connection, PivotWidget widget, Map<String, Object> urlQueryParameters)
      throws ReportRunnerException {

    Entity entity = widget.getEntity();
    ro.nextreports.engine.Report report =
        NextUtil.getNextReport(storageService.getSettings(), entity);
    DataSource dataSource = getDataSource(entity);

    String sql = ro.nextreports.engine.util.ReportUtil.getSql(report);
    // retrieves the report parameters
    Map<String, QueryParameter> parameters = new LinkedHashMap<String, QueryParameter>();
    List<QueryParameter> parameterList = report.getParameters();
    if (parameterList != null) {
      for (QueryParameter param : parameterList) {
        parameters.put(param.getName(), param);
      }
    }

    Map<String, Object> parameterValues = new HashMap<String, Object>();

    // pivot is running with settings parameter values
    ChartUtil.initParameterSettings(
        parameterValues,
        widget.getQueryRuntime(),
        dashboardService.getUserWidgetParameters(widget.getId()));

    // parameters from embedded code
    try {
      ReportUtil.addUrlQueryParameters(
          storageService.getSettings(), entity, parameterValues, urlQueryParameters);
    } catch (Exception e1) {
      e1.printStackTrace();
      LOG.error(e1.getMessage(), e1);
    }

    QueryExecutor executor = null;
    try {
      boolean csv = CSVDialect.DRIVER_CLASS.equals(dataSource.getDriver());

      Query query = new Query(sql);
      executor = new QueryExecutor(query, parameters, parameterValues, connection, true, true, csv);
      executor.setMaxRows(0);
      executor.setTimeout(storageService.getSettings().getQueryTimeout());

      QueryResult queryResult = executor.execute();

      return queryResult.getResultSet();
    } catch (Exception e) {
      throw new ReportRunnerException(e);
    } finally {
      if (executor != null) {
        executor.closeCursors();
      }
    }
  }
  // User demo (on demo.next-reports.com instance) means :
  //   Change Password disabled (HeaderPanel.java)
  //   Distribution ok and test buttons are generated a message (AbstractDestinationPanel.java)
  //   Delete History not visible (RunHistoryPanel.java)
  public boolean isDemo() {
    if (!isSignedIn()) {
      return false;
    }

    Settings settings = storageService.getSettings();
    String baseUrl = settings.getBaseUrl();

    return getUser().getName().equals("demo") && "http://demo.next-reports.com".equals(baseUrl);
  }
  public NextServerSession(Request request) {
    super(request);
    Injector.get().inject(this);

    sectionContexts = new HashMap<String, SectionContext>();
    List<Section> sections = sectionManager.getSections();
    for (Section section : sections) {
      sectionContexts.put(section.getId(), SectionContextFactory.createSectionContext(section));
    }
    //		if (!sections.isEmpty()) {
    //			selectedSectionId = sections.get(0).getId();
    //		}
    String language = storageService.getSettings().getLanguage();
    Locale locale = LanguageManager.getInstance().getLocale(language);
    setLocale(locale);
    LOG.info("--------------------> Set locale to: " + language);
  }