for (Object object : bookings) {
Booking booking = (Booking) object;
if(booking.getType().equals("CONFIRMED") || booking.getType().equals("BOOKING")) {
GregorianCalendar beginDate = booking.getBeginDate();
GregorianCalendar finishDate = booking.getFinishDate();
// Controllo se e quali camere sono occupate
if((beginDate.equals(startDate) && CalendarUtils.isDayIntoDateRange(beginDate, finishDate, endDate)) || (finishDate.equals(endDate) && CalendarUtils.isDayIntoDateRange(beginDate, finishDate, startDate)))
{
rooms.remove(booking.getRoom());
}
if((beginDate.equals(startDate) && finishDate.equals(endDate)) || (beginDate.before(startDate) && finishDate.after(endDate)))
{
rooms.remove(booking.getRoom());
}
if((beginDate.equals(startDate) && beginDate.equals(endDate)) || (finishDate.equals(startDate) && finishDate.equals(endDate)))
{
rooms.remove(booking.getRoom());
}
// controllo se e quali camere sono parzialmente occupate
if((beginDate.equals(endDate) && beginDate.after(startDate)) || (finishDate.equals(startDate) && finishDate.before(endDate)))
{
roomsMap.put("partial_"+booking.getRoom().getId(), booking.getRoom());
rooms.remove(booking.getRoom());
}
if((beginDate.after(startDate) && CalendarUtils.isDayIntoDateRange(beginDate, finishDate, endDate)) || (CalendarUtils.isDayIntoDateRange(beginDate, finishDate, startDate) && finishDate.before(endDate)))
{
roomsMap.put("partial_"+booking.getRoom().getId(), booking.getRoom());
rooms.remove(booking.getRoom());
}
if(beginDate.after(startDate) && finishDate.before(endDate))
{
roomsMap.put("partial_"+booking.getRoom().getId(), booking.getRoom());
rooms.remove(booking.getRoom());
}
// controllo per le camere libere
if((beginDate.after(endDate) && beginDate.after(startDate)) || (finishDate.before(startDate) && finishDate.before(endDate)))
{
roomsMap.put("free_"+ booking.getRoom().getId(), booking.getRoom());
rooms.remove(booking.getRoom());
}
}
}