Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/release-notes/10134-link-draft-datasets.md
Original file line number Diff line number Diff line change
@@ -0,0 +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.
2 changes: 2 additions & 0 deletions doc/sphinx-guides/source/user/dataverse-management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ In order to link a dataset, you will need your account to have the "Publish Data

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.

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.

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).

.. _dataverse-linking:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ public LinkDatasetCommand(DataverseRequest aRequest, Dataverse dataverse, Datase

@Override
public DatasetLinkingDataverse execute(CommandContext ctxt) throws CommandException {

if (!linkedDataset.isReleased() && !linkedDataset.isHarvested()) {
throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.link.not.available"), this);
}

if (linkedDataset.getOwner().equals(linkingDataverse)) {
throw new IllegalCommandException(BundleUtil.getStringFromBundle("dataset.link.not.to.owner"), this);
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,6 @@ dataset.link.title=Link Dataset
dataset.link.save=Save Linked Dataset
dataset.link.not.to.owner=Can't link a dataset to its dataverse
dataset.link.not.to.parent.dataverse=Can't link a dataset to its parent dataverses
dataset.link.not.published=Can't link a dataset that has not been published
dataset.link.not.available=Can't link a dataset that has not been published or is not harvested
dataset.link.not.already.linked=Can't link a dataset that has already been linked to this dataverse
dataset.unlink.title=Unlink Dataset
dataset.unlink.delete=Remove Linked Dataset
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
<!-- END: Edit Dataset -->

<!-- LINK -->
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and DatasetPage.dataset.released}">
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned}">
<p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
action="#{DatasetPage.setShowLinkingPopup(true)}"
oncomplete="PF('linkDatasetForm').show();"
Expand All @@ -529,7 +529,7 @@
</div>
<!-- END: LINK -->
<!-- UNLINK -->
<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}">
<div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and !empty DatasetPage.dataset.datasetLinkingDataverses}">
<p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
action="#{DatasetPage.setShowUnLinkingPopup(true)}"
oncomplete="PF('unlinkDatasetForm').show();"
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3259,22 +3259,22 @@ public void testLinkingDatasets() {
UtilIT.publishDataverseViaNativeApi(dataverse1Alias, apiToken).then().assertThat()
.statusCode(OK.getStatusCode());

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

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

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

// Link another to test the list of linked datasets
Response createDataverse3 = UtilIT.createRandomDataverse(apiToken);
Expand Down
15 changes: 1 addition & 14 deletions src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,10 @@ public void testLinkedDataset() {
UtilIT.publishDataverseViaNativeApi(dataverse1Alias, apiToken).then().assertThat()
.statusCode(OK.getStatusCode());

// You can't link an unpublished dataset.
// You can link an unpublished dataset
Response tryToLinkUnpublishedDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
tryToLinkUnpublishedDataset.prettyPrint();
tryToLinkUnpublishedDataset.then().assertThat()
.statusCode(FORBIDDEN.getStatusCode())
.body("message", equalTo("Can't link a dataset that has not been published or is not harvested"));

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

UtilIT.publishDataverseViaNativeApi(dataverse2Alias, apiToken).then().assertThat()
.statusCode(OK.getStatusCode());

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

// Link dataset to non-parent dataverse (allowed).
Response linkDataset = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
linkDataset.prettyPrint();
linkDataset.then().assertThat()
.statusCode(OK.getStatusCode());

// A dataset cannot be linked to the same dataverse again.
Response tryToLinkAgain = UtilIT.linkDataset(datasetPid, dataverse2Alias, superuserApiToken);
tryToLinkAgain.prettyPrint();
Expand Down