final Set<OldRoom> occupiedRooms = new HashSet<OldRoom>(); for (final RoomOccupation roomOccupation : getAssociatedRoomOccupationSet()) { if (roomOccupation.getRoom().findOccupationSet(period, this.getBeginning(), this.getEnd(), roomOccupation.getDayOfWeek(), RoomOccupation.DIARIA, null).size() > 1) { occupiedRooms.add(roomOccupation.getRoom()); } } if (!occupiedRooms.isEmpty()) { final StringBuilder stringBuilder = new StringBuilder(); for (final OldRoom oldRoom : occupiedRooms) { stringBuilder.append(oldRoom.getNome()).append(" "); } throw new DomainException("error.occupied.rooms", stringBuilder.toString()); }
    protected void setAttributesAndAssociateRooms(Date day, Date beginning, Date end,            List<ExecutionCourse> executionCoursesToAssociate,            List<CurricularCourseScope> curricularCourseScopesToAssociate, List<OldRoom> rooms,            OccupationPeriod period) {        if (rooms == null) {            rooms = new ArrayList<OldRoom>(0);        }        checkValidHours(beginning, end);        this.getAssociatedExecutionCourses().addAll(executionCoursesToAssociate);        this.getAssociatedCurricularCourseScope().addAll(curricularCourseScopesToAssociate);        this.setDayDate(day);        this.setBeginningDate(beginning);        this.setEndDate(end);        associateRooms(rooms, period);        final Set<RoomOccupation> roomOccupationsToDelete = new HashSet<RoomOccupation>();        for (final RoomOccupation roomOccupation : getAssociatedRoomOccupation()) {            final Room room = roomOccupation.getRoom();            if (!rooms.contains(room)) {                roomOccupationsToDelete.add(roomOccupation);            }        }        for (final RoomOccupation roomOccupation : roomOccupationsToDelete) {            roomOccupation.delete();        }    }