Skip to content

Commit 0774f97

Browse files
authored
Merge pull request IQSS#11491 from vera/feat/10134
feat: allow linking unpublished datasets to collections
2 parents 69aa522 + e75f5db commit 0774f97

7 files changed

Lines changed: 13 additions & 28 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
It is now possible to link draft datasets to other Dataverse collections. As usual, the datasets will only become publicly visible in the linked collection(s) after they have been published. To publish a linked dataset, your account must have the "Publish Dataset" permission for the Dataverse collection in which the dataset was originally created. Permissions in the linked Dataverse collections do not apply.

doc/sphinx-guides/source/user/dataverse-management.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ In order to link a dataset, you will need your account to have the "Publish Data
219219

220220
To link a dataset to your Dataverse collection, you must navigate to that dataset and click the white "Link" button in the upper-right corner of the dataset page. This will open up a window where you can type in the name of the Dataverse collection that you would like to link the dataset to. Select your Dataverse collection and click the save button. This will establish the link, and the dataset will now appear under your Dataverse collection.
221221

222+
A draft dataset can be linked to other Dataverse collections. It will only become publicly visible in the linked collection(s) after it has been published. To publish the dataset, your account must have the "Publish Dataset" permission for the Dataverse collection in which the dataset was originally created. Permissions in the linked Dataverse collections do not apply.
223+
222224
There is currently no way to remove established links in the UI. If you need to remove a link between a Dataverse collection and a dataset, please contact the support team for the Dataverse installation you are using (see the :ref:`unlink-a-dataset` section of the Admin Guide for more information).
223225

224226
.. _dataverse-linking:

src/main/java/edu/harvard/iq/dataverse/engine/command/impl/LinkDatasetCommand.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ public LinkDatasetCommand(DataverseRequest aRequest, Dataverse dataverse, Datase
4040

4141
@Override
4242
public DatasetLinkingDataverse execute(CommandContext ctxt) throws CommandException {
43-
44-
if (!linkedDataset.isReleased() && !linkedDataset.isHarvested()) {
45-
throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.link.not.available"), this);
46-
}
43+
4744
if (linkedDataset.getOwner().equals(linkingDataverse)) {
4845
throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.link.not.to.owner"), this);
4946
}

src/main/java/propertyFiles/Bundle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,6 @@ dataset.link.title=Link Dataset
16061606
dataset.link.save=Save Linked Dataset
16071607
dataset.link.not.to.owner=Can't link a dataset to its dataverse
16081608
dataset.link.not.to.parent.dataverse=Can't link a dataset to its parent dataverses
1609-
dataset.link.not.published=Can't link a dataset that has not been published
1610-
dataset.link.not.available=Can't link a dataset that has not been published or is not harvested
16111609
dataset.link.not.already.linked=Can't link a dataset that has already been linked to this dataverse
16121610
dataset.unlink.title=Unlink Dataset
16131611
dataset.unlink.delete=Remove Linked Dataset

src/main/webapp/dataset.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
<!-- END: Edit Dataset -->
518518

519519
<!-- LINK -->
520-
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and DatasetPage.dataset.released}">
520+
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned}">
521521
<p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
522522
action="#{DatasetPage.setShowLinkingPopup(true)}"
523523
oncomplete="PF('linkDatasetForm').show();"
@@ -527,7 +527,7 @@
527527
</div>
528528
<!-- END: LINK -->
529529
<!-- UNLINK -->
530-
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and DatasetPage.dataset.released and !empty DatasetPage.dataset.datasetLinkingDataverses}">
530+
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and !empty DatasetPage.dataset.datasetLinkingDataverses}">
531531
<p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
532532
action="#{DatasetPage.setShowUnLinkingPopup(true)}"
533533
oncomplete="PF('unlinkDatasetForm').show();"

src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,22 +3259,22 @@ public void testLinkingDatasets() {
32593259
UtilIT.publishDataverseViaNativeApi(dataverse1Alias, apiToken).then().assertThat()
32603260
.statusCode(OK.getStatusCode());
32613261

3262-
// Link dataset to second dataverse.
3263-
//should fail if dataset is not published
3262+
// Link dataset to second dataverse
3263+
// Should succeed even though dataset is not published
32643264
Response linkDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
32653265
linkDataset.prettyPrint();
32663266
linkDataset.then().assertThat()
3267-
.body("message", equalTo(BundleUtil.getStringFromBundle("dataset.link.not.available")))
3268-
.statusCode(FORBIDDEN.getStatusCode());
3267+
.statusCode(OK.getStatusCode());
32693268

32703269
UtilIT.publishDatasetViaNativeApi(datasetPid, "major", apiToken).then().assertThat()
32713270
.statusCode(OK.getStatusCode());
32723271

3273-
//Once published you should be able to link it
3272+
// Linking again to the same dataverse should fail
32743273
linkDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
32753274
linkDataset.prettyPrint();
32763275
linkDataset.then().assertThat()
3277-
.statusCode(OK.getStatusCode());
3276+
.body("message", equalTo(BundleUtil.getStringFromBundle("dataset.link.not.already.linked")))
3277+
.statusCode(FORBIDDEN.getStatusCode());
32783278

32793279
// Link another to test the list of linked datasets
32803280
Response createDataverse3 = UtilIT.createRandomDataverse(apiToken);

src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,10 @@ public void testLinkedDataset() {
6969
UtilIT.publishDataverseViaNativeApi(dataverse1Alias, apiToken).then().assertThat()
7070
.statusCode(OK.getStatusCode());
7171

72-
// You can't link an unpublished dataset.
72+
// You can link an unpublished dataset
7373
Response tryToLinkUnpublishedDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
7474
tryToLinkUnpublishedDataset.prettyPrint();
7575
tryToLinkUnpublishedDataset.then().assertThat()
76-
.statusCode(FORBIDDEN.getStatusCode())
77-
.body("message", equalTo("Can't link a dataset that has not been published or is not harvested"));
78-
79-
UtilIT.publishDatasetViaNativeApi(datasetPid, "major", apiToken).then().assertThat()
80-
.statusCode(OK.getStatusCode());
81-
82-
UtilIT.publishDataverseViaNativeApi(dataverse2Alias, apiToken).then().assertThat()
8376
.statusCode(OK.getStatusCode());
8477

8578
// A dataset cannot be linked to its parent dataverse.
@@ -89,12 +82,6 @@ public void testLinkedDataset() {
8982
.statusCode(FORBIDDEN.getStatusCode())
9083
.body("message", equalTo("Can't link a dataset to its dataverse"));
9184

92-
// Link dataset to non-parent dataverse (allowed).
93-
Response linkDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
94-
linkDataset.prettyPrint();
95-
linkDataset.then().assertThat()
96-
.statusCode(OK.getStatusCode());
97-
9885
// A dataset cannot be linked to the same dataverse again.
9986
Response tryToLinkAgain = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
10087
tryToLinkAgain.prettyPrint();

0 commit comments

Comments
 (0)