Search in sources :

Example 1 with AnalyticsTableType

use of org.hisp.dhis.analytics.table.AnalyticsTableType in project dhis2-core by dhis2.

the class ResourceTableController method analytics.

@RequestMapping(value = "/analytics", method = { RequestMethod.PUT, RequestMethod.POST })
@PreAuthorize("hasRole('ALL') or hasRole('F_DATA_MART_ADMIN')")
public void analytics(@RequestParam(required = false) boolean skipResourceTables, @RequestParam(required = false) boolean skipAggregate, @RequestParam(required = false) boolean skipEvents, @RequestParam(required = false) boolean skipEnrollment, @RequestParam(required = false) Integer lastYears, HttpServletResponse response, HttpServletRequest request) {
    TaskId taskId = new TaskId(TaskCategory.ANALYTICSTABLE_UPDATE, currentUserService.getCurrentUser());
    Set<AnalyticsTableType> skipTableTypes = new HashSet<>();
    if (skipAggregate) {
        skipTableTypes.add(AnalyticsTableType.DATA_VALUE);
        skipTableTypes.add(AnalyticsTableType.COMPLETENESS);
        skipTableTypes.add(AnalyticsTableType.COMPLETENESS_TARGET);
    }
    if (skipEvents) {
        skipTableTypes.add(AnalyticsTableType.EVENT);
    }
    if (skipEnrollment) {
        skipTableTypes.add(AnalyticsTableType.ENROLLMENT);
    }
    scheduler.executeTask(() -> analyticsTableGenerator.generateTables(lastYears, taskId, skipTableTypes, skipResourceTables));
    webMessageService.send(WebMessageUtils.ok("Initiated analytics table update"), response, request);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) AnalyticsTableType(org.hisp.dhis.analytics.table.AnalyticsTableType) HashSet(java.util.HashSet) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

HashSet (java.util.HashSet)1 AnalyticsTableType (org.hisp.dhis.analytics.table.AnalyticsTableType)1 TaskId (org.hisp.dhis.scheduling.TaskId)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1