Commit 980ef3d9 by Tuukka Kivilahti

fixes #21 , Admin voi varata nyt lukitun paikan

1 parent 49e5e369
...@@ -182,7 +182,8 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -182,7 +182,8 @@ public class PlaceBean implements PlaceBeanLocal {
} }
/** /**
* Reserve the place for user. This reservation will timeout after a while buy() method should be called after this when buying place; * Reserve the place for user. This reservation will timeout after a while
* buy() method should be called after this when buying place;
* *
* @param place * @param place
* place to be reserved * place to be reserved
...@@ -196,24 +197,31 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -196,24 +197,31 @@ public class PlaceBean implements PlaceBeanLocal {
place = placeFacade.find(place.getId()); place = placeFacade.find(place.getId());
user = eventUserFacade.find(user.getId()); user = eventUserFacade.find(user.getId());
boolean ret = false; boolean ret = false;
if (place.isBuyable() && !place.isTaken()) { if (!place.isTaken()) {
place.setCurrentUser(user); if (place.isBuyable() || permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
place.setReleaseTime(Calendar.getInstance());
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES); if(!place.isBuyable()) {
place.setBuyable(true);
// Create timeout service to timeout the reserved place in
// RESERVE_MINUTES
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
} }
place.setCurrentUser(user);
place.setReleaseTime(Calendar.getInstance());
place.getReleaseTime().add(Calendar.MINUTE, RESERVE_MINUTES);
// Create timeout service to timeout the reserved place in
// RESERVE_MINUTES
boolean foundTimeout = false;
for (Timer t : ts.getTimers()) {
if (t.getInfo().equals(PLACE_RESERVE_TIMEOUTER)) {
foundTimeout = true;
}
}
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
} }
if (!foundTimeout) {
logger.info("Place timeout calculator not started. Starting new.");
ts.createTimer(new Date(), 1000 * 60, PLACE_RESERVE_TIMEOUTER);
}
ret = true;
} }
return ret; return ret;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!