private static Attends findAttend(final ExecutionCourse executionCourse, final String attendId) { for (final Attends attend : executionCourse.getAttends()) { if (attend.getExternalId().equals(attendId)) { return attend; } } return null; }
private static void addMark( List<AttendsMark> result, StudentMark studentMark, Attends attend, List<DomainException> exceptionList) { if (studentMark.mark.length() - studentMark.mark.indexOf('.') - 1 > 2) { exceptionList.add( new DomainException("error.mark.more.than.two.decimals", studentMark.studentNumber)); } else { result.add(new AttendsMark(attend.getExternalId(), studentMark.mark)); } }
private static List<AttendsMark> convertMarks( final ExecutionCourse executionCourse, final List<StudentMark> marks) throws FenixServiceMultipleException { final List<DomainException> exceptionList = new ArrayList<DomainException>(); final List<AttendsMark> result = new ArrayList<AttendsMark>(); for (final StudentMark studentMark : marks) { final Attends attend = findAttend(executionCourse, studentMark.studentNumber, exceptionList); if (attend != null) { result.add(new AttendsMark(attend.getExternalId(), studentMark.mark)); } } if (!exceptionList.isEmpty()) { throw new FenixServiceMultipleException(exceptionList); } return result; }