08-17-2020 06:02 AM
Hi Everyone,
I'm using the Apache chemistry opencmis library to interact with Alfresco. To query documents there is a method called queryObjects, which takes in an OperationContext as an argument. On this context, I can set a boolean flag, called setLoadSecondaryTypeProperties. However, even if I set it to true, it won't return the secondary type properties. I can only reach those properties if i use a SELECT query and join the two "tables" together on cmisbjectId.
The problem is, that the select query doesn't return cmis Document types, it returns QueryResult types, and it can't be casted, and I really need the Document.
Am I missing something here?
Thanks in advance!
Bence
08-17-2020 10:55 AM
You can try
operationContext.setFilter(null);
It means select all properties from query type
08-18-2020 04:47 AM
Sadly, it doesn't seem to work
08-18-2020 05:00 AM
queryObjects(String typeId, String where, boolean searchAllVersions, OperationContext context);Have you tried to pass typeId your specified type instead of cmis:document/cmis:folder?
08-18-2020 05:52 AM
Yes, we have a custom type derived from cmis:document, lets call it invoiceScan
final OperationContext ctx = OperationContextUtils.createMaximumOperationContext(); ctx.setLoadSecondaryTypeProperties(true); ctx.setFilter(null); final ItemIterable<CmisObject> result = session.queryObjects( "invoiceScan", "cmis:name = 'testName'", false, ctx);
This way i get back the desired document and all the properties from our specified custom type, i can see the "SecondaryTypeIds" property too, but i dont't get the properties OF the secondary type.
I've tried creating the minimum operation context, the maximum, the default from the OperationContextUtils aswell.
Now i use cmis:name in the where clause, but I'll want to use secondary type properties there if i somehow manage to get them.
08-19-2020 12:03 AM
I have tested it ,you are right,it did not work.The only opiton you can choose is to use session.query which returns QueryResult.
then you can iterate the query result and load the document one by one , or you can use session.queryObjects to batch query documents by uuids
If you want to use aspect properties ,you can get from QueryResult
08-19-2020 02:43 AM
Thanks for your help! Currently I use session.query, then iterate over the result. Didn't wanted to use this method as I have to make severaly trips to the repository, but i have to, as I need to query these result by a secondary type property.
Explore our Alfresco products with the links below. Use labels to filter content by product module.