Package org.eclipse.ecf.presence.search

Examples of org.eclipse.ecf.presence.search.ResultList


   *
   * @see IUserSearchManager#search(ICriteria).
   */
  public ISearch search(ICriteria criteria) throws UserSearchException {

    ResultList resultList = new ResultList();
    try {
      // initialize the form by chance it is null
      if (form == null)
        form = manager.getSearchForm(ecfConnection.getXMPPConnection(),
            SERVICE_SEARCH
                + ecfConnection.getXMPPConnection()
                    .getServiceName());

      /*
       * For XMPP criterion is considered. The XMPP server will deal with
       * the search.
       */
      List criterions = criteria.getCriterions();
      // add the fields for the search dynamically
      // consider just the fields used on the search
      // fields checked by user

      String fields[] = getUserPropertiesFields();
      for (int i = 0; i < fields.length; i++) {
        Iterator criterionsIterator = criterions.iterator();
        // for each user properties field check if it
        // was added by user for the criteria
        // for each field, a search is performed, and
        // the partial result is added to the result list
        while (criterionsIterator.hasNext()) {
          ICriterion criterion = (ICriterion) criterionsIterator
              .next();
          if (criterion.equals(fields[i])) {
            Form answerForm = form.createAnswerForm();
            answerForm.setAnswer(fields[i], true);
            answerForm.setAnswer(SEARCH_ACTION, criterion
                .toExpression());
            ReportedData data = manager.sendSearchForm(
                ecfConnection.getXMPPConnection(), answerForm,
                SERVICE_SEARCH
                    + ecfConnection.getXMPPConnection()
                        .getServiceName());
            // create a result list from ReportedData
            IResultList partialResultList = createResultList(data);
            resultList.addAll(partialResultList.getResults());
          }
        }
      }

      return new XMPPSearch(resultList);
View Full Code Here


   *            ReportedData
   * @return {@link IResultList} a list of users
   * @throws
   */
  protected IResultList createResultList(ReportedData data) {
    ResultList result = new ResultList();
    Iterator rows = data.getRows();
    while (rows.hasNext()) {
      Row row = (Row) rows.next();
      Iterator jids = row.getValues(JID);
      Iterator names = row.getValues(NAME);
      String jid = null;
      String name = null;
      // XMPP server returns the same length for both
      while (jids.hasNext() && names.hasNext()) {
        try {
          jid = (String) jids.next();
          name = (String) names.next();
          IUser user = new User(new XMPPID(connectNamespace, jid),
              name);
          result.add(new XMPPResultItem(user));
        } catch (URISyntaxException e) {
          throw new RuntimeException(
              "cannot create connect id for client " + jid //$NON-NLS-1$
                  + " , name = " + name, e); //$NON-NLS-1$
        }
View Full Code Here

TOP

Related Classes of org.eclipse.ecf.presence.search.ResultList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.