protected void generateReport(Report report) throws SAXException {
    if (report == null) {
      throw new NullPointerException("Parameter report must not be null");
    }
    if (handler == null) {
      throw new IllegalStateException("ContentHandler not set");
    }

    handler.startElement("report");

    String reportTitle = M_rm.getReportFormattedParams().getReportTitle(report);
    if (reportTitle != null && reportTitle.trim().length() != 0) {
      reportTitle =
          msgs.getString("reportres_title_detailed").replaceAll("\\$\\{title\\}", reportTitle);
    } else {
      reportTitle = msgs.getString("reportres_title");
    }
    handler.element("title", reportTitle);

    // description
    String reportDescription = M_rm.getReportFormattedParams().getReportDescription(report);
    if (reportDescription != null) {
      generateReportSummaryHeaderRow(
          msgs.getString("reportres_summ_description"), reportDescription);
    }
    // site
    String reportSite = M_rm.getReportFormattedParams().getReportSite(report);
    if (reportSite != null) {
      generateReportSummaryHeaderRow(msgs.getString("reportres_summ_site"), reportSite);
    }
    // activity based on
    generateReportSummaryHeaderRow(
        msgs.getString("reportres_summ_act_basedon"),
        M_rm.getReportFormattedParams().getReportActivityBasedOn(report));
    String reportResourceAction = M_rm.getReportFormattedParams().getReportResourceAction(report);
    // resources action
    if (reportResourceAction != null)
      generateReportSummaryHeaderRow(
          M_rm.getReportFormattedParams().getReportResourceActionTitle(report),
          reportResourceAction);
    // activity selection
    String reportActivitySelection =
        M_rm.getReportFormattedParams().getReportActivitySelection(report);
    if (reportActivitySelection != null)
      generateReportSummaryHeaderRow(
          M_rm.getReportFormattedParams().getReportActivitySelectionTitle(report),
          reportActivitySelection);
    // time period
    generateReportSummaryHeaderRow(
        msgs.getString("reportres_summ_timeperiod"),
        M_rm.getReportFormattedParams().getReportTimePeriod(report));
    // user selection type
    generateReportSummaryHeaderRow(
        msgs.getString("reportres_summ_usr_selectiontype"),
        M_rm.getReportFormattedParams().getReportUserSelectionType(report));
    // user selection
    String reportUserSelection = M_rm.getReportFormattedParams().getReportUserSelection(report);
    if (reportUserSelection != null)
      generateReportSummaryHeaderRow(
          M_rm.getReportFormattedParams().getReportUserSelectionTitle(report), reportUserSelection);
    // report timestamp
    generateReportSummaryHeaderRow(
        msgs.getString("reportres_summ_generatedon"),
        M_rm.getReportFormattedParams().getReportGenerationDate(report));

    // set column display info
    setColumnDisplayInfo(report.getReportDefinition().getReportParams());

    // display chart and/or table?
    /*ReportParams params = report.getReportDefinition().getReportParams();
        boolean showChart = ReportManager.HOW_PRESENTATION_BOTH.equals(params.getHowPresentationMode())
    || ReportManager.HOW_PRESENTATION_CHART.equals(params.getHowPresentationMode());
        boolean showTable = ReportManager.HOW_PRESENTATION_BOTH.equals(params.getHowPresentationMode())
    || ReportManager.HOW_PRESENTATION_TABLE.equals(params.getHowPresentationMode());*/
    boolean showChart = false;
    boolean showTable = true;
    handler.element("showChart", String.valueOf(showChart));
    handler.element("showTable", String.valueOf(showTable));

    // report chart
    if (showChart) {
      // TODO Embbed image in fop
      generateReportChart(report);
    }

    // report table
    if (showTable) {
      generateReportDataHeader(report.getReportDefinition().getReportParams());
      generateReportTable(report.getReportData(), report.getReportDefinition().getReportParams());
    }

    handler.endElement("report");
  }
Esempio n. 2
0
  public void testGetMoreReports() {
    M_sum.collectEvents(getSampleData());
    String siteId = null;
    Report r = null;
    ReportDef rd = null;
    ReportParams rp = null;
    List<String> totalsBy = null;

    // resources
    siteId = FakeData.SITE_A_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_RESOURCES);
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_USER);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
    rd.setReportParams(rp);
    r = M_rm.getReport(rd, true, null, false);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());

    // visits
    rp.setWhat(ReportManager.WHAT_VISITS);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(2, r.getReportData().size());

    // visits totals
    rp.setWhat(ReportManager.WHAT_VISITS_TOTALS);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    rp.setHowTotalsBy(totalsBy);
    rd.setId(1);
    r = M_rm.getReport(rd, true, new PagingPosition(0, 5), true);
    assertEquals(1, r.getReportData().size());
    assertEquals(9, ((SiteVisits) (r.getReportData().get(0))).getTotalVisits());
    assertEquals(7, ((SiteVisits) (r.getReportData().get(0))).getTotalUnique());

    //		// activity totals
    //		rp.setWhat(ReportManager.WHAT_ACTIVITY_TOTALS);
    //		rp.setWhatEventIds(FakeData.EVENTIDS);
    //		rp.setWhen(ReportManager.WHEN_LAST365DAYS);
    //		r = M_rm.getReport(rd, false, null, false);
    //		System.out.println(r.getReportData());
    //		System.out.println("ReportParams: "+ rp);
    //		System.out.println("ReportData: "+ r.getReportData());
    //		assertEquals(1, r.getReportData().size());
    //		assertEquals(1, r.getReportData().get(0).getCount());

    // presences I
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_USER);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(7, r.getReportData().size());

    // presences II
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(5, r.getReportData().size());

    // presences III
    rp.setWhat(ReportManager.WHAT_PRESENCES);
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_SITE);
    rp.setHowTotalsBy(totalsBy);
    rp.setHowSort(false);
    r = M_rm.getReport(rd, true, null, true);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());
  }
Esempio n. 3
0
  public void testReportsFromOverviewPage() {
    M_sum.collectEvents(getSampleData2());

    // MiniStatsVisits & MiniStatUniqueVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS_TOTALS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_ALL);
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_DATE);
      totalsBy.add(StatsManager.T_VISITS);
      totalsBy.add(StatsManager.T_UNIQUEVISITS);
      rp.setHowTotalsBy(totalsBy);
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_DATE);
      rp.setHowSortAscending(false);
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_BOTH);
      rp.setHowChartType(StatsManager.CHARTTYPE_TIMESERIESBAR);
      rp.setHowChartSource(StatsManager.T_DATE);
      rp.setHowChartSeriesSource(StatsManager.T_NONE);
      rp.setHowChartSeriesPeriod(StatsManager.CHARTTIMESERIES_DAY);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(5, rep.getReportData().size());
    }

    // MiniStatEnrolledUsersWithVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatEnrolledUsersWithoutVisits
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      rp.setWhat(ReportManager.WHAT_VISITS);
      rp.setWhen(ReportManager.WHEN_ALL);
      rp.setWho(ReportManager.WHO_NONE);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(0, rep.getReportData().size());
    }

    // MiniStatActivityEvents
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_EVENTS);
      rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYEVENTS);
      rp.setWhatEventIds(new ArrayList<String>(M_ers.getEventIds()));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_EVENT);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_EVENT);
      rp.setHowSortAscending(true);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(6, rep.getReportData().size());
    }

    // MiniStatMostActiveUser
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_EVENTS);
      rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYEVENTS);
      rp.setWhatEventIds(new ArrayList<String>(M_ers.getEventIds()));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(3, rep.getReportData().size());
    }

    // MiniStatFiles (files with new event)
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_NEW);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_RESOURCE);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_RESOURCE);
      rp.setHowSortAscending(true);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatOpenedFiles (files with read event)
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_READ);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_RESOURCE);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }

    // MiniStatUserThatOpenedMoreFiles
    {
      ReportDef r = new ReportDef();
      r.setId(0);
      r.setSiteId(FakeData.SITE_A_ID);
      ReportParams rp = new ReportParams(FakeData.SITE_A_ID);
      // what
      rp.setWhat(ReportManager.WHAT_RESOURCES);
      rp.setWhatLimitedAction(true);
      rp.setWhatResourceAction(ReportManager.WHAT_RESOURCES_ACTION_READ);
      rp.setWhatLimitedResourceIds(true);
      rp.setWhatResourceIds(Arrays.asList(StatsManager.RESOURCES_DIR + FakeData.SITE_A_ID + "/"));
      // when
      rp.setWhen(ReportManager.WHEN_ALL);
      // who
      rp.setWho(ReportManager.WHO_ALL);
      // grouping
      List<String> totalsBy = new ArrayList<String>();
      totalsBy.add(StatsManager.T_USER);
      rp.setHowTotalsBy(totalsBy);
      // sorting
      rp.setHowSort(true);
      rp.setHowSortBy(StatsManager.T_TOTAL);
      rp.setHowSortAscending(false);
      // chart
      rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
      r.setReportParams(rp);
      Report rep = M_rm.getReport(r, false);
      assertNotNull(rep);
      assertEquals(2, rep.getReportData().size());
    }
  }
Esempio n. 4
0
  // ---- TESTS ----
  public void testGetReport() {
    M_sum.collectEvents(getSampleData());
    String siteId = null;
    Report r = null;
    ReportDef rd = null;
    ReportParams rp = null;
    List<String> totalsBy = null;

    // #1 getReport(ReportDef reportDef, boolean restrictToToolsInSite)
    siteId = FakeData.SITE_B_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_EVENTS);
    rp.setWhatEventSelType(ReportManager.WHAT_EVENTS_BYTOOL);
    rp.setWhatToolIds(Arrays.asList(ReportManager.WHAT_EVENTS_ALLTOOLS));
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    // grouping
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_TOOL);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    // sorting
    rp.setHowSort(true);
    rp.setHowSortBy(StatsManager.T_TOOL);
    rp.setHowSortAscending(false);
    // chart
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_BOTH);
    rp.setHowChartType(StatsManager.CHARTTYPE_TIMESERIESBAR);
    rp.setHowChartSource(StatsManager.T_DATE);
    rp.setHowChartSeriesSource(StatsManager.T_NONE);
    rp.setHowChartSeriesPeriod(StatsManager.CHARTTIMESERIES_DAY);
    rd.setReportParams(rp);
    r = M_rm.getReport(rd, true);
    checkCollumns(rd.getReportParams());
    assertEquals(1, r.getReportData().size());
    r = M_rm.getReport(rd, false);
    checkCollumns(rd.getReportParams());
    assertEquals(2, r.getReportData().size());
    assertNotNull(M_rm.getReportFormattedParams());

    // #2 getReportRowCount(ReportDef reportDef, boolean restrictToToolsInSite)
    assertEquals(1, M_rm.getReportRowCount(rd, true));
    assertEquals(2, M_rm.getReportRowCount(rd, false));

    siteId = FakeData.SITE_B_ID;
    rd = new ReportDef();
    rd.setId(0);
    rd.setSiteId(siteId);
    rp = new ReportParams(siteId);
    rp.setWhat(ReportManager.WHAT_RESOURCES);
    rp.setWhen(ReportManager.WHEN_ALL);
    rp.setWho(ReportManager.WHO_ALL);
    // grouping
    totalsBy = new ArrayList<String>();
    totalsBy.add(StatsManager.T_RESOURCE);
    totalsBy.add(StatsManager.T_DATE);
    rp.setHowTotalsBy(totalsBy);
    // sorting
    rp.setHowSort(true);
    rp.setHowSortBy(StatsManager.T_TOOL);
    rp.setHowSortAscending(false);
    // chart
    rp.setHowPresentationMode(ReportManager.HOW_PRESENTATION_TABLE);
    rd.setReportParams(rp);
    assertEquals(1, M_rm.getReportRowCount(rd, true));
    assertEquals(1, M_rm.getReportRowCount(rd, false));
  }