From 13b727a15c8df71008819f2b15b43f57744d7e7e Mon Sep 17 00:00:00 2001 From: qqmyers Date: Mon, 9 Dec 2024 14:53:39 -0500 Subject: [PATCH] fix Dataset Differencing --- .../dataverse/DatasetVersionDifference.java | 7 ++++ src/main/java/propertyFiles/Bundle.properties | 4 ++- .../DatasetVersionDifferenceTest.java | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionDifference.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionDifference.java index 92f3bc856b0..0dd6ff67e45 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionDifference.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionDifference.java @@ -264,6 +264,13 @@ private void getTermsDifferences() { BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection")); checkAndAddToChangeList(originalTerms.getStudyCompletion(), newTerms.getStudyCompletion(), BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion")); + checkAndAddToChangeList(Boolean.toString(originalTerms.isFileAccessRequest()), Boolean.toString(newTerms.isFileAccessRequest()), + BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfAccess.addInfo.fileAccessRequest")); + String customTerms = BundleUtil.getStringFromBundle("license.custom"); + checkAndAddToChangeList( + (originalTerms.getLicense() == null) ? customTerms : originalTerms.getLicense().getName(), + (newTerms.getLicense() == null) ? customTerms : newTerms.getLicense().getName(), + BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfUse.addInfo.license")); } private void checkAndAddToChangeList(String originalTerm, String newTerm, diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index c47356008ff..122a29c0cc9 100644 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1994,10 +1994,10 @@ file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions=Conditions file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions.title=Any additional information that will assist the user in understanding the access and use conditions of the Dataset. file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer=Disclaimer file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer.title=Information regarding responsibility for uses of the Dataset. +file.dataFilesTab.terms.list.termsOfUse.addInfo.license=License file.dataFilesTab.terms.list.termsOfAccess.header=Restricted Files + Terms of Access file.dataFilesTab.terms.list.termsOfAccess.description=Restricting limits access to published files. People who want to use the restricted files can request access by default. If you disable request access, you must add information about access to the Terms of Access field. file.dataFilesTab.terms.list.termsOfAccess.description.line.2=Learn about restricting files and dataset access in the User Guide. - file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles=Restricted Files file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles.title=The number of restricted files in this dataset. file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles.txt=There {0, choice, 0#are|1#is|2#are} {0} restricted {0, choice, 0#files|1#file|2#files} in this dataset. @@ -2023,6 +2023,8 @@ file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection=Size of Coll file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection.tip=Summary of the number of physical files that exist in a Dataset, recording the number of files that contain data and noting whether the collection contains machine readable documentation and/or other supplementary files and information, such as code, data dictionaries, data definition statements, or data collection instruments. file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion=Study Completion file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion.title=Relationship of the data collected to the amount of data coded and stored in the Dataset. Information as to why certain items of collected information were not included in the dataset or a specific data file should be provided. +file.dataFilesTab.terms.list.termsOfAccess.addInfo.fileAccessRequest=File Access Requests Allowed + file.dataFilesTab.terms.list.guestbook=Guestbook file.dataFilesTab.terms.list.guestbook.title=User information (i.e., name, email, institution, and position) will be collected when files are downloaded. file.dataFilesTab.terms.list.guestbook.noSelected.tip=No guestbook is assigned to this dataset so users will not be prompted to provide any information when downloading files. diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java index d0ac7078915..527f0d14ba8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionDifferenceTest.java @@ -195,6 +195,37 @@ public void testDifferencing() { compareResults(datasetVersion, datasetVersion2, expectedAddedFiles, expectedRemovedFiles, expectedChangedFileMetadata, expectedChangedVariableMetadata, expectedReplacedFiles, changedTerms); + // Set file access + + datasetVersion.getTermsOfUseAndAccess().setFileAccessRequest(false); + datasetVersion2.getTermsOfUseAndAccess().setFileAccessRequest(true); + String[] termField3 = new String[] { + BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfAccess.addInfo.fileAccessRequest"), + "false", "true" }; + changedTerms.add(termField3); + + compareResults(datasetVersion, datasetVersion2, expectedAddedFiles, expectedRemovedFiles, + expectedChangedFileMetadata, expectedChangedVariableMetadata, expectedReplacedFiles, changedTerms); + + // Set License + + License license2 = new License("CC-BY-4.0", + "Creative Commons Attribution 4.0 International License.", + URI.create("http://creativecommons.org/licenses/by/4.0"), URI.create("https://licensebuttons.net/l/by/4.0/88x31.png"), + true, 1l); + + datasetVersion.getTermsOfUseAndAccess().setLicense(license); + datasetVersion2.getTermsOfUseAndAccess().setLicense(license2); + String[] termField4 = new String[] { + BundleUtil.getStringFromBundle("file.dataFilesTab.terms.list.termsOfUse.addInfo.license"), + license.getName(), license2.getName() }; + changedTerms.add(termField4); + changedTerms.remove(termField); + changedTerms.remove(termField2); + + compareResults(datasetVersion, datasetVersion2, expectedAddedFiles, expectedRemovedFiles, + expectedChangedFileMetadata, expectedChangedVariableMetadata, expectedReplacedFiles, changedTerms); + } private FileMetadata createFileMetadata(long id, DatasetVersion datasetVersion, DataFile dataFile, String label) { @@ -250,6 +281,7 @@ private void compareResults(DatasetVersion datasetVersion, DatasetVersion datase assertEquals(changedTerms.size(), diff.getChangedTermsAccess().size()); for (int i = 0; i < changedTerms.size(); i++) { + System.out.println("Changed Terms: " + Arrays.toString(changedTerms.get(i))); String[] diffArray = diff.getChangedTermsAccess().get(i); assertEquals(changedTerms.get(i)[0], diffArray[0]); assertEquals(changedTerms.get(i)[1], diffArray[1]);