Search folder hierarchy in FileNet for a particular folder

纵然是瞬间 提交于 2019-12-11 10:58:36

问题


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.



来源:https://stackoverflow.com/questions/56098141/search-folder-hierarchy-in-filenet-for-a-particular-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!