ITurno shift = (ITurno) sp.getITurnoPersistente().readByOID(Turno.class, infoShiftOld.getIdInternal());
ITurno shiftToEdit = (ITurno) sp.getITurnoPersistente().readByOID(Turno.class, infoShiftOld.getIdInternal());
    public Object run(InfoShift infoShiftOld, InfoShift infoShiftNew) throws FenixServiceException {        InfoShift infoShift = null;        try {            newShiftIsValid(infoShiftOld, infoShiftNew.getTipo(), infoShiftNew                    .getInfoDisciplinaExecucao(), infoShiftNew.getLotacao());        } catch (InvalidNewShiftExecutionCourse ex) {            throw new InvalidNewShiftExecutionCourse();        } catch (InvalidNewShiftType ex) {            throw new InvalidNewShiftType();        } catch (InvalidNewShiftCapacity ex) {            throw new InvalidNewShiftCapacity();        }        try {            ISuportePersistente sp;            sp = SuportePersistenteOJB.getInstance();            ITurno shift = (ITurno) sp.getITurnoPersistente().readByOID(Turno.class,                    infoShiftOld.getIdInternal());            int capacityDiference = infoShiftNew.getLotacao().intValue() - shift.getLotacao().intValue();            if (shift.getAvailabilityFinal().intValue() + capacityDiference < 0) {                throw new InvalidFinalAvailabilityException();            }            sp.getITurnoPersistente().simpleLockWrite(shift);            shift.setNome(infoShiftNew.getNome());            shift.setTipo(infoShiftNew.getTipo());            shift.setLotacao(infoShiftNew.getLotacao());            shift.setAvailabilityFinal(new Integer(shift.getAvailabilityFinal().intValue()                    + capacityDiference));            IExecutionCourse executionCourse = (IExecutionCourse) sp.getIPersistentExecutionCourse()                    .readByOID(ExecutionCourse.class,                            infoShiftNew.getInfoDisciplinaExecucao().getIdInternal());            shift.setDisciplinaExecucao(executionCourse);            // Also change the type of associated lessons and lessons execution            // course            if (shift.getAssociatedLessons() != null) {                for (int i = 0; i < shift.getAssociatedLessons().size(); i++) {                    sp.getIAulaPersistente().simpleLockWrite(                            (IDomainObject) shift.getAssociatedLessons().get(i));                    ((IAula) shift.getAssociatedLessons().get(i)).setTipo(infoShiftNew.getTipo());                    ((IAula) shift.getAssociatedLessons().get(i)).setShift(shift);                    //((IAula)                    // shift.getAssociatedLessons().get(i)).setDisciplinaExecucao(executionCourse);                }            }            infoShift = Cloner.copyShift2InfoShift(shift);        } catch (ExcepcaoPersistencia ex) {            throw new ExistingShiftException(ex);        }        // NOTE: changed the lock twice strategy to see if the new turn exists        //        catch (ExcepcaoPersistencia ex)        //        {        //            throw new FenixServiceException(ex);        //        }        return infoShift;    }