@Test public void testApplyOptionalField() { List<EntityBody> entities = new ArrayList<EntityBody>(); EntityBody body = new EntityBody(); body.putAll(studentEntity.getBody()); body.put("id", studentEntity.getEntityId()); entities.add(body); entities = studentTranscriptOptionalFieldAppender.applyOptionalField(entities, null); assertEquals("Should match", 1, entities.size()); EntityBody transcripts = (EntityBody) entities.get(0).get("transcript"); assertNotNull("Should be not null", transcripts); List<EntityBody> studentSectionAssociations = (List<EntityBody>) transcripts.get("studentSectionAssociations"); assertNotNull("Should be not null", studentSectionAssociations); assertEquals("Should match", 2, studentSectionAssociations.size()); EntityBody section = (EntityBody) studentSectionAssociations.get(0).get("sections"); assertNotNull("Should not be null", section); assertNotNull("Should not be null", section.get("sessions")); assertEquals("Should match", "1999", ((EntityBody) section.get("sessions")).get("schoolYear")); assertEquals("Should match", section.get("sessionId"), ((EntityBody) section.get("sessions")).get("id")); assertNotNull("Should not be null", section.get("courses")); assertEquals("Should match", "Math", ((EntityBody) section.get("courses")).get("courseTitle")); assertEquals("Should match", "Math A", section.get("sectionname")); List<EntityBody> courseTranscripts = (List<EntityBody>) transcripts.get("courseTranscripts"); assertNotNull("Should not be null", courseTranscripts); assertEquals("Should match", 2, courseTranscripts.size()); assertEquals("Should match", "A", courseTranscripts.get(0).get("letterGradeEarned")); }
@Override public List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters) { List<String> studentIds = optionalFieldAppenderHelper.getIdList(entities, "id"); List<EntityBody> studentSectionAssociations = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_SECTION_ASSOCIATIONS, ParameterConstants.STUDENT_ID, studentIds); List<String> sectionIds = optionalFieldAppenderHelper.getIdList(studentSectionAssociations, ParameterConstants.SECTION_ID); List<EntityBody> sections = optionalFieldAppenderHelper.queryEntities(ResourceNames.SECTIONS, "_id", sectionIds); List<EntityBody> studentAcademicRecords = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); List<String> studentAcademicRecordIds = optionalFieldAppenderHelper.getIdList(studentAcademicRecords, "id"); List<EntityBody> courseTranscripts = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_TRANSCRIPTS, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordIds); List<String> sessionIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.SESSION_ID); List<EntityBody> sessions = optionalFieldAppenderHelper .queryEntities(ResourceNames.SESSIONS, "_id", sessionIds); List<String> courseOfferingIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.COURSE_OFFERING_ID); List<EntityBody> courseOfferings = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_OFFERINGS, "_id", courseOfferingIds); List<String> courseIds = optionalFieldAppenderHelper.getIdList(courseOfferings, ParameterConstants.COURSE_ID); List<EntityBody> courses = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSES, "_id", courseIds); List<EntityBody> studentAcademicRecordsForStudents = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); for (EntityBody student : entities) { String studentId = (String) student.get("id"); List<EntityBody> studentSectionAssociationsForStudent = optionalFieldAppenderHelper.getEntitySubList( studentSectionAssociations, ParameterConstants.STUDENT_ID, studentId); List<EntityBody> studentCourseTranscripts = new ArrayList<EntityBody>(); for (EntityBody studentSectionAssociationForStudent : studentSectionAssociationsForStudent) { String sectionId = (String) studentSectionAssociationForStudent.get(ParameterConstants.SECTION_ID); EntityBody sectionForStudent = optionalFieldAppenderHelper.getEntityFromList(sections, "id", sectionId); if (sectionForStudent == null) { continue; } EntityBody sessionForSection = optionalFieldAppenderHelper.getEntityFromList(sessions, "id", (String) sectionForStudent.get(ParameterConstants.SESSION_ID)); EntityBody courseOfferingForSection = optionalFieldAppenderHelper.getEntityFromList(courseOfferings, "id", (String) sectionForStudent.get(ParameterConstants.COURSE_OFFERING_ID)); if (courseOfferingForSection == null) { continue; } EntityBody courseForSection = optionalFieldAppenderHelper.getEntityFromList(courses, "id", (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); List<EntityBody> studentAcademicRecordsForStudent = optionalFieldAppenderHelper.getEntitySubList(studentAcademicRecordsForStudents, ParameterConstants.STUDENT_ID, studentId); List<String> studentAcademicRecordIdsForStudent = optionalFieldAppenderHelper.getIdList(studentAcademicRecordsForStudent, "id"); List<EntityBody> studentTranscriptsForStudent = new ArrayList<EntityBody>(); for (String studentAcademicRecordId : studentAcademicRecordIdsForStudent) { studentTranscriptsForStudent.addAll(optionalFieldAppenderHelper.getEntitySubList(courseTranscripts, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordId)); } List<EntityBody> studentTranscriptsForStudentAndCourse = optionalFieldAppenderHelper.getEntitySubList( studentTranscriptsForStudent, ParameterConstants.COURSE_ID, (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); studentCourseTranscripts.addAll(studentTranscriptsForStudentAndCourse); sectionForStudent.put(PathConstants.SESSIONS, sessionForSection); sectionForStudent.put(PathConstants.COURSES, courseForSection); studentSectionAssociationForStudent.put(PathConstants.SECTIONS, sectionForStudent); } EntityBody body = new EntityBody(); body.put(PathConstants.STUDENT_SECTION_ASSOCIATIONS, studentSectionAssociationsForStudent); body.put(PathConstants.COURSE_TRANSCRIPTS, studentCourseTranscripts); student.put(ParameterConstants.OPTIONAL_FIELD_TRANSCRIPT, body); } return entities; }
StudentTranscriptOptionalFieldAppender implements OptionalFieldAppender { @Override public List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters) { List<String> studentIds = optionalFieldAppenderHelper.getIdList(entities, "id"); List<EntityBody> studentSectionAssociations = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_SECTION_ASSOCIATIONS, ParameterConstants.STUDENT_ID, studentIds); List<String> sectionIds = optionalFieldAppenderHelper.getIdList(studentSectionAssociations, ParameterConstants.SECTION_ID); List<EntityBody> sections = optionalFieldAppenderHelper.queryEntities(ResourceNames.SECTIONS, "_id", sectionIds); List<EntityBody> studentAcademicRecords = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); List<String> studentAcademicRecordIds = optionalFieldAppenderHelper.getIdList(studentAcademicRecords, "id"); List<EntityBody> courseTranscripts = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_TRANSCRIPTS, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordIds); List<String> sessionIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.SESSION_ID); List<EntityBody> sessions = optionalFieldAppenderHelper .queryEntities(ResourceNames.SESSIONS, "_id", sessionIds); List<String> courseOfferingIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.COURSE_OFFERING_ID); List<EntityBody> courseOfferings = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_OFFERINGS, "_id", courseOfferingIds); List<String> courseIds = optionalFieldAppenderHelper.getIdList(courseOfferings, ParameterConstants.COURSE_ID); List<EntityBody> courses = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSES, "_id", courseIds); List<EntityBody> studentAcademicRecordsForStudents = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); for (EntityBody student : entities) { String studentId = (String) student.get("id"); List<EntityBody> studentSectionAssociationsForStudent = optionalFieldAppenderHelper.getEntitySubList( studentSectionAssociations, ParameterConstants.STUDENT_ID, studentId); List<EntityBody> studentCourseTranscripts = new ArrayList<EntityBody>(); for (EntityBody studentSectionAssociationForStudent : studentSectionAssociationsForStudent) { String sectionId = (String) studentSectionAssociationForStudent.get(ParameterConstants.SECTION_ID); EntityBody sectionForStudent = optionalFieldAppenderHelper.getEntityFromList(sections, "id", sectionId); if (sectionForStudent == null) { continue; } EntityBody sessionForSection = optionalFieldAppenderHelper.getEntityFromList(sessions, "id", (String) sectionForStudent.get(ParameterConstants.SESSION_ID)); EntityBody courseOfferingForSection = optionalFieldAppenderHelper.getEntityFromList(courseOfferings, "id", (String) sectionForStudent.get(ParameterConstants.COURSE_OFFERING_ID)); if (courseOfferingForSection == null) { continue; } EntityBody courseForSection = optionalFieldAppenderHelper.getEntityFromList(courses, "id", (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); List<EntityBody> studentAcademicRecordsForStudent = optionalFieldAppenderHelper.getEntitySubList(studentAcademicRecordsForStudents, ParameterConstants.STUDENT_ID, studentId); List<String> studentAcademicRecordIdsForStudent = optionalFieldAppenderHelper.getIdList(studentAcademicRecordsForStudent, "id"); List<EntityBody> studentTranscriptsForStudent = new ArrayList<EntityBody>(); for (String studentAcademicRecordId : studentAcademicRecordIdsForStudent) { studentTranscriptsForStudent.addAll(optionalFieldAppenderHelper.getEntitySubList(courseTranscripts, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordId)); } List<EntityBody> studentTranscriptsForStudentAndCourse = optionalFieldAppenderHelper.getEntitySubList( studentTranscriptsForStudent, ParameterConstants.COURSE_ID, (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); studentCourseTranscripts.addAll(studentTranscriptsForStudentAndCourse); sectionForStudent.put(PathConstants.SESSIONS, sessionForSection); sectionForStudent.put(PathConstants.COURSES, courseForSection); studentSectionAssociationForStudent.put(PathConstants.SECTIONS, sectionForStudent); } EntityBody body = new EntityBody(); body.put(PathConstants.STUDENT_SECTION_ASSOCIATIONS, studentSectionAssociationsForStudent); body.put(PathConstants.COURSE_TRANSCRIPTS, studentCourseTranscripts); student.put(ParameterConstants.OPTIONAL_FIELD_TRANSCRIPT, body); } return entities; } }
StudentTranscriptOptionalFieldAppender implements OptionalFieldAppender { @Override public List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters) { List<String> studentIds = optionalFieldAppenderHelper.getIdList(entities, "id"); List<EntityBody> studentSectionAssociations = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_SECTION_ASSOCIATIONS, ParameterConstants.STUDENT_ID, studentIds); List<String> sectionIds = optionalFieldAppenderHelper.getIdList(studentSectionAssociations, ParameterConstants.SECTION_ID); List<EntityBody> sections = optionalFieldAppenderHelper.queryEntities(ResourceNames.SECTIONS, "_id", sectionIds); List<EntityBody> studentAcademicRecords = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); List<String> studentAcademicRecordIds = optionalFieldAppenderHelper.getIdList(studentAcademicRecords, "id"); List<EntityBody> courseTranscripts = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_TRANSCRIPTS, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordIds); List<String> sessionIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.SESSION_ID); List<EntityBody> sessions = optionalFieldAppenderHelper .queryEntities(ResourceNames.SESSIONS, "_id", sessionIds); List<String> courseOfferingIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.COURSE_OFFERING_ID); List<EntityBody> courseOfferings = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_OFFERINGS, "_id", courseOfferingIds); List<String> courseIds = optionalFieldAppenderHelper.getIdList(courseOfferings, ParameterConstants.COURSE_ID); List<EntityBody> courses = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSES, "_id", courseIds); List<EntityBody> studentAcademicRecordsForStudents = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); for (EntityBody student : entities) { String studentId = (String) student.get("id"); List<EntityBody> studentSectionAssociationsForStudent = optionalFieldAppenderHelper.getEntitySubList( studentSectionAssociations, ParameterConstants.STUDENT_ID, studentId); List<EntityBody> studentCourseTranscripts = new ArrayList<EntityBody>(); for (EntityBody studentSectionAssociationForStudent : studentSectionAssociationsForStudent) { String sectionId = (String) studentSectionAssociationForStudent.get(ParameterConstants.SECTION_ID); EntityBody sectionForStudent = optionalFieldAppenderHelper.getEntityFromList(sections, "id", sectionId); if (sectionForStudent == null) { continue; } EntityBody sessionForSection = optionalFieldAppenderHelper.getEntityFromList(sessions, "id", (String) sectionForStudent.get(ParameterConstants.SESSION_ID)); EntityBody courseOfferingForSection = optionalFieldAppenderHelper.getEntityFromList(courseOfferings, "id", (String) sectionForStudent.get(ParameterConstants.COURSE_OFFERING_ID)); if (courseOfferingForSection == null) { continue; } EntityBody courseForSection = optionalFieldAppenderHelper.getEntityFromList(courses, "id", (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); List<EntityBody> studentAcademicRecordsForStudent = optionalFieldAppenderHelper.getEntitySubList(studentAcademicRecordsForStudents, ParameterConstants.STUDENT_ID, studentId); List<String> studentAcademicRecordIdsForStudent = optionalFieldAppenderHelper.getIdList(studentAcademicRecordsForStudent, "id"); List<EntityBody> studentTranscriptsForStudent = new ArrayList<EntityBody>(); for (String studentAcademicRecordId : studentAcademicRecordIdsForStudent) { studentTranscriptsForStudent.addAll(optionalFieldAppenderHelper.getEntitySubList(courseTranscripts, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordId)); } List<EntityBody> studentTranscriptsForStudentAndCourse = optionalFieldAppenderHelper.getEntitySubList( studentTranscriptsForStudent, ParameterConstants.COURSE_ID, (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); studentCourseTranscripts.addAll(studentTranscriptsForStudentAndCourse); sectionForStudent.put(PathConstants.SESSIONS, sessionForSection); sectionForStudent.put(PathConstants.COURSES, courseForSection); studentSectionAssociationForStudent.put(PathConstants.SECTIONS, sectionForStudent); } EntityBody body = new EntityBody(); body.put(PathConstants.STUDENT_SECTION_ASSOCIATIONS, studentSectionAssociationsForStudent); body.put(PathConstants.COURSE_TRANSCRIPTS, studentCourseTranscripts); student.put(ParameterConstants.OPTIONAL_FIELD_TRANSCRIPT, body); } return entities; }  }
StudentTranscriptOptionalFieldAppender implements OptionalFieldAppender { @Override public List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters) { List<String> studentIds = optionalFieldAppenderHelper.getIdList(entities, "id"); List<EntityBody> studentSectionAssociations = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_SECTION_ASSOCIATIONS, ParameterConstants.STUDENT_ID, studentIds); List<String> sectionIds = optionalFieldAppenderHelper.getIdList(studentSectionAssociations, ParameterConstants.SECTION_ID); List<EntityBody> sections = optionalFieldAppenderHelper.queryEntities(ResourceNames.SECTIONS, "_id", sectionIds); List<EntityBody> studentAcademicRecords = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); List<String> studentAcademicRecordIds = optionalFieldAppenderHelper.getIdList(studentAcademicRecords, "id"); List<EntityBody> courseTranscripts = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_TRANSCRIPTS, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordIds); List<String> sessionIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.SESSION_ID); List<EntityBody> sessions = optionalFieldAppenderHelper .queryEntities(ResourceNames.SESSIONS, "_id", sessionIds); List<String> courseOfferingIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.COURSE_OFFERING_ID); List<EntityBody> courseOfferings = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_OFFERINGS, "_id", courseOfferingIds); List<String> courseIds = optionalFieldAppenderHelper.getIdList(courseOfferings, ParameterConstants.COURSE_ID); List<EntityBody> courses = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSES, "_id", courseIds); List<EntityBody> studentAcademicRecordsForStudents = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); for (EntityBody student : entities) { String studentId = (String) student.get("id"); List<EntityBody> studentSectionAssociationsForStudent = optionalFieldAppenderHelper.getEntitySubList( studentSectionAssociations, ParameterConstants.STUDENT_ID, studentId); List<EntityBody> studentCourseTranscripts = new ArrayList<EntityBody>(); for (EntityBody studentSectionAssociationForStudent : studentSectionAssociationsForStudent) { String sectionId = (String) studentSectionAssociationForStudent.get(ParameterConstants.SECTION_ID); EntityBody sectionForStudent = optionalFieldAppenderHelper.getEntityFromList(sections, "id", sectionId); if (sectionForStudent == null) { continue; } EntityBody sessionForSection = optionalFieldAppenderHelper.getEntityFromList(sessions, "id", (String) sectionForStudent.get(ParameterConstants.SESSION_ID)); EntityBody courseOfferingForSection = optionalFieldAppenderHelper.getEntityFromList(courseOfferings, "id", (String) sectionForStudent.get(ParameterConstants.COURSE_OFFERING_ID)); if (courseOfferingForSection == null) { continue; } EntityBody courseForSection = optionalFieldAppenderHelper.getEntityFromList(courses, "id", (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); List<EntityBody> studentAcademicRecordsForStudent = optionalFieldAppenderHelper.getEntitySubList(studentAcademicRecordsForStudents, ParameterConstants.STUDENT_ID, studentId); List<String> studentAcademicRecordIdsForStudent = optionalFieldAppenderHelper.getIdList(studentAcademicRecordsForStudent, "id"); List<EntityBody> studentTranscriptsForStudent = new ArrayList<EntityBody>(); for (String studentAcademicRecordId : studentAcademicRecordIdsForStudent) { studentTranscriptsForStudent.addAll(optionalFieldAppenderHelper.getEntitySubList(courseTranscripts, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordId)); } List<EntityBody> studentTranscriptsForStudentAndCourse = optionalFieldAppenderHelper.getEntitySubList( studentTranscriptsForStudent, ParameterConstants.COURSE_ID, (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); studentCourseTranscripts.addAll(studentTranscriptsForStudentAndCourse); sectionForStudent.put(PathConstants.SESSIONS, sessionForSection); sectionForStudent.put(PathConstants.COURSES, courseForSection); studentSectionAssociationForStudent.put(PathConstants.SECTIONS, sectionForStudent); } EntityBody body = new EntityBody(); body.put(PathConstants.STUDENT_SECTION_ASSOCIATIONS, studentSectionAssociationsForStudent); body.put(PathConstants.COURSE_TRANSCRIPTS, studentCourseTranscripts); student.put(ParameterConstants.OPTIONAL_FIELD_TRANSCRIPT, body); } return entities; }  @Override List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters); }
StudentTranscriptOptionalFieldAppender implements OptionalFieldAppender { @Override public List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters) { List<String> studentIds = optionalFieldAppenderHelper.getIdList(entities, "id"); List<EntityBody> studentSectionAssociations = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_SECTION_ASSOCIATIONS, ParameterConstants.STUDENT_ID, studentIds); List<String> sectionIds = optionalFieldAppenderHelper.getIdList(studentSectionAssociations, ParameterConstants.SECTION_ID); List<EntityBody> sections = optionalFieldAppenderHelper.queryEntities(ResourceNames.SECTIONS, "_id", sectionIds); List<EntityBody> studentAcademicRecords = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); List<String> studentAcademicRecordIds = optionalFieldAppenderHelper.getIdList(studentAcademicRecords, "id"); List<EntityBody> courseTranscripts = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_TRANSCRIPTS, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordIds); List<String> sessionIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.SESSION_ID); List<EntityBody> sessions = optionalFieldAppenderHelper .queryEntities(ResourceNames.SESSIONS, "_id", sessionIds); List<String> courseOfferingIds = optionalFieldAppenderHelper.getIdList(sections, ParameterConstants.COURSE_OFFERING_ID); List<EntityBody> courseOfferings = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSE_OFFERINGS, "_id", courseOfferingIds); List<String> courseIds = optionalFieldAppenderHelper.getIdList(courseOfferings, ParameterConstants.COURSE_ID); List<EntityBody> courses = optionalFieldAppenderHelper.queryEntities(ResourceNames.COURSES, "_id", courseIds); List<EntityBody> studentAcademicRecordsForStudents = optionalFieldAppenderHelper.queryEntities(ResourceNames.STUDENT_ACADEMIC_RECORDS, ParameterConstants.STUDENT_ID, studentIds); for (EntityBody student : entities) { String studentId = (String) student.get("id"); List<EntityBody> studentSectionAssociationsForStudent = optionalFieldAppenderHelper.getEntitySubList( studentSectionAssociations, ParameterConstants.STUDENT_ID, studentId); List<EntityBody> studentCourseTranscripts = new ArrayList<EntityBody>(); for (EntityBody studentSectionAssociationForStudent : studentSectionAssociationsForStudent) { String sectionId = (String) studentSectionAssociationForStudent.get(ParameterConstants.SECTION_ID); EntityBody sectionForStudent = optionalFieldAppenderHelper.getEntityFromList(sections, "id", sectionId); if (sectionForStudent == null) { continue; } EntityBody sessionForSection = optionalFieldAppenderHelper.getEntityFromList(sessions, "id", (String) sectionForStudent.get(ParameterConstants.SESSION_ID)); EntityBody courseOfferingForSection = optionalFieldAppenderHelper.getEntityFromList(courseOfferings, "id", (String) sectionForStudent.get(ParameterConstants.COURSE_OFFERING_ID)); if (courseOfferingForSection == null) { continue; } EntityBody courseForSection = optionalFieldAppenderHelper.getEntityFromList(courses, "id", (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); List<EntityBody> studentAcademicRecordsForStudent = optionalFieldAppenderHelper.getEntitySubList(studentAcademicRecordsForStudents, ParameterConstants.STUDENT_ID, studentId); List<String> studentAcademicRecordIdsForStudent = optionalFieldAppenderHelper.getIdList(studentAcademicRecordsForStudent, "id"); List<EntityBody> studentTranscriptsForStudent = new ArrayList<EntityBody>(); for (String studentAcademicRecordId : studentAcademicRecordIdsForStudent) { studentTranscriptsForStudent.addAll(optionalFieldAppenderHelper.getEntitySubList(courseTranscripts, ParameterConstants.STUDENT_ACADEMIC_RECORD_ID, studentAcademicRecordId)); } List<EntityBody> studentTranscriptsForStudentAndCourse = optionalFieldAppenderHelper.getEntitySubList( studentTranscriptsForStudent, ParameterConstants.COURSE_ID, (String) courseOfferingForSection.get(ParameterConstants.COURSE_ID)); studentCourseTranscripts.addAll(studentTranscriptsForStudentAndCourse); sectionForStudent.put(PathConstants.SESSIONS, sessionForSection); sectionForStudent.put(PathConstants.COURSES, courseForSection); studentSectionAssociationForStudent.put(PathConstants.SECTIONS, sectionForStudent); } EntityBody body = new EntityBody(); body.put(PathConstants.STUDENT_SECTION_ASSOCIATIONS, studentSectionAssociationsForStudent); body.put(PathConstants.COURSE_TRANSCRIPTS, studentCourseTranscripts); student.put(ParameterConstants.OPTIONAL_FIELD_TRANSCRIPT, body); } return entities; }  @Override List<EntityBody> applyOptionalField(List<EntityBody> entities, String parameters);  }