使用 FileNet API 获取 DocumentSet 中最新版本文档的检索名称

Posted

技术标签:

【中文标题】使用 FileNet API 获取 DocumentSet 中最新版本文档的检索名称【英文标题】:Acquiring retrieval name for latest version of a document in a DocumentSet using FileNet API 【发布时间】:2017-10-30 12:43:48 【问题描述】:

我有这段代码:

Folder fold = Factory.Folder.fetchInstance(os, folderPath, null);
DocumentSet docs = fold.get_ContainedDocuments();
Iterator it = docs.iterator();

Document retr;
try 
    while (it.hasNext()) 
        retr = (Document)it.next();
        String name = retr.get_Name();
        System.out.println(name);

        if(name.equals(fileName)) 
            System.out.println("Match Found");
            System.out.println("Document Name : " + retr.get_Name());
            return retr;
        
    
 catch (Exception e) 
    e.printStackTrace();

目前,此代码可正常用于检索具有特定文件名的文档。我想添加它,以便它还可以选择具有该名称的文件的最新版本。我该怎么办?

我考虑在现有的内部添加一个额外的,但我担心影响性能。

【问题讨论】:

我认为性能不是问题。为什么不尝试并自己测量它,然后发布结果作为答案。 您的标题与您的问题不完全相符。您是在尝试排序,还是只是尝试根据请求检索某个文档? @ChristopherPowell 我正在尝试检索文档。也许我的措辞令人困惑。 【参考方案1】:

这是获取最新版本文档的方法

    Folder fold = Factory.Folder.fetchInstance(os, folderPath, null);
        DocumentSet docs = fold.get_ContainedDocuments();
        Iterator it = docs.iterator();

        Document retr;
        try 
            while (it.hasNext()) 
                retr = (Document)it.next();
                String name = retr.get_Name();
                System.out.println(name);

                if(name.equals(fileName)) 

                    System.out.println("Match Found");
                    System.out.println("Document Name : " + retr.get_Name());
//here you are checking the document for the name. It also can happen that, this document might have more than version but the title remained same for each version. You can get the latest version like

                    return retr.get_CurrentVersion();
                
            
         catch (Exception e) 
            e.printStackTrace();
        

【讨论】:

【参考方案2】:

如果您正在提交文档(或文档的子类),则包含的文档将是当前文档版本。在这种情况下,当前文档版本是(按使用顺序):

发布版本(如果有),否则 当前版本(如果有的话),否则, 预订版本。

您不能使用Folder.file 方法将特定文档版本归档到文件夹中,因此您将始终在文件夹中拥有最新版本的DocumentSet

【讨论】:

以上是关于使用 FileNet API 获取 DocumentSet 中最新版本文档的检索名称的主要内容,如果未能解决你的问题,请参考以下文章

使用 FileNet API 获取 DocumentSet 中最新版本文档的检索名称

在 Filenet 中获取和更新工作流数据

通过符号名称获取 PropertyTemplate 的最快方法是 IBM FileNet CE API

通过 com.filenet.api.util.UserContext 进行文件网身份验证

FileNet:获取存储区域上的可用空间

SearchScope fetchRows 与 fetchObjects (IBM FileNet CE API)