use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class ViteroBookingWebService method getMembers.
/**
* Returns the list of members of the booking.
*
* @response.representation.200.qname {http://www.example.com}viteroGroupMemberVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc This is the list of all bookings of a resource
* @response.representation.200.example {@link org.olat.modules.vitero.restapi.Examples#SAMPLE_ViteroGroupMemberVO}
* @param bookingId The id of the booking
* @return The list of members in the specified booking
*/
@GET
@Path("{bookingId}/members")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getMembers(@PathParam("bookingId") int bookingId) {
try {
ViteroBooking booking = viteroManager.getBookingById(null, ores, subIdentifier, bookingId);
if (booking == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
ViteroGroupRoles roles = viteroManager.getGroupRoles(booking.getGroupId());
if (roles == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
List<String> currentEmails = new ArrayList<>(roles.getEmailsOfParticipants());
List<ViteroGroupMemberVO> memberList = new ArrayList<>(currentEmails.size());
for (String email : currentEmails) {
SearchIdentityParams params = new SearchIdentityParams();
params.setUserProperties(Collections.singletonMap(UserConstants.EMAIL, email));
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(params, 0, 1);
for (Identity identity : identities) {
GroupRole role = roles.getEmailsToRole().get(email);
memberList.add(new ViteroGroupMemberVO(identity.getKey(), role.name()));
}
}
ViteroGroupMemberVO[] members = memberList.toArray(new ViteroGroupMemberVO[memberList.size()]);
return Response.ok(members).build();
} catch (VmsNotAvailableException e) {
log.error("", e);
return handleNotAvailableException();
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
the class StartColumnDescriptor method getAction.
@Override
public String getAction(int row) {
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)) {
return super.getAction(row);
}
} else {
return super.getAction(row);
}
}
return null;
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
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);
}
}
use of org.olat.modules.vitero.model.ViteroBooking in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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