use of fi.otavanopisto.pyramus.rest.model.Nationality 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;
}
Aggregations