use of fi.otavanopisto.pyramus.rest.model.CourseParticipationType in project muikku by otavanopisto.
the class PyramusWorkspaceSchoolDataBridge method updateWorkspaceStudentActivity.
@Override
public void updateWorkspaceStudentActivity(WorkspaceUser workspaceUser, boolean active) {
Long courseId = identifierMapper.getPyramusCourseId(workspaceUser.getWorkspaceIdentifier().getIdentifier());
Long courseStudentId = identifierMapper.getPyramusCourseStudentId(workspaceUser.getIdentifier().getIdentifier());
CourseStudent courseStudent = pyramusClient.get(String.format("/courses/courses/%d/students/%d", courseId, courseStudentId), CourseStudent.class);
if (courseStudent != null) {
Long currentParticipationType = courseStudent.getParticipationTypeId();
if (pyramusStudentActivityMapper.isActive(currentParticipationType) != active) {
Long newParticipationType = active ? pyramusStudentActivityMapper.toActive(currentParticipationType) : pyramusStudentActivityMapper.toInactive(currentParticipationType);
if (newParticipationType == null) {
newParticipationType = currentParticipationType;
}
CourseParticipationType participationType = pyramusClient.get(String.format("/courses/participationTypes/%d", newParticipationType), CourseParticipationType.class);
if (participationType != null) {
courseStudent.setParticipationTypeId(participationType.getId());
pyramusClient.put(String.format("/courses/courses/%d/students/%d", courseId, courseStudentId), courseStudent);
} else {
logger.warning(String.format("Could not find participation type %d", newParticipationType));
}
}
}
}
Aggregations