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);
}
}
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());
}
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());
}
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;
}
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();
}
Aggregations