Exemplo n.º 1
0
  // TODO: Remove this @RequiresPermissions, as it is added to test permission workflow
  // @RequiresPermissions(value = "lookup:semester")
  public JsonObject buildSemesters(final List<Semester> pSemesters, final UriInfo pUriInfo) {

    JsonObjectBuilder object = Json.createObjectBuilder();
    JsonArrayBuilder children = Json.createArrayBuilder();
    LocalCache localCache = new LocalCache();
    for (Semester readOnly : pSemesters) {
      children.add(toJson(readOnly, pUriInfo, localCache));
    }
    object.add("entries", children);
    localCache.invalidate();
    return object.build();
  }
Exemplo n.º 2
0
  @Override
  public void build(
      JsonObjectBuilder pBuilder, Examiner pReadOnly, UriInfo pUriInfo, LocalCache pLocalCache) {
    if (pReadOnly.getId() != null) {
      pBuilder.add("id", pReadOnly.getId());
    }

    Course course =
        (Course)
            pLocalCache.cache(() -> pReadOnly.getCourse(), pReadOnly.getCourseId(), Course.class);

    pBuilder.add("courseId", course.getId());
    pBuilder.add("courseNo", course.getNo());
    pBuilder.add("courseTitle", course.getTitle());
    pBuilder.add("courseCrHr", course.getCrHr());
    pBuilder.add("year", course.getYear());
    pBuilder.add("semester", course.getSemester());
    pBuilder.add("syllabusId", course.getSyllabusId());

    if (!StringUtils.isEmpty(pReadOnly.getPreparerId())) {
      Teacher teacher =
          (Teacher)
              pLocalCache.cache(
                  () -> pReadOnly.getPreparer(), pReadOnly.getPreparerId(), Teacher.class);

      pBuilder.add("preparerId", teacher.getId());
      pBuilder.add("preparerName", teacher.getName());
    }

    if (!StringUtils.isEmpty(pReadOnly.getScrutinizerId())) {
      Teacher teacher =
          (Teacher)
              pLocalCache.cache(
                  () -> pReadOnly.getScrutinizer(), pReadOnly.getScrutinizerId(), Teacher.class);

      pBuilder.add("scrutinizerId", teacher.getId());
      pBuilder.add("scrutinizerName", teacher.getName());
    }

    Department department =
        (Department)
            pLocalCache.cache(
                () -> course.getOfferedBy(), course.getOfferedDepartmentId(), Department.class);

    pBuilder.add("courseOfferedByDepartmentId", department.getId());
    pBuilder.add("courseOfferedByDepartmentName", department.getShortName());

    Syllabus syllabus =
        (Syllabus)
            pLocalCache.cache(() -> course.getSyllabus(), course.getSyllabusId(), Syllabus.class);

    Program program =
        (Program)
            pLocalCache.cache(() -> syllabus.getProgram(), syllabus.getProgramId(), Program.class);

    Department offeredToDepartment =
        (Department)
            pLocalCache.cache(
                () -> program.getDepartment(), program.getDepartmentId(), Department.class);

    pBuilder.add("courseOfferedToDepartmentId", offeredToDepartment.getId());
    pBuilder.add("courseOfferedToDepartmentName", offeredToDepartment.getShortName());
  }