/** * Adds agents to a request queue. * * @param queue the <code>RequestQueue</code> to add agents to. * @param agents a comma-delimited list of agents. */ public static void addAgents(RequestQueue queue, String agents) { WorkgroupManager workgroupManager = WorkgroupManager.getInstance(); AgentManager agentManager = workgroupManager.getAgentManager(); // loop thru all params StringTokenizer tokenizer = new StringTokenizer(agents, ", \t\n\r\f"); while (tokenizer.hasMoreTokens()) { String usernameToken = tokenizer.nextToken(); if (usernameToken.indexOf('@') != -1) { usernameToken = JID.escapeNode(usernameToken); } try { // See if they are a user in the system. UserManager.getInstance().getUser(usernameToken); usernameToken += ("@" + ComponentManagerFactory.getComponentManager().getServerName()); JID address = new JID(usernameToken.trim()); Agent agent; if (agentManager.hasAgent(address)) { agent = agentManager.getAgent(address); } else { agent = agentManager.createAgent(address); } queue.addMember(agent); } catch (Exception e) { Log.error(e.getMessage(), e); } } }
/** * Returns the total number of chats that have occured within a workgroup. * * @param workgroupName the jid of the workgroup. * @return the total number of chats that have occured within a workgroup. */ public static int getNumberOfChatsForWorkgroup(String workgroupName) { Workgroup workgroup = null; try { workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName)); } catch (Exception ex) { Log.error(ex.getMessage(), ex); } int count = 0; for (RequestQueue requestQueue : workgroup.getRequestQueues()) { count += requestQueue.getTotalChatCount(); } return count; }