0

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.

Dark Star1
  • 6,986
  • 16
  • 73
  • 121
  • if i understand your question you need it to get the children of one particular folder ?!? – Yagami Light Sep 13 '16 at 09:20
  • The question is 2 parts. First to be able to retrieve all the children of a folder in one query (doesn't seem possible far as I can tell) and second to filter the results of what's returned such that only arbitral types specified (i.e. cmis:objectTypeId = my:type) are returned. – Dark Star1 Sep 13 '16 at 10:52
  • I assure you that my example worked fine, i will update my answer to get it with a type – Yagami Light Sep 13 '16 at 10:59
  • @YagamiLight I have tried and haven't come up with a way to get the arbitral types from within a folder with one query, especially since I am restricted to CMIS 1.0. I think 1.1 has the possibility to retrieve children by leveraging cmis:item but this I do not know, and can't test as of now. – Dark Star1 Sep 13 '16 at 13:29

1 Answers1

1

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.

Yagami Light
  • 1,756
  • 4
  • 19
  • 39
  • I more or less did this. I was just wondering whether it is possible to filter the result I retrieve via query. but I am doing that post retrieval now. Thanks – Dark Star1 Sep 13 '16 at 10:50
  • @DarkStar1 please note that in my example i only get `cmis:objectId` you can get more https://wiki.alfresco.com/wiki/CMIS_Query_Language – Yagami Light Sep 13 '16 at 10:52
  • I already know this. I was asking for something that I haven't found examples to – Dark Star1 Sep 13 '16 at 10:54
  • @DarkStar1 read this very interesting post http://stackoverflow.com/questions/39468515/how-to-do-mass-update-in-alfresco-using-cmis – Yagami Light Sep 18 '16 at 10:49