gpt4 book ai didi

java - 需要有关 Filenet Enterprise 记录的帮助

转载 作者:行者123 更新时间:2023-12-01 11:00:29 25 4
gpt4 key购买 nike

我对 Filenet 非常陌生。我有一个要求,我需要提取特定文件夹中每个文档/记录的元数据。然后我需要将该元数据导出到 XML 中。首先,我需要检查是否有与该文件夹关联的任何文档,然后我需要执行此步骤,例如:Folder1 有 4 个文件,即 File1、File2、File3 和 File4。现在我需要将所有这些文件的元数据(例如:createdBy、createdDate 等)提取为 xml。我知道我可以通过查询来获取元数据,但不知道如何获取文件夹内文档/记录的数量并迭代以获取元数据。我需要使用 Java 来完成这些事情。

非常感谢立即提供帮助/意见。

谢谢,标记

最佳答案

最好的办法是查询文件夹中的所有文档,然后迭代它们,提取元数据,并以您认为最好的方式构建 xml。

您可以找到显示如何通过 API 使用查询的代码示例 here 。查询构建语法可以找到 here (特别检查文件夹操作符部分)。

现在您已经有了文档,只需迭代它们,检索属性集合,获取各个属性,并使用适当的方法(getStringValue、getInt32Value 等)读取值

注意:如果您希望查询仅包含当前版本,而不考虑旧版本,请将此子句添加到您的查询中:([IsCurrentVersion] = TRUE)

总而言之,使用样板代码,您应该具有如下所示的内容:(从旧代码中复制粘贴的部分,不保证立即工作)

    // Set connection parameters; usually loaded from a properties file.
String uri = "http://server:port/wsi/FNCEWS40MTOM/";
String username = "username";
String password = "password";

// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);

try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());

// Get object stores for domain.
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "OS_Name", null);

// Build the query you want to use here
// Add the attributes you want, the document class you're interested in, etc.
String sqlstr = "SELECT [This], [createdBy], [createdDate] FROM [docClass] WHERE ([IsCurrentVersion] = TRUE) AND Document.This INFOLDER '/f1/f2'";

SearchSQL sql = new SearchSQL(sqlstr)
SearchScope scope = new SearchScope(os);
IndependentObjectSet docs = scope.fetchObjects(sql, 1000, null, true);
// Get the page iterator
PageIterator p = docs.pageIterator();

// Loop through each page
while(p.nextPage())
{
// Loop through each item in the page
for(Object objct : p.getCurrentPage())
{
// Get the document object and write Document Title
Document doc = (Document)objct;
Properties props = doc.getProperties();

String creator = props.getStringValue("createdBy");
Date creationDate = props.getDateTimeValue("creationDate");

// Now that you have the values, do what you want with them :)
}
}
}

关于java - 需要有关 Filenet Enterprise 记录的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33368721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com