简体   繁体   English

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

[英]Acquiring retrieval name for latest version of a document in a DocumentSet using FileNet API

I have this piece of code:我有这段代码:

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();
}

Currently, this code works fine for retrieving a document with a certain file name.目前,此代码适用于检索具有特定文件名的文档。 I want to add to this so that it can also select the latest version of the file with that name.我想添加到它,以便它也可以选择具有该名称的文件的最新版本。 What should i do?我该怎么办?

I've considered adding an extra if inside the existing one, but i'm afraid of impacting the performance.我已经考虑在现有的内部添加一个额外的,但我担心影响性能。

this is what you can do to get the latest version of the document这是您可以获得最新版本文档的方法

    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();
        }

If you are filing a Document (or a subclass of Document), the contained document will be the current document version.如果您正在提交文件(或文件的子类),则包含的文件将是当前文件版本。 In this case, the current document version is (in order of use):在这种情况下,当前文档版本是(按使用顺序):

  • the released version (if there is one), else已发布的版本(如果有),否则
  • the current version (if there is one), otherwise,当前版本(如果有),否则,
  • the reservation version.保留版本。

You cannot use the Folder.file method to file a specific document version into the folder, and hence you will always have the DocumentSet with the latest version in the folder您不能使用Folder.file方法将特定文档版本归档到文件夹中,因此您将始终在文件夹中拥有包含最新版本的DocumentSet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM