org.jivesoftware.smackx.search.ReportedData Java Examples
The following examples show how to use
org.jivesoftware.smackx.search.ReportedData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchForm.java From Spark with Apache License 2.0 | 5 votes |
/** * Starts a search based on the Answered form. */ public void performSearch() { searchResults.clearTable(); SwingWorker worker = new SwingWorker() { ReportedData data; @Override public Object construct() { try { Form answerForm = questionForm.getFilledForm(); data = searchManager.getSearchResults(answerForm, serviceName); } catch (XMPPException | SmackException | InterruptedException e) { Log.error("Unable to load search service.", e); } return data; } @Override public void finished() { if (data != null && !data.getRows().isEmpty() ) { searchResults.showUsersFound(data); searchResults.invalidate(); searchResults.validate(); searchResults.repaint(); } else { UIManager.put("OptionPane.okButtonText", Res.getString("ok")); JOptionPane.showMessageDialog(searchResults, Res.getString("message.no.results.found"), Res.getString("title.notification"), JOptionPane.ERROR_MESSAGE); } } }; worker.start(); }
Example #2
Source File: ChatSearchResult.java From Spark with Apache License 2.0 | 5 votes |
public ChatSearchResult(ReportedData.Row row, String query) { UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); String startDate = getFirstValue(row, "startDate"); try { creationDate = UTC_FORMAT.parse(startDate); } catch (ParseException e) { Log.error(e); } sessionID = getFirstValue(row, "sessionID"); StringBuffer authors = new StringBuffer(); for ( final CharSequence agentJID : row.getValues("agentJIDs") ) { authors.append(agentJID); authors.append(" "); } String rell = getFirstValue(row, "relevance"); Double o = Double.valueOf(rell); relevance = ((int)o.doubleValue() * 100); question = getFirstValue(row, "question"); customerName = getFirstValue(row, "username"); email = getFirstValue(row, "email"); fields.add(customerName); fields.add(question); fields.add(email); fields.add(authors.toString()); fields.add(creationDate); }
Example #3
Source File: ChatSearchResult.java From Spark with Apache License 2.0 | 5 votes |
public String getFirstValue(ReportedData.Row row, String key) { final List<CharSequence> values = row.getValues( key ); if ( values.isEmpty() ) { return null; } return values.get(0).toString(); }
Example #4
Source File: RosterDialog.java From Spark with Apache License 2.0 | 4 votes |
/** * Creates a Popupdialog above the Search Button displaying matching * Contacts * * @param byname * , the Searchname, atleast 5 Chars long * @param event * , the MouseEvent which triggered it * @throws XMPPException * @throws InterruptedException */ public void searchForContact(String byname, MouseEvent event) throws XMPPException, SmackException.NotConnectedException, SmackException.NoResponseException, InterruptedException { UIManager.put("OptionPane.okButtonText", Res.getString("ok")); if (byname.contains("@")) { byname = byname.substring(0, byname.indexOf("@")); } if (byname.length() <= 1) { JOptionPane.showMessageDialog(jidField, Res.getString("message.search.input.short"), Res.getString("title.notification"), JOptionPane.ERROR_MESSAGE); } else { JPopupMenu popup = new JPopupMenu(); JMenuItem header = new JMenuItem( Res.getString("group.search.results") + ":"); header.setBackground(UIManager.getColor("List.selectionBackground")); header.setForeground(Color.red); popup.add(header); for (DomainBareJid search : _usersearchservice) { ReportedData data; UserSearchManager usersearchManager = new UserSearchManager( SparkManager.getConnection()); Form f = usersearchManager.getSearchForm(search); Form answer = f.createAnswerForm(); answer.setAnswer("Name", true); answer.setAnswer("Email", true); answer.setAnswer("Username", true); answer.setAnswer("search", byname); data = usersearchManager.getSearchResults(answer, search); ArrayList<String> columnnames = new ArrayList<>(); for ( ReportedData.Column column : data.getColumns() ) { String label = column.getLabel(); columnnames.add(label); } for (ReportedData.Row row : data.getRows() ) { if (!row.getValues(columnnames.get(0)).isEmpty()) { String s = row.getValues(columnnames.get(0)) .get(0).toString(); final JMenuItem item = new JMenuItem(s); popup.add(item); item.addActionListener( e -> { jidField.setText(item.getText()); nicknameField.setText(XmppStringUtils .parseLocalpart(item.getText())); } ); } } } if (popup.getComponentCount() > 2) { popup.setVisible(true); popup.show(_searchForName, event.getX(), event.getY()); } else if (popup.getComponentCount() == 2) { jidField.setText(((JMenuItem) popup.getComponent(1)).getText()); nicknameField.setText(XmppStringUtils.parseLocalpart(((JMenuItem) popup .getComponent(1)).getText())); } else { JOptionPane.showMessageDialog(jidField, Res.getString("message.no.results.found"), Res.getString("title.notification"), JOptionPane.ERROR_MESSAGE); } } }
Example #5
Source File: TranscriptSearchManager.java From Smack with Apache License 2.0 | 3 votes |
/** * Submits the completed form and returns the result of the transcript search. The result * will include all the data returned from the server so be careful with the amount of * data that the search may return. * * @param serviceJID the address of the workgroup service. * @param completedForm the filled out search form. * @return the result of the transcript search. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public ReportedData submitSearch(DomainBareJid serviceJID, FillableForm completedForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { TranscriptSearch search = new TranscriptSearch(); search.setType(IQ.Type.get); search.setTo(serviceJID); search.addExtension(completedForm.getDataFormToSubmit()); TranscriptSearch response = connection.createStanzaCollectorAndSend( search).nextResultOrThrow(); return ReportedData.getReportedDataFrom(response); }
Example #6
Source File: AgentSession.java From Smack with Apache License 2.0 | 2 votes |
/** * Submits the completed form and returns the result of the transcript search. The result * will include all the data returned from the server so be careful with the amount of * data that the search may return. * * @param completedForm the filled out search form. * @return the result of the transcript search. * @throws SmackException if Smack detected an exceptional situation. * @throws XMPPException if an XMPP protocol error was received. * @throws InterruptedException if the calling thread was interrupted. */ public ReportedData searchTranscripts(FillableForm completedForm) throws XMPPException, SmackException, InterruptedException { return transcriptSearchManager.submitSearch(workgroupJID.asDomainBareJid(), completedForm); }
Example #7
Source File: UserSearchResults.java From Spark with Apache License 2.0 | 2 votes |
/** * Returns the first value found in the ReportedData.Row. * * @param row the ReportedData.Row. * @param key the specified key in the ReportedData.Row. * @return the first value found in the ReportedData.Row */ public String getFirstValue(ReportedData.Row row, String key) { List<CharSequence> values = row.getValues( key ); return values == null || values.isEmpty() ? null : values.get( 0 ).toString(); }