Search in sources :

Example 46 with SchoolDataIdentifier

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) PyramusCurriculum(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCurriculum) ArrayList(java.util.ArrayList) Curriculum(fi.otavanopisto.muikku.schooldata.entity.Curriculum) PyramusCurriculum(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCurriculum)

Example 47 with SchoolDataIdentifier

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) ArrayList(java.util.ArrayList) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) PyramusCompositeGradingScale(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGradingScale) CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) PyramusCompositeGradingScale(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGradingScale) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)

Example 48 with SchoolDataIdentifier

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Example 49 with SchoolDataIdentifier

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Example 50 with SchoolDataIdentifier

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;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) RoleSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier) UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) CourseStudent(fi.otavanopisto.pyramus.rest.model.CourseStudent)

Aggregations

SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)130 Path (javax.ws.rs.Path)63 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)59 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)58 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)53 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)50 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)48 ArrayList (java.util.ArrayList)38 GET (javax.ws.rs.GET)36 User (fi.otavanopisto.muikku.schooldata.entity.User)30 HashMap (java.util.HashMap)19 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)13 SearchResult (fi.otavanopisto.muikku.search.SearchResult)13 WorkspaceUser (fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser)12 Date (java.util.Date)11 POST (javax.ws.rs.POST)11 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)10 WorkspaceAssessment (fi.otavanopisto.muikku.schooldata.entity.WorkspaceAssessment)10 HashSet (java.util.HashSet)9 PUT (javax.ws.rs.PUT)9