Dark Star1
Dark Star1

Reputation: 7393

How to filter folder children using cmis query?

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.

Upvotes: 0

Views: 4616

Answers (1)

Yagami Light
Yagami Light

Reputation: 1796

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.

Upvotes: 1

Related Questions