How to return files from folder with secondary type "P:cm:emailed" property only?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

How to return files from folder with secondary type "P:cm:emailed" property only?

Hello

There are 300 files inside the folder, 100 files have the P:cm:emailed secondary type property.

Following code takes 30 seconds to run, because Im getting all 300 items, asking each item if you have the P:cm:emailed secondary type property or not.

Would it be possible to return only items with P:cm:emailed secondary type property?

OperationContext folderOpCtx = cmisSession.createOperationContext();
folderOpCtx.setFilterString("cmis:secondaryObjectTypeIds");
folderOpCtx.setRenditionFilterString("P:cm:emailed");

Folder folder = (Folder) cmisSession.getObjectByPath(emailFolderPath, folderOpCtx);

for (CmisObject child : children) {
System.out.println(i + " " + child.getName() + " emailed: " +
child.getProperty("cmis:secondaryObjectTypeIds").getValues().contains("P:cm:emailed"));
i++;
}
1 Reply
Highlighted
Professional

Re: How to return files from folder with secondary type "P:cm:emailed" property only?

How about doing a join on the aspect and then using a contains/path for the folder path:

import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*

String cql = "SELECT D.cmis:objectId, D.cmis:name FROM cmis:document as D join cm:emailed as E on D.cmis:objectId = E.cmis:objectId where CONTAINS(D, 'PATH:\"/app:company_home/cm:test//*\"')"

ItemIterable<QueryResult> results = session.query(cql, false)

results.each { hit ->
    hit.properties.each { println "${it.queryName}: ${it.firstValue}" }
    println "--------------------------------------"
}

println "--------------------------------------"
println "Total number: ${results.totalNumItems}"
println "Has more: ${results.hasMoreItems}"
println "--------------------------------------"‍‍‍‍‍‍‍‍‍