IPersistentSummary persistentSummary = ps.getIPersistentSummary(); List summaryList = persistentSummary.readByTeacher(professorship.getExecutionCourse(), professorship.getTeacher()); if (summaryList != null && !summaryList.isEmpty()) { for (Iterator iteratorSummaries = summaryList.iterator(); iteratorSummaries.hasNext(); ) { ISummary summary = (ISummary) iteratorSummaries.next(); persistentSummary.simpleLockWrite(summary); summary.setProfessorship(null); summary.setKeyProfessorship(null); } }
    private void copyProfessorshipsAndResponsibleFors(IExecutionCourse destination,            IExecutionCourse source, ISuportePersistente ps) throws ExcepcaoPersistencia {        IPersistentProfessorship persistentProfessorship = ps.getIPersistentProfessorship();        IPersistentShiftProfessorship persistentShiftProfessorship = ps                .getIPersistentShiftProfessorship();        IPersistentSupportLesson persistentSupportLesson = ps.getIPersistentSupportLesson();        List destinationProfessorships = persistentProfessorship.readByExecutionCourse(destination);        if (destinationProfessorships == null) {            destinationProfessorships = new ArrayList();        }        List sourceProfessorships = persistentProfessorship.readByExecutionCourse(source);        if (sourceProfessorships != null) {            Iterator iter = sourceProfessorships.iterator();            while (iter.hasNext()) {                IProfessorship professorship = (IProfessorship) iter.next();                final IProfessorship professorship2Compare = professorship;                if (CollectionUtils.find(destinationProfessorships, new Predicate() {                    public boolean evaluate(Object arg0) {                        IProfessorship prof = (IProfessorship) arg0;                        if (prof.getTeacher() == professorship2Compare.getTeacher()) {                            return true;                        }                        return false;                    }                }) == null) {                    persistentProfessorship.simpleLockWrite(professorship);                    professorship.setExecutionCourse(destination);                } else {                    List associatedShiftsProfessorships = professorship                            .getAssociatedShiftProfessorship();                    Iterator iterator = associatedShiftsProfessorships.iterator();                    while (iterator.hasNext()) {                        IShiftProfessorship shiftProfessorship = (IShiftProfessorship) iterator.next();                        persistentShiftProfessorship.delete(shiftProfessorship);                    }                    List supportLessons = persistentSupportLesson.readByProfessorship(professorship);                    iterator = supportLessons.iterator();                    while (iterator.hasNext()) {                        ISupportLesson supportLesson = (ISupportLesson) iterator.next();                        persistentSupportLesson.delete(supportLesson);                    }                    persistentProfessorship.delete(professorship);                }            }        }        IPersistentResponsibleFor persistentResponsibleFor = ps.getIPersistentResponsibleFor();        List destinationResponsibleFor = persistentResponsibleFor.readByExecutionCourse(destination);        if (destinationResponsibleFor == null) {            destinationResponsibleFor = new ArrayList();        }        List sourceResponsibleFor = persistentResponsibleFor.readByExecutionCourse(source);        if (sourceResponsibleFor != null) {            Iterator iter = sourceResponsibleFor.iterator();            while (iter.hasNext()) {                IResponsibleFor responsibleFor = (IResponsibleFor) iter.next();                final IResponsibleFor responsibleFor2Compare = responsibleFor;                if (CollectionUtils.find(destinationResponsibleFor, new Predicate() {                    public boolean evaluate(Object arg0) {                        IResponsibleFor respons = (IResponsibleFor) arg0;                        if (respons.getTeacher() == responsibleFor2Compare.getTeacher()) {                            return true;                        }                        return false;                    }                }) == null) {                    persistentResponsibleFor.simpleLockWrite(responsibleFor);                    responsibleFor.setExecutionCourse(destination);                } else {                    persistentResponsibleFor.delete(responsibleFor);                }            }        }    }