private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status, int averageWaitTime, Date oldestEntry, Set<QueueUser> users) { synchronized (queueUsersListeners) { for (QueueUsersListener listener : queueUsersListeners) { if (status != null) { listener.statusUpdated(queue, status); } if (averageWaitTime != -1) { listener.averageWaitTimeUpdated(queue, averageWaitTime); } if (oldestEntry != null) { listener.oldestEntryUpdated(queue, oldestEntry); } if (users != null) { listener.usersUpdated(queue, users); } } } }
/** * Returns an Iterator for the users in the queue waiting to be routed to * an agent (QueueUser instances). * * @return an Iterator for the users waiting in the queue. */ public Iterator<QueueUser> getUsers() { if (users == null) { return new HashSet<QueueUser>().iterator(); } return Collections.unmodifiableSet(users).iterator(); }
public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">"); synchronized (users) { for (Iterator<QueueUser> i=users.iterator(); i.hasNext(); ) { QueueUser user = (QueueUser)i.next(); int position = user.getQueuePosition(); int timeRemaining = user.getEstimatedRemainingTime(); Date timestamp = user.getQueueJoinTimestamp(); buf.append("<user jid=\"").append(user.getUserID()).append("\">"); if (position != -1) { buf.append("<position>").append(position).append("</position>"); } if (timeRemaining != -1) { buf.append("<time>").append(timeRemaining).append("</time>"); } if (timestamp != null) { buf.append("<join-time>"); buf.append(dateFormat.format(timestamp)); buf.append("</join-time>"); } buf.append("</user>"); } } buf.append("</").append(ELEMENT_NAME).append(">"); return buf.toString(); }
public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">"); synchronized (users) { for (Iterator<QueueUser> i=users.iterator(); i.hasNext(); ) { QueueUser user = (QueueUser)i.next(); int position = user.getQueuePosition(); int timeRemaining = user.getEstimatedRemainingTime(); Date timestamp = user.getQueueJoinTimestamp(); buf.append("<user jid=\"").append(user.getUserID()).append("\">"); if (position != -1) { buf.append("<position>").append(position).append("</position>"); } if (timeRemaining != -1) { buf.append("<time>").append(timeRemaining).append("</time>"); } if (timestamp != null) { buf.append("<join-time>"); buf.append(DATE_FORMATTER.format(timestamp)); buf.append("</join-time>"); } buf.append("</user>"); } } buf.append("</").append(ELEMENT_NAME).append(">"); return buf.toString(); }
public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"") .append(NAMESPACE).append("\">"); synchronized (users) { for (Iterator<QueueUser> i = users.iterator(); i.hasNext();) { QueueUser user = (QueueUser) i.next(); int position = user.getQueuePosition(); int timeRemaining = user.getEstimatedRemainingTime(); Date timestamp = user.getQueueJoinTimestamp(); buf.append("<user jid=\"").append(user.getUserID()) .append("\">"); if (position != -1) { buf.append("<position>").append(position) .append("</position>"); } if (timeRemaining != -1) { buf.append("<time>").append(timeRemaining) .append("</time>"); } if (timestamp != null) { buf.append("<join-time>"); buf.append(dateFormat.format(timestamp)); buf.append("</join-time>"); } buf.append("</user>"); } } buf.append("</").append(ELEMENT_NAME).append(">"); return buf.toString(); }
void setUsers(Set<QueueUser> users) { this.users = users; }
/** * Creates a new QueueDetails packet */ private QueueDetails() { users = new HashSet<QueueUser>(); }
/** * Adds a user to the packet. * * @param user the user. */ private void addUser(QueueUser user) { synchronized (users) { users.add(user); } }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { QueueDetails queueDetails = new QueueDetails(); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_TAG && "notify-queue-details".equals(parser.getName())) { eventType = parser.next(); while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) { String uid = null; int position = -1; int time = -1; Date joinTime = null; uid = parser.getAttributeValue("", "jid"); if (uid == null) { // throw exception } eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) || (! "user".equals(parser.getName()))) { if ("position".equals(parser.getName())) { position = Integer.parseInt(parser.nextText()); } else if ("time".equals(parser.getName())) { time = Integer.parseInt(parser.nextText()); } else if ("join-time".equals(parser.getName())) { joinTime = DATE_FORMATTER.parse(parser.nextText()); } else if( parser.getName().equals( "waitTime" ) ) { Date wait = DATE_FORMATTER.parse( parser.nextText() ); System.out.println( wait ); } eventType = parser.next(); if (eventType != XmlPullParser.END_TAG) { // throw exception } } queueDetails.addUser(new QueueUser(uid, position, time, joinTime)); eventType = parser.next(); } } return queueDetails; }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); QueueDetails queueDetails = new QueueDetails(); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_TAG && "notify-queue-details".equals(parser.getName())) { eventType = parser.next(); while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) { String uid = null; int position = -1; int time = -1; Date joinTime = null; uid = parser.getAttributeValue("", "jid"); if (uid == null) { // throw exception } eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) || (! "user".equals(parser.getName()))) { if ("position".equals(parser.getName())) { position = Integer.parseInt(parser.nextText()); } else if ("time".equals(parser.getName())) { time = Integer.parseInt(parser.nextText()); } else if ("join-time".equals(parser.getName())) { joinTime = dateFormat.parse(parser.nextText()); } else if( parser.getName().equals( "waitTime" ) ) { Date wait = dateFormat.parse(parser.nextText()); System.out.println( wait ); } eventType = parser.next(); if (eventType != XmlPullParser.END_TAG) { // throw exception } } queueDetails.addUser(new QueueUser(uid, position, time, joinTime)); eventType = parser.next(); } } return queueDetails; }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); QueueDetails queueDetails = new QueueDetails(); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_TAG && "notify-queue-details".equals(parser.getName())) { eventType = parser.next(); while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) { String uid = null; int position = -1; int time = -1; Date joinTime = null; uid = parser.getAttributeValue("", "jid"); if (uid == null) { // throw exception } eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) || (!"user".equals(parser.getName()))) { if ("position".equals(parser.getName())) { position = Integer.parseInt(parser.nextText()); } else if ("time".equals(parser.getName())) { time = Integer.parseInt(parser.nextText()); } else if ("join-time".equals(parser.getName())) { joinTime = dateFormat.parse(parser.nextText()); } else if (parser.getName().equals("waitTime")) { Date wait = dateFormat.parse(parser.nextText()); System.out.println(wait); } eventType = parser.next(); if (eventType != XmlPullParser.END_TAG) { // throw exception } } queueDetails.addUser(new QueueUser(uid, position, time, joinTime)); eventType = parser.next(); } } return queueDetails; }
/** * The list of users waiting in the queue was updated. * * @param queue the workgroup queue. * @param users the list of users waiting in the queue. */ public void usersUpdated(WorkgroupQueue queue, Set<QueueUser> users);
/** * Returns the set of users in the queue that are waiting to * be routed to an agent (as QueueUser objects). * * @return a Set for the users waiting in a queue. */ public Set<QueueUser> getUsers() { synchronized (users) { return users; } }