Commit 2c6396cb by Tuomas Riihimäki

Add method for fetching the position of user in the queue.

1 parent 34646e33
......@@ -139,6 +139,23 @@ public class QueueBean implements QueueBeanLocal {
return ret;
}
public Integer getPosition(EventUser user) {
Integer ret = null;
if (reserving.contains(user)) {
ret = 0;
} else if (queue.contains(user)) {
ret = 1;
for (EventUser eu : queue) {
if (eu.equals(user)) {
break;
}
++ret;
}
}
return ret;
}
}
@EJB
......@@ -177,7 +194,7 @@ public class QueueBean implements QueueBeanLocal {
}
// DO housekeeping every 10 seconds.
nextReservingTimeoutCheck.compareAndSet(oldTime, System.currentTimeMillis() + 1000*10);
nextReservingTimeoutCheck.compareAndSet(oldTime, System.currentTimeMillis() + 1000 * 10);
} catch (Throwable t) {
logger.warn("Exception while checking reservingTimeouts");
}
......@@ -194,6 +211,12 @@ public class QueueBean implements QueueBeanLocal {
}
@Lock(LockType.READ)
public Integer getQueuePosition(EventMap map, EventUser user)
{
return getMapque(map).getPosition(user);
}
@Lock(LockType.READ)
public boolean isQueueEnabled() {
boolean ret = false;
LanEventProperty mapque = eventbean.getProperty(LanEventPropertyKey.MAP_QUEUE);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!