if (shiftEnrollments == null || shiftEnrollments.isEmpty()) { filteredShiftsIdsToEnroll = shiftIdsToEnroll; } else { calculateShiftsToUnEnroll(shiftIdsToEnroll, shiftEnrollments, shiftsToUnEnroll); calculateShiftsToEnroll(shiftIdsToEnroll, shiftEnrollments, filteredShiftsIdsToEnroll); }
shiftsToUnEnroll = calculateShiftsToUnEnroll(shiftIdsToEnroll, shiftEnrollments, shiftsToUnEnroll); filteredShiftsIdsToEnroll = calculateShiftsToEnroll( shiftIdsToEnroll, shiftEnrollments, filteredShiftsIdsToEnroll);
    public ShiftEnrollmentErrorReport run(Integer studentId,            final List shiftIdsToEnroll)            throws StudentNotFoundServiceException, FenixServiceException    {        try        {            ISuportePersistente sp = SuportePersistenteOJB.getInstance();            IPersistentStudent persistentStudent = sp.getIPersistentStudent();            ITurnoPersistente persistentShift = sp.getITurnoPersistente();            ITurnoAlunoPersistente persistentShiftStudent = sp                    .getITurnoAlunoPersistente();            IPersistentExecutionPeriod persistentExecutionPeriod = sp                    .getIPersistentExecutionPeriod();            ShiftEnrollmentErrorReport errorReport = new ShiftEnrollmentErrorReport();            if (shiftIdsToEnroll != null && !shiftIdsToEnroll.isEmpty())            {                IStudent student = (IStudent) persistentStudent.readByOId(                        new Student(studentId), false);                if (student == null) { throw new StudentNotFoundServiceException(); }                IExecutionPeriod executionPeriod = persistentExecutionPeriod                        .readActualExecutionPeriod();                List shiftEnrollments = persistentShiftStudent                        .readByStudentAndExecutionPeriod(student,                                executionPeriod);                List shiftsToUnEnroll = new ArrayList();                List filteredShiftsIdsToEnroll = new ArrayList();                if (shiftEnrollments == null || shiftEnrollments.isEmpty())                {                    filteredShiftsIdsToEnroll = shiftIdsToEnroll;                }                else                {                    calculateShiftsToUnEnroll(shiftIdsToEnroll,                            shiftEnrollments, shiftsToUnEnroll);                    calculateShiftsToEnroll(shiftIdsToEnroll, shiftEnrollments,                            filteredShiftsIdsToEnroll);                }                enrollStudentsInShifts(student, filteredShiftsIdsToEnroll,                        errorReport, persistentShift, persistentShiftStudent);                unEnrollStudentsInShifts(shiftsToUnEnroll, errorReport,                        persistentShiftStudent);            }            return errorReport;        }        catch (ExcepcaoPersistencia e)        {        	e.printStackTrace();            throw new FenixServiceException(e);        }    }