#StackBounty: #java #nuxeo How to make a query with properties parameter in nuxeo

Bounty: 50

I want to make a request with “dynamic” properties fetch from my Java app with nuxeo 8.10.

There is the declatation of my NuxeoDocument:

    <schema name="TestDocumentProperties" src="data/TestDocumentProperties.xsd" prefix="test" />
    <doctype name="TestDocument" extends="Document">
        <schema name="dublincore"/>
        <schema name="TestDocumentProperties"/>
    </doctype>

There is the schema:

<xs:schema ...>  
  <xs:element name="summary" type="xs:string"/>
  <xs:element name="content" type="xs:string"/>
</xs:schema>

There is a “Get” request to my Nuxeo server:

https:xxx/nuxeo/site/api/v1/search/lang/NXQL/execute?query=SELECT * FROM Document WHERE ecm:fulltext = 'test'&properties=TestDocumentProperties, dublincore

When i execute this request directly from my browser, the result contains all of the properties of “dublincore” and “TestDocumentProperties”:

{
    "entity-type": "document",
    "type": "TestDocument",
    ...
    "properties": {
        "test:summary": "test text to search in summary",
        "test:content": "test text to search in content",
        "dc:description": null,
        "dc:language": null,
        "dc:coverage": null,
        "dc:valid": null,
        "dc:creator": "xxx",
        "dc:modified": "2017-12-13T16:28:38.44Z",
        ...
    },...
}

So, I want to execute a nuxeo nxql request from my Java application with the same parameter.
Before, i execute only the request from my java app, without the “properties” parameter with this code:

return this.nuxeoClient.repository().query("SELECT * FROM Document WHERE ecm:fulltext = 'test'");

But with “query” method from repository, there isn’t possible to specify the properties to fetch. So, today, i try with this code:

    Map<String, Object> parameters = new HashMap<>();
    parameters.put("query", "SELECT * FROM Document WHERE ecm:fulltext = 'test'");
    parameters.put("properties", "TestDocumentProperties, dublincore");
    return this.nuxeoClient.automation("Repository.Query").parameters(parameters).execute();

Unfortunately, the result isn’t fetch correctly, i don’t have the “dublincore” properties in my response but i have the “TestDocumentProperties”. If i remove the “TestDocumentProperties” in the list of fetch properties parameters, there is no change to the response…

Can you help me to correct this code or indicate me an alternative ?

Thank’s


Get this bounty!!!

Leave a Reply