use of fi.otavanopisto.pyramus.rest.model.StudyProgramme in project muikku by otavanopisto.
the class PyramusUpdater method updateStudyProgramme.
public void updateStudyProgramme(Long pyramusId) {
StudyProgramme studentGroup = pyramusClient.get().get(String.format("/students/studyProgrammes/%d", pyramusId), StudyProgramme.class);
String identifier = identifierMapper.getStudyProgrammeIdentifier(pyramusId);
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityByDataSourceAndIdentifier(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, identifier, true);
if (studentGroup == null) {
if (userGroupEntity != null)
fireUserGroupRemoved(identifier);
} else {
if (userGroupEntity == null) {
fireUserGroupDiscovered(identifier);
} else {
fireUserGroupUpdated(identifier);
}
}
}
use of fi.otavanopisto.pyramus.rest.model.StudyProgramme 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;
}
use of fi.otavanopisto.pyramus.rest.model.StudyProgramme in project muikku by otavanopisto.
the class PyramusMocks method mockStudyProgrammes.
private static void mockStudyProgrammes() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
StudyProgrammeCategory spc = new StudyProgrammeCategory(1l, "All Study Programmes", 1l, false);
StudyProgramme sp = new StudyProgramme(1l, "test", "Test Study Programme", 1l, false);
StudyProgramme[] sps = { sp };
StudyProgrammeCategory[] spcs = { spc };
stubFor(get(urlEqualTo("/1/students/studyProgrammes")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(sps)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammes/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(sp)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammeCategories")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(spcs)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammeCategories/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(spc)).withStatus(200)));
}
use of fi.otavanopisto.pyramus.rest.model.StudyProgramme in project muikku by otavanopisto.
the class PyramusMocksRest method mockStudyProgrammes.
private static void mockStudyProgrammes(List<String> payloads) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
StudyProgrammeCategory spc = new StudyProgrammeCategory(1l, "All Study Programmes", 1l, false);
StudyProgramme sp = new StudyProgramme(1l, "test", "Test Study Programme", 1l, false);
StudyProgramme[] sps = { sp };
StudyProgrammeCategory[] spcs = { spc };
stubFor(get(urlEqualTo("/1/students/studyProgrammes")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(sps)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammes/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(sp)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammeCategories")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(spcs)).withStatus(200)));
stubFor(get(urlEqualTo("/1/students/studyProgrammeCategories/1")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(spc)).withStatus(200)));
}
Aggregations