Skip to content

Commit e0d735e

Browse files
kopporDominikVoigt
andauthored
SLR Remove "last-search-date" (#9116)
Co-authored-by: Dominik Voigt <[email protected]>
1 parent 48f9270 commit e0d735e

File tree

6 files changed

+21
-86
lines changed

6 files changed

+21
-86
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2323
- We call backup files `.bak` and temporary writing files now `.sav`.
2424
- 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)
2525
- We changed the button label from "Return to JabRef" to "Return to library" to better indicate the purpose of the action.
26+
- We removed "last-search-date" from the SLR feature, because the last-search-date can be deducted from the git logs.
2627
- We reworked the External Changes Resolver dialog. [#9021](https://github.com/JabRef/jabref/pull/9021)
2728

2829

@@ -46,7 +47,6 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
4647

4748

4849

49-
5050
## [5.7] - 2022-08-05
5151

5252
### Added

src/main/java/org/jabref/logic/crawler/StudyRepository.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.nio.charset.UnsupportedCharsetException;
77
import java.nio.file.Files;
88
import java.nio.file.Path;
9-
import java.time.LocalDate;
109
import java.time.LocalDateTime;
1110
import java.time.temporal.ChronoUnit;
1211
import java.util.List;
@@ -119,7 +118,7 @@ public StudyRepository(Path pathToRepository,
119118
gitHandler.createCommitOnCurrentBranch("Setup/Update Repository Structure", false);
120119
gitHandler.checkoutBranch(SEARCH_BRANCH);
121120
// If study definition does not exist on this branch or was changed on work branch, copy it from work
122-
boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile).equalsBesideLastSearchDate(study));
121+
boolean studyDefinitionDoesNotExistOrChanged = !(Files.exists(studyDefinitionFile) && new StudyYamlParser().parseStudyYamlFile(studyDefinitionFile).equals(study));
123122
if (studyDefinitionDoesNotExistOrChanged) {
124123
new StudyYamlParser().writeStudyYamlFile(study, studyDefinitionFile);
125124
}
@@ -218,15 +217,13 @@ public Study getStudy() {
218217
*/
219218
public void persist(List<QueryResult> crawlResults) throws IOException, GitAPIException, SaveException {
220219
updateWorkAndSearchBranch();
221-
study.setLastSearchDate(LocalDate.now());
222220
persistStudy();
223221
gitHandler.createCommitOnCurrentBranch("Update search date", true);
224222
gitHandler.checkoutBranch(SEARCH_BRANCH);
225223
persistResults(crawlResults);
226-
study.setLastSearchDate(LocalDate.now());
227224
persistStudy();
228225
try {
229-
// First commit changes to search branch branch and update remote
226+
// First commit changes to search branch and update remote
230227
String commitMessage = "Conducted search: " + LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
231228
boolean newSearchResults = gitHandler.createCommitOnCurrentBranch(commitMessage, false);
232229
gitHandler.checkoutBranch(WORK_BRANCH);

src/main/java/org/jabref/model/study/Study.java

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.jabref.model.study;
22

3-
import java.time.LocalDate;
43
import java.util.List;
54
import java.util.Objects;
65

@@ -12,16 +11,17 @@
1211
*
1312
* This class defines all aspects of a scientific study relevant to the application. It is a proxy for the file based study definition.
1413
*/
15-
16-
@JsonPropertyOrder({"authors", "title", "last-search-date", "research-questions", "queries", "databases"})
14+
@JsonPropertyOrder({"authors", "title", "research-questions", "queries", "databases"})
1715
public class Study {
1816
private List<String> authors;
17+
1918
private String title;
20-
@JsonProperty("last-search-date")
21-
private LocalDate lastSearchDate;
19+
2220
@JsonProperty("research-questions")
2321
private List<String> researchQuestions;
22+
2423
private List<StudyQuery> queries;
24+
2525
private List<StudyDatabase> databases;
2626

2727
public Study(List<String> authors, String title, List<String> researchQuestions, List<StudyQuery> queryEntries, List<StudyDatabase> databases) {
@@ -54,14 +54,6 @@ public void setQueries(List<StudyQuery> queries) {
5454
this.queries = queries;
5555
}
5656

57-
public LocalDate getLastSearchDate() {
58-
return lastSearchDate;
59-
}
60-
61-
public void setLastSearchDate(LocalDate date) {
62-
lastSearchDate = date;
63-
}
64-
6557
public List<StudyDatabase> getDatabases() {
6658
return databases;
6759
}
@@ -91,65 +83,28 @@ public String toString() {
9183
return "Study{" +
9284
"authors=" + authors +
9385
", studyName='" + title + '\'' +
94-
", lastSearchDate=" + lastSearchDate +
9586
", researchQuestions=" + researchQuestions +
9687
", queries=" + queries +
9788
", libraries=" + databases +
9889
'}';
9990
}
10091

10192
@Override
102-
public boolean equals(Object o) {
103-
if (this == o) {
93+
public boolean equals(Object other) {
94+
if (this == other) {
10495
return true;
10596
}
106-
if (o == null || getClass() != o.getClass()) {
97+
if (other == null || getClass() != other.getClass()) {
10798
return false;
10899
}
109100

110-
Study study = (Study) o;
101+
Study otherStudy = (Study) other;
111102

112-
if (getAuthors() != null ? !getAuthors().equals(study.getAuthors()) : study.getAuthors() != null) {
113-
return false;
114-
}
115-
if (getTitle() != null ? !getTitle().equals(study.getTitle()) : study.getTitle() != null) {
116-
return false;
117-
}
118-
if (getLastSearchDate() != null ? !getLastSearchDate().equals(study.getLastSearchDate()) : study.getLastSearchDate() != null) {
119-
return false;
120-
}
121-
if (getResearchQuestions() != null ? !getResearchQuestions().equals(study.getResearchQuestions()) : study.getResearchQuestions() != null) {
122-
return false;
123-
}
124-
if (getQueries() != null ? !getQueries().equals(study.getQueries()) : study.getQueries() != null) {
125-
return false;
126-
}
127-
return getDatabases() != null ? getDatabases().equals(study.getDatabases()) : study.getDatabases() == null;
128-
}
129-
130-
public boolean equalsBesideLastSearchDate(Object o) {
131-
if (this == o) {
132-
return true;
133-
}
134-
if (o == null || getClass() != o.getClass()) {
135-
return false;
136-
}
137-
138-
Study study = (Study) o;
139-
140-
if (getAuthors() != null ? !getAuthors().equals(study.getAuthors()) : study.getAuthors() != null) {
141-
return false;
142-
}
143-
if (getTitle() != null ? !getTitle().equals(study.getTitle()) : study.getTitle() != null) {
144-
return false;
145-
}
146-
if (getResearchQuestions() != null ? !getResearchQuestions().equals(study.getResearchQuestions()) : study.getResearchQuestions() != null) {
147-
return false;
148-
}
149-
if (getQueries() != null ? !getQueries().equals(study.getQueries()) : study.getQueries() != null) {
150-
return false;
151-
}
152-
return getDatabases() != null ? getDatabases().equals(study.getDatabases()) : study.getDatabases() == null;
103+
return Objects.equals(authors, otherStudy.authors) &&
104+
Objects.equals(title, otherStudy.title) &&
105+
Objects.equals(researchQuestions, otherStudy.researchQuestions) &&
106+
Objects.equals(queries, otherStudy.queries) &&
107+
Objects.equals(databases, otherStudy.databases);
153108
}
154109

155110
@Override

src/test/java/org/jabref/logic/crawler/StudyRepositoryTest.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.net.URL;
55
import java.nio.file.Files;
66
import java.nio.file.Path;
7-
import java.time.LocalDate;
87
import java.util.ArrayList;
98
import java.util.HashSet;
109
import java.util.List;
@@ -41,6 +40,7 @@
4140

4241
import static org.jabref.logic.citationkeypattern.CitationKeyGenerator.DEFAULT_UNWANTED_CHARACTERS;
4342
import static org.junit.jupiter.api.Assertions.assertEquals;
43+
import static org.junit.jupiter.api.Assertions.assertFalse;
4444
import static org.junit.jupiter.api.Assertions.assertThrows;
4545
import static org.junit.jupiter.api.Assertions.assertTrue;
4646
import static org.mockito.Mockito.mock;
@@ -124,9 +124,9 @@ void repositoryStructureCorrectlyCreated() {
124124
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "Springer.bib")));
125125
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "Springer.bib")));
126126
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "Springer.bib")));
127-
assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "IEEEXplore.bib")));
128-
assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "IEEEXplore.bib")));
129-
assertTrue(Files.notExists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "IEEEXplore.bib")));
127+
assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "IEEEXplore.bib")));
128+
assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "IEEEXplore.bib")));
129+
assertFalse(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeSoftwareEngineering + " - Software Engineering", "IEEEXplore.bib")));
130130
}
131131

132132
/**
@@ -165,21 +165,10 @@ void mergedResultsPersistedCorrectly() throws Exception {
165165
assertEquals(getSpringerCloudComputingMockResults(), getTestStudyRepository().getQueryResultEntries("Cloud Computing").getEntries());
166166
}
167167

168-
@Test
169-
void setsLastSearchDatePersistedCorrectly() throws Exception {
170-
List<QueryResult> mockResults = getMockResults();
171-
172-
studyRepository.persist(mockResults);
173-
174-
assertEquals(LocalDate.now(), getTestStudyRepository().getStudy().getLastSearchDate());
175-
}
176-
177168
@Test
178169
void studyResultsPersistedCorrectly() throws Exception {
179170
List<QueryResult> mockResults = getMockResults();
180-
181171
studyRepository.persist(mockResults);
182-
183172
assertEquals(new HashSet<>(getNonDuplicateBibEntryResult().getEntries()), new HashSet<>(getTestStudyRepository().getStudyResultEntries().getEntries()));
184173
}
185174

src/test/java/org/jabref/logic/crawler/StudyYamlParserTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.net.URL;
44
import java.nio.file.Path;
5-
import java.time.LocalDate;
65
import java.util.List;
76

87
import org.jabref.logic.util.io.FileUtil;
@@ -35,22 +34,18 @@ void setupStudy() throws Exception {
3534
new StudyDatabase("Medline/PubMed", true), new StudyDatabase("IEEEXplore", false));
3635

3736
expectedStudy = new Study(authors, studyName, researchQuestions, queryEntries, libraryEntries);
38-
expectedStudy.setLastSearchDate(LocalDate.parse("2020-11-26"));
3937
}
4038

4139
@Test
4240
public void parseStudyFileSuccessfully() throws Exception {
4341
Study study = new StudyYamlParser().parseStudyYamlFile(testDirectory.resolve("study.yml"));
44-
4542
assertEquals(expectedStudy, study);
4643
}
4744

4845
@Test
4946
public void writeStudyFileSuccessfully() throws Exception {
5047
new StudyYamlParser().writeStudyYamlFile(expectedStudy, testDirectory.resolve("study.yml"));
51-
5248
Study study = new StudyYamlParser().parseStudyYamlFile(testDirectory.resolve("study.yml"));
53-
5449
assertEquals(expectedStudy, study);
5550
}
5651
}

src/test/resources/org/jabref/logic/crawler/study.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
authors:
22
- Jab Ref
33
title: TestStudyName
4-
last-search-date: 2020-11-26
54
research-questions:
65
- Question1
76
- Question2

0 commit comments

Comments
 (0)