06-29-2012 11:09 AM
06-29-2012 11:24 AM
>>> query = "select cmis:objectId, cmis:name from cmis:document where cmis:name like 'test-plain%' order by cmis:lastModificationDate desc"
>>> rs = repo.query(query, maxItems="1")
>>> rs[0].name
u'test-plain-3.txt'That file, test-plain-3.txt, is the most recently modified file matching the query.>>> folder = repo.getObjectByPath('/Sites/test-site-1/documentLibrary')
>>> query = "select cmis:objectId, cmis:name from cmis:document where in_folder('%s') order by cmis:lastModificationDate desc" % folder.id
>>> query
"select cmis:objectId, cmis:name from cmis:document where in_folder('workspace://SpacesStore/388e0fed-9104-4507-a702-30c4768e119b') order by cmis:lastModificationDate desc"
>>> rs = repo.query(query, maxItems="1")
>>> rs[0].name
u'test-plain-3.txt'Yes, it sucks that I have to retrieve the folder first to get its ID just to build the in_folder clause.06-29-2012 11:32 AM
Probably the easiest thing to do is to order by cmis:lastModificationDate descending. And you can make it more efficient by setting maxItems to 1.>>> query = "select cmis:objectId, cmis:name from cmis:document where cmis:name like 'test-plain%' order by cmis:lastModificationDate desc"
>>> rs = repo.query(query, maxItems="1")
>>> rs[0].name
u'test-plain-3.txt'
Yes, it sucks that I have to retrieve the folder first to get its ID just to build the in_folder clause.Remember you mentioning this in your webinar. Agree with your assessment.
06-29-2012 12:01 PM
String query = "select * from cmis:document";
OperationContext oc = new OperationContextImpl();
oc.setMaxItemsPerPage(5);
ItemIterable<QueryResult> q = getSession().query(query, false, oc);So grab an OperationContext, call that method, then pass it in when you do the query. Voila. Now you're down with the OC.06-29-2012 12:09 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.