diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ab6ce7ec3a..6df0aae6bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We call backup files `.bak` and temporary writing files now `.sav`. - JabRef keeps 10 older versions of a `.bib` file in the [user data dir](https://github.com/harawata/appdirs#supported-directories) (instead of a single `.sav` (now: `.bak`) file in the directory of the `.bib` file) - We changed the button label from "Return to JabRef" to "Return to library" to better indicate the purpose of the action. +- We removed "last-search-date" from the SLR feature, because the last-search-date can be deducted from the git logs. - We reworked the External Changes Resolver dialog. [#9021](https://github.com/JabRef/jabref/pull/9021) @@ -46,7 +47,6 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - ## [5.7] - 2022-08-05 ### Added diff --git a/src/main/java/org/jabref/logic/crawler/StudyRepository.java b/src/main/java/org/jabref/logic/crawler/StudyRepository.java index 0453642b9c8..19fdd7e4abe 100644 --- a/src/main/java/org/jabref/logic/crawler/StudyRepository.java +++ b/src/main/java/org/jabref/logic/crawler/StudyRepository.java @@ -6,7 +6,6 @@ import java.nio.charset.UnsupportedCharsetException; import java.nio.file.Files; import java.nio.file.Path; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.List; @@ -119,7 +118,7 @@ public StudyRepository(Path pathToRepository, gitHandler.createCommitOnCurrentBranch("Setup/Update Repository Structure", false); gitHandler.checkoutBranch(SEARCH_BRANCH); // If study definition does not exist on this branch or was changed on work branch, copy it from work - boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile).equalsBesideLastSearchDate(study)); + boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile).equals(study)); if (studyDefinitionDoesNotExistOrChanged) { new StudyYamlParser().writeStudyYamlFile(study, studyDefinitionFile); } @@ -218,15 +217,13 @@ public Study getStudy() { */ public void persist(List crawlResults) throws IOException, GitAPIException, SaveException { updateWorkAndSearchBranch(); - study.setLastSearchDate(LocalDate.now()); persistStudy(); gitHandler.createCommitOnCurrentBranch("Update search date", true); gitHandler.checkoutBranch(SEARCH_BRANCH); persistResults(crawlResults); - study.setLastSearchDate(LocalDate.now()); persistStudy(); try { - // First commit changes to search branch branch and update remote + // First commit changes to search branch and update remote String commitMessage = "Conducted search: " + LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS); boolean newSearchResults = gitHandler.createCommitOnCurrentBranch(commitMessage, false); gitHandler.checkoutBranch(WORK_BRANCH); diff --git a/src/main/java/org/jabref/model/study/Study.java b/src/main/java/org/jabref/model/study/Study.java index cc117f0160e..1c85a1d77c2 100644 --- a/src/main/java/org/jabref/model/study/Study.java +++ b/src/main/java/org/jabref/model/study/Study.java @@ -1,6 +1,5 @@ package org.jabref.model.study; -import java.time.LocalDate; import java.util.List; import java.util.Objects; @@ -12,16 +11,17 @@ * * This class defines all aspects of a scientific study relevant to the application. It is a proxy for the file based study definition. */ - -@JsonPropertyOrder({"authors", "title", "last-search-date", "research-questions", "queries", "databases"}) +@JsonPropertyOrder({"authors", "title", "research-questions", "queries", "databases"}) public class Study { private List authors; + private String title; - @JsonProperty("last-search-date") - private LocalDate lastSearchDate; + @JsonProperty("research-questions") private List researchQuestions; + private List queries; + private List databases; public Study(List authors, String title, List researchQuestions, List queryEntries, List databases) { @@ -54,14 +54,6 @@ public void setQueries(List queries) { this.queries = queries; } - public LocalDate getLastSearchDate() { - return lastSearchDate; - } - - public void setLastSearchDate(LocalDate date) { - lastSearchDate = date; - } - public List getDatabases() { return databases; } @@ -91,7 +83,6 @@ public String toString() { return "Study{" + "authors=" + authors + ", studyName='" + title + '\'' + - ", lastSearchDate=" + lastSearchDate + ", researchQuestions=" + researchQuestions + ", queries=" + queries + ", libraries=" + databases + @@ -99,57 +90,21 @@ public String toString() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (o == null || getClass() != o.getClass()) { + if (other == null || getClass() != other.getClass()) { return false; } - Study study = (Study) o; + Study otherStudy = (Study) other; - if (getAuthors() != null ? !getAuthors().equals(study.getAuthors()) : study.getAuthors() != null) { - return false; - } - if (getTitle() != null ? !getTitle().equals(study.getTitle()) : study.getTitle() != null) { - return false; - } - if (getLastSearchDate() != null ? !getLastSearchDate().equals(study.getLastSearchDate()) : study.getLastSearchDate() != null) { - return false; - } - if (getResearchQuestions() != null ? !getResearchQuestions().equals(study.getResearchQuestions()) : study.getResearchQuestions() != null) { - return false; - } - if (getQueries() != null ? !getQueries().equals(study.getQueries()) : study.getQueries() != null) { - return false; - } - return getDatabases() != null ? getDatabases().equals(study.getDatabases()) : study.getDatabases() == null; - } - - public boolean equalsBesideLastSearchDate(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Study study = (Study) o; - - if (getAuthors() != null ? !getAuthors().equals(study.getAuthors()) : study.getAuthors() != null) { - return false; - } - if (getTitle() != null ? !getTitle().equals(study.getTitle()) : study.getTitle() != null) { - return false; - } - if (getResearchQuestions() != null ? !getResearchQuestions().equals(study.getResearchQuestions()) : study.getResearchQuestions() != null) { - return false; - } - if (getQueries() != null ? !getQueries().equals(study.getQueries()) : study.getQueries() != null) { - return false; - } - return getDatabases() != null ? getDatabases().equals(study.getDatabases()) : study.getDatabases() == null; + return Objects.equals(authors, otherStudy.authors) && + Objects.equals(title, otherStudy.title) && + Objects.equals(researchQuestions, otherStudy.researchQuestions) && + Objects.equals(queries, otherStudy.queries) && + Objects.equals(databases, otherStudy.databases); } @Override diff --git a/src/test/java/org/jabref/logic/crawler/StudyRepositoryTest.java b/src/test/java/org/jabref/logic/crawler/StudyRepositoryTest.java index ec0911431d0..697b04958f6 100644 --- a/src/test/java/org/jabref/logic/crawler/StudyRepositoryTest.java +++ b/src/test/java/org/jabref/logic/crawler/StudyRepositoryTest.java @@ -4,7 +4,6 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.time.LocalDate; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -41,6 +40,7 @@ import static org.jabref.logic.citationkeypattern.CitationKeyGenerator.DEFAULT_UNWANTED_CHARACTERS; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; @@ -124,9 +124,9 @@ void repositoryStructureCorrectlyCreated() { assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "Springer.bib"))); assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "Springer.bib"))); assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "Springer.bib"))); - assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "IEEEXplore.bib"))); - assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "IEEEXplore.bib"))); - assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "IEEEXplore.bib"))); + assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "IEEEXplore.bib"))); + assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "IEEEXplore.bib"))); + assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "IEEEXplore.bib"))); } /** @@ -165,21 +165,10 @@ void mergedResultsPersistedCorrectly() throws Exception { assertEquals(getSpringerCloudComputingMockResults(), getTestStudyRepository().getQueryResultEntries("Cloud Computing").getEntries()); } - @Test - void setsLastSearchDatePersistedCorrectly() throws Exception { - List mockResults = getMockResults(); - - studyRepository.persist(mockResults); - - assertEquals(LocalDate.now(), getTestStudyRepository().getStudy().getLastSearchDate()); - } - @Test void studyResultsPersistedCorrectly() throws Exception { List mockResults = getMockResults(); - studyRepository.persist(mockResults); - assertEquals(new HashSet<>(getNonDuplicateBibEntryResult().getEntries()), new HashSet<>(getTestStudyRepository().getStudyResultEntries().getEntries())); } diff --git a/src/test/java/org/jabref/logic/crawler/StudyYamlParserTest.java b/src/test/java/org/jabref/logic/crawler/StudyYamlParserTest.java index f5ab98e9c81..1b169f7f00a 100644 --- a/src/test/java/org/jabref/logic/crawler/StudyYamlParserTest.java +++ b/src/test/java/org/jabref/logic/crawler/StudyYamlParserTest.java @@ -2,7 +2,6 @@ import java.net.URL; import java.nio.file.Path; -import java.time.LocalDate; import java.util.List; import org.jabref.logic.util.io.FileUtil; @@ -35,22 +34,18 @@ void setupStudy() throws Exception { new StudyDatabase("Medline/PubMed", true), new StudyDatabase("IEEEXplore", false)); expectedStudy = new Study(authors, studyName, researchQuestions, queryEntries, libraryEntries); - expectedStudy.setLastSearchDate(LocalDate.parse("2020-11-26")); } @Test public void parseStudyFileSuccessfully() throws Exception { Study study = new StudyYamlParser().parseStudyYamlFile(testDirectory.resolve("study.yml")); - assertEquals(expectedStudy, study); } @Test public void writeStudyFileSuccessfully() throws Exception { new StudyYamlParser().writeStudyYamlFile(expectedStudy, testDirectory.resolve("study.yml")); - Study study = new StudyYamlParser().parseStudyYamlFile(testDirectory.resolve("study.yml")); - assertEquals(expectedStudy, study); } } diff --git a/src/test/resources/org/jabref/logic/crawler/study.yml b/src/test/resources/org/jabref/logic/crawler/study.yml index 3b5b45bbb66..af2ed218297 100644 --- a/src/test/resources/org/jabref/logic/crawler/study.yml +++ b/src/test/resources/org/jabref/logic/crawler/study.yml @@ -1,7 +1,6 @@ authors: - Jab Ref title: TestStudyName -last-search-date: 2020-11-26 research-questions: - Question1 - Question2