for (int i = 0; i < selection.length; i++) { curricularCoursesToEnroll.add(selection[i]); }
List<ICandidateEnrolment> candidateEnrolments = masterDegreeCandidate.getCandidateEnrolments(); List<Integer> candidateEnrolmentsCurricularCoursesIDs = (List<Integer>) CollectionUtils.collect( candidateEnrolments, new Transformer() { public Object transform(Object arg0) { ICandidateEnrolment candidateEnrolment = (ICandidateEnrolment) arg0; return candidateEnrolment.getCurricularCourse().getIdInternal(); } });
    public void run(Integer[] selection, Integer candidateID, Double credits, String givenCreditsRemarks)            throws FenixServiceException {        try {            ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();            IPersistentCandidateEnrolment persistentCandidateEnrolment = sp                    .getIPersistentCandidateEnrolment();            IMasterDegreeCandidate masterDegreeCandidate = (IMasterDegreeCandidate) sp                    .getIPersistentMasterDegreeCandidate().readByOID(MasterDegreeCandidate.class,                            candidateID, true);            if (masterDegreeCandidate == null) {                throw new NonExistingServiceException();            }            masterDegreeCandidate.setGivenCredits(credits);            if (credits.floatValue() != 0) {                masterDegreeCandidate.setGivenCreditsRemarks(givenCreditsRemarks);            }            List candidateEnrollmentsToDelete = new ArrayList();            List curricularCoursesToEnroll = new ArrayList();            for (int i = 0; i < selection.length; i++) {                curricularCoursesToEnroll.add(selection[i]);            }            List curricularCoursesToEnrollFiltered = filterEnrollments(persistentCandidateEnrolment,                    masterDegreeCandidate, candidateEnrollmentsToDelete, curricularCoursesToEnroll);            writeFilteredEnrollments(sp, masterDegreeCandidate, curricularCoursesToEnrollFiltered);            deleteRemainingEnrollments(persistentCandidateEnrolment, candidateEnrollmentsToDelete);        } catch (ExcepcaoPersistencia ex) {            FenixServiceException newEx = new FenixServiceException("Persistence layer error");            newEx.fillInStackTrace();            throw newEx;        }    }