Search in sources :

Example 1 with ReportDTO

use of org.activityinfo.legacy.shared.model.ReportDTO in project activityinfo by bedatadriven.

the class GetReportModelHandler method execute.

@Override
public void execute(final GetReportModel cmd, final ExecutionContext context, final AsyncCallback<ReportDTO> callback) {
    LOGGER.finest("Loading model for report id = " + cmd.getReportId());
    Preconditions.checkNotNull(cmd.getReportId());
    ReportDTO cachedReport = (ReportDTO) memcacheService.get(cmd);
    if (cachedReport != null) {
        callback.onSuccess(cachedReport);
        return;
    }
    // always load report
    ReportDefinition entity = em.find(ReportDefinition.class, cmd.getReportId());
    Report report = parseReport(entity).setId(cmd.getReportId());
    ReportDTO reportDTO = new ReportDTO(report);
    if (cmd.isLoadMetadata()) {
        loadMetadataAndCallback(cmd, context, reportDTO, callback);
    } else {
        // report object without metadata
        memcache(cmd, reportDTO);
        callback.onSuccess(reportDTO);
    }
}
Also used : Report(org.activityinfo.legacy.shared.reports.model.Report) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) ReportDefinition(org.activityinfo.server.database.hibernate.entity.ReportDefinition)

Example 2 with ReportDTO

use of org.activityinfo.legacy.shared.model.ReportDTO in project activityinfo by bedatadriven.

the class GetReportModelTest method serializationDeserialization.

// AI-1359
@Test
public void serializationDeserialization() throws IOException, ClassNotFoundException {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3, true));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(result);
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    ReportDTO rereadDto = (ReportDTO) ois.readObject();
    assertEquals(result.getReportMetadataDTO().getId(), rereadDto.getReportMetadataDTO().getId());
    assertEquals(result.getReportMetadataDTO().getSubscribers(), rereadDto.getReportMetadataDTO().getSubscribers());
    assertEquals(result.getReportMetadataDTO().getAmOwner(), rereadDto.getReportMetadataDTO().getAmOwner());
    assertEquals(result.getReportMetadataDTO().getEmailDelivery(), rereadDto.getReportMetadataDTO().getEmailDelivery());
    assertEquals(result.getReportMetadataDTO().getOwnerName(), rereadDto.getReportMetadataDTO().getOwnerName());
    assertEquals(result.getReportMetadataDTO().getDay(), rereadDto.getReportMetadataDTO().getDay());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Example 3 with ReportDTO

use of org.activityinfo.legacy.shared.model.ReportDTO in project activityinfo by bedatadriven.

the class GetReportModelTest method selectReportWithMetadata.

@Test
public void selectReportWithMetadata() {
    setUser(1);
    ReportDTO result = execute(new GetReportModel(3, true));
    assertNotNull(result.getReport());
    assertEquals("Report 3", result.getReport().getTitle());
    assertNotNull(result.getReportMetadataDTO());
    assertEquals("Alex", result.getReportMetadataDTO().getOwnerName());
}
Also used : GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) Test(org.junit.Test)

Example 4 with ReportDTO

use of org.activityinfo.legacy.shared.model.ReportDTO in project activityinfo by bedatadriven.

the class PivotTestResource method get.

@GET
@Path("report")
@Produces(MediaType.APPLICATION_JSON)
public List<PivotSites.PivotResult> get(@QueryParam("reportId") int reportId, @QueryParam("userId") int userId, @QueryParam("new") boolean newEngine, @QueryParam("details") boolean showDetails) {
    assertRunningInLocalDevelopmentEnvironment();
    authProvider.set(new AuthenticatedUser("XYZ", userId, "user@user.org"));
    ReportDTO report = dispatcher.execute(new GetReportModel(reportId));
    Report model = report.getReport();
    List<PivotSites.PivotResult> results = Lists.newArrayList();
    for (ReportElement element : model.getElements()) {
        if (element instanceof PivotReportElement) {
            PivotSites command = command(model, (PivotReportElement) element, newEngine, showDetails);
            if (!command.isTooBroad()) {
                results.add(dispatcher.execute(command));
            } else {
                results.add(new PivotSites.PivotResult());
            }
        }
    }
    return results;
}
Also used : Report(org.activityinfo.legacy.shared.reports.model.Report) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser)

Example 5 with ReportDTO

use of org.activityinfo.legacy.shared.model.ReportDTO in project activityinfo by bedatadriven.

the class PivotTestResource method show.

@GET
@Path("show")
@Produces(MediaType.TEXT_PLAIN)
public String show(@QueryParam("reportId") int reportId) {
    assertRunningInLocalDevelopmentEnvironment();
    ReportDTO report = dispatcher.execute(new GetReportModel(reportId));
    Report model = report.getReport();
    StringBuilder text = new StringBuilder();
    text.append(model.getTitle()).append("\n");
    text.append("Filter: " + model.getFilter()).append("\n");
    for (ReportElement element : model.getElements()) {
        text.append("-- " + element.getClass().getSimpleName() + ": " + element.getTitle()).append("\n");
        text.append("   Filter: " + element.getFilter()).append("\n");
        if (element instanceof PivotReportElement) {
            text.append("   Dimensions: " + ((PivotReportElement) element).allDimensions()).append("\n");
        }
    }
    return text.toString();
}
Also used : Report(org.activityinfo.legacy.shared.reports.model.Report) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) PivotReportElement(org.activityinfo.legacy.shared.reports.model.PivotReportElement) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement)

Aggregations

ReportDTO (org.activityinfo.legacy.shared.model.ReportDTO)9 GetReportModel (org.activityinfo.legacy.shared.command.GetReportModel)5 Test (org.junit.Test)4 Report (org.activityinfo.legacy.shared.reports.model.Report)3 ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)3 PivotReportElement (org.activityinfo.legacy.shared.reports.model.PivotReportElement)2 AuthenticatedUser (org.activityinfo.legacy.shared.AuthenticatedUser)1 DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)1 TextReportElement (org.activityinfo.legacy.shared.reports.model.TextReportElement)1 ReportDefinition (org.activityinfo.server.database.hibernate.entity.ReportDefinition)1 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)1