Package com.centraview.report.valueobject

Examples of com.centraview.report.valueobject.ReportResultVO


    reportId = getTheId("reportId", request);
    // if we are coming from one of the form pages, we should have
    // a searchVO on the form, if so pass it on.
    SearchVO search = getSearchVOFromForm(actionForm, request);

    ReportResultVO reportResults = getReportResults(userId, reportId, search);
    String action = request.getParameter("action");
    if (action != null) {
      if (action.equals("export")) {
        nextURL = "csvadhocreportresult";
        request.setAttribute("reportResults", reportResults);
      } else if (action.equals("print")) {
        nextURL = "printadhocreportresult";
      }
    }

    moduleId = reportResults.getModuleId();
    ArrayList columnHeaders = reportResults.getTitles();
    ArrayList columns = new ArrayList();
    ValueListParameters parameters = new ValueListParameters(0, reportResults.getResults().size(), 1);
    for (int i = 0; i < columnHeaders.size(); i++) {
      columns.add(new FieldDescriptor((String)columnHeaders.get(i), i+1, false, ""));
    }
    parameters.setColumns(columns);
    // results is an arraylist of arraylists, it needs to be converted to an arraylist of ValueListRows
    ArrayList results = reportResults.getResults();
    ArrayList list = new ArrayList();
    for (int j = 0; j < results.size(); j++) {
      list.add(new ValueListRow(j, (ArrayList)results.get(j)));
    }
    ValueListVO valueList = new ValueListVO(list, parameters);
    ValueListDisplay displayParameters = new ValueListDisplay(new ArrayList(), false, false, false, false, false, false);
    valueList.setDisplay(displayParameters);
    request.setAttribute("valueList", valueList);
    request.setAttribute("reportName", reportResults.getName());
    request.setAttribute("moduleId", String.valueOf(moduleId));
    session.setAttribute("moduleId", String.valueOf(moduleId));
    request.setAttribute("reportId", String.valueOf(reportId));
    session.setAttribute("reportId", String.valueOf(reportId));
    request.setAttribute("reportType", String.valueOf(ReportConstants.ADHOC_REPORT_CODE));
View Full Code Here


   * @return ReportResultList
   */
  public ReportResultVO getReportResults(int userID, int reportId, SearchVO search) throws ServletException
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
    ReportResultVO reportResult = null;
    try {
      ReportFacade remote = SessionBeanFactory.getReportFacade();
      remote.setDataSource(dataSource);
      reportResult = remote.getAdHocReportResult(userID, reportId, search);
    } catch (Exception e) {
View Full Code Here

        }
        // Run the report and get the results.
        if (action.equals("export") || action.equals("print")){
          search = (SearchVO)session.getAttribute("searchVO");
        }
        ReportResultVO reportResultVO = remote.getStandardReportResult(userId, reportId, search);
        moduleId = reportResultVO.getModuleId();
        request.setAttribute("pagedata", reportResultVO);
      }
      request.setAttribute("reportId", String.valueOf(reportId));
      request.setAttribute("moduleId", String.valueOf(moduleId));
      session.setAttribute("moduleId", String.valueOf(moduleId));
View Full Code Here

   * @param reportId int
   * @return ReportResultVO
   */
  public ReportResultVO getAdHocReportResult(int userId, int reportId, SearchVO search)
  {
    ReportResultVO reportResult = getReportResult(userId, reportId, search);
    return reportResult;
  }
View Full Code Here

   * @param reportId int
   * @return ReportResultVO
   */
  protected ReportResultVO getReportResult(int userId, int reportId, SearchVO search)
  {
    ReportResultVO reportResult = new ReportResultVO();
    ArrayList results = new ArrayList();
    ArrayList resultLine = null;
    CVDal dataAccessLayer = new CVDal(this.dataSource);
    ResultSet resultSet = null;
    try {
      ReportLocalHome reportHome = EntityHomeFactory.getReportLocalHome();
      ReportLocal reportLocal = reportHome.findByPrimaryKey(new ReportPK(reportId, this.dataSource));
      reportResult.setReportId(reportLocal.getReportId());
      reportResult.setModuleId(reportLocal.getModuleId());
      reportResult.setName(reportLocal.getName());
      reportResult.setSearchCriteria(getSearchCriteriaString(userId, reportId));
      Date dateFrom = reportLocal.getDateFrom();
      Date dateTo = reportLocal.getDateTo();

      try {
        String query = getQueryForResultReport(userId, reportId, search, dataAccessLayer);

        dataAccessLayer.setSqlQuery(query);
        resultSet = dataAccessLayer.executeQueryNonParsed();
        ResultSetMetaData metaData = resultSet.getMetaData();
        int cols = metaData.getColumnCount();
        int i = 0;
        boolean exclude = false;
        boolean[] isDate = new boolean[cols + 1];
        for (i = 1; i <= cols; i++) {
          isDate[i] = false;
        }
        for (i = 1; i <= cols; i++) {
          if ((Types.DATE == metaData.getColumnType(i) || Types.TIMESTAMP == metaData.getColumnType(i))
              && !metaData.getColumnName(i).equalsIgnoreCase("Modified") && !metaData.getColumnName(i).equalsIgnoreCase("Created")) {
            isDate[i] = true;
          }
        } // end for ( i = 1; i <= cols; i++)

        while (resultSet.next()) {
          resultLine = new ArrayList();
          exclude = false;
          for (i = 1; i <= cols; i++) {
            if (isDate[i]) {
              Date dateField = resultSet.getDate(i);
              if (dateField != null) {
                if (dateFrom != null && dateFrom.after(dateField)) {
                  exclude = true;
                }
                if (dateTo != null && dateTo.before(dateField)) {
                  exclude = true;
                }
              } // end if (dateField != null)
            } // end if (isDate[i])
          } // end for (i = 1; i <= cols; i++)

          if (exclude) {
            continue;
          }

          for (i = 1; i <= cols; i++) {
            resultLine.add(resultSet.getString(i));
          }
          results.add(resultLine);
        }
      } catch (SQLException se) {
        logger.error("[Exception][ReportFacadeEJB.getReportResult] Exception Thrown: " + se);
        logger.error("> Caused by: " + se);
        throw new EJBException(se);
      }
      reportResult.setTitles(getTitles(reportId));
      reportResult.setResults(results);
      return reportResult;
    } catch (Exception e) {
      throw new EJBException(e);
    } finally {
      if (resultSet != null) {
View Full Code Here

   * @return ReportResultVO
   */

  public ReportResultVO getStandardReportResult(int userId, int reportId, SearchVO search)
  {
    ReportResultVO resultVO = new ReportResultVO();
    try {
      InitialContext ctx = new InitialContext();
      Object oh = ctx.lookup("local/AdvancedSearch");
      AdvancedSearchLocalHome cfh = (AdvancedSearchLocalHome) javax.rmi.PortableRemoteObject.narrow(oh,
          com.centraview.advancedsearch.AdvancedSearchLocalHome.class);
      AdvancedSearchLocal localAdvancedSearch = (AdvancedSearchLocal) cfh.create();
      localAdvancedSearch.setDataSource(this.dataSource);

      ReportLocalHome reportHome = EntityHomeFactory.getReportLocalHome();
      ReportLocal reportLocal = reportHome.findByPrimaryKey(new ReportPK(reportId, this.dataSource));
      resultVO.setReportId(reportLocal.getReportId());
      resultVO.setModuleId(reportLocal.getModuleId());
      resultVO.setName(reportLocal.getName());
      resultVO.setSearchCriteria(getSearchCriteriaString(userId, reportId));
      // get report dates
      java.sql.Date fromDate = reportLocal.getDateFrom();
      java.sql.Date toDate = reportLocal.getDateTo();

      resultVO.setDateRange(fromDate, toDate);

      String where = localAdvancedSearch.getWhereClauseForReport(userId, search, "");
      ReportBuilder reportbuilder = null;
      switch (reportId) {
        case ReportBuilder.CONTACTS1_REPORT_ID: // Contacts1
        case ReportBuilder.CONTACTS2_REPORT_ID: // Contacts2
        {
          reportbuilder = new Contacts1ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.HR1_REPORT_ID: // Hr1
        {
          reportbuilder = new Hr1ReportBuilder(fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.HR2_REPORT_ID: // Hr2
        {
          reportbuilder = new Hr2ReportBuilder(fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.HR3_REPORT_ID: // Hr3
        case ReportBuilder.HR4_REPORT_ID: // Hr4
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "tsl");

          reportbuilder = new Hr3ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }

        case ReportBuilder.ACTIVITIES1_REPORT_ID: // Activities1
        case ReportBuilder.ACTIVITIES2_REPORT_ID: // Activities2
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "act");

          reportbuilder = new Activities1ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.SALES1_REPORT_ID: // Sales1
        case ReportBuilder.SALES2_REPORT_ID: // Sales2
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "op");

          reportbuilder = new Sales1ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.SALES3_REPORT_ID: // Sales3
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "pi");

          reportbuilder = new Sales3ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.SALES4_REPORT_ID: // Sales4
        {

          // where =
          // localAdvancedSearch.getWhereClauseByReportIdWithAlias(userId,
          // reportId, reportLocal.getModuleId(),"cvord");

          reportbuilder = new Sales4ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.PROJECTS1_REPORT_ID: // Project1
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "task");

          reportbuilder = new Project1ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.SUPPORT1_REPORT_ID: // Support1
        case ReportBuilder.SUPPORT2_REPORT_ID: // Support2
        case ReportBuilder.SUPPORT3_REPORT_ID: // Support3
        {

          where = localAdvancedSearch.getWhereClauseForReport(userId, search, "tick");

          reportbuilder = new Support1ReportBuilder(reportId, fromDate, toDate, this.dataSource, where);
          break;
        }
        case ReportBuilder.INDIVIDUAL_NOTE_ID:
       {
         reportbuilder = new IndividualNoteStandardReport(fromDate, toDate, this.dataSource, where);
       }

      }

      if (reportbuilder != null) {
        resultVO.setResults(reportbuilder.runReport());
        reportbuilder.closeConnection();
      }

      // this.debugStandardReport(resultVO);

View Full Code Here

TOP

Related Classes of com.centraview.report.valueobject.ReportResultVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.