Search in sources :

Example 41 with ViteroBooking

use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.

the class ViteroBookingsEditController method newBooking.

protected void newBooking(UserRequest ureq) {
    try {
        ViteroBooking viteroBooking = viteroManager.createBooking(resourceName);
        editBooking(ureq, viteroBooking);
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException)

Example 42 with ViteroBooking

use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.

the class ViteroBookingWebService method saveRoom.

private Response saveRoom(ViteroBookingVO booking) {
    try {
        ViteroBooking vBooking = new ViteroBooking();
        vBooking.setBookingId(booking.getBookingId());
        vBooking.setExternalId(booking.getExternalId());
        vBooking.setGroupId(booking.getGroupId());
        vBooking.setGroupName(booking.getGroupName());
        vBooking.setEventName(booking.getEventName());
        vBooking.setStart(booking.getStart());
        vBooking.setStartBuffer(booking.getStartBuffer());
        vBooking.setEnd(booking.getEnd());
        vBooking.setEndBuffer(booking.getEndBuffer());
        vBooking.setRoomSize(booking.getRoomSize());
        vBooking.setAutoSignIn(booking.isAutoSignIn());
        vBooking.setTimeZoneId(viteroModule.getTimeZoneId());
        ViteroStatus status;
        if (booking.getBookingId() > 0) {
            status = viteroManager.updateVmsBooking(vBooking);
        } else {
            status = viteroManager.createBooking(null, ores, subIdentifier, vBooking);
        }
        Response response;
        if (status.isOk()) {
            response = Response.ok(new ViteroBookingVO(vBooking)).build();
        } else {
            response = handleViteroError(status);
        }
        return response;
    } catch (VmsNotAvailableException e) {
        log.error("", e);
        return handleNotAvailableException();
    }
}
Also used : Response(javax.ws.rs.core.Response) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Example 43 with ViteroBooking

use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.

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();
    }
}
Also used : ViteroGroupRoles(org.olat.modules.vitero.model.ViteroGroupRoles) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ArrayList(java.util.ArrayList) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) GroupRole(org.olat.modules.vitero.model.GroupRole) Identity(org.olat.core.id.Identity) SearchIdentityParams(org.olat.basesecurity.SearchIdentityParams) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 44 with ViteroBooking

use of org.olat.modules.vitero.model.ViteroBooking in project openolat by klemens.

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();
            }
        }
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) Date(java.util.Date)

Aggregations

ViteroBooking (org.olat.modules.vitero.model.ViteroBooking)44 VmsNotAvailableException (org.olat.modules.vitero.manager.VmsNotAvailableException)16 ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)8 Property (org.olat.properties.Property)8 Booking_Type (de.vitero.schema.booking.Booking_Type)6 Bookingtype (de.vitero.schema.booking.Bookingtype)6 ConnectException (java.net.ConnectException)6 ArrayList (java.util.ArrayList)6 Produces (javax.ws.rs.Produces)6 WebServiceException (javax.xml.ws.WebServiceException)6 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)6 Booking (de.vitero.schema.booking.Booking)4 Date (java.util.Date)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 SearchIdentityParams (org.olat.basesecurity.SearchIdentityParams)4 TableEvent (org.olat.core.gui.components.table.TableEvent)4 Identity (org.olat.core.id.Identity)4 ErrorCode (org.olat.modules.vitero.model.ErrorCode)4 GroupRole (org.olat.modules.vitero.model.GroupRole)4