Search in sources :

Example 1 with ReportParams

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;
}
Also used : Report(org.hisp.dhis.report.Report) ReportTable(org.hisp.dhis.reporttable.ReportTable) ReportParams(org.hisp.dhis.reporttable.ReportParams) CacheStrategy(org.hisp.dhis.common.cache.CacheStrategy)

Aggregations

CacheStrategy (org.hisp.dhis.common.cache.CacheStrategy)1 Report (org.hisp.dhis.report.Report)1 ReportParams (org.hisp.dhis.reporttable.ReportParams)1 ReportTable (org.hisp.dhis.reporttable.ReportTable)1