This project is not covered by Drupal’s security advisory policy.
INTRODUCTION
Clone an existing DKAN dataset including its distributions and references.
Features
- Form at
/node/clone-datasetwith a select field for the dataset, an optional title for the clone and an option for the files of the distributions: copy uploaded files, use the same files or clone without files. - Preselect a dataset with
?dataset=. - "Clone" tab on dataset nodes (
/node/{node}/clone). - "Clone dataset" button on the DKAN datasets list (
/admin/dkan/datasets) and a menu link under DKAN > Datasets. - The clone is validated against the dataset schema before it is saved.
- The clone is saved as draft (if the DKAN workflow has this state) and the edit form of the clone is opened, so it can be adjusted before publishing.
- Uses Select2 for the dataset field if the module is installed.
How it works
The metastore returns the dataset dereferenced, i.e. distributions, publisher, keywords, themes etc. as full objects. The clone gets this metadata with a new identifier and the new title (default: "Copy of" and the dataset's title).
The clone is created as a duplicate of the dataset node, so other fields of the data node (e.g. images or visualizations) are cloned too. The URL alias is not copied; pathauto creates a new one, if installed.
When the node is saved, DKAN references the metadata as for any other dataset:
- Shared references like publisher, keywords or themes are reused, both datasets point to the same reference nodes.
- Distributions are matched by their content too: a distribution that is identical in both datasets uses the same distribution node. A distribution gets its own node as soon as it differs, e.g. by a copied file or when it is changed in the clone.
- With "Copy uploaded files", uploaded files of the distributions are copied (next to the original, with a suffix like
_0). The clone then has its own resources and its own datastore import. File usage is added for the new distribution nodes. With "Use the same files" (and for links to other sites), both datasets use the same resource and datastore table. - With "Without files", the download URLs of all distributions (uploaded files and links) are removed. The distributions keep their other metadata and get their own nodes, files can be added to the clone later.
Shared nodes and resources are safe: when the clone is deleted, DKAN only removes references and resources that no other dataset uses. The kernel test CloneDatasetTest checks this: it clones a dataset (with each option for the files), deletes the clone and verifies that the original dataset, its references, resources and files are unchanged.
If saving fails, copied files are deleted again.
REQUIREMENTS
- DKAN (dkan_metastore)
INSTALLATION
Install as you would normally install a Drupal module. See: https://www.drupal.org/node/895232 for further information.
CONFIGURATION
Grant the permissions "Clone dataset" and "Data: Create new content" to the roles that should use the form, the clone is a new data node (other modules can restrict creating data nodes further). Users can clone any dataset they can view.
MAINTAINERS
Current maintainers:
- Stefan Korn (stefan.korn) - https://www.drupal.org/u/stefankorn
Project information
- Project categories: Content editing experience
- Ecosystem: DKAN
- By stefan.korn on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
