use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class ReportJsonFactory method decodeFilter.
public Filter decodeFilter(JsonObject filter) {
Filter elementFilter = new Filter();
JsonElement jsonMinDate = filter.get("minDate");
JsonElement jsonMaxDate = filter.get("maxDate");
DateRange dateRange = new DateRange();
if (jsonMinDate != null) {
jsonMinDate.getAsLong();
Date minDate = new Date(jsonMinDate.getAsLong());
dateRange.setMinDate(minDate);
}
if (jsonMaxDate != null) {
Date maxDate = new Date(jsonMaxDate.getAsLong());
dateRange.setMaxDate(maxDate);
}
elementFilter.setDateRange(dateRange);
JsonArray restrictions = (JsonArray) filter.get("restrictions");
for (int i = 0; i < restrictions.size(); i++) {
JsonObject rest = (JsonObject) restrictions.get(i);
JsonArray arr = rest.get("set").getAsJsonArray();
Set<Integer> set = new HashSet<Integer>();
Iterator<JsonElement> it = arr.iterator();
while (it.hasNext()) {
set.add(it.next().getAsInt());
}
elementFilter.addRestriction(DimensionType.valueOf(rest.get("type").getAsString()), set);
}
return elementFilter;
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class DateUtilGWTImpl method yearRange.
@Override
public DateRange yearRange(int year) {
DateRange range = new DateRange();
DateWrapper date = new DateWrapper(year, 0, 1);
range.setMinDate(date.asDate());
date = new DateWrapper(year, 11, 31);
range.setMaxDate(date.asDate());
return range;
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class RenderReportHtmlHandler method execute.
@Override
@LogException
public CommandResult execute(RenderReportHtml cmd, User user) throws CommandException {
ReportElement model = cmd.getModel();
LOGGER.fine("Model: " + model);
// don't show the title: it will be rendered by the container
model.setTitle(null);
generator.generateElement(user, model, new Filter(), new DateRange());
StringWriter writer = new StringWriter();
try {
renderer.render(model, writer);
} catch (IOException e) {
throw new CommandException(e);
}
return new HtmlResult(writer.toString());
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class ReportMailer method execute.
public void execute(Date today, ReportSubscription sub, Report report) throws IOException {
// set up authentication for the subscriber of this report
authProvider.set(sub.getUser());
DomainFilters.applyUserFilter(sub.getUser(), em);
// render the report to a temp file
// generate the report
reportGenerator.generate(sub.getUser(), report, null, new DateRange());
ByteArrayOutputStream rtf = new ByteArrayOutputStream();
rtfReportRenderer.render(report, rtf);
rtf.close();
try {
mailReport(sub, report, today, rtf.toByteArray());
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Report mailing of " + sub.getTemplate().getId() + " failed for user " + sub.getUser().getEmail(), e);
}
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class DateUtilCalendarImpl method yearRange.
@Override
public DateRange yearRange(int year) {
DateRange range = new DateRange();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DATE, 1);
range.setMinDate(calendar.getTime());
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
calendar.set(Calendar.DATE, 31);
range.setMaxDate(calendar.getTime());
return range;
}
Aggregations