if(toAdd){ professorship.getAssociatedShiftProfessorship().add(shiftProfessorship); shift.getAssociatedShiftProfessorship().add(shiftProfessorship);
if (toAdd) { if (professorship.getAssociatedShiftProfessorship() != null) { professorship.getAssociatedShiftProfessorship().add(shiftProfessorship); } if (shift.getAssociatedShiftProfessorship() != null) { shift.getAssociatedShiftProfessorship().add(shiftProfessorship); }
    private void lockOrDeleteShiftProfessorship(IPersistentShiftProfessorship shiftProfessorshipDAO,            IProfessorship professorship, Double percentage, IShift shift,            IShiftProfessorship shiftProfessorship, List shiftProfessorshipDeleted,            List shiftProfessorshipAdded) throws ExcepcaoPersistencia, OverlappingPeriodException,            FenixServiceException {        boolean toAdd = false;        if (percentage.doubleValue() == 0) {            shiftProfessorshipDAO.delete(shiftProfessorship);            shiftProfessorshipDeleted.add(shiftProfessorship);        } else {            if (shiftProfessorship == null) {                toAdd = true;                shiftProfessorship = new ShiftProfessorship();                shiftProfessorship.setProfessorship(professorship);                shiftProfessorship.setShift(shift);                            }            shiftProfessorshipDAO.simpleLockWrite(shiftProfessorship);            if(toAdd){                professorship.getAssociatedShiftProfessorship().add(shiftProfessorship);                shift.getAssociatedShiftProfessorship().add(shiftProfessorship);            }            shiftProfessorship.setPercentage(percentage);                        CreditsValidator.validatePeriod(professorship.getTeacher().getIdInternal(), professorship                    .getExecutionCourse().getExecutionPeriod().getIdInternal(), shiftProfessorship);            shiftProfessorshipAdded.add(shiftProfessorship);        }    }