Loading secondary types

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

Loading secondary types

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 cmisSmiley SurprisedbjectId.

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

6 Replies
Advanced

Re: Loading secondary types

You can try 

operationContext.setFilter(null);

It means select all properties from query type

Active Member

Re: Loading secondary types

Sadly, it doesn't seem to work

Advanced

Re: Loading secondary types

Could you paste your code here ?
 
what params did you pass to 
 queryObjects(String typeId, String where, boolean searchAllVersions,
            OperationContext context);
Have you tried to pass typeId your specified type instead of cmis:document/cmis:folder?
 
 
Active Member

Re: Loading secondary types

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.

 

Advanced

Re: Loading secondary types

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

Active Member

Re: Loading secondary types

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.