use of fi.otavanopisto.muikku.plugins.schooldatapyramus.PyramusIdentifierMapper.StudentGroupType in project muikku by otavanopisto.
the class PyramusSchoolDataUserListener method handlePyramusUserUpdated.
private void handlePyramusUserUpdated(SchoolDataIdentifier identifier) {
Long pyramusStudentId = identifierMapper.getPyramusStudentId(identifier.getIdentifier());
if (pyramusStudentId != null) {
Student student = pyramusClient.get().get(String.format("/students/students/%d", pyramusStudentId), Student.class);
if (student != null) {
Long pyramusStudyProgrammeId = student.getStudyProgrammeId();
if (pyramusStudyProgrammeId != null) {
String userGroupIdentifier = identifierMapper.getStudyProgrammeIdentifier(pyramusStudyProgrammeId);
boolean found = false;
boolean isActive = !student.getArchived() && (student.getStudyEndDate() == null || student.getStudyEndDate().isAfter(OffsetDateTime.now()));
if (!isActive) {
schoolDataUserInactiveEvent.fire(new SchoolDataUserInactiveEvent(identifier.getDataSource(), identifier.getIdentifier()));
}
// Remove StudyProgrammeGroups
UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierController.findUserSchoolDataIdentifierByDataSourceAndIdentifier(identifier.getDataSource(), identifier.getIdentifier());
List<UserGroupUserEntity> userGroupUsers = userGroupEntityController.listUserGroupUsersByUserSchoolDataIdentifier(userSchoolDataIdentifier);
for (UserGroupUserEntity userGroupUser : userGroupUsers) {
UserGroupEntity userGroup = userGroupUser.getUserGroupEntity();
StudentGroupType studentGroupType = identifierMapper.getStudentGroupType(userGroup.getIdentifier());
if (studentGroupType == StudentGroupType.STUDYPROGRAMME) {
boolean archived = Boolean.TRUE.equals(userGroupUser.getArchived());
if (!archived && !isActive) {
fireUserGroupUserRemoved(userGroupUser.getIdentifier(), userGroup.getIdentifier(), identifier.getIdentifier());
} else {
found = !archived;
}
}
}
if (!found && isActive) {
String userGroupUserIdentifier = identifierMapper.getStudyProgrammeStudentIdentifier(pyramusStudentId);
fireUserGroupUserDiscovered(userGroupUserIdentifier, userGroupIdentifier, identifier.getIdentifier());
}
}
}
}
}
use of fi.otavanopisto.muikku.plugins.schooldatapyramus.PyramusIdentifierMapper.StudentGroupType in project muikku by otavanopisto.
the class PyramusSchoolDataUserListener method handlePyramusUserRemoved.
private void handlePyramusUserRemoved(SchoolDataIdentifier identifier) {
UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierController.findUserSchoolDataIdentifierByDataSourceAndIdentifier(identifier.getDataSource(), identifier.getIdentifier());
List<UserGroupUserEntity> userGroupUsers = userGroupEntityController.listUserGroupUsersByUserSchoolDataIdentifier(userSchoolDataIdentifier);
for (UserGroupUserEntity userGroupUser : userGroupUsers) {
UserGroupEntity userGroup = userGroupUser.getUserGroupEntity();
StudentGroupType studentGroupType = identifierMapper.getStudentGroupType(userGroup.getIdentifier());
if (studentGroupType == StudentGroupType.STUDYPROGRAMME) {
fireUserGroupUserRemoved(userGroupUser.getIdentifier(), userGroup.getIdentifier(), identifier.getIdentifier());
}
}
}
Aggregations