首页 > 解决方案 > 使用 IBM filenet 中的文件对象获取绝对或相对路径

问题描述

String mySQLString = "select * from document where documentTitle like '%test%' ";
SearchSQL sql = new SearchSQL(mySQLString);
IndependentObjectSet s = search.fetchObjects(sql, 10, null, true);
Document doc;
PageIterator iterator = s.pageIterator();
iterator.nextPage();

for (Object object : iterator.getCurrentPage()) {
    doc = (Document) object;
    Properties properties = doc.getProperties();
    //I am trying to get an absolute or relative path here for every document.
    // for eg: /objectstorename/foldername/filename like this.
}

我尝试在文档中搜索属性和类描述。但无法找到路径。?

标签: filenet-p8filenet-content-engine

解决方案


要在一个查询中完成所有操作(就像您在代码中尝试做的那样),您可以创建与ReferentialContainmentRelationship表的连接。该Head表的属性指向文档,属性Tail指向文档填写的文件夹,属性ContainmentName是文档在文件夹中的名称。使用以下代码构造文档路径:

SearchSQL searchSQL = new SearchSQL("SELECT R.ContainmentName, R.Tail, D.This FROM Document AS D WITH INCLUDESUBCLASSES INNER JOIN ReferentialContainmentRelationship AS R WITH INCLUDESUBCLASSES ON D.This = R.Head WHERE DocumentTitle like '%test%'");
SearchScope searchScope = new SearchScope(objectStore);
RepositoryRowSet objects = searchScope.fetchRows(searchSQL, null, null, null);
Iterator<RepositoryRow> iterator = objects.iterator();

while (iterator.hasNext()) {
    RepositoryRow repositoryRow = iterator.next();
    Properties properties = repositoryRow.getProperties();
    Folder folder = (Folder) properties.get("Tail").getEngineObjectValue();
    String containmentName = properties.get("ContainmentName").getStringValue();

    System.out.println(folder.get_PathName() + "/" + containmentName);
}

以这种方式构建的路径也可用于从对象存储中获取对象。可以通过使用属性过滤器作为方法的第三个参数来优化查询代码fetchRows()。如果文档被归档在多个文件夹中,不知道这是如何表现的。


推荐阅读