Nuxeo Server

Bulk Actions Directory

Updated: December 7, 2018 Page Information Edit on GitHub

Directory

Nuxeo provides several actions for the Bulk Action Framework:

Action name Description Parameters Java Class
setProperties Allow to set several properties on each document Parameters represent the couple (xpath, value) to set SetPropertiesAction
setSystemProperties Allow to set several system properties on each document Parameters represent the couple (xpath, value) to set SetSystemPropertiesAction
csvExport Allow to export several documents as a csv file Parameters represent the options (schemas, xpaths, zip/sort, lang) CSVExportAction

Examples

Let's see some examples of bulk actions in use.

SetPropertiesAction

The following example shows how to use setPropertiesAction with Java Service:

// build command
BulkCommand command = new BulkCommand.Builder(SetPropertiesAction.ACTION_NAME, "SELECT * from Document")
        .repository("default")
        .user("Administrator")
        .param("dc:nature", "article")
        .param("dc:subjects", ImmutableList.of("art/architecture"))
        .build();

// run command
BulkService bulkService = Framework.getService(BulkService.class);
String commandId = bulkService.submit(command);

// await end of computation
bulkService.await(commandId, Duration.ofMinutes(1));

// get status
BulkStatus status = bulkService.getStatus(commandId);

You can submit the same command through REST and Command endpoint:

curl -u Administrator:Administrator \
 -H 'Content-Type: application/json' \
 -X POST 'http://localhost:8080/nuxeo/api/v1/automation/Bulk.RunAction' \
-d '{"params":{
        "query":"SELECT * FROM Document",
        "action":"setProperties",
        "parameters":"{\"dc:nature\":\"article\",\"dc:subjects\":[\"art\/architecture\"]}"
        }
    }'

CSVExportAction

It exports requested documents as a CSV File which can be sorted and zipped.

System properties are always exported as first columns, then all the properties from provided schemas and xpaths are exported if they can be found.

For exported multi-valued properties, the values are separated from each other with the pipe | character.

... ,dc:contributors, ...
... , user1 | user2 , ...  

The following example shows how to use csvExportAction with Java Service:

// build command
ImmutableList<String> xpaths = ImmutableList.of("file:content/name", "file:content/length");
BulkCommand command = new BulkCommand.Builder(CSVExportAction.ACTION_NAME, "SELECT * from Document")
        .repository("default")
        .user("Administrator")
        .param(CSVProjectionComputation.PARAM_SCHEMAS, ImmutableList.of("dublincore"))
        .param(CSVProjectionComputation.PARAM_XPATHS, xpaths)
        .param(CSVProjectionComputation.PARAM_LANG, "fr") // default is context Locale
        .param(SortBlob.SORT_PARAMETER, Boolean.FALSE) // default is TRUE
        .param(ZipBlob.ZIP_PARAMETER, Boolean.TRUE) // default is FALSE
        .build();



// run command
BulkService bulkService = Framework.getService(BulkService.class);
String commandId = bulkService.submit(command);

// await end of computation
bulkService.await(commandId, Duration.ofMinutes(1));

// get status
BulkStatus status = bulkService.getStatus(commandId);

You can submit the same command through REST and Command endpoint:

curl -u Administrator:Administrator \
 -H 'Content-Type: application/json' \
 -X POST 'http://localhost:8080/nuxeo/api/v1/automation/Bulk.RunAction' \
 -d '{"params":{
        "query":"SELECT * FROM Document",
        "action":"csvExport",
        "parameters":"{\"schemas\":[\"dublincore\"],\"xpaths\":[\"file:content\/name\", \"file:content\/length\"],\"lang\":\"fr\",\"sort\":false,\"zip\":true}"
        }
     }'

And then get the status containing the URL to the result:

curl -u Administrator:Administrator \
 -H 'Content-Type: application/json' \
 -X GET 'http://localhost:8080/nuxeo/api/v1/bulk/<id-from-previous-command>'
11 days ago manonlumeau NXP-26341: add some doc about the separator for multi-valued fields
11 days ago manonlumeau NXDOC-1709: update bulk directory and add csv export doc
14 days ago manonlumeau NXDOC-1709: update bulk directory and add csv export doc
14 days ago manonlumeau Review typos and format
a month ago manonlumeau NXP-26138: update Bulk.RunAction documentation
2 months ago Loubna Benzaama Fix Showcase Content add-on doc
History: Created by Loubna Benzaama

We'd love to hear your thoughts!

All fields required