How to filter folder children using cmis query?

2019-03-03 15:06发布

I would like to filter the children of folders from a cmis 1.0 compliant repository with one query. So far that doesn't seem to be possible so I have settled to execute two queries to retrieve the children (i.e. folders and documents), however would still like to filter children by custom types so I have the following query:

SELECT cmis:objectTypeId, cmis:objectId FROM cmis:folder WHERE cmis:objectTypeId = 'my:custom1' OR cmis:objectTypeId = 'my:custom2' OR cmis:objectTypeId = 'cmis:folder' IN_FOLDER('workspace://SpacesStore/fhj738tw-45hW-659u-9DS1-9cX3Nh95r089')

Which doesn't work as I keep getting an error about mismatched input.

1条回答
何必那么认真
2楼-- · 2019-03-03 15:39

I've used this query in order to get children of a particular folder

String query;
query = "SELECT * FROM cmis:document WHERE IN_FOLDER('" + folderId + "')";

and to get all the children

ItemIterable<QueryResult> resultList = session.query(query, false);// No need to say about session ???

and finally

for (QueryResult qr : resultList) {

String idDocument = qr.getPropertyByQueryName("cmis:objectId").getFirstValue().toString();
Document doc = (Document) session.getObject(idDocument);

}

Note that in my example i only get cmis:objectId you can get more from Cmis Query

Hope that will help you.

查看更多
登录 后发表回答