Search in sources :

Example 6 with ICriterion

use of org.eclipse.ecf.presence.search.ICriterion in project ecf by eclipse.

the class XMPPSearchTest method testRetrieveBuddiesNameFieldSync.

/**
 * Try to locate buddies on the XMPP server in a call block way
 *
 * @throws ContainerConnectException
 */
public void testRetrieveBuddiesNameFieldSync() throws Exception {
    assertNotNull(searchManager);
    IRestriction selection = searchManager.createRestriction();
    assertNotNull(selection);
    // fields to consider on XMPP server side search
    // search field for XMPP, criterion to match the search
    ICriterion name = selection.eq(NAME, "marcelo*");
    // create a specific criteria
    try {
        ICriteria criteria = searchManager.createCriteria();
        assertNotNull(criteria);
        // criteria.add(searchCriterion);
        criteria.add(name);
        // call the block search
        ISearch search = searchManager.search(criteria);
        // the collection of IResult
        IResultList resultList = search.getResultList();
        int resultListSize = resultList.getResults().size();
        if (resultListSize == 0)
            System.out.println("XMPPSearchTest.testRetrieveBuddiesNameFieldSync...no email field retrieved");
        else
            assertTrue(1 == resultListSize);
    } catch (UserSearchException e) {
        e.printStackTrace();
    }
}
Also used : IRestriction(org.eclipse.ecf.presence.search.IRestriction) ISearch(org.eclipse.ecf.presence.search.ISearch) IResultList(org.eclipse.ecf.presence.search.IResultList) ICriterion(org.eclipse.ecf.presence.search.ICriterion) UserSearchException(org.eclipse.ecf.presence.search.UserSearchException) ICriteria(org.eclipse.ecf.presence.search.ICriteria)

Aggregations

ICriterion (org.eclipse.ecf.presence.search.ICriterion)6 ICriteria (org.eclipse.ecf.presence.search.ICriteria)4 IRestriction (org.eclipse.ecf.presence.search.IRestriction)4 IResultList (org.eclipse.ecf.presence.search.IResultList)4 UserSearchException (org.eclipse.ecf.presence.search.UserSearchException)4 Iterator (java.util.Iterator)3 ISearch (org.eclipse.ecf.presence.search.ISearch)3 ECFException (org.eclipse.ecf.core.util.ECFException)2 List (java.util.List)1 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 IResult (org.eclipse.ecf.presence.search.IResult)1 IUserSearchCompleteEvent (org.eclipse.ecf.presence.search.IUserSearchCompleteEvent)1 IUserSearchEvent (org.eclipse.ecf.presence.search.IUserSearchEvent)1 IUserSearchListener (org.eclipse.ecf.presence.search.IUserSearchListener)1 ResultList (org.eclipse.ecf.presence.search.ResultList)1 XMPPException (org.jivesoftware.smack.XMPPException)1 Form (org.jivesoftware.smackx.Form)1 ReportedData (org.jivesoftware.smackx.ReportedData)1