Search in sources :

Example 1 with Curriculum

use of fi.otavanopisto.muikku.schooldata.entity.Curriculum 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 2 with Curriculum

use of fi.otavanopisto.muikku.schooldata.entity.Curriculum in project muikku by otavanopisto.

the class CoursePickerRESTService method listCurriculums.

@GET
@Path("/curriculums")
@RESTPermit(requireLoggedIn = false, handling = Handling.UNSECURED)
public Response listCurriculums() {
    schoolDataBridgeSessionController.startSystemSession();
    try {
        List<Curriculum> curriculums = courseMetaController.listCurriculums();
        List<CoursePickerCurriculum> restCurriculums = new ArrayList<CoursePickerCurriculum>();
        for (Curriculum curriculum : curriculums) restCurriculums.add(new CoursePickerCurriculum(curriculum.getIdentifier().toId(), curriculum.getName()));
        restCurriculums.sort((CoursePickerCurriculum a, CoursePickerCurriculum b) -> {
            return b.getName().compareTo(a.getName());
        });
        return Response.ok(restCurriculums).build();
    } finally {
        schoolDataBridgeSessionController.endSystemSession();
    }
}
Also used : ArrayList(java.util.ArrayList) Curriculum(fi.otavanopisto.muikku.schooldata.entity.Curriculum) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

Curriculum (fi.otavanopisto.muikku.schooldata.entity.Curriculum)2 ArrayList (java.util.ArrayList)2 PyramusCurriculum (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCurriculum)1 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)1 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1