Search in sources :

Example 6 with UserGroup

use of fi.otavanopisto.muikku.schooldata.entity.UserGroup in project muikku by otavanopisto.

the class SchoolDataSearchReindexListener method reindexUserGroups.

private boolean reindexUserGroups() {
    try {
        List<UserGroupEntity> userGroups = userGroupEntityController.listUserGroupEntities();
        int groupIndex = getOffset("groupIndex");
        if (groupIndex < userGroups.size()) {
            int last = Math.min(userGroups.size(), groupIndex + getBatchSize());
            for (int i = groupIndex; i < last; i++) {
                UserGroupEntity groupEntity = userGroups.get(i);
                UserGroup userGroup = userGroupController.findUserGroup(groupEntity.getSchoolDataSource(), groupEntity.getIdentifier());
                try {
                    indexer.index(UserGroup.class.getSimpleName(), userGroup);
                } catch (Exception e) {
                    logger.log(Level.WARNING, "could not index UserGroup #" + groupEntity.getSchoolDataSource() + '/' + groupEntity.getIdentifier(), e);
                }
            }
            logger.log(Level.INFO, "Reindexed batch of usergroups (" + groupIndex + "-" + last + ")");
            setOffset("groupIndex", groupIndex + getBatchSize());
            return false;
        } else
            return true;
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Could not finish indexing usergroup entities.", ex);
        return true;
    }
}
Also used : UserGroupEntity(fi.otavanopisto.muikku.model.users.UserGroupEntity) UserGroup(fi.otavanopisto.muikku.schooldata.entity.UserGroup)

Aggregations

UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)6 UserGroup (fi.otavanopisto.muikku.schooldata.entity.UserGroup)6 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)2 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Permission (fi.otavanopisto.muikku.model.security.Permission)1 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 LogProvider (fi.otavanopisto.muikku.plugins.commonlog.LogProvider)1 CommunicatorMessageRecipientUserGroup (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup)1 GroupUser (fi.otavanopisto.muikku.schooldata.entity.GroupUser)1 User (fi.otavanopisto.muikku.schooldata.entity.User)1 SearchProvider (fi.otavanopisto.muikku.search.SearchProvider)1 SearchResult (fi.otavanopisto.muikku.search.SearchResult)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)1