Search in sources :

Example 1 with Objects

use of org.hisp.dhis.common.Objects in project dhis2-core by dhis2.

the class SystemController method getObjectCounts.

@RequestMapping(value = "/objectCounts", method = RequestMethod.GET)
@ResponseBody
public RootNode getObjectCounts() {
    Map<Objects, Integer> objectCounts = statisticsProvider.getObjectCounts();
    RootNode rootNode = NodeUtils.createRootNode("objectCounts");
    for (Objects objects : objectCounts.keySet()) {
        rootNode.addChild(new SimpleNode(objects.getValue(), objectCounts.get(objects)));
    }
    return rootNode;
}
Also used : RootNode(org.hisp.dhis.node.types.RootNode) Objects(org.hisp.dhis.common.Objects) SimpleNode(org.hisp.dhis.node.types.SimpleNode) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Objects

use of org.hisp.dhis.common.Objects 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

Objects (org.hisp.dhis.common.Objects)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 RootNode (org.hisp.dhis.node.types.RootNode)1 SimpleNode (org.hisp.dhis.node.types.SimpleNode)1 UserInvitationStatus (org.hisp.dhis.user.UserInvitationStatus)1 UserQueryParams (org.hisp.dhis.user.UserQueryParams)1 DateTime (org.joda.time.DateTime)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1