-->

Search folder hierarchy in FileNet for a particula

2019-08-11 07:59发布

问题:

I am new to accessing FileNet CE from Java.

From my test program, I can connect, create folders, upload files and retrieve the list.

Now, I need to find a folder within the ObjectStore. That is to say, given a hierarchy of folders within folders: Folder1 -- Folder1a -- Folder1b ---- Folder1b1 ---- Folder1b2 -- Folder1c ---- Folder1c1 ---- Folder1c2 Folder2 ...

How do I search for a folder given its name? It could be N levels deep.

Similarly, how do I search using wildcards in the name?

Similarly, I created a sub-class of a folder (PersonnelFolder) and gave it some attributes (Personnel ID, Department, etc.). How do I search for a Personnel ID? i.e. Search in properties within objects of a given class?

回答1:

Searching on the Documentation, there are no examples about it, just snippet of code that address specific paths. Like this:

Get the parent folder of a subpath:

String childFolderPath = "/Loans/MyLoans";
Folder currentFolder = Factory.Folder.fetchInstance(os, childFolderPath, null);
Folder parent = currentFolder.get_Parent();

Get the folders directly contained in a path

String folderPath = "/Loans";
Folder currentFolder = Factory.Folder.fetchInstance(os, folderPath, null);
FolderSet childFolders = currentFolder.get_SubFolders();

By the way, doing a research via FEM, it's easy to build a sql that addresses only part of the name. Like this:

SELECT * FROM [Folder] WHERE ([FolderName] like '%Folder1a%')

Similarly with a custom metadata:

SELECT * FROM [YourFolderSubType] WHERE ([YourCustomAttribute] = 'yourValue')

Then, accessing the attribute PathName gives you the complete path. Or, alternatively, you could just retrieve its ID in order to fetch the Folder object from it.

You could try to execute a query like these from the APIs, then cast each result as a Folder object in order to work on it.

An example (untested):

SearchSQL sqlObject = new SearchSQL(sqlStatement);
RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
Iterator iter = myRows.iterator();
while (iter.hasNext()) {
    RepositoryRow row = (RepositoryRow) iter.next();
    row.getProperties().getStringValue("ID");
    com.filenet.api.core.Folder folder = Factory.Folder.fetchInstance(os, id, null);
}

Hope this helps.