Search in sources :

Example 11 with ViteroBooking

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);
        }
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) Property(org.olat.properties.Property) ConnectException(java.net.ConnectException) WebServiceException(javax.xml.ws.WebServiceException) ConnectTimeoutException(org.apache.commons.httpclient.ConnectTimeoutException) ParseException(java.text.ParseException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 12 with ViteroBooking

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

Example 13 with ViteroBooking

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();
    }
}
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 14 with ViteroBooking

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

Example 15 with ViteroBooking

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;
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) Booking_Type(de.vitero.schema.booking.Booking_Type) Property(org.olat.properties.Property) Bookingtype(de.vitero.schema.booking.Bookingtype)

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