use of fi.otavanopisto.muikku.model.users.UserGroupEntity in project muikku by otavanopisto.
the class PyramusUpdater method updateStudyProgramme.
public void updateStudyProgramme(Long pyramusId) {
StudyProgramme studentGroup = pyramusClient.get().get(String.format("/students/studyProgrammes/%d", pyramusId), StudyProgramme.class);
String identifier = identifierMapper.getStudyProgrammeIdentifier(pyramusId);
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, identifier, true);
if (studentGroup == null) {
if (userGroupEntity != null)
fireUserGroupRemoved(identifier);
} else {
if (userGroupEntity == null) {
fireUserGroupDiscovered(identifier);
} else {
fireUserGroupUpdated(identifier);
}
}
}
use of fi.otavanopisto.muikku.model.users.UserGroupEntity in project muikku by otavanopisto.
the class DefaultSchoolDataUserGroupListener method onSchoolDataUserGroupUserUpdatedEvent.
public void onSchoolDataUserGroupUserUpdatedEvent(@Observes SchoolDataUserGroupUserUpdatedEvent event) {
UserGroupUserEntity userGroupUserEntity = userGroupEntityController.findUserGroupUserEntityByDataSourceAndIdentifier(event.getDataSource(), event.getIdentifier());
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(event.getUserGroupDataSource(), event.getUserGroupIdentifier());
UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierController.findUserSchoolDataIdentifierByDataSourceAndIdentifier(event.getUserDataSource(), event.getUserIdentifier());
if ((userGroupUserEntity != null) && (userGroupEntity != null) && (userSchoolDataIdentifier != null)) {
userGroupEntityController.updateUserGroupEntity(userGroupUserEntity, userGroupEntity);
userGroupEntityController.updateUserSchoolDataIdentifier(userGroupUserEntity, userSchoolDataIdentifier);
} else
logger.warning(String.format("Couldn't find userGroupUserEntity (%s) or userGroupEntity (%s)", event.getIdentifier(), event.getUserGroupIdentifier()));
}
use of fi.otavanopisto.muikku.model.users.UserGroupEntity in project muikku by otavanopisto.
the class DefaultSchoolDataUserGroupListener method onSchoolDataUserGroupUserDiscoveredEvent.
public void onSchoolDataUserGroupUserDiscoveredEvent(@Observes SchoolDataUserGroupUserDiscoveredEvent event) {
String discoverId = getUserGroupUserDiscoveryId(event.getDataSource(), event.getIdentifier());
if (discoveredUserGroupUsers.containsKey(discoverId)) {
event.setDiscoveredUserGroupUserEntityId(discoveredUserGroupUsers.get(discoverId));
return;
}
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(event.getUserGroupDataSource(), event.getUserGroupIdentifier(), true);
if (userGroupEntity != null) {
if (!userGroupEntity.getArchived()) {
UserGroupUserEntity userGroupUserEntity = userGroupEntityController.findUserGroupUserEntityByDataSourceAndIdentifier(event.getDataSource(), event.getIdentifier(), true);
if ((userGroupUserEntity == null) || (userGroupUserEntity.getArchived())) {
UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierController.findUserSchoolDataIdentifierByDataSourceAndIdentifier(event.getUserDataSource(), event.getUserIdentifier());
if (userSchoolDataIdentifier != null) {
if (userGroupUserEntity == null) {
userGroupUserEntity = userGroupEntityController.createUserGroupUserEntity(userGroupEntity, event.getDataSource(), event.getIdentifier(), userSchoolDataIdentifier);
} else {
userGroupEntityController.unarchiveUserGroupUserEntity(userGroupUserEntity);
userGroupEntityController.updateUserSchoolDataIdentifier(userGroupUserEntity, userSchoolDataIdentifier);
}
discoveredUserGroupUsers.put(discoverId, userGroupUserEntity.getId());
event.setDiscoveredUserGroupUserEntityId(userGroupUserEntity.getId());
} else {
logger.warning("could not add group user because UserSchoolDataIdentifier for " + event.getUserIdentifier() + "/" + event.getUserDataSource() + " wasn't found");
}
} else {
logger.warning("UserGroupUserEntity for " + event.getIdentifier() + "/" + event.getDataSource() + " already exists");
}
}
} else {
logger.warning("could not init user group user because usergroup #" + event.getUserGroupIdentifier() + '/' + event.getUserGroupDataSource() + " could not be found");
}
}
use of fi.otavanopisto.muikku.model.users.UserGroupEntity in project muikku by otavanopisto.
the class DefaultSchoolDataUserGroupListener method onSchoolDataUserGroupDiscoveredEvent.
public void onSchoolDataUserGroupDiscoveredEvent(@Observes SchoolDataUserGroupDiscoveredEvent event) {
String discoverId = getUserGroupDiscoveryId(event.getDataSource(), event.getIdentifier());
if (discoveredUserGroups.containsKey(discoverId)) {
event.setDiscoveredUserGroupEntityId(discoveredUserGroups.get(discoverId));
return;
}
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(event.getDataSource(), event.getIdentifier(), true);
if ((userGroupEntity == null) || (userGroupEntity.getArchived())) {
if (userGroupEntity == null) {
userGroupEntity = userGroupEntityController.createUserGroupEntity(event.getDataSource(), event.getIdentifier());
} else {
userGroupEntityController.unarchiveUserGroupEntity(userGroupEntity);
}
discoveredUserGroups.put(discoverId, userGroupEntity.getId());
event.setDiscoveredUserGroupEntityId(userGroupEntity.getId());
} else {
logger.warning("UserGroupEntity for " + event.getIdentifier() + "/" + event.getDataSource() + " already exists");
}
}
use of fi.otavanopisto.muikku.model.users.UserGroupEntity in project muikku by otavanopisto.
the class WorkspacePermissionsManagementBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.WORKSPACE_MANAGE_PERMISSIONS, workspaceEntity)) {
return NavigationRules.NOT_FOUND;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
userGroupBeans = new ArrayList<WorkspacePermissionsManagementBackingBean.UserGroupBean>();
permissions = new ArrayList<Permission>();
// TODO: atm we only support the sign up permission
Permission permission = permissionController.findByName(MuikkuPermissions.WORKSPACE_SIGNUP);
permissions.add(permission);
List<UserGroupEntity> userGroupEntities;
String permissionGroupIds = pluginSettingsController.getPluginSetting("workspace", "permission-group-ids");
if (permissionGroupIds == null) {
userGroupEntities = userGroupEntityController.listUserGroupEntities();
} else {
userGroupEntities = new ArrayList<UserGroupEntity>();
String[] idArray = permissionGroupIds.split(",");
for (int i = 0; i < idArray.length; i++) {
Long groupId = NumberUtils.createLong(idArray[i]);
if (groupId != null) {
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityById(groupId);
if (userGroupEntity == null) {
logger.warning(String.format("Missing group %d in plugin setting workspace.permission-group-ids", groupId));
} else {
userGroupEntities.add(userGroupEntity);
}
} else {
logger.warning(String.format("Malformatted plugin setting workspace.permission-group-ids %s", permissionGroupIds));
}
}
}
for (UserGroupEntity userGroupEntity : userGroupEntities) {
UserGroup userGroup = userGroupController.findUserGroup(userGroupEntity);
userGroupBeans.add(new UserGroupBean(userGroupEntity.getId(), userGroup.getName()));
}
Collections.sort(userGroupBeans, new Comparator<UserGroupBean>() {
@Override
public int compare(UserGroupBean o1, UserGroupBean o2) {
return o1.getName().compareTo(o2.getName());
}
});
return null;
}
Aggregations