Search in sources :

Example 1 with CompositeGradingScale

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

the class Evaluation2RESTService method listGrades.

@GET
@Path("/compositeGradingScales")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listGrades() {
    if (!sessionController.isLoggedIn()) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
        return Response.status(Status.FORBIDDEN).build();
    }
    List<WorkspaceGradingScale> restGradingScales = new ArrayList<WorkspaceGradingScale>();
    List<CompositeGradingScale> gradingScales = gradingController.listCompositeGradingScales();
    for (CompositeGradingScale gradingScale : gradingScales) {
        List<CompositeGrade> grades = gradingScale.getGrades();
        List<WorkspaceGrade> restGrades = new ArrayList<WorkspaceGrade>();
        for (CompositeGrade grade : grades) {
            restGrades.add(new WorkspaceGrade(grade.getGradeName(), grade.getGradeIdentifier(), gradingScale.getSchoolDataSource()));
        }
        restGradingScales.add(new WorkspaceGradingScale(gradingScale.getScaleName(), gradingScale.getScaleIdentifier(), gradingScale.getSchoolDataSource(), restGrades));
    }
    return Response.ok(restGradingScales).build();
}
Also used : WorkspaceGrade(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade) ArrayList(java.util.ArrayList) CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) WorkspaceGradingScale(fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 2 with CompositeGradingScale

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

the class PyramusGradingSchoolDataBridge method listCompositeGradingScales.

@Override
public List<CompositeGradingScale> listCompositeGradingScales() {
    List<CompositeGradingScale> localGradingScales = new ArrayList<fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale>();
    fi.otavanopisto.pyramus.rest.model.composite.CompositeGradingScale[] restGradingScales = pyramusClient.get("/composite/gradingScales/", fi.otavanopisto.pyramus.rest.model.composite.CompositeGradingScale[].class);
    Set<Long> gradingScaleFilter = getGradingScaleFilter();
    for (int i = 0; i < restGradingScales.length; i++) {
        if (!gradingScaleFilter.isEmpty() && !gradingScaleFilter.contains(restGradingScales[i].getScaleId())) {
            continue;
        }
        List<CompositeGrade> localGrades = new ArrayList<CompositeGrade>();
        List<fi.otavanopisto.pyramus.rest.model.composite.CompositeGrade> restGrades = restGradingScales[i].getGrades();
        for (fi.otavanopisto.pyramus.rest.model.composite.CompositeGrade restGrade : restGrades) {
            SchoolDataIdentifier gradeIdentifier = identifierMapper.getGradeIdentifier(restGrade.getGradeId());
            localGrades.add(new PyramusCompositeGrade(gradeIdentifier.getIdentifier(), restGrade.getGradeName()));
        }
        SchoolDataIdentifier gradingScaleIdentifier = identifierMapper.getGradingScaleIdentifier(restGradingScales[i].getScaleId());
        localGradingScales.add(new PyramusCompositeGradingScale(gradingScaleIdentifier.getIdentifier(), restGradingScales[i].getScaleName(), localGrades));
    }
    return localGradingScales;
}
Also used : SchoolDataIdentifier(fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier) ArrayList(java.util.ArrayList) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) PyramusCompositeGradingScale(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGradingScale) CompositeGrade(fi.otavanopisto.muikku.schooldata.entity.CompositeGrade) PyramusCompositeGrade(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade) PyramusCompositeGradingScale(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGradingScale) CompositeGradingScale(fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)

Aggregations

CompositeGrade (fi.otavanopisto.muikku.schooldata.entity.CompositeGrade)2 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)2 ArrayList (java.util.ArrayList)2 WorkspaceGrade (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGrade)1 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)1 PyramusCompositeGrade (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGrade)1 PyramusCompositeGradingScale (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCompositeGradingScale)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