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 all 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 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
15 changes: 7 additions & 8 deletions src/test/java/org/jabref/logic/crawler/CrawlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import org.jabref.logic.bibtex.FieldContentFormatterPreferences;
import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences;
Expand Down Expand Up @@ -52,14 +53,12 @@ public void testWhetherAllFilesAreCreated() throws Exception {
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum")));
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing")));

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

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(), hashCodeQuantum + " - Quantum", "result.bib")));
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", "result.bib")));
List<String> filesToAssert = List.of("ArXiv.bib", "Springer.bib", "result.bib", "Medline_PubMed.bib");
filesToAssert.forEach(
fileName -> {
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeQuantum + " - Quantum", fileName)));
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), hashCodeCloudComputing + " - Cloud Computing", fileName)));
});
assertTrue(Files.exists(Path.of(tempRepositoryDirectory.toString(), "studyResult.bib")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

import org.jabref.logic.bibtex.FieldContentFormatterPreferences;
import org.jabref.logic.exporter.SavePreferences;
Expand Down Expand Up @@ -60,9 +61,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(result.get(0).getName(), "Springer");
Assertions.assertEquals(result.get(1).getName(), "ArXiv");
Assertions.assertEquals(
List.of("Springer", "ArXiv", "Medline/PubMed"),
result.stream().map(SearchBasedFetcher::getName).collect(Collectors.toList())
);
}

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