Skip to content

Commit

Permalink
Implemented setTermsOfAccess and setFileAccessRequest.
Browse files Browse the repository at this point in the history
  • Loading branch information
janvanmansum committed Dec 10, 2024
1 parent 7c182d5 commit d296193
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,17 @@ public Dataset getDatasetMetadataFromDansDeposit(DansBagDeposit dansDeposit, Dat
dansDeposit.getHasOrganizationalIdentifier(),
dansDeposit.getHasOrganizationalIdentifierVersion());
var version = dataset.getDatasetVersion();
version.setFileAccessRequest(dansDeposit.allowAccessRequests());

// TODO: when processing an update-deposit, retrieve terms of access from the previous version
if (!dansDeposit.allowAccessRequests() && StringUtils.isBlank(version.getTermsOfAccess())) {
// Allow access requests only if it was not forbidden in previous versions
var fileAccessRequest = dansDeposit.allowAccessRequests() && (currentMetadata == null || currentMetadata.getFileAccessRequest());
version.setFileAccessRequest(fileAccessRequest);
if (StringUtils.isBlank(version.getTermsOfAccess()) && currentMetadata != null) {
version.setTermsOfAccess(currentMetadata.getTermsOfAccess());
}
if (!fileAccessRequest && StringUtils.isBlank(version.getTermsOfAccess())) {
// Dataverse requires terms of access to be set if file access requests are disabled, so set it to "N/a" if not explicitly provided
version.setTermsOfAccess("N/a");
}


version.setLicense(supportedLicenses.getLicenseFromDansDeposit(dansDeposit));
return dataset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static nl.knaw.dans.dvingest.core.dansbag.xml.XPathConstants.DDM_DCMI_METADATA;

// TODO: move to mapping package
public class SupportedLicenses {
private final Map<URI, License> supportedLicenses;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@ public void getUpdatesDataset_finds_dataset_for_update_deposit() throws Exceptio
// When / Then
assertThat(mappingService.getUpdatesDataset(testDepositDir)).isEqualTo(doi);
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

import static org.assertj.core.api.Assertions.assertThat;

/**
* Test class for {@link DansDepositConverter}. It uses the valid examples from the dd-dans-sword2-examples project.
*/
public class DansDepositConverterTest extends DansConversionFixture {

private final YamlService yamlService = new YamlServiceImpl();
Expand Down

0 comments on commit d296193

Please sign in to comment.