Patrick's Lucky Dip - Searching Objective |
||
The ProblemIf you know the objective document id (String oid) it is easy to get a handle
to the document or object using the session object (OjiSession apiSession): The SolutionThe search below illustrates the syntax: you use the session object to create a new search object. You then define the type of object you are searching for (this affects what criteria you can use to search). The next stage is to define how the criteria are combined (this is only necessary if you have multiple criteria). Add the criteria to the search and then execute it. The search returns a collection: you can use an iterator or whatever method you prefer to cycle through the results.
try
{
OjiSearch newSearch = apiSession.initSearch();
newSearch.setObjectSearchType(apiSession.getTypeDefnByName("user"));
newSearch.setCriteriaRelation(OjiSearch.AND_RELATION);
newSearch.addCriteria("email address", "begins", userEmailAddress);
newSearch.addCriteria("parent folder", "is", "gA1"); // Active Users
newSearch.execute();
Collection results = newSearch.getResults();
int i = results.iterator();
while (i.hasNext())
{
OjiUser theUser = (OjiUser) i.next();
UserId = theUser.getLoginId();
}
}
catch(OjiException e)
{
e.printStackTrace();
}
If you need to know more about the available search criteria, the easiest way is to log into Objective and manually enter the search you are trying to build. You may have to experiment a bit to find the right criteria names and the right object type names. Patrick Haston |
||