private void transferShifts(final IPersistentObject persistentObject, final ISuportePersistente sp, final List shifts, final Integer[] shiftIdsToTransfer, final Collection transferedStudents, final IExecutionCourse destinationExecutionCourse) throws ExcepcaoPersistencia {  for (Iterator iterator = shifts.iterator(); iterator.hasNext();) { IShift shift = (IShift) iterator.next(); if (contains(shiftIdsToTransfer, shift.getIdInternal())) { persistentObject.simpleLockWrite(shift); shift.setDisciplinaExecucao(destinationExecutionCourse);        try { ((SuportePersistenteOJB) sp).currentBroker().store(shift); } catch (Exception ex) { throw new ExcepcaoPersistencia("Failed to store shift", ex); } } List<IStudent> students = shift.getStudents(); Iterator<IStudent> iter = students.iterator(); while(iter.hasNext()){ IStudent student = iter.next(); if (transferedStudents.contains(student.getIdInternal())) { iter.remove(); } } }
private void transferShifts(final IExecutionCourse originExecutionCourse, final IExecutionCourse destinationExecutionCourse, final Integer[] shiftIdsToTransfer) { for (final Integer shiftId : shiftIdsToTransfer) { final IShift shift = (IShift) findDomainObjectByID(originExecutionCourse.getAssociatedShifts(), shiftId); shift.setDisciplinaExecucao(destinationExecutionCourse); }
    private void transferShifts(final IPersistentObject persistentObject, final ISuportePersistente sp,            final List shifts, final Integer[] shiftIdsToTransfer, final Collection transferedStudents,            final IExecutionCourse destinationExecutionCourse) throws ExcepcaoPersistencia {                for (Iterator iterator = shifts.iterator(); iterator.hasNext();) {            IShift shift = (IShift) iterator.next();            if (contains(shiftIdsToTransfer, shift.getIdInternal())) {                persistentObject.simpleLockWrite(shift);                shift.setDisciplinaExecucao(destinationExecutionCourse);                // This is very ugly code to find in a service. It should not                // be necessary. The above lock and set should take care of                // everything. However, the first shift doesn't get                // transfered...                // and I don't know why. This is the workaround we found unit                // the mystory can be resolved.                try {                    ((SuportePersistenteOJB) sp).currentBroker().store(shift);                } catch (Exception ex) {                    throw new ExcepcaoPersistencia("Failed to store shift", ex);                }            }            List<IStudent> students = shift.getStudents();            Iterator<IStudent> iter = students.iterator();            while(iter.hasNext()){                IStudent student = iter.next();                if (transferedStudents.contains(student.getIdInternal())) {                    iter.remove();                }            }       	}    }