diff --git a/src/main/java/org/olat/modules/vitero/manager/ViteroManager.java b/src/main/java/org/olat/modules/vitero/manager/ViteroManager.java index 08893cf590e467082dc07a3539876ccd9ac5efea..8d7c7f8fdd0e3e5cddf0be9d404d5edcff3547d4 100644 --- a/src/main/java/org/olat/modules/vitero/manager/ViteroManager.java +++ b/src/main/java/org/olat/modules/vitero/manager/ViteroManager.java @@ -231,10 +231,7 @@ public class ViteroManager implements UserDataDeletable { cal.add(Calendar.MINUTE, booking.getEndBuffer()); Date end = cal.getTime(); - if(start.before(now) && end.after(now)) { - return true; - } - return false; + return(start.before(now) && end.after(now)); } public String getURLToBooking(Identity identity, ViteroBooking booking) @@ -1039,6 +1036,8 @@ public class ViteroManager implements UserDataDeletable { booking.setEnd(cal.getTime()); booking.setEndBuffer(15); + booking.setInspire(viteroModule.isInspire()); + List<Integer> roomSizes = getLicencedRoomSizes(); if(!roomSizes.isEmpty()) { booking.setRoomSize(roomSizes.get(0)); @@ -1304,7 +1303,7 @@ public class ViteroManager implements UserDataDeletable { throws VmsNotAvailableException { ViteroBooking booking = null; List<Property> properties = propertyManager.listProperties(null, group, ores, VMS_CATEGORY, Integer.toString(bookingId)); - if(properties.size() > 0) { + if(!properties.isEmpty()) { Property property = properties.get(0); String propIdentifier = property.getStringValue(); if((propIdentifier == null || subIdentifier == null) @@ -1388,7 +1387,7 @@ public class ViteroManager implements UserDataDeletable { //check if vms user with an openolat login exists on vms server //without the need authentication object in openolat. List<Usertype> users = getCustomersUsers(); - if(users != null && users.size() > 0) { + if(users != null && !users.isEmpty()) { for(Usertype user:users) { String vmsUsername = user.getUsername(); if(vmsUsername.startsWith(prefix)) { @@ -1549,7 +1548,7 @@ public class ViteroManager implements UserDataDeletable { private final List<ViteroBooking> convert(List<Booking_Type> bookings) { List<ViteroBooking> viteroBookings = new ArrayList<>(); - if(bookings != null && bookings.size() > 0) { + if(bookings != null && !bookings.isEmpty()) { for(Booking_Type b:bookings) { viteroBookings.add(convert(b)); } @@ -1574,6 +1573,7 @@ public class ViteroManager implements UserDataDeletable { vb.setStartBuffer(booking.getStartbuffer()); vb.setEnd(parse(booking.getEnd())); vb.setEndBuffer(booking.getEndbuffer()); + vb.setInspire(booking.isInspire()); return vb; } diff --git a/src/main/java/org/olat/modules/vitero/model/ViteroBooking.java b/src/main/java/org/olat/modules/vitero/model/ViteroBooking.java index 8d6b73a537a3ad868604138e36fd24c8a0d99209..9d18d639a32aac5b9494395f133ff8d4db7f7fa0 100644 --- a/src/main/java/org/olat/modules/vitero/model/ViteroBooking.java +++ b/src/main/java/org/olat/modules/vitero/model/ViteroBooking.java @@ -45,6 +45,7 @@ public class ViteroBooking { private int endBuffer; private int roomSize; private boolean autoSignIn; + private boolean inspire; private String timeZoneId; private String resourceName; @@ -167,4 +168,12 @@ public class ViteroBooking { public void setAutoSignIn(boolean autoSignIn) { this.autoSignIn = autoSignIn; } + + public boolean isInspire() { + return inspire; + } + + public void setInspire(boolean inspire) { + this.inspire = inspire; + } } \ No newline at end of file diff --git a/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingVO.java b/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingVO.java index cf98ffbd2e0aabda92aff271bc38c003840849a7..f4a0286b5d0ab5726ba882072c73e0590f318d8c 100644 --- a/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingVO.java +++ b/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingVO.java @@ -47,6 +47,7 @@ public class ViteroBookingVO { private Date end; private int endBuffer; private int roomSize; + private boolean inspire; private boolean autoSignIn; private String timeZoneId; @@ -66,6 +67,7 @@ public class ViteroBookingVO { endBuffer = booking.getEndBuffer(); roomSize = booking.getRoomSize(); autoSignIn = booking.isAutoSignIn(); + inspire = booking.isInspire(); timeZoneId = booking.getTimeZoneId(); } @@ -157,6 +159,14 @@ public class ViteroBookingVO { this.autoSignIn = autoSignIn; } + public boolean isInspire() { + return inspire; + } + + public void setInspire(boolean inspire) { + this.inspire = inspire; + } + public String getTimeZoneId() { return timeZoneId; } diff --git a/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingWebService.java b/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingWebService.java index 306954d8ed475ff7c71643a3310c5208b6702ceb..7a6c540bef367cd9127c58a1b29e120d2a64b579 100644 --- a/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingWebService.java +++ b/src/main/java/org/olat/modules/vitero/restapi/ViteroBookingWebService.java @@ -155,6 +155,7 @@ public class ViteroBookingWebService { vBooking.setEndBuffer(booking.getEndBuffer()); vBooking.setRoomSize(booking.getRoomSize()); vBooking.setAutoSignIn(booking.isAutoSignIn()); + vBooking.setInspire(booking.isInspire()); vBooking.setTimeZoneId(viteroModule.getTimeZoneId()); ViteroStatus status; diff --git a/src/main/java/org/olat/modules/vitero/ui/ViteroAdminBookingRawInfosController.java b/src/main/java/org/olat/modules/vitero/ui/ViteroAdminBookingRawInfosController.java index e96c6b0c8b972e05ed1f2b28b7925d43aec3e823..ca004684a787c9634aa1331d51569212a1f9b276 100644 --- a/src/main/java/org/olat/modules/vitero/ui/ViteroAdminBookingRawInfosController.java +++ b/src/main/java/org/olat/modules/vitero/ui/ViteroAdminBookingRawInfosController.java @@ -26,8 +26,10 @@ import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.core.util.Formatter; +import org.olat.modules.vitero.ViteroModule; import org.olat.modules.vitero.model.ViteroBooking; import org.olat.modules.vitero.model.ViteroGroup; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -43,18 +45,18 @@ public class ViteroAdminBookingRawInfosController extends FormBasicController { private final ViteroGroup group; private final ViteroBooking booking; private final Formatter formatter; - private static final String[] autoSignInKeys = new String[]{"on"}; - private final String[] autoSignInValues; + private static final String[] onKeys = new String[]{"on"}; + + + @Autowired + private ViteroModule viteroModule; public ViteroAdminBookingRawInfosController(UserRequest ureq, WindowControl wControl, ViteroBooking booking, ViteroGroup group) { super(ureq, wControl); - this.group = group; this.booking = booking; - this.formatter = Formatter.getInstance(getLocale()); - autoSignInValues = new String[]{ translate("enabled") }; - + formatter = Formatter.getInstance(getLocale()); initForm(ureq); } @@ -75,10 +77,18 @@ public class ViteroAdminBookingRawInfosController extends FormBasicController { name = name.substring(0, sepIndex); } uifactory.addStaticTextElement("group.name", name, formLayout); + + String[] enabledValues = new String[]{translate("enabled")}; + MultipleSelectionElement inspireEl = uifactory.addCheckboxesHorizontal("option.inspire", formLayout, onKeys, enabledValues); + inspireEl.setVisible(viteroModule.isInspire()); + if(viteroModule.isInspire() && booking.isInspire()) { + inspireEl.select(onKeys[0], true); + } + inspireEl.setEnabled(false); - MultipleSelectionElement autoSignIn = uifactory.addCheckboxesHorizontal("booking.autoSignIn", formLayout, autoSignInKeys, autoSignInValues); + MultipleSelectionElement autoSignIn = uifactory.addCheckboxesHorizontal("booking.autoSignIn", formLayout, onKeys, enabledValues); if(booking.isAutoSignIn()) { - autoSignIn.select(autoSignInKeys[0], true); + autoSignIn.select(onKeys[0], true); } autoSignIn.setEnabled(false); } diff --git a/src/main/java/org/olat/modules/vitero/ui/ViteroBookingEditController.java b/src/main/java/org/olat/modules/vitero/ui/ViteroBookingEditController.java index 18486e0684bd55dccf84a07414bdd71d374f7f2a..613de8b13423b30f9b644ee96c8987c6a721bf33 100644 --- a/src/main/java/org/olat/modules/vitero/ui/ViteroBookingEditController.java +++ b/src/main/java/org/olat/modules/vitero/ui/ViteroBookingEditController.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.Date; import java.util.List; -import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.elements.DateChooser; @@ -39,10 +38,12 @@ import org.olat.core.helpers.Settings; import org.olat.core.id.OLATResourceable; import org.olat.core.util.StringHelper; import org.olat.group.BusinessGroup; +import org.olat.modules.vitero.ViteroModule; import org.olat.modules.vitero.manager.ViteroManager; import org.olat.modules.vitero.manager.VmsNotAvailableException; import org.olat.modules.vitero.model.ViteroBooking; import org.olat.modules.vitero.model.ViteroStatus; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -54,14 +55,17 @@ import org.olat.modules.vitero.model.ViteroStatus; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com */ public class ViteroBookingEditController extends FormBasicController { + + private static final String[] enabledKeys = new String[]{"on"}; + private TextElement groupName; private DateChooser beginChooser; private DateChooser endChooser; private SingleSelection beginBufferEl; private SingleSelection endBufferEl; private SingleSelection roomSizeEl; - + private MultipleSelectionElement inspireEl; private MultipleSelectionElement autoSignIn; private static final String[] bufferKeys = new String[]{"0", "15", "30", "45", "60"}; @@ -74,7 +78,11 @@ public class ViteroBookingEditController extends FormBasicController { private final OLATResourceable ores; private final String subIdentifier; private final ViteroBooking booking; - private final ViteroManager viteroManager; + + @Autowired + private ViteroModule viteroModule; + @Autowired + private ViteroManager viteroManager; public ViteroBookingEditController(UserRequest ureq, WindowControl wControl, BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking booking) { @@ -84,7 +92,6 @@ public class ViteroBookingEditController extends FormBasicController { this.ores = ores; this.subIdentifier = subIdentifier; this.booking = booking; - viteroManager = (ViteroManager)CoreSpringFactory.getBean("viteroManager"); List<Integer> sizes; try { @@ -156,6 +163,14 @@ public class ViteroBookingEditController extends FormBasicController { } roomSizeEl.setEnabled(editable); + String[] enabledValues = new String[]{translate("enabled")}; + inspireEl = uifactory.addCheckboxesHorizontal("option.inspire", formLayout, enabledKeys, enabledValues); + inspireEl.setVisible(viteroModule.isInspire()); + if(viteroModule.isInspire() && booking.isInspire()) { + inspireEl.select(enabledKeys[0], true); + } + inspireEl.setEnabled(editable); + autoSignIn = uifactory.addCheckboxesHorizontal("booking.autoSignIn", formLayout, autoSignInKeys, autoSignInValues); if(booking.isAutoSignIn()) { autoSignIn.select(autoSignInKeys[0], true); @@ -188,7 +203,7 @@ public class ViteroBookingEditController extends FormBasicController { @Override protected boolean validateFormLogic(UserRequest ureq) { - boolean allOk = true; + boolean allOk = super.validateFormLogic(ureq); String name = groupName.getValue(); groupName.clearError(); @@ -207,10 +222,10 @@ public class ViteroBookingEditController extends FormBasicController { beginChooser.clearError(); if(begin == null) { beginChooser.setErrorKey("form.legende.mandatory", null); - allOk = false; + allOk &= false; } else if(new Date().after(begin)) { beginChooser.setErrorKey("error.bookingInPast", null); - allOk = false; + allOk &= false; } } @@ -219,13 +234,10 @@ public class ViteroBookingEditController extends FormBasicController { endChooser.clearError(); if(end == null) { endChooser.setErrorKey("form.legende.mandatory", null); - allOk = false; - } else if(new Date().after(begin)) { - beginChooser.setErrorKey("error.bookingInPast", null); - allOk = false; - } else if(end.before(begin)) { + allOk &= false; + } else if(new Date().after(begin) || end.before(begin)) { beginChooser.setErrorKey("error.bookingInPast", null); - allOk = false; + allOk &= false; } } @@ -235,7 +247,7 @@ public class ViteroBookingEditController extends FormBasicController { allOk = false; } - return allOk && super.validateFormLogic(ureq); + return allOk; } @Override @@ -270,6 +282,9 @@ public class ViteroBookingEditController extends FormBasicController { boolean auto = autoSignIn.isMultiselect() && autoSignIn.isSelected(0); booking.setAutoSignIn(auto); + boolean inspire = inspireEl.isVisible() && inspireEl.isAtLeastSelected(1); + booking.setInspire(inspire); + try { if(booking.getBookingId() >= 0) { ViteroBooking updatedBooking = viteroManager.updateBooking(group, ores, subIdentifier, booking);