Search in sources :

Example 1 with Bookingtype

use of de.vitero.schema.booking.Bookingtype 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);
    }
}
Also used : CreateBookingRequest(de.vitero.schema.booking.CreateBookingRequest) CreateBookingResponse(de.vitero.schema.booking.CreateBookingResponse) WebServiceException(javax.xml.ws.WebServiceException) Booking(de.vitero.schema.booking.Booking) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Bookingtype(de.vitero.schema.booking.Bookingtype) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) Newbookingtype(de.vitero.schema.booking.Newbookingtype) ConnectException(java.net.ConnectException)

Example 2 with Bookingtype

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

Example 3 with Bookingtype

use of de.vitero.schema.booking.Bookingtype 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;
}
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)

Example 4 with Bookingtype

use of de.vitero.schema.booking.Bookingtype in project OpenOLAT by OpenOLAT.

the class ViteroManager method updateBooking.

/**
 * There is not update on vms. We can only update some OLAT specific options.
 * @param group
 * @param ores
 * @param vBooking
 * @return
 * @throws VmsNotAvailableException
 */
public ViteroBooking updateBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking vBooking) throws VmsNotAvailableException {
    Bookingtype bookingType = getVmsBookingById(vBooking.getBookingId());
    if (bookingType == null) {
        log.info("Booking doesn't exist: " + vBooking.getBookingId());
        return null;
    }
    Booking_Type booking = bookingType.getBooking();
    // set the vms values
    update(vBooking, booking);
    // update the property
    updateProperty(group, ores, subIdentifier, vBooking);
    return vBooking;
}
Also used : Booking_Type(de.vitero.schema.booking.Booking_Type) Bookingtype(de.vitero.schema.booking.Bookingtype)

Example 5 with Bookingtype

use of de.vitero.schema.booking.Bookingtype 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

Bookingtype (de.vitero.schema.booking.Bookingtype)10 Booking_Type (de.vitero.schema.booking.Booking_Type)6 ViteroBooking (org.olat.modules.vitero.model.ViteroBooking)6 ConnectException (java.net.ConnectException)4 WebServiceException (javax.xml.ws.WebServiceException)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 ErrorCode (org.olat.modules.vitero.model.ErrorCode)4 Property (org.olat.properties.Property)4 Booking (de.vitero.schema.booking.Booking)2 Bookingid (de.vitero.schema.booking.Bookingid)2 CreateBookingRequest (de.vitero.schema.booking.CreateBookingRequest)2 CreateBookingResponse (de.vitero.schema.booking.CreateBookingResponse)2 Newbookingtype (de.vitero.schema.booking.Newbookingtype)2 ArrayList (java.util.ArrayList)2 ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)2