cancel
Showing results for 
Search instead for 
Did you mean: 

Document query casting error?

karl_harris_
Star Collaborator
Star Collaborator

I've done the following query two ways:

  1. Using parent/child in Studio.

  2. Using NXQL query in Studio and get the same error. Here is the NXQL.

    SELECT * FROM Document WHERE ecm:isCheckedInVersion = 0 AND ecm:parentId = '@{Context["TRAVELERID"]}' AND ecm:primaryType = '@{Context["NEXTRECIPEDOCTYPE"]}' AND ecm:currentLifeCycleState = '@{Context["NEXTRECIPESTARTSTATE"]}'

All of the context variables resolve correctly in both cases. I have used similar queries in content views with success.

I get the following error:

org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector cannot be cast to org.nuxeo.ecm.core.api.DocumentModel

I basically have a container document that has just made a state transition and I want to select one of the documents in the container. The query is trying to retrieve the "now active" document context so I can edit the metadata.

Any suggestions on what is wrong and how to troubleshoot this effort!?

1 ACCEPTED ANSWER

karl_harris_
Star Collaborator
Star Collaborator

I found the automation chain I was calling did not return a document this was by my design. I was using Run Document Chain which expects a document or documents to be returned. Since nothing was returned (the end result of the called chain was a task being queued) the casting error was thrown.

The Fix:

Changing the the Automation command to Run Chain fixed the casting issue.

View answer in original post

4 REPLIES 4

karl_harris_
Star Collaborator
Star Collaborator

After digging a bit in the code it appears the public class OperationServiceImpl which implements AutomationService returns a DocumentModelCollector rather than a DocumentModel which produces the error above.

karl_harris_
Star Collaborator
Star Collaborator

I also tried Get Children rather that Get Child and go the same error.

karl_harris_
Star Collaborator
Star Collaborator

My container document has several documents of different types. It appears the DocumentModelCollector returns a document model list. Which then returns each DocumentModel contained in the parent document. For some reason the DocumentModelCollector itself is being returned NOT each individual DocumentModel.

karl_harris_
Star Collaborator
Star Collaborator

I found the automation chain I was calling did not return a document this was by my design. I was using Run Document Chain which expects a document or documents to be returned. Since nothing was returned (the end result of the called chain was a task being queued) the casting error was thrown.

The Fix:

Changing the the Automation command to Run Chain fixed the casting issue.

Getting started

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.