use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class PyramusCourseMetaSchoolDataBridge method listCurriculums.
@Override
public List<Curriculum> listCurriculums() {
List<Curriculum> result = new ArrayList<>();
fi.otavanopisto.pyramus.rest.model.Curriculum[] curriculums = pyramusClient.get("/common/curriculums?filterArchived=true", fi.otavanopisto.pyramus.rest.model.Curriculum[].class);
if (curriculums != null) {
for (fi.otavanopisto.pyramus.rest.model.Curriculum curriculum : curriculums) {
SchoolDataIdentifier identifier = pyramusIdentifierMapper.getCurriculumIdentifier(curriculum.getId());
result.add(new PyramusCurriculum(identifier, curriculum.getName()));
}
}
return result;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class PyramusGradingSchoolDataBridge method listCompositeGradingScales.
@Override
public List<CompositeGradingScale> listCompositeGradingScales() {
List<CompositeGradingScale> localGradingScales = new ArrayList<fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale>();
fi.otavanopisto.pyramus.rest.model.composite.CompositeGradingScale[] restGradingScales = pyramusClient.get("/composite/gradingScales/", fi.otavanopisto.pyramus.rest.model.composite.CompositeGradingScale[].class);
Set<Long> gradingScaleFilter = getGradingScaleFilter();
for (int i = 0; i < restGradingScales.length; i++) {
if (!gradingScaleFilter.isEmpty() && !gradingScaleFilter.contains(restGradingScales[i].getScaleId())) {
continue;
}
List<CompositeGrade> localGrades = new ArrayList<CompositeGrade>();
List<fi.otavanopisto.pyramus.rest.model.composite.CompositeGrade> restGrades = restGradingScales[i].getGrades();
for (fi.otavanopisto.pyramus.rest.model.composite.CompositeGrade restGrade : restGrades) {
SchoolDataIdentifier gradeIdentifier = identifierMapper.getGradeIdentifier(restGrade.getGradeId());
localGrades.add(new PyramusCompositeGrade(gradeIdentifier.getIdentifier(), restGrade.getGradeName()));
}
SchoolDataIdentifier gradingScaleIdentifier = identifierMapper.getGradingScaleIdentifier(restGradingScales[i].getScaleId());
localGradingScales.add(new PyramusCompositeGradingScale(gradingScaleIdentifier.getIdentifier(), restGradingScales[i].getScaleName(), localGrades));
}
return localGradingScales;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class PyramusUpdater method updateInactiveWorkspaceStudents.
/**
* Updates inactive course students from Pyramus
*
* @param courseId id of course in Pyramus
* @return count of updated course students
*/
public int updateInactiveWorkspaceStudents(WorkspaceEntity workspaceEntity) {
int count = 0;
Long courseId = identifierMapper.getPyramusCourseId(workspaceEntity.getIdentifier());
CourseStudent[] nonActiveCourseStudents = pyramusClient.get().get("/courses/courses/" + courseId + "/students?filterArchived=false&activeStudents=false", CourseStudent[].class);
if (nonActiveCourseStudents != null) {
for (CourseStudent nonActiveCourseStudent : nonActiveCourseStudents) {
SchoolDataIdentifier workspaceUserIdentifier = toIdentifier(identifierMapper.getWorkspaceStudentIdentifier(nonActiveCourseStudent.getId()));
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(workspaceUserIdentifier);
if (workspaceUserEntity != null) {
if (nonActiveCourseStudent.getArchived()) {
fireCourseStudentRemoved(nonActiveCourseStudent.getId(), nonActiveCourseStudent.getStudentId(), nonActiveCourseStudent.getCourseId());
count++;
} else {
fireCourseStudentUpdated(nonActiveCourseStudent, false);
count++;
}
} else {
fireCourseStudentDiscovered(nonActiveCourseStudent, false);
count++;
}
}
}
return count;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class PyramusUpdater method updateCourseStudent.
/**
* Updates course student from Pyramus
*
* @param courseStudentId id of course student in Pyramus
* @param courseId id of course in Pyramus
* @param studentId id of student in Pyramus
* @return returns whether new course student was created or not
*/
public boolean updateCourseStudent(Long courseStudentId, Long courseId, Long studentId) {
String workspaceIdentifier = identifierMapper.getWorkspaceIdentifier(courseId);
String identifier = identifierMapper.getWorkspaceStudentIdentifier(courseStudentId);
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, workspaceIdentifier);
if (workspaceEntity == null) {
updateCourse(courseId);
workspaceEntity = workspaceController.findWorkspaceEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, workspaceIdentifier);
}
if (workspaceEntity != null) {
SchoolDataIdentifier workspaceUserIdentifier = new SchoolDataIdentifier(identifier, SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE);
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(workspaceUserIdentifier);
CourseStudent courseStudent = pyramusClient.get().get("/courses/courses/" + courseId + "/students/" + courseStudentId, CourseStudent.class);
if (courseStudent != null && !courseStudent.getArchived()) {
boolean studentActive = isStudentActive(courseStudent.getStudentId());
if (workspaceUserEntity == null) {
fireCourseStudentDiscovered(courseStudent, studentActive);
return true;
} else {
fireCourseStudentUpdated(courseStudent, studentActive);
}
} else {
if (workspaceUserEntity != null) {
fireCourseStudentRemoved(courseStudentId, studentId, courseId);
}
}
}
return false;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class PyramusUpdater method updateActiveWorkspaceStudents.
/**
* Updates active course students from Pyramus
*
* @param courseId id of course in Pyramus
* @return count of updated course students
*/
public int updateActiveWorkspaceStudents(WorkspaceEntity workspaceEntity) {
int count = 0;
Long courseId = identifierMapper.getPyramusCourseId(workspaceEntity.getIdentifier());
CourseStudent[] courseStudents = pyramusClient.get().get("/courses/courses/" + courseId + "/students?filterArchived=false&activeStudents=true", CourseStudent[].class);
if (courseStudents != null) {
for (CourseStudent courseStudent : courseStudents) {
SchoolDataIdentifier workspaceUserIdentifier = toIdentifier(identifierMapper.getWorkspaceStudentIdentifier(courseStudent.getId()));
WorkspaceUserEntity workspaceUserEntity = workspaceUserEntityController.findWorkspaceUserEntityByWorkspaceUserIdentifierIncludeArchived(workspaceUserIdentifier);
if (courseStudent.getArchived()) {
if (workspaceUserEntity != null) {
fireCourseStudentRemoved(courseStudent.getId(), courseStudent.getStudentId(), courseStudent.getCourseId());
count++;
}
} else {
if (workspaceUserEntity == null) {
fireCourseStudentDiscovered(courseStudent, true);
count++;
} else {
fireCourseStudentUpdated(courseStudent, true);
}
}
}
}
return count;
}
Aggregations