use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class ViteroManager method slayZombies.
public void slayZombies() {
List<Property> properties = propertyManager.listProperties(null, null, null, VMS_CATEGORY_ZOMBIE, null);
for (Property property : properties) {
try {
String bookingStr = property.getTextValue();
ViteroBooking booking = deserializeViteroBooking(bookingStr);
deleteBooking(booking);
} catch (VmsNotAvailableException e) {
// try later
log.debug("Cannot clean-up vitero room, vms not available");
} catch (Exception e) {
log.error("", e);
}
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class ViteroManager method createBooking.
public ViteroBooking createBooking(String resourceName) throws VmsNotAvailableException {
ViteroBooking booking = new ViteroBooking();
booking.setBookingId(-1);
booking.setGroupId(-1);
booking.setResourceName(resourceName);
Calendar cal = Calendar.getInstance();
int minute = cal.get(Calendar.MINUTE);
if (minute < 10) {
cal.set(Calendar.MINUTE, 15);
} else if (minute < 25) {
cal.set(Calendar.MINUTE, 30);
} else if (minute < 40) {
cal.set(Calendar.MINUTE, 45);
} else {
cal.add(Calendar.HOUR, 1);
cal.set(Calendar.MINUTE, 0);
}
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
booking.setStart(cal.getTime());
booking.setStartBuffer(15);
cal.add(Calendar.HOUR, 1);
booking.setEnd(cal.getTime());
booking.setEndBuffer(15);
List<Integer> roomSizes = getLicencedRoomSizes();
if (!roomSizes.isEmpty()) {
booking.setRoomSize(roomSizes.get(0));
}
return booking;
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class ViteroManager method getBookingByDate.
public List<ViteroBooking> getBookingByDate(Date start, Date end) throws VmsNotAvailableException {
try {
Booking bookingWs = getBookingWebService();
GetBookingListByDateRequest dateRequest = new GetBookingListByDateRequest();
dateRequest.setStart(format(start));
dateRequest.setEnd(format(end));
dateRequest.setTimezone(viteroModule.getTimeZoneId());
dateRequest.setCustomerid(viteroModule.getCustomerId());
Bookinglist bookingList = bookingWs.getBookingListByDate(dateRequest);
List<Booking_Type> bookings = bookingList.getBooking();
return convert(bookings);
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot get the list of bookings by date.", f);
}
return Collections.emptyList();
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
return Collections.emptyList();
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.
the class ViteroManager method deleteAll.
public void deleteAll(BusinessGroup group, OLATResourceable ores, String subIdentifier) {
try {
List<Property> properties = propertyManager.listProperties(null, group, ores, VMS_CATEGORY, null);
for (Property property : properties) {
String bookingStr = property.getTextValue();
ViteroBooking booking = deserializeViteroBooking(bookingStr);
deleteBooking(booking);
}
} catch (VmsNotAvailableException e) {
log.error("", e);
markAsZombie(group, ores, subIdentifier);
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.
the class ViteroManager method getBookingById.
public ViteroBooking getBookingById(BusinessGroup group, OLATResourceable ores, String subIdentifier, int bookingId) throws VmsNotAvailableException {
ViteroBooking booking = null;
List<Property> properties = propertyManager.listProperties(null, group, ores, VMS_CATEGORY, Integer.toString(bookingId));
if (properties.size() > 0) {
Property property = properties.get(0);
String propIdentifier = property.getStringValue();
if ((propIdentifier == null || subIdentifier == null) || (subIdentifier != null && (propIdentifier == null || subIdentifier.equals(propIdentifier)))) {
String bookingStr = property.getTextValue();
booking = deserializeViteroBooking(bookingStr);
Bookingtype bookingType = getVmsBookingById(booking.getBookingId());
if (bookingType != null) {
Booking_Type vmsBooking = bookingType.getBooking();
booking.setProperty(property);
update(booking, vmsBooking);
}
}
}
return booking;
}
Aggregations