The DataManager interface provides a number of ways for searching the EKM repository for data. These are:
Search for a specific object by its path
Search for a specific object by its unique identifier
Search for all objects that have a property containing a specific keyword
Search for objects using an existing saved query on the server
Search for objects using a query created on the client.
Each of these operations returns one or more instances of a ModelObject. The ModelObject is a representation of the object stored in the EKM repository.
The simplest search provided is to search for an object by its path. The examples below show this operation.
DataManager dm = conn.getDataManager()
ModelObject object = dm.findByPath("/Data/Shared Data");dm = conn.getDataManager()
object = dm.findByPath("/Data/Shared Data")dm = conn.GetDataManager()
object = dm.FindByPath("/Data/My Data/My Projects")DataManager dm = conn.GetDataManager()
ModelObject obj = dm.FindByPath("/Data/Shared Data");Each object stored in the EKM repository has a unique identifier that can also be used when searching for an object. The following shows this operation:
ModelObject object = dm.findById("d23ae05b-3a07-446c-a052-1eae22ce06ec");object = dm.findById("d23ae05b-3a07-446c-a052-1eae22ce06ec");object = dm.FindById("d23ae05b-3a07-446c-a052-1eae22ce06ec");ModelObject obj = dm.FindById("d23ae05b-3a07-446c-a052-1eae22ce06ec");Multiple objects can be located by searching the repository
for objects containing specific keywords. When using this type of
search, every property of every object in both the /Data/Shared
Data folder and the user’s /Data/My
Data folder is searched to see if they contain the keyword.
For example, if searching for the keyword “test”, any
object that has the keyword in its name, description, or any other
property would be returned. The following code snippets show this
operation and how to iterate over the results.
Set<ModelObject> objects = dm.findByKeyword("test");
if (objects.size() == 0)
System.out.println(">>>>> No objects found with keyword \"test\"");
else
for (ModelObject obj : objects)
System.out.println(">>>>> Object with keyword \"test\" found at " +
obj.getPath());objects = dm.findByKeyword("test")
if objects.size() == 0:
print ">>>>> No objects found with keyword \"test\""
else:
for obj in objects:
print ">>>>> Object with keyword \"test\" found at " + obj.getPath()objects = dm.FindByKeyword("test")
if objects.Count == 0:
print ">>>>> No objects found with keyword \"test\""
else:
for obj in objects:
print ">>>>> Object with keyword \"test\" found at " + obj.PathHashSet<ModelObject> results = dm.FindByKeyword("test");
if (results.Count == 0)
Console.WriteLine(">>>>> No objects found with keyword \"test\"");
else
foreach (ModelObject result in results)
Console.WriteLine(">>>>> Object with keyword \"test\" found at " + result.Path);
EKM provides a powerful search user interface that enables users to execute very complex queries. Once complete, the user can save a query so it can be executed again at a later time. Queries are saved on the user’s Home/My Queries page or on the Administration/Shared Queries page for those queries that should be available to all users. The library provides a way to execute these saved queries. When executing one of these queries from an application, the application must specify the name of the query to execute, and whether or not the query is shared. The results of the query are processed exactly like those returned when searching using a keyword.
The following examples show this operation:
// Execute a saved query in the user's "My Queries" folder.
Set<ModelObject> objects = dm.executeSavedQuery("my-query", false);
// Execute a saved query in the "Shared Queries" folder.
Set<ModelObject> objects = dm.executeSavedQuery("shared-query", true);# Execute a saved query in the user's "My Queries" folder.
objects = dm.executeSavedQuery("my-query", False)
# Execute a saved query in the "Shared Queries" folder.
objects = dm.executeSavedQuery("shared-query", True)# Execute a saved query in the user's "My Queries" folder.
objects = dm.ExecuteSavedQuery("my-query", False)
# Execute a saved query in the "Shared Queries" folder.
objects = dm.ExecuteSavedQuery("my-query", True)// Execute a saved query in the user's "My Queries" folder.
HashSet<ModelObject> objects = dm.ExecuteSavedQuery("my-query", false);
// Execute a saved query in the "Shared Queries" folder.
HashSet<ModelObject> objects = dm.ExecuteSavedQuery("shared-query", true);You can also generate complex queries using the API. You do
this by first creating a Query object and
then adding QueryRow instances to the query.
When creating a query object, you can specify specific object types
that you want to limit the query to. For example, in Java:
Query myQuery = new Query(“WorkbenchProjectArchiveFile”);
This executes a query that searches only Workbench project archive objects. In addition, you must specify the query operation to perform. This is one of match all rows or match any rows:
QueryOperation queryOp = new QueryOperation(); queryOp.setMatch(QueryMatch.ALL);
Next, you need to add rows to the query operation. This is where you specify the actual properties and values to search:
List<QueryRow> rows = new ArrayList<QueryRow>(); QueryRow row = myQuery.createRow(“property”, Condition.EQUAL, “value”); queryOp.setRows(rows);
You can also limit the query to a specific location in the EKM server. This is done by setting the path of the query. This path must be an actual EKM path. To do this, make sure to fix up the path prior to setting it in the query:
String path = PathUtils.fixUpPath(“/Data/My Data”, “AnEkmUsername”); myQuery.setPath(path);
Finally, apply the operation to the query and execute it:
myQuery.setOp(queryOp); Set<ModelObject> results = dm.findByQuery(myQuery);