Search in sources :

Example 11 with ReportTable

use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.

the class ReportTableController method getReportTableGrid.

private Grid getReportTableGrid(String uid, String organisationUnitUid, Date date) throws Exception {
    ReportTable reportTable = reportTableService.getReportTableNoAcl(uid);
    if (organisationUnitUid == null && reportTable.hasReportParams() && reportTable.getReportParams().isOrganisationUnitSet()) {
        organisationUnitUid = organisationUnitService.getRootOrganisationUnits().iterator().next().getUid();
    }
    date = date != null ? date : new Date();
    return reportTableService.getReportTableGrid(uid, date, organisationUnitUid);
}
Also used : ReportTable(org.hisp.dhis.reporttable.ReportTable) Date(java.util.Date)

Example 12 with ReportTable

use of org.hisp.dhis.reporttable.ReportTable 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)

Example 13 with ReportTable

use of org.hisp.dhis.reporttable.ReportTable in project dhis2-core by dhis2.

the class AclServiceTest method testVerifyReportTableCantExternalize.

@Test
public void testVerifyReportTableCantExternalize() {
    User user = createAdminUser("F_REPORTTABLE_PUBLIC_ADD");
    ReportTable reportTable = new ReportTable();
    reportTable.setAutoFields();
    reportTable.setPublicAccess(AccessStringHelper.DEFAULT);
    reportTable.setExternalAccess(true);
    assertFalse(aclService.verifySharing(reportTable, user).isEmpty());
}
Also used : User(org.hisp.dhis.user.User) ReportTable(org.hisp.dhis.reporttable.ReportTable) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

ReportTable (org.hisp.dhis.reporttable.ReportTable)13 DhisSpringTest (org.hisp.dhis.DhisSpringTest)4 Test (org.junit.Test)4 Date (java.util.Date)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 Period (org.hisp.dhis.period.Period)3 User (org.hisp.dhis.user.User)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CalendarPeriodType (org.hisp.dhis.period.CalendarPeriodType)2 Report (org.hisp.dhis.report.Report)2 PastAndCurrentPeriodFilter (org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter)2 BiConsumer (java.util.function.BiConsumer)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Calendar (org.hisp.dhis.calendar.Calendar)1 DateTimeUnit (org.hisp.dhis.calendar.DateTimeUnit)1 Chart (org.hisp.dhis.chart.Chart)1 AnalyticalObject (org.hisp.dhis.common.AnalyticalObject)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1