Search in sources :

Example 16 with ViteroBooking

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

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();
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) GetBookingListByDateRequest(de.vitero.schema.booking.GetBookingListByDateRequest) Booking_Type(de.vitero.schema.booking.Booking_Type) Booking(de.vitero.schema.booking.Booking) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Bookinglist(de.vitero.schema.booking.Bookinglist) ConnectException(java.net.ConnectException)

Example 17 with ViteroBooking

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

the class ViteroBookingsController method loadModel.

protected void loadModel() {
    try {
        List<ViteroBooking> bookings = viteroManager.getBookings(group, ores, subIdentifier);
        List<ViteroBooking> myBookings = viteroManager.getBookingInFutures(getIdentity());
        FilterBookings.filterMyFutureBookings(bookings, myBookings);
        Collections.sort(bookings, new StartBookingComparator());
        TableDataModel<ViteroBooking> tableData = new ViteroBookingDataModel(bookings, myBookings);
        tableCtr.setTableDataModel(tableData);
    } catch (VmsNotAvailableException e) {
        TableDataModel<ViteroBooking> tableData = new ViteroBookingDataModel();
        tableCtr.setTableDataModel(tableData);
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) StartBookingComparator(org.olat.modules.vitero.model.StartBookingComparator) TableDataModel(org.olat.core.gui.components.table.TableDataModel)

Example 18 with ViteroBooking

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

the class ViteroBookingsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableCtr) {
        if (event instanceof TableEvent) {
            TableEvent e = (TableEvent) event;
            int row = e.getRowId();
            ViteroBooking booking = (ViteroBooking) tableCtr.getTableDataModel().getObject(row);
            if ("start".equals(e.getActionId())) {
                openVitero(ureq, booking);
            } else if ("signin".equals(e.getActionId())) {
                signInVitero(ureq, booking);
            } else if ("signout".equals(e.getActionId())) {
                signOutVitero(ureq, booking);
            } else if ("opengroup".equals(e.getActionId())) {
                openGroup(ureq, booking);
            }
        }
    } else if (source == cmc) {
        removeAsListenerAndDispose(cmc);
        viteroGroupVC = null;
        cmc = null;
    }
    super.event(ureq, source, event);
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) TableEvent(org.olat.core.gui.components.table.TableEvent)

Example 19 with ViteroBooking

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

the class ViteroBookingsEditController method reloadModel.

protected void reloadModel() {
    try {
        bookingDisplays.clear();
        List<ViteroBooking> bookings = viteroManager.getBookings(group, ores, subIdentifier);
        int i = 0;
        for (ViteroBooking booking : bookings) {
            BookingDisplay display = new BookingDisplay(booking);
            if (!readOnly) {
                display.setDeleteButton(uifactory.addFormLink("delete_" + i++, "delete", "delete", flc, Link.BUTTON));
                display.setEditButton(uifactory.addFormLink("edit_" + i++, "edit", "edit", flc, Link.BUTTON));
            }
            display.setUsersButton(uifactory.addFormLink("users_" + i++, "users", "users", flc, Link.BUTTON));
            display.setGroupButton(uifactory.addFormLink("group_" + i++, "group.open", "group.open", flc, Link.BUTTON));
            bookingDisplays.add(display);
        }
        flc.contextPut("bookingDisplays", bookingDisplays);
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException)

Example 20 with ViteroBooking

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

the class ViteroBookingWebService method addMembers.

/**
 * Update the list of members of the booking, it add and mutates the
 * members and delete the missing members.
 *
 * @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
 * @param members The array of members
 * @return Nothing
 */
@POST
@Path("{bookingId}/members")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addMembers(@PathParam("bookingId") int bookingId, ViteroGroupMemberVO[] members) {
    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<ViteroErrorVO> errors = new ArrayList<>();
        List<String> currentEmails = new ArrayList<>(roles.getEmailsOfParticipants());
        for (ViteroGroupMemberVO member : members) {
            GroupRole role = GroupRole.valueOf(member.getGroupRole());
            Identity identity = securityManager.loadIdentityByKey(member.getIdentityKey());
            String currentEmail = identity.getUser().getProperty(UserConstants.EMAIL, null);
            GroupRole currentRole = roles.getEmailsToRole().get(currentEmail);
            if (currentRole == null) {
                ViteroStatus status = viteroManager.addToRoom(booking, identity, role);
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            } else if (!currentRole.equals(role)) {
                Integer vmsUserId = roles.getEmailsToVmsUserId().get(currentEmail);
                ViteroStatus status = viteroManager.changeGroupRole(booking.getGroupId(), vmsUserId.intValue(), role.getVmsValue());
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            }
            currentEmails.remove(currentEmail);
        }
        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) {
                ViteroStatus status = viteroManager.removeFromRoom(booking, identity);
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            }
        }
        return Response.ok().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) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) SearchIdentityParams(org.olat.basesecurity.SearchIdentityParams) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

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