0

我正在使用 Apache Chemistry OpenCMIS java 库。给定一个 QueryResult(例如,我通过搜索元数据属性找到了一个文档或一堆文档),这是检索 Document 对象本身的合理方法吗?或者有没有更有效的方法?

ItemIterable<QueryResult> results = session.query("SELECT * FROM cmis:document WHERE cmis:name LIKE 'test%'", false);

for(QueryResult hit: results) {
        Document document = (Document) session.getObject(session.createObjectId((String) hit.getPropertyValueById("cmis:objectId"))); 
    }
4

2 回答 2

3

尝试Session.queryObjects()方法。

于 2014-06-12T16:51:58.940 回答
0

对我来说,这非常有效

String myType = "my:documentType";

// get the query name of cmis:objectId
ObjectType type = session.getTypeDefinition(myType);
PropertyDefinition<?> objectIdPropDef = type.getPropertyDefinitions().get(PropertyIds.OBJECT_ID);
String objectIdQueryName = objectIdPropDef.getQueryName();

String queryString = "SELECT " + objectIdQueryName + " FROM " + type.getQueryName();

// execute query
ItemIterable<QueryResult> results = session.query(queryString, false);

for (QueryResult qResult : results) {
   String objectId = qResult.getPropertyValueByQueryName(objectIdQueryName);
   Document doc = (Document) session.getObject(session.createObjectId(objectId));
}

在这里找到:https ://chemistry.apache.org/java/examples/example-process-query-results.html

于 2019-07-05T10:05:24.393 回答