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 { ...@@ -139,6 +139,23 @@ public class QueueBean implements QueueBeanLocal {
return ret; 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 @EJB
...@@ -153,7 +170,7 @@ public class QueueBean implements QueueBeanLocal { ...@@ -153,7 +170,7 @@ public class QueueBean implements QueueBeanLocal {
boolean ret = getMapque(map).isReserving(user); boolean ret = getMapque(map).isReserving(user);
// Do some housekeeping, but only on each 120 // Do some housekeeping, but only on each 120
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long nextTime = nextReservingTimeoutCheck.get(); long nextTime = nextReservingTimeoutCheck.get();
// Update next checktime to 120 seconds in to the future, so we should have plenty of time // Update next checktime to 120 seconds in to the future, so we should have plenty of time
...@@ -175,9 +192,9 @@ public class QueueBean implements QueueBeanLocal { ...@@ -175,9 +192,9 @@ public class QueueBean implements QueueBeanLocal {
for (MapQueue m : mapqueues.values()) { for (MapQueue m : mapqueues.values()) {
m.timeoutEntries(); m.timeoutEntries();
} }
// DO housekeeping every 10 seconds. // DO housekeeping every 10 seconds.
nextReservingTimeoutCheck.compareAndSet(oldTime, System.currentTimeMillis() + 1000*10); nextReservingTimeoutCheck.compareAndSet(oldTime, System.currentTimeMillis() + 1000 * 10);
} catch (Throwable t) { } catch (Throwable t) {
logger.warn("Exception while checking reservingTimeouts"); logger.warn("Exception while checking reservingTimeouts");
} }
...@@ -194,6 +211,12 @@ public class QueueBean implements QueueBeanLocal { ...@@ -194,6 +211,12 @@ public class QueueBean implements QueueBeanLocal {
} }
@Lock(LockType.READ) @Lock(LockType.READ)
public Integer getQueuePosition(EventMap map, EventUser user)
{
return getMapque(map).getPosition(user);
}
@Lock(LockType.READ)
public boolean isQueueEnabled() { public boolean isQueueEnabled() {
boolean ret = false; boolean ret = false;
LanEventProperty mapque = eventbean.getProperty(LanEventPropertyKey.MAP_QUEUE); 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!