background image

Finding Organizations by Name

<< Querying a Registry | Finding Organizations by Classification >>
<< Querying a Registry | Finding Organizations by Classification >>
182
J
AVA
API
FOR
XML R
EGISTRIES
· Finding services and service bindings
Finding Organizations by Name
To search for organizations by name, you normally use a combination of find
qualifiers (which affect sorting and pattern matching) and name patterns (which
specify the strings to be searched). The
findOrganizations
method takes a col-
lection of
findQualifier
objects as its first argument and takes a collection of
namePattern
objects as its second argument. The following fragment shows
how to find all the organizations in the registry whose names begin with a speci-
fied string,
qString
, and sort them in alphabetical order.
// Define find qualifiers and name patterns
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
Collection<String> namePatterns = new ArrayList<String>();
namePatterns.add(qString);
// Find orgs whose names begin with qString
BulkResponse response =
bqm.findOrganizations(findQualifiers, namePatterns, null,
null, null, null);
Collection orgs = response.getCollection();
The last four arguments to
findOrganizations
allow you to search using other
criteria than the name: classifications, specification concepts, external identifiers,
or external links. Finding Organizations by Classification (page 183) describes
searching by classification and by specification concept. The other searches are
less common and are not described in this tutorial.
A client can use percent signs (
%
) to specify that the query string can occur any-
where within the organization name. For example, the following code fragment
performs a case-sensitive search for organizations whose names contain
qString
:
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.CASE_SENSITIVE_MATCH);
Collection<String> namePatterns = new ArrayList<String>();
namePatterns.add("%" + qString + "%");
// Find orgs with names that contain qString