Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve File Creation Issue With Medline/PubMed #8552

Merged
merged 7 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where someone could add a duplicate field in the customize entry type dialog. [#8194](https://github.com/JabRef/jabref/issues/8194)
- We fixed a typo in the library properties tab: "String constants". There, one can configure [BibTeX string constants](https://docs.jabref.org/advanced/strings).
- We fixed an issue when writing a non-UTF-8 encoded file: The header is written again. [#8417](https://github.com/JabRef/jabref/issues/8417)
- We fixed an issue where folder creation during systemic review failed due illegal fetcher name. [#8552](https://github.com/JabRef/jabref/pull/8552)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- We fixed an issue where folder creation during systemic review failed due illegal fetcher name. [#8552](https://github.com/JabRef/jabref/pull/8552)
- We fixed an issue where folder creation during systemic literature review failed due to an illegal fetcher name. [#8552](https://github.com/JabRef/jabref/pull/8552)


## [5.4] - 2021-12-20

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/logic/crawler/StudyRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jabref.logic.importer.SearchBasedFetcher;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.logic.util.io.FileNameCleaner;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
Expand Down Expand Up @@ -428,7 +429,7 @@ private void writeResultToFile(Path pathToFile, BibDatabase entries) throws IOEx
}

private Path getPathToFetcherResultFile(String query, String fetcherName) {
return Path.of(repositoryPath.toString(), trimNameAndAddID(query), fetcherName + ".bib");
return Path.of(repositoryPath.toString(), trimNameAndAddID(query), FileNameCleaner.cleanFileName(fetcherName) + ".bib");
}

private Path getPathToQueryResultFile(String query) {
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/jabref/logic/crawler/CrawlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void testWhetherAllFilesAreCreated() throws Exception {

assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "result.bib")));
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "result.bib")));

assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", "Medline_PubMed.bib")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense to convert this test to a parameterized unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need multiple "study.yml" files, so... yeah, let me know what you think would be better

assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "Medline_PubMed.bib")));
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), "studyResult.bib")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public void getActiveFetcherInstances() throws Exception {
StudyDatabaseToFetcherConverter converter = new StudyDatabaseToFetcherConverter(studyRepository.getActiveLibraryEntries(), importFormatPreferences);
List<SearchBasedFetcher> result = converter.getActiveFetchers();

Assertions.assertEquals(2, result.size());
Assertions.assertEquals(3, result.size());
Assertions.assertEquals(result.get(0).getName(), "Springer");
Assertions.assertEquals(result.get(1).getName(), "ArXiv");
Assertions.assertEquals(result.get(2).getName(), "Medline/PubMed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it is better you compare two collections directly, this makes it easier to spot differences in case of failure.
e.g. you have on the one hand:
expectedFetcherNames = LIst.of(.......)
actualFetcherNames = result.stream.map(Fetcher::getName).toCollection...
assertEquals(expectedFetcherNames,

}

private void copyTestStudyDefinitionFileIntoDirectory(Path destination) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ void setupStudy() throws Exception {
String studyName = "TestStudyName";
List<String> researchQuestions = List.of("Question1", "Question2");
List<StudyQuery> queryEntries = List.of(new StudyQuery("Quantum"), new StudyQuery("Cloud Computing"), new StudyQuery("\"Software Engineering\""));
List<StudyDatabase> libraryEntries = List.of(new StudyDatabase("Springer", true), new StudyDatabase("ArXiv", true), new StudyDatabase("IEEEXplore", false));
List<StudyDatabase> libraryEntries = List.of(new StudyDatabase("Springer", true), new StudyDatabase("ArXiv", true),
new StudyDatabase("Medline/PubMed", true), new StudyDatabase("IEEEXplore", false));

expectedStudy = new Study(authors, studyName, researchQuestions, queryEntries, libraryEntries);
expectedStudy.setLastSearchDate(LocalDate.parse("2020-11-26"));
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/org/jabref/logic/crawler/study.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ queries:
databases:
- name: Springer
- name: ArXiv
- name: Medline/PubMed
- name: IEEEXplore
enabled: false