public Object run(List shiftOIDs) throws FenixServiceException, ExcepcaoPersistencia {  boolean result = false;  for (int j = 0; j < shiftOIDs.size(); j++) { Integer shiftOID = (Integer) shiftOIDs.get(j);  final ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();  IShift shift = (IShift) sp.getITurnoPersistente().readByOID(Shift.class, shiftOID);  if (shift != null) {  List studentShifts = shift.getStudents(); if (studentShifts != null && studentShifts.size() > 0) { throw new FenixServiceException("error.deleteShift.with.students"); }    List studentGroupShift = shift.getAssociatedStudentGroups();  if (studentGroupShift.size() > 0) { throw new FenixServiceException("error.deleteShift.with.studentGroups"); }   IPersistentSummary persistentSummary = sp.getIPersistentSummary(); List summariesShift = persistentSummary.readByShift(shift.getDisciplinaExecucao() .getIdInternal(), shift.getIdInternal()); if (summariesShift != null && summariesShift.size() > 0) { throw new FenixServiceException("error.deleteShift.with.summaries"); }  IPersistentShiftProfessorship persistentShiftProfessorship = sp .getIPersistentShiftProfessorship(); List professorshipShift = persistentShiftProfessorship.readByShift(shift); for (int i = 0; i < professorshipShift.size(); i++) { persistentShiftProfessorship.delete((IShiftProfessorship) professorshipShift.get(i)); }  for (int i = 0; i < shift.getAssociatedLessons().size(); i++) { ILesson lesson = shift.getAssociatedLessons().get(i);  DeleteLessons.deleteLesson(sp, lesson.getIdInternal()); }  for (int i = 0; i < shift.getAssociatedClasses().size(); i++) { ISchoolClass schoolClass = shift.getAssociatedClasses().get(i); schoolClass.getAssociatedShifts().remove(shift); } shift.getAssociatedClasses().clear();  shift.setDisciplinaExecucao(null);  sp.getITurnoPersistente().deleteByOID(Shift.class, shift.getIdInternal());  result = true; }
public Object run(final List<Integer> shiftOIDs) throws FenixServiceException, ExcepcaoPersistencia { for (final Integer shiftID : shiftOIDs) { DeleteShift.deleteShift(shiftID);
    public Object run(List shiftOIDs) throws FenixServiceException, ExcepcaoPersistencia {        boolean result = false;        for (int j = 0; j < shiftOIDs.size(); j++) {            Integer shiftOID = (Integer) shiftOIDs.get(j);            final ISuportePersistente sp = PersistenceSupportFactory.getDefaultPersistenceSupport();            IShift shift = (IShift) sp.getITurnoPersistente().readByOID(Shift.class, shiftOID);            if (shift != null) {                // if the shift has students associated it can't be deleted                List studentShifts = shift.getStudents();                if (studentShifts != null && studentShifts.size() > 0) {                    throw new FenixServiceException("error.deleteShift.with.students");                }                // if the shift has student groups associated it can't be                // deleted                List studentGroupShift = shift.getAssociatedStudentGroups();                if (studentGroupShift.size() > 0) {                    throw new FenixServiceException("error.deleteShift.with.studentGroups");                }                // if the shift has summaries it can't be deleted                IPersistentSummary persistentSummary = sp.getIPersistentSummary();                List summariesShift = persistentSummary.readByShift(shift.getDisciplinaExecucao()                        .getIdInternal(), shift.getIdInternal());                if (summariesShift != null && summariesShift.size() > 0) {                    throw new FenixServiceException("error.deleteShift.with.summaries");                }                IPersistentShiftProfessorship persistentShiftProfessorship = sp                        .getIPersistentShiftProfessorship();                List professorshipShift = persistentShiftProfessorship.readByShift(shift);                for (int i = 0; i < professorshipShift.size(); i++) {                    persistentShiftProfessorship.delete((IShiftProfessorship) professorshipShift.get(i));                }                for (int i = 0; i < shift.getAssociatedLessons().size(); i++) {                    ILesson lesson = shift.getAssociatedLessons().get(i);                    DeleteLessons.deleteLesson(sp, lesson.getIdInternal());                }                for (int i = 0; i < shift.getAssociatedClasses().size(); i++) {                    ISchoolClass schoolClass = shift.getAssociatedClasses().get(i);                    schoolClass.getAssociatedShifts().remove(shift);                }                shift.getAssociatedClasses().clear();                shift.setDisciplinaExecucao(null);                sp.getITurnoPersistente().deleteByOID(Shift.class, shift.getIdInternal());                result = true;            }        }        return new Boolean(result);    }