Search in sources :

Example 31 with ViteroBooking

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

the class StartColumnDescriptor method renderValue.

@Override
public void renderValue(StringOutput sb, int row, Renderer renderer) {
    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)) {
                sb.append(translator.translate(getHeaderKey()));
            }
        } else {
            sb.append(translator.translate(getHeaderKey()));
        }
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking)

Example 32 with ViteroBooking

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

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)

Example 33 with ViteroBooking

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

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 34 with ViteroBooking

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

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 35 with ViteroBooking

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

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)

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