From 75705262f984bab8b873d263876b63548505871b Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Fri, 3 Jun 2022 09:45:15 -0400 Subject: [PATCH 1/5] #165 ensure ordering of MDBs with Citation first --- .../harvard/iq/dataverse/DatasetVersionUI.java | 16 +++++++++------- .../edu/harvard/iq/dataverse/MetadataBlock.java | 10 +++++++++- .../command/impl/MoveDataverseCommandTest.java | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) 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/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); From 2be974f8c2b1f79ed8ec32d1f902b6c14178e52e Mon Sep 17 00:00:00 2001 From: Kaitlin Newson Date: Tue, 7 Jun 2022 15:19:07 -0400 Subject: [PATCH 2/5] add migration scripts to apps page --- doc/sphinx-guides/source/api/apps.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/sphinx-guides/source/api/apps.rst b/doc/sphinx-guides/source/api/apps.rst index 75853d3b2f8..368229b5a5f 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 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 ---- From c87f8d9bd42810bbc555a3bd58d5203f45bb014a Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Tue, 7 Jun 2022 15:32:51 -0400 Subject: [PATCH 3/5] link to Migration API docs #8275 --- doc/sphinx-guides/source/api/apps.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/api/apps.rst b/doc/sphinx-guides/source/api/apps.rst index 368229b5a5f..48b5e1f3584 100755 --- a/doc/sphinx-guides/source/api/apps.rst +++ b/doc/sphinx-guides/source/api/apps.rst @@ -90,7 +90,7 @@ https://github.com/jupyter/repo2docker/blob/master/repo2docker/contentproviders/ 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 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 `_. +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 From 537ad57f87aab9eca7d5432670bc4747b6f81ce9 Mon Sep 17 00:00:00 2001 From: Gustavo Durand Date: Thu, 9 Jun 2022 14:09:52 -0400 Subject: [PATCH 4/5] Create V5.10.1.3__8599-legacy-templates.sql --- .../db/migration/V5.10.1.3__8599-legacy-templates.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/resources/db/migration/V5.10.1.3__8599-legacy-templates.sql 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) + From 19b568dffab289fb3ae36937f390d06f2872b6f1 Mon Sep 17 00:00:00 2001 From: Gustavo Durand Date: Thu, 9 Jun 2022 14:17:51 -0400 Subject: [PATCH 5/5] Create 8599-legacy-templates --- doc/release-notes/8599-legacy-templates | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 doc/release-notes/8599-legacy-templates 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.