Search in sources :

Example 1 with School

use of fi.otavanopisto.pyramus.rest.model.School in project muikku by otavanopisto.

the class PyramusUserSchoolDataBridge method createStudentEntities.

private List<User> createStudentEntities(Student... students) {
    Map<Long, StudyProgramme> studyProgrammeMap = new HashMap<Long, StudyProgramme>();
    List<User> users = new ArrayList<User>();
    for (Student student : students) {
        StudyProgramme studyProgramme;
        String nationality = null;
        String language = null;
        String municipality = null;
        String school = null;
        boolean hidden = false;
        if (student.getStudyProgrammeId() != null) {
            if (!studyProgrammeMap.containsKey(student.getStudyProgrammeId())) {
                StudyProgramme studyProgrammeO = pyramusClient.get("/students/studyProgrammes/" + student.getStudyProgrammeId(), StudyProgramme.class);
                if (studyProgrammeO != null)
                    studyProgrammeMap.put(student.getStudyProgrammeId(), studyProgrammeO);
            }
            studyProgramme = studyProgrammeMap.get(student.getStudyProgrammeId());
        } else {
            studyProgramme = null;
        }
        if (student.getNationalityId() != null) {
            Nationality nationalityO = pyramusClient.get("/students/nationalities/" + student.getNationalityId(), Nationality.class);
            if (nationalityO != null)
                nationality = nationalityO.getName();
        }
        if (student.getLanguageId() != null) {
            Language languageO = pyramusClient.get("/students/languages/" + student.getLanguageId(), Language.class);
            if (languageO != null)
                language = languageO.getName();
        }
        if (student.getMunicipalityId() != null) {
            Municipality municipalityO = pyramusClient.get("/students/municipalities/" + student.getMunicipalityId(), Municipality.class);
            if (municipalityO != null)
                municipality = municipalityO.getName();
        }
        if (student.getSchoolId() != null) {
            School schoolO = pyramusClient.get("/schools/schools/" + student.getSchoolId(), School.class);
            if (schoolO != null)
                school = schoolO.getName();
        }
        if (student.getPersonId() != null) {
            Person person = pyramusClient.get("/persons/persons/" + student.getPersonId(), Person.class);
            if (person != null)
                hidden = person.getSecureInfo() != null ? person.getSecureInfo() : false;
        }
        String curriculumIdentifier = student.getCurriculumId() != null ? identifierMapper.getCurriculumIdentifier(student.getCurriculumId()).toId() : null;
        // #3069: User has evaluation fees if their study program begins with Internetix/
        boolean evaluationFees = studyProgramme != null && StringUtils.startsWith(studyProgramme.getName(), "Internetix/");
        users.add(entityFactory.createEntity(student, studyProgramme, nationality, language, municipality, school, student.getStudyStartDate(), student.getStudyEndDate(), student.getStudyTimeEnd(), evaluationFees, hidden, curriculumIdentifier));
    }
    return users;
}
Also used : User(fi.otavanopisto.muikku.schooldata.entity.User) PyramusGroupUser(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusGroupUser) StudentGroupUser(fi.otavanopisto.pyramus.rest.model.StudentGroupUser) GroupUser(fi.otavanopisto.muikku.schooldata.entity.GroupUser) Municipality(fi.otavanopisto.pyramus.rest.model.Municipality) StudyProgramme(fi.otavanopisto.pyramus.rest.model.StudyProgramme) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Student(fi.otavanopisto.pyramus.rest.model.Student) StudentGroupStudent(fi.otavanopisto.pyramus.rest.model.StudentGroupStudent) Nationality(fi.otavanopisto.pyramus.rest.model.Nationality) School(fi.otavanopisto.pyramus.rest.model.School) Language(fi.otavanopisto.pyramus.rest.model.Language) Person(fi.otavanopisto.pyramus.rest.model.Person)

Aggregations

PyramusGroupUser (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusGroupUser)1 GroupUser (fi.otavanopisto.muikku.schooldata.entity.GroupUser)1 User (fi.otavanopisto.muikku.schooldata.entity.User)1 Language (fi.otavanopisto.pyramus.rest.model.Language)1 Municipality (fi.otavanopisto.pyramus.rest.model.Municipality)1 Nationality (fi.otavanopisto.pyramus.rest.model.Nationality)1 Person (fi.otavanopisto.pyramus.rest.model.Person)1 School (fi.otavanopisto.pyramus.rest.model.School)1 Student (fi.otavanopisto.pyramus.rest.model.Student)1 StudentGroupStudent (fi.otavanopisto.pyramus.rest.model.StudentGroupStudent)1 StudentGroupUser (fi.otavanopisto.pyramus.rest.model.StudentGroupUser)1 StudyProgramme (fi.otavanopisto.pyramus.rest.model.StudyProgramme)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1