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