public synchronized RealAgent findAgentConnectedWithCall(RealCall call) { for (RealAgent realAgent : list.values()) { if (call.equals(realAgent.getConnectedCall())) { return realAgent; } } return null; }
public synchronized boolean addAgent(RealAgent agent) { if (!list.containsKey(agent.getId())) { list.put(agent.getId(), agent); return true; } else { return false; } }
public synchronized int getPosition(RealAgent agent, Comparator<RealAgent> comparator) { RealAgent[] l = new RealAgent[0]; l = list.values().toArray(l); Arrays.sort(l, comparator); for (int i = 0; i < l.length; i++) { RealAgent a = (RealAgent) l[i]; if (a.getId().equals(agent.getId())) return i; } return 0; }
public synchronized int getPausedAgentCount(int idDefault) { int count = 0; for (RealAgent realAgent : list.values()) { if (realAgent.isPaused() && (idDefault == -1 || realAgent.getPauseType().getId() == idDefault)) { count++; } } return count; }
public synchronized boolean add(RealAgent realAgent) { if (!list.containsKey(realAgent.getId())) { list.put(realAgent.getId(), realAgent); queueAgentListenerList.onAgentAdd(realAgent); return true; } else { // update ?! // get(realQueue.getName()).setWaitCount(realQueue.getWaitCount()); return false; } }
public synchronized int getFreeAgentCount() { int count = 0; for (RealAgent realAgent : list.values()) { if ((realAgent.connectedCall == null) && (!realAgent.isPaused()) && (realAgent.status != AgentStatusInQueue.IN_USE)) { count++; } } return count; }
public synchronized RealAgent get(RealAgent agent) { return list.get(agent.getId()); }
public synchronized RealAgent remove(RealAgent realAgent) { return remove(realAgent.getId()); }
public synchronized void onCallLeave(RealCall call, RealQueue queue) { for (RealAgent agent : list.values()) { agent.onCallLeave(call, queue); } }
public synchronized RealAgent getByExtension(String extension) { for (RealAgent a : list.values()) { if (a.getExtension().endsWith(extension)) return a; } return null; }