Commit 6a87475b by Tuomas Riihimäki

If user has reserved places, but has not yet locked them user can not return to …

…place selection and lock the places
1 parent b79c2f77
...@@ -88,7 +88,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -88,7 +88,7 @@ public class AjaxMapView extends GenericCDIView {
if (super.requirePermissions(MapPermission.BUY_PLACES) && map == null) { if (super.requirePermissions(MapPermission.BUY_PLACES) && map == null) {
EventUser u = userview.getSelectedUser(); EventUser u = userview.getSelectedUser();
EventMap map = initMap(); EventMap map = initMap();
List<PlaceSlot> usersPlaceslots = placebean.getFreePlaceslots(u, map); List<PlaceSlot> usersPlaceslots = placebean.getPlaceslots(u);
if (usersPlaceslots.isEmpty()) { if (usersPlaceslots.isEmpty()) {
logger.info("There are no placeslots available for user"); logger.info("There are no placeslots available for user");
...@@ -100,13 +100,12 @@ public class AjaxMapView extends GenericCDIView { ...@@ -100,13 +100,12 @@ public class AjaxMapView extends GenericCDIView {
super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true"); super.navihandler.forward("/neomap/notenoughslots?faces-redirect=true");
} else { } else {
quebean.enterQueue(map, u); quebean.enterQueue(map, u);
countPlaceslots(usersPlaceslots); slotcount = countPlaceslots(placebean.getFreePlaceslots(u, map));
} }
} }
} }
private void countPlaceslots(List<PlaceSlot> slots) private static Collection<Slotcounter> countPlaceslots(List<PlaceSlot> slots)
{ {
HashMap<Product, Slotcounter> prodmap = new HashMap<Product, Slotcounter>(); HashMap<Product, Slotcounter> prodmap = new HashMap<Product, Slotcounter>();
for (PlaceSlot p : slots) { for (PlaceSlot p : slots) {
...@@ -115,9 +114,10 @@ public class AjaxMapView extends GenericCDIView { ...@@ -115,9 +114,10 @@ public class AjaxMapView extends GenericCDIView {
} }
prodmap.get(p.getProduct()).increment(); prodmap.get(p.getProduct()).increment();
} }
slotcount = prodmap.values(); Collection<Slotcounter> ret = prodmap.values();
logger.info("Slotcount size {}", slotcount.size());
logger.info("Slotcount size {}", ret);
return ret;
} }
public void initViewMap() { public void initViewMap() {
...@@ -139,7 +139,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -139,7 +139,7 @@ public class AjaxMapView extends GenericCDIView {
{ {
logger.info("Entering queue"); logger.info("Entering queue");
if (isQueueEnabled()) if (isQueueEnabled())
queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser()); queueEntry = quebean.enterQueue(initMap(), userview.getSelectedUser());
else { else {
logger.warn("QueueNot enabled. Not entering queue"); logger.warn("QueueNot enabled. Not entering queue");
} }
...@@ -167,7 +167,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -167,7 +167,7 @@ public class AjaxMapView extends GenericCDIView {
} }
public Integer getQueuePosition() { public Integer getQueuePosition() {
return quebean.getQueuePosition(initMap(), userview.getSelectedUser()); return quebean.getQueuePosition(initMap(), userview.getSelectedUser());
} }
public Long getPlacesLeftToSelect() { public Long getPlacesLeftToSelect() {
...@@ -194,7 +194,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -194,7 +194,7 @@ public class AjaxMapView extends GenericCDIView {
public boolean isReserving() public boolean isReserving()
{ {
if (reserving == null) { if (reserving == null) {
reserving = quebean.isReserving(initMap(), userview.getSelectedUser()); reserving = quebean.isReserving(initMap(), userview.getSelectedUser());
} }
return reserving; return reserving;
} }
...@@ -202,7 +202,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -202,7 +202,7 @@ public class AjaxMapView extends GenericCDIView {
public boolean canUserBuy() { public boolean canUserBuy() {
return permbean.hasPermission(MapPermission.BUY_PLACES) && return permbean.hasPermission(MapPermission.BUY_PLACES) &&
(permbean.hasPermission(MapPermission.MANAGE_OTHERS) || (permbean.hasPermission(MapPermission.MANAGE_OTHERS) ||
quebean.isReserving(initMap(), userview.getSelectedUser()) quebean.isReserving(initMap(), userview.getSelectedUser())
); );
} }
...@@ -255,7 +255,7 @@ public class AjaxMapView extends GenericCDIView { ...@@ -255,7 +255,7 @@ public class AjaxMapView extends GenericCDIView {
} }
public EventMap getMap() { public EventMap getMap() {
if(map == null) if (map == null)
return initMap(); return initMap();
return map; return map;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!