use of org.hisp.dhis.reporttable.ReportParams in project dhis2-core by dhis2.
the class AddReportAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
// ---------------------------------------------------------------------
// New report or update existing object?
// ---------------------------------------------------------------------
boolean isNewReport = id == null;
if (fileName == null && currentDesign != null) {
fileName = currentDesign;
}
if (id == null && (fileName == null || fileName.trim().length() == 0)) {
return ERROR;
}
// ---------------------------------------------------------------------
// Create report
// ---------------------------------------------------------------------
Report report = isNewReport ? new Report() : reportService.getReport(id);
ReportTable reportTable = reportTableService.getReportTable(reportTableId);
ReportParams reportParams = new ReportParams(paramReportingMonth, false, false, paramOrganisationUnit);
report.setName(name);
report.setType(type);
report.setReportTable(reportTable);
report.setRelatives(getRelativePeriods());
report.setReportParams(reportParams);
log.info("Upload file name: " + fileName + ", content type: " + contentType);
if (file != null) {
report.setDesignContent(FileUtils.readFileToString(file));
}
if (cacheStrategy != null) {
CacheStrategy strategy = EnumUtils.getEnum(CacheStrategy.class, cacheStrategy);
report.setCacheStrategy(strategy != null ? strategy : Report.DEFAULT_CACHE_STRATEGY);
} else if (isNewReport) {
report.setCacheStrategy(CacheStrategy.RESPECT_SYSTEM_SETTING);
}
reportService.saveReport(report);
return SUCCESS;
}
Aggregations