You can contribute your own actions to use in the Bulk Import. Actions that you contribute appear in a drop-down list labeled Import Actions.
To add an import action, you have to contribute an action in the category DAM_IMPORT_ASSETS
. Actions in this category must define two properties: an automation chain and a form layout.
<action id="dndDamBulkImportAssets" link=""
order="10" label="label.smart.import"
help="desc.smart.import.file">
<category>DAM_IMPORT_ASSETS</category>
<properties>
<property name="chainId">Dam.ImportWithMetaDataInSeam</property>
<property name="layout">damBulkImport@create</property>
</properties>
</action>
When an action is selected, the layout defined in the properties is shown, along with an "Import" button.
The bean attached to the "Import" button creates a Map Object ( DataModelProperties
instance). It pushes the metadata from the form in the Map Object (without schema validation) and starts the automation chain id defined in the action. The chain takes the blob list as input, puts the Map Object in the context and names it docMetaData
.
<chain id="Dam.ImportWithMetaDataInSeam">
<operation id="Dam.Import">
<param type="boolean" name="overwrite">true</param>
</operation>
<operation id="Document.Update">
<param type="properties" name="properties">expr:Context.get("docMetaData")
</param>
</operation>
<operation id="Seam.AddMessage">
<param type="string" name="severity">INFO</param>
<param type="string" name="message">label.dam.assets.imported</param>
</operation>
<operation id="Seam.Refresh" />
</chain>
DataModelProperties
is a map object that stores each value set in the form layout with the field name as key and without validation of the schema manager (as we can have in DocumentModel
). If you bind a widget to a field foo:bar
that doesn't exist, the DataModelProperties
object will store it without generating an exception and you can fetch this field as usual (dataModelProperties.get("foo:bar")
).
Starting with 5.9.5
It's possible to specify a custom Document Type to use in your import action. This is useful if your application uses custom Document Types and you need to import many rich assets (Pictures, PDFs, Videos, etc.) to store in Nuxeo using a document type you defined.
The definition for the action is the same as outlined above.
The automation chain will be similar - you would add a parameter to the Dam.Import
operation which specifies the docType.
<extension target="org.nuxeo.ecm.core.operation.OperationServiceComponent"
point="chains">
<chain id="Dam.ImportFile">
<operation id="Dam.Import">
<param type="String" name="docType">File</param>
<param type="boolean" name="overwrite">true</param>
<param type="boolean" name="importInCurrentDocument">true</param>
</operation>
<operation id="Document.Update">
<param type="properties" name="properties">expr:Context.get("docMetaData")
</param>
</operation>
<operation id="Seam.AddMessage">
<param type="string" name="severity">INFO</param>
<param type="string" name="message">label.dam.assets.imported</param>
</operation>
<operation id="Seam.Refresh" />
</chain>
</extension>