Search in sources :

Example 1 with UserInvitationStatus

use of org.hisp.dhis.user.UserInvitationStatus in project dhis2-core by dhis2.

the class GetStatisticsAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    Map<Objects, Integer> counts = statisticsProvider.getObjectCounts();
    Date lastHour = new DateTime().minusHours(1).toDate();
    objects = new EnumMapWrapper<>(Objects.class, counts);
    activeUsers.put(0, userService.getActiveUsersCount(lastHour));
    activeUsers.put(1, userService.getActiveUsersCount(0));
    activeUsers.put(2, userService.getActiveUsersCount(1));
    activeUsers.put(7, userService.getActiveUsersCount(7));
    activeUsers.put(30, userService.getActiveUsersCount(30));
    Map<UserInvitationStatus, Integer> invitations = new HashMap<>();
    UserQueryParams inviteAll = new UserQueryParams();
    inviteAll.setInvitationStatus(UserInvitationStatus.ALL);
    invitations.put(UserInvitationStatus.ALL, userService.getUserCount(inviteAll));
    UserQueryParams inviteExpired = new UserQueryParams();
    inviteExpired.setInvitationStatus(UserInvitationStatus.EXPIRED);
    invitations.put(UserInvitationStatus.EXPIRED, userService.getUserCount(inviteExpired));
    userInvitations = new EnumMapWrapper<>(UserInvitationStatus.class, invitations);
    dataValueCount.put(0, dataValueService.getDataValueCount(0));
    dataValueCount.put(1, dataValueService.getDataValueCount(1));
    dataValueCount.put(7, dataValueService.getDataValueCount(7));
    dataValueCount.put(30, dataValueService.getDataValueCount(30));
    eventCount.put(0, programStageInstanceService.getProgramStageInstanceCount(0));
    eventCount.put(1, programStageInstanceService.getProgramStageInstanceCount(1));
    eventCount.put(7, programStageInstanceService.getProgramStageInstanceCount(7));
    eventCount.put(30, programStageInstanceService.getProgramStageInstanceCount(30));
    return SUCCESS;
}
Also used : HashMap(java.util.HashMap) UserInvitationStatus(org.hisp.dhis.user.UserInvitationStatus) Objects(org.hisp.dhis.common.Objects) Date(java.util.Date) DateTime(org.joda.time.DateTime) UserQueryParams(org.hisp.dhis.user.UserQueryParams)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 Objects (org.hisp.dhis.common.Objects)1 UserInvitationStatus (org.hisp.dhis.user.UserInvitationStatus)1 UserQueryParams (org.hisp.dhis.user.UserQueryParams)1 DateTime (org.joda.time.DateTime)1