Shift shiftToEdit = (Shift) persistentObject.readByOID(Shift.class, infoShiftOld.getIdInternal());
final Shift shiftToEdit = (Shift) persistentObject.readByOID(Shift.class, infoShiftOld.getIdInternal());
	public Object run(InfoShift infoShiftOld, InfoShift infoShiftNew) throws FenixServiceException,			ExcepcaoPersistencia {		newShiftIsValid(infoShiftOld, infoShiftNew.getTipo(), infoShiftNew.getInfoDisciplinaExecucao(),				infoShiftNew.getLotacao());		Shift shiftToEdit = (Shift) persistentObject.readByOID(Shift.class,				infoShiftOld.getIdInternal());		int capacityDiference = infoShiftNew.getLotacao().intValue()				- shiftToEdit.getLotacao().intValue();		if (shiftToEdit.getAvailabilityFinal().intValue() + capacityDiference < 0) {			throw new InvalidFinalAvailabilityException();		}		Shift otherShiftWithSameNewName = persistentSupport.getITurnoPersistente().readByNameAndExecutionCourse(				infoShiftNew.getNome(), infoShiftNew.getInfoDisciplinaExecucao().getIdInternal());		if ((otherShiftWithSameNewName != null)				&& !(otherShiftWithSameNewName.getIdInternal().equals(shiftToEdit.getIdInternal()))) {			throw new ExistingServiceException("Duplicate Entry: " + otherShiftWithSameNewName.getNome());		}		shiftToEdit.setNome(infoShiftNew.getNome());		shiftToEdit.setTipo(infoShiftNew.getTipo());		shiftToEdit.setLotacao(infoShiftNew.getLotacao());		shiftToEdit.setAvailabilityFinal(new Integer(shiftToEdit.getAvailabilityFinal().intValue()				+ capacityDiference));		final ExecutionCourse executionCourse = (ExecutionCourse) persistentObject				.readByOID(ExecutionCourse.class,						infoShiftNew.getInfoDisciplinaExecucao().getIdInternal());		shiftToEdit.setDisciplinaExecucao(executionCourse);		// Also change the type of associated lessons and lessons execution		// course		if (shiftToEdit.getAssociatedLessons() != null) {			for (int i = 0; i < shiftToEdit.getAssociatedLessons().size(); i++) {				shiftToEdit.getAssociatedLessons().get(i).setTipo(infoShiftNew.getTipo());				//shiftToEdit.getAssociatedLessons().get(i).setShift(shiftToEdit);			}		}		return InfoShift.newInfoFromDomain(shiftToEdit);	}