/** * Returns the transcripts of a given user. The answer will contain the complete history of * conversations that a user had. * * @param userID the id of the user to get his conversations. * @param workgroupJID the JID of the workgroup that will process the request. * @return the transcripts of a given user. * @throws XMPPException if an error occurs while getting the information. */ public Transcripts getTranscripts(String workgroupJID, String userID) throws XMPPException { Transcripts request = new Transcripts(userID); request.setTo(workgroupJID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); // Send the request connection.sendPacket(request); Transcripts response = (Transcripts) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } return response; }
/** * Returns the transcripts of a given user. The answer will contain the * complete history of conversations that a user had. * * @param userID * the id of the user to get his conversations. * @param workgroupJID * the JID of the workgroup that will process the request. * @return the transcripts of a given user. * @throws XMPPException * if an error occurs while getting the information. */ public Transcripts getTranscripts(String workgroupJID, String userID) throws XMPPException { Transcripts request = new Transcripts(userID); request.setTo(workgroupJID); PacketCollector collector = connection .createPacketCollector(new PacketIDFilter(request.getPacketID())); // Send the request connection.sendPacket(request); Transcripts response = (Transcripts) collector .nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } return response; }
public void init(Collection<Transcripts.TranscriptSummary> transcriptList) { model.removeAllElements(); Iterator<Transcripts.TranscriptSummary> iter = transcriptList.iterator(); while (iter.hasNext()) { Transcripts.TranscriptSummary summary = iter.next(); UserHistoryItem item = new UserHistoryItem(summary.getAgentDetails(), summary.getJoinTime(), summary.getLeftTime()); item.setSessionID(summary.getSessionID()); model.addElement(item); } list.validate(); list.repaint(); }
public int compare(Object o1, Object o2) { final Transcripts.TranscriptSummary item1 = (Transcripts.TranscriptSummary)o1; final Transcripts.TranscriptSummary item2 = (Transcripts.TranscriptSummary)o2; long int1 = item1.getJoinTime().getTime(); long int2 = item2.getJoinTime().getTime(); if (int1 == int2) { return 0; } if (int1 > int2) { return -1; } if (int1 < int2) { return 1; } return 0; }
public void loadHistory() { SwingWorker transcriptThread = new SwingWorker() { final List<TranscriptSummary> transcriptList = new ArrayList<TranscriptSummary>(); public Object construct() { try { Transcripts transcripts = FastpathPlugin.getAgentSession().getTranscripts(userID); Iterator<TranscriptSummary> iter = transcripts.getSummaries().iterator(); while (iter.hasNext()) { Transcripts.TranscriptSummary summary = (Transcripts.TranscriptSummary)iter.next(); transcriptList.add(summary); } } catch (XMPPException e) { Log.error("Error getting transcripts.", e); } Collections.sort(transcriptList, timeComparator); return transcriptList; } public void finished() { init(transcriptList); } }; transcriptThread.start(); }
public UserHistoryItem(Collection<Transcripts.AgentDetail> agentDetails, Date joinTime, Date endTime) { setBackground(Color.white); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); setLayout(new GridBagLayout()); final JLabel conLabel = new JLabel(); conLabel.setText(FpRes.getString("duration") + ":"); conLabel.setFont(new Font("Dialog", Font.BOLD, 11)); add(conLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(durationLabel, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); long duration = endTime.getTime() - joinTime.getTime(); durationLabel.setText(ModelUtil.getTimeFromLong(duration)); final JLabel nameLabel = new JLabel(); nameLabel.setText(FpRes.getString("agents") + ":"); nameLabel.setFont(new Font("Dialog", Font.BOLD, 11)); add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(agentsLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); agentsLabel.setBackground(Color.white); agentsLabel.setOpaque(false); final SimpleDateFormat simpleFormat = new SimpleDateFormat("MM/dd/yyyy h:mm a"); JLabel timeLabel = new JLabel(FpRes.getString("date") + ":"); timeLabel.setFont(new Font("Dialog", Font.BOLD, 11)); String theDate = simpleFormat.format(joinTime); add(timeLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(startTimeLabel, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); startTimeLabel.setText(theDate); StringBuffer buf = new StringBuffer(); Iterator<Transcripts.AgentDetail> agents = agentDetails.iterator(); while (agents.hasNext()) { Transcripts.AgentDetail agentDetail = agents.next(); String agentJID = agentDetail.getAgentJID(); agentJID = UserManager.unescapeJID(agentJID); buf.append(agentJID); if (agents.hasNext()) { buf.append("\n"); } } agentsLabel.setText(buf.toString()); }
/** * Returns the transcripts of a given user. The answer will contain the complete history of * conversations that a user had. * * @param userID the id of the user to get his conversations. * @param workgroupJID the JID of the workgroup that will process the request. * @return the transcripts of a given user. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Transcripts getTranscripts(String workgroupJID, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException { Transcripts request = new Transcripts(userID); request.setTo(workgroupJID); Transcripts response = (Transcripts) connection.createPacketCollectorAndSend(request).nextResultOrThrow(); return response; }
/** * Returns the transcripts of a given user. The answer will contain the complete history of * conversations that a user had. * * @param userID the id of the user to get his conversations. * @return the transcripts of a given user. * @throws XMPPException if an error occurs while getting the information. * @throws SmackException */ public Transcripts getTranscripts(String userID) throws XMPPException, SmackException { return transcriptManager.getTranscripts(workgroupJID, userID); }