Search in sources :

Example 1 with StudyProgramme

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);
        }
    }
}
Also used : StudyProgramme(fi.otavanopisto.pyramus.rest.model.StudyProgramme) UserGroupEntity(fi.otavanopisto.muikku.model.users.UserGroupEntity)

Example 2 with StudyProgramme

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;
}
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)

Example 3 with StudyProgramme

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)));
}
Also used : StudyProgramme(fi.otavanopisto.pyramus.rest.model.StudyProgramme) StudyProgrammeCategory(fi.otavanopisto.pyramus.rest.model.StudyProgrammeCategory) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with StudyProgramme

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)));
}
Also used : StudyProgramme(fi.otavanopisto.pyramus.rest.model.StudyProgramme) StudyProgrammeCategory(fi.otavanopisto.pyramus.rest.model.StudyProgrammeCategory) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

StudyProgramme (fi.otavanopisto.pyramus.rest.model.StudyProgramme)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)2 StudyProgrammeCategory (fi.otavanopisto.pyramus.rest.model.StudyProgrammeCategory)2 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)1 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 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1