diff --git a/doc/release-notes/8599-legacy-templates b/doc/release-notes/8599-legacy-templates new file mode 100644 index 00000000000..7285a613635 --- /dev/null +++ b/doc/release-notes/8599-legacy-templates @@ -0,0 +1,5 @@ +Some older legacy templates did not have an associated termsofuseandaccess linked to them. When custom licenses were added, dataverses that these legacy templates as default would not allow the creation of a new dataset (500 error). + +In this release, we run a script that creates a default empty termsofuseandaccess for each of these templates and links them. + +Note the termsofuseandaccess that are created this way default to using the license with id=1 (cc0) and the fileaccessrequest to false. diff --git a/doc/sphinx-guides/source/api/apps.rst b/doc/sphinx-guides/source/api/apps.rst index 75853d3b2f8..48b5e1f3584 100755 --- a/doc/sphinx-guides/source/api/apps.rst +++ b/doc/sphinx-guides/source/api/apps.rst @@ -87,6 +87,13 @@ Docker image from a code repository that follows the [reproducible executable en https://github.com/jupyter/repo2docker/blob/master/repo2docker/contentproviders/dataverse.py +dataverse-migration-scripts +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This series of Python scripts offers a starting point for migrating datasets from one Dataverse installation to another. Multiple parts of the process are handled in these scripts, including adding users, collections, and multiple versions of datasets. These scripts were developed to migrate data from version 4.20 to 5.1, but may provide a helpful starting point for other software versions. The :doc:`migration APIs ` added in version 5.6 are not used. You can find more details in the repository, as well as `this Google group thread `_. + +https://github.com/scholarsportal/dataverse-migration-scripts + Java ---- diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionUI.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionUI.java index b20cf0debaa..d09457c86bf 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionUI.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionUI.java @@ -18,6 +18,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TreeMap; +import static java.util.stream.Collectors.toList; import javax.ejb.EJB; import javax.faces.view.ViewScoped; import javax.inject.Named; @@ -39,22 +41,22 @@ public class DatasetVersionUI implements Serializable { public DatasetVersionUI() { } - private Map> metadataBlocksForView = new HashMap<>(); - private Map> metadataBlocksForEdit = new HashMap<>(); + private TreeMap> metadataBlocksForView = new TreeMap<>(); + private TreeMap> metadataBlocksForEdit = new TreeMap<>(); - public Map> getMetadataBlocksForView() { + public TreeMap> getMetadataBlocksForView() { return metadataBlocksForView; } - public void setMetadataBlocksForView(Map> metadataBlocksForView) { + public void setMetadataBlocksForView(TreeMap> metadataBlocksForView) { this.metadataBlocksForView = metadataBlocksForView; } - public Map> getMetadataBlocksForEdit() { + public TreeMap> getMetadataBlocksForEdit() { return metadataBlocksForEdit; } - public void setMetadataBlocksForEdit(Map> metadataBlocksForEdit) { + public void setMetadataBlocksForEdit(TreeMap> metadataBlocksForEdit) { this.metadataBlocksForEdit = metadataBlocksForEdit; } @@ -417,7 +419,7 @@ public void setMetadataValueBlocks(DatasetVersion datasetVersion) { actualMDB.add(mdbTest); } } - } + } for (MetadataBlock mdb : actualMDB) { mdb.setEmpty(true); diff --git a/src/main/java/edu/harvard/iq/dataverse/MetadataBlock.java b/src/main/java/edu/harvard/iq/dataverse/MetadataBlock.java index 039915c7201..844c0ec5be7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/MetadataBlock.java +++ b/src/main/java/edu/harvard/iq/dataverse/MetadataBlock.java @@ -35,7 +35,7 @@ @NamedQuery( name="MetadataBlock.findByName", query = "SELECT mdb FROM MetadataBlock mdb WHERE mdb.name=:name") }) @Entity -public class MetadataBlock implements Serializable { +public class MetadataBlock implements Serializable, Comparable { private static final long serialVersionUID = 1L; @@ -210,4 +210,12 @@ public String getLocaleDisplayName() return displayName; } } + + @Override + public int compareTo(Object arg0) { + //guaranteeing that citation will be shown first with custom blocks in order of creation + MetadataBlock other = (MetadataBlock) arg0; + Long t = "citation".equals(name) ? -1 : this.getId(); + return t.compareTo("citation".equals(other.name) ? -1 : other.getId()); + } } diff --git a/src/main/resources/db/migration/V5.10.1.3__8599-legacy-templates.sql b/src/main/resources/db/migration/V5.10.1.3__8599-legacy-templates.sql new file mode 100644 index 00000000000..5027c48df59 --- /dev/null +++ b/src/main/resources/db/migration/V5.10.1.3__8599-legacy-templates.sql @@ -0,0 +1,10 @@ +-- this script finds legacy templates that do not hava an associated termsofuseandaccess +-- and creates / links a termsofuseandaccess to them +with _update as +( +update template set termsofuseandaccess_id = nextval('termsofuseandaccess_id_seq' ) +where termsofuseandaccess_id is null +returning termsofuseandaccess_id +) +insert into termsofuseandaccess (id, fileaccessrequest, license_id) (select termsofuseandaccess_id, false, 1 from _update) + diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java index e6f7a5ea34f..13b60f875d5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java @@ -156,9 +156,11 @@ public void setUp() { mbA = new MetadataBlock(); mbA.setOwner(root); mbA.setId(1l); + mbA.setName("mbA"); mbB = new MetadataBlock(); mbB.setOwner(childE); mbB.setId(2l); + mbB.setName("mbB"); mbsE.add(mbB); mbsEE.add(mbA); mbsEE.add(mbB);