use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class StartColumnDescriptor method renderValue.
@Override
public void renderValue(StringOutput sb, int row, Renderer renderer) {
int sortedRow = table.getSortedRow(row);
ViteroBooking booking = (ViteroBooking) getTable().getTableDataModel().getObject(sortedRow);
if (viteroManager.canGoBooking(booking)) {
if (booking.isAutoSignIn()) {
Object state = getTable().getTableDataModel().getValueAt(sortedRow, ViteroBookingDataModel.Column.sign.ordinal());
if (Sign.signout.equals(state)) {
sb.append(translator.translate(getHeaderKey()));
}
} else {
sb.append(translator.translate(getHeaderKey()));
}
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class FilterBookings method filterMyFutureBookings.
public static void filterMyFutureBookings(final List<ViteroBooking> bookings, final List<ViteroBooking> signedInBookings) {
// only the bookings in the future
Date now = new Date();
for (Iterator<ViteroBooking> it = bookings.iterator(); it.hasNext(); ) {
ViteroBooking booking = it.next();
Date end = booking.getEnd();
if (end.before(now)) {
it.remove();
} else if (!booking.isAutoSignIn()) {
boolean in = false;
for (ViteroBooking signedInBooking : signedInBookings) {
if (signedInBooking.getBookingId() == booking.getBookingId()) {
// already in
in = true;
}
}
if (!in) {
it.remove();
}
}
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.
the class ViteroManager method getBookings.
/**
* Return the
* @param group The group (optional)
* @param ores The OLAT resourceable (of the course) (optional)
* @return
*/
public List<ViteroBooking> getBookings(BusinessGroup group, OLATResourceable ores, String subIdentifier) throws VmsNotAvailableException {
List<Property> properties = propertyManager.listProperties(null, group, ores, VMS_CATEGORY, null);
List<ViteroBooking> bookings = new ArrayList<ViteroBooking>();
for (Property property : properties) {
String propIdentifier = property.getStringValue();
if ((propIdentifier == null || subIdentifier == null) || (subIdentifier != null && (propIdentifier == null || subIdentifier.equals(propIdentifier)))) {
String bookingStr = property.getTextValue();
ViteroBooking booking = deserializeViteroBooking(bookingStr);
Bookingtype bookingType = getVmsBookingById(booking.getBookingId());
if (bookingType != null) {
Booking_Type vmsBooking = bookingType.getBooking();
booking.setProperty(property);
update(booking, vmsBooking);
bookings.add(booking);
}
}
}
return bookings;
}
use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.
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 klemens.
the class ViteroManager method createBooking.
public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking vBooking) throws VmsNotAvailableException {
Bookingtype booking = getVmsBookingById(vBooking.getBookingId());
if (booking != null) {
log.info("Booking already exists: " + vBooking.getBookingId());
return new ViteroStatus();
}
try {
// a group per meeting
String groupName = vBooking.getGroupName();
int groupId = createGroup(groupName);
if (groupId < 0) {
return new ViteroStatus(ErrorCode.unkown);
}
vBooking.setGroupId(groupId);
// create the meeting with the new group
Booking bookingWs = getBookingWebService();
CreateBookingRequest createRequest = new CreateBookingRequest();
Newbookingtype newBooking = new Newbookingtype();
// mandatory
newBooking.setStart(format(vBooking.getStart()));
newBooking.setEnd(format(vBooking.getEnd()));
newBooking.setStartbuffer(vBooking.getStartBuffer());
newBooking.setEndbuffer(vBooking.getEndBuffer());
newBooking.setGroupid(groupId);
newBooking.setRoomsize(vBooking.getRoomSize());
newBooking.setTimezone(viteroModule.getTimeZoneId());
if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
newBooking.setEventname(vBooking.getEventName());
}
createRequest.setBooking(newBooking);
CreateBookingResponse response = bookingWs.createBooking(createRequest);
Boolean bookingCollision = response.isBookingcollision();
Boolean moduleCollision = response.isModulecollision();
int bookingId = response.getBookingid();
if (bookingCollision != null && bookingCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.bookingCollision);
} else if (moduleCollision != null && moduleCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.moduleCollision);
}
vBooking.setBookingId(bookingId);
getOrCreateProperty(group, ores, subIdentifier, vBooking);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case invalidTimezone:
log.error("Invalid time zone!", f);
break;
case bookingCollision:
log.error("Booking collision!", f);
break;
case moduleCollision:
log.error("Invalid module selection!", f);
break;
case bookingInPast:
log.error("Booking in the past!", f);
break;
case licenseExpired:
log.error("License/customer expired!", f);
break;
default:
logAxisError("Cannot create a booking.", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot create a booking.", e);
return new ViteroStatus(ErrorCode.remoteException);
}
}
Aggregations