Skip to content
Snippets Groups Projects
Commit 8a14f7f3 authored by srosse's avatar srosse
Browse files

OO-4256: make the inspire flag configurable at event level

parent 239056fe
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment