Search in sources :

Example 1 with UserStatisticsVO

use of org.olat.restapi.system.vo.UserStatisticsVO in project OpenOLAT by OpenOLAT.

the class SystemTest method testSystemUserStatistics.

@Test
public void testSystemUserStatistics() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("openolat").path("users").build();
    UserStatisticsVO userStats = conn.get(systemUri, UserStatisticsVO.class);
    assertNotNull(userStats);
    long totalUserCount = userStats.getTotalUserCount();
    assertTrue(totalUserCount > 0);
    long activeUserCount = userStats.getActiveUserCount();
    assertTrue(activeUserCount >= 0);
    long activeUserCountLastDay = userStats.getActiveUserCountLastDay();
    assertTrue(activeUserCountLastDay >= 0);
    long activeUserCountLastWeek = userStats.getActiveUserCountLastWeek();
    assertTrue(activeUserCountLastWeek >= 0);
    long activeUserCountLastMonth = userStats.getActiveUserCountLastMonth();
    assertTrue(activeUserCountLastMonth >= 0);
    long activeUserCountLast6Month = userStats.getActiveUserCountLast6Month();
    assertTrue(activeUserCountLast6Month >= 0);
    long blockedUserCount = userStats.getBlockedUserCount();
    assertTrue(blockedUserCount >= 0);
    long deletedUserCount = userStats.getDeletedUserCount();
    assertTrue(deletedUserCount >= 0);
    long externalUserCount = userStats.getExternalUserCount();
    assertTrue(externalUserCount >= 0);
    long totalGroupCount = userStats.getTotalGroupCount();
    assertTrue(totalGroupCount >= 0);
    conn.shutdown();
}
Also used : URI(java.net.URI) UserStatisticsVO(org.olat.restapi.system.vo.UserStatisticsVO) Test(org.junit.Test)

Example 2 with UserStatisticsVO

use of org.olat.restapi.system.vo.UserStatisticsVO in project OpenOLAT by OpenOLAT.

the class OpenOLATStatisticsWebService method getUserStatisticsVO.

private UserStatisticsVO getUserStatisticsVO() {
    UserStatisticsVO stats = new UserStatisticsVO();
    BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    // activeUserCount="88" // registered and activated identities, same as in GUI
    long countActiveUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE);
    stats.setActiveUserCount(countActiveUsers);
    // active last day
    Calendar lastDay = Calendar.getInstance();
    lastDay.add(Calendar.DATE, -1);
    long activeUserCountDay = securityManager.countUniqueUserLoginsSince(lastDay.getTime());
    stats.setActiveUserCountLastDay(activeUserCountDay);
    // active last week
    Calendar lastWeek = Calendar.getInstance();
    lastWeek.add(Calendar.DATE, -7);
    long activeUserCountWeek = securityManager.countUniqueUserLoginsSince(lastWeek.getTime());
    stats.setActiveUserCountLastWeek(activeUserCountWeek);
    // active last month
    Calendar lastMonth = Calendar.getInstance();
    lastMonth.add(Calendar.MONTH, -1);
    long activeUserCountMonth = securityManager.countUniqueUserLoginsSince(lastMonth.getTime());
    stats.setActiveUserCountLastMonth(activeUserCountMonth);
    // active last 6 month
    Calendar last6Month = Calendar.getInstance();
    last6Month.add(Calendar.MONTH, -6);
    long activeUserCount6Month = securityManager.countUniqueUserLoginsSince(last6Month.getTime());
    stats.setActiveUserCountLast6Month(activeUserCount6Month);
    // externalUserCount="12" // EP invite identities, later maybe also used in courses for MOOCS, external experts etc)
    long invitationsCount = CoreSpringFactory.getImpl(InvitationDAO.class).countInvitations();
    stats.setExternalUserCount(invitationsCount);
    // blockedUserCount="0" // identities in login blocked state
    long blockedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED);
    stats.setBlockedUserCount(blockedUserCount);
    // deletedUserCount="943" // deleted identities
    long deletedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_DELETED);
    stats.setDeletedUserCount(deletedUserCount);
    // totalUserCount="1043" // Sum of all above
    long countUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, null);
    stats.setTotalUserCount(countUsers);
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    long countGroups = bgs.countBusinessGroups(null, null);
    stats.setTotalGroupCount(countGroups);
    return stats;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) Calendar(java.util.Calendar) InvitationDAO(org.olat.portfolio.manager.InvitationDAO) UserStatisticsVO(org.olat.restapi.system.vo.UserStatisticsVO) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 3 with UserStatisticsVO

use of org.olat.restapi.system.vo.UserStatisticsVO in project openolat by klemens.

the class OpenOLATStatisticsWebService method getUserStatisticsVO.

private UserStatisticsVO getUserStatisticsVO() {
    UserStatisticsVO stats = new UserStatisticsVO();
    BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    // activeUserCount="88" // registered and activated identities, same as in GUI
    long countActiveUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE);
    stats.setActiveUserCount(countActiveUsers);
    // active last day
    Calendar lastDay = Calendar.getInstance();
    lastDay.add(Calendar.DATE, -1);
    long activeUserCountDay = securityManager.countUniqueUserLoginsSince(lastDay.getTime());
    stats.setActiveUserCountLastDay(activeUserCountDay);
    // active last week
    Calendar lastWeek = Calendar.getInstance();
    lastWeek.add(Calendar.DATE, -7);
    long activeUserCountWeek = securityManager.countUniqueUserLoginsSince(lastWeek.getTime());
    stats.setActiveUserCountLastWeek(activeUserCountWeek);
    // active last month
    Calendar lastMonth = Calendar.getInstance();
    lastMonth.add(Calendar.MONTH, -1);
    long activeUserCountMonth = securityManager.countUniqueUserLoginsSince(lastMonth.getTime());
    stats.setActiveUserCountLastMonth(activeUserCountMonth);
    // active last 6 month
    Calendar last6Month = Calendar.getInstance();
    last6Month.add(Calendar.MONTH, -6);
    long activeUserCount6Month = securityManager.countUniqueUserLoginsSince(last6Month.getTime());
    stats.setActiveUserCountLast6Month(activeUserCount6Month);
    // externalUserCount="12" // EP invite identities, later maybe also used in courses for MOOCS, external experts etc)
    long invitationsCount = CoreSpringFactory.getImpl(InvitationDAO.class).countInvitations();
    stats.setExternalUserCount(invitationsCount);
    // blockedUserCount="0" // identities in login blocked state
    long blockedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED);
    stats.setBlockedUserCount(blockedUserCount);
    // deletedUserCount="943" // deleted identities
    long deletedUserCount = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_DELETED);
    stats.setDeletedUserCount(deletedUserCount);
    // totalUserCount="1043" // Sum of all above
    long countUsers = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, null);
    stats.setTotalUserCount(countUsers);
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    long countGroups = bgs.countBusinessGroups(null, null);
    stats.setTotalGroupCount(countGroups);
    return stats;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) Calendar(java.util.Calendar) InvitationDAO(org.olat.portfolio.manager.InvitationDAO) UserStatisticsVO(org.olat.restapi.system.vo.UserStatisticsVO) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 4 with UserStatisticsVO

use of org.olat.restapi.system.vo.UserStatisticsVO in project openolat by klemens.

the class SystemTest method testSystemUserStatistics.

@Test
public void testSystemUserStatistics() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI systemUri = conn.getContextURI().path("system").path("monitoring").path("openolat").path("users").build();
    UserStatisticsVO userStats = conn.get(systemUri, UserStatisticsVO.class);
    assertNotNull(userStats);
    long totalUserCount = userStats.getTotalUserCount();
    assertTrue(totalUserCount > 0);
    long activeUserCount = userStats.getActiveUserCount();
    assertTrue(activeUserCount >= 0);
    long activeUserCountLastDay = userStats.getActiveUserCountLastDay();
    assertTrue(activeUserCountLastDay >= 0);
    long activeUserCountLastWeek = userStats.getActiveUserCountLastWeek();
    assertTrue(activeUserCountLastWeek >= 0);
    long activeUserCountLastMonth = userStats.getActiveUserCountLastMonth();
    assertTrue(activeUserCountLastMonth >= 0);
    long activeUserCountLast6Month = userStats.getActiveUserCountLast6Month();
    assertTrue(activeUserCountLast6Month >= 0);
    long blockedUserCount = userStats.getBlockedUserCount();
    assertTrue(blockedUserCount >= 0);
    long deletedUserCount = userStats.getDeletedUserCount();
    assertTrue(deletedUserCount >= 0);
    long externalUserCount = userStats.getExternalUserCount();
    assertTrue(externalUserCount >= 0);
    long totalGroupCount = userStats.getTotalGroupCount();
    assertTrue(totalGroupCount >= 0);
    conn.shutdown();
}
Also used : URI(java.net.URI) UserStatisticsVO(org.olat.restapi.system.vo.UserStatisticsVO) Test(org.junit.Test)

Aggregations

UserStatisticsVO (org.olat.restapi.system.vo.UserStatisticsVO)4 URI (java.net.URI)2 Calendar (java.util.Calendar)2 Test (org.junit.Test)2 BaseSecurity (org.olat.basesecurity.BaseSecurity)2 BusinessGroupService (org.olat.group.BusinessGroupService)2 InvitationDAO (org.olat.portfolio.manager.InvitationDAO)2