From 9a25b8e33e001a51a93d9816702f0f24ae52db5f Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Wed, 1 Jul 2020 15:34:02 +0100 Subject: [PATCH 01/12] Add Collection of Comp Sci Bibliographies fetcher --- CHANGELOG.md | 1 + .../jabref/logic/importer/WebFetchers.java | 2 + ...fComputerScienceBibliographiesFetcher.java | 36 +++++++ ...OfComputerScienceBibliographiesParser.java | 100 ++++++++++++++++++ ...puterScienceBibliographiesFetcherTest.java | 67 ++++++++++++ ...mputerScienceBibliographiesParserTest.java | 46 ++++++++ ...er_science_bibliographies_empty_result.xml | 16 +++ ...cience_bibliographies_multiple_results.xml | 66 ++++++++++++ ...graphies_multiple_results_first_result.bib | 5 + ...raphies_multiple_results_second_result.bib | 5 + ...r_science_bibliographies_single_result.bib | 6 ++ ...r_science_bibliographies_single_result.xml | 45 ++++++++ 12 files changed, 395 insertions(+) create mode 100644 src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java create mode 100644 src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java create mode 100644 src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java create mode 100644 src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_empty_result.xml create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results.xml create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib create mode 100644 src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 175d11e6bf3..f58a9c60e49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added +- We added a new fetcher to enable users to search "Collection of Computer Science Bibliographies". [#6638](https://github.com/JabRef/jabref/issues/6638) - We improved responsiveness of general fields specification dialog window. [#6643](https://github.com/JabRef/jabref/issues/6604) - We added support for importing ris file and load DOI [#6530](https://github.com/JabRef/jabref/issues/6530) - We added the Library properties to a context menu on the library tabs [#6485](https://github.com/JabRef/jabref/issues/6485) diff --git a/src/main/java/org/jabref/logic/importer/WebFetchers.java b/src/main/java/org/jabref/logic/importer/WebFetchers.java index bc2efc8b90d..fe9b38f4c4b 100644 --- a/src/main/java/org/jabref/logic/importer/WebFetchers.java +++ b/src/main/java/org/jabref/logic/importer/WebFetchers.java @@ -12,6 +12,7 @@ import org.jabref.logic.importer.fetcher.ArXiv; import org.jabref.logic.importer.fetcher.AstrophysicsDataSystem; import org.jabref.logic.importer.fetcher.CiteSeer; +import org.jabref.logic.importer.fetcher.CollectionOfComputerScienceBibliographiesFetcher; import org.jabref.logic.importer.fetcher.CompositeSearchBasedFetcher; import org.jabref.logic.importer.fetcher.CrossRef; import org.jabref.logic.importer.fetcher.DBLPFetcher; @@ -101,6 +102,7 @@ public static SortedSet getSearchBasedFetchers(ImportFormatP set.add(new DOAJFetcher(importFormatPreferences)); set.add(new IEEE(importFormatPreferences)); set.add(new CompositeSearchBasedFetcher(set, 30)); + set.add(new CollectionOfComputerScienceBibliographiesFetcher()); return set; } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java new file mode 100644 index 00000000000..4bd4e94a9f0 --- /dev/null +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -0,0 +1,36 @@ +package org.jabref.logic.importer.fetcher; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + +import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.Parser; +import org.jabref.logic.importer.SearchBasedParserFetcher; +import org.jabref.logic.importer.fetcher.CollectionOfComputerScienceBibliographiesParser; + +import com.microsoft.applicationinsights.core.dependencies.http.client.utils.URIBuilder; + +public class CollectionOfComputerScienceBibliographiesFetcher implements SearchBasedParserFetcher { + private static final String BASIC_SEARCH_URL = "http://liinwww.ira.uka.de/bibliography/rss?"; + + @Override + public URL getURLForQuery(String query) throws URISyntaxException, MalformedURLException, FetcherException { + URIBuilder uriBuilder = new URIBuilder(BASIC_SEARCH_URL); + uriBuilder.addParameter("query", query); + uriBuilder.addParameter("sort", "score"); + URI uri = uriBuilder.build(); + return uri.toURL(); + } + + @Override + public Parser getParser() { + return new CollectionOfComputerScienceBibliographiesParser(); + } + + @Override + public String getName() { + return "Collection of Computer Science Bibliographies"; + } +} diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java new file mode 100644 index 00000000000..92a05c83fa8 --- /dev/null +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java @@ -0,0 +1,100 @@ +package org.jabref.logic.importer.fetcher; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.LinkedList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.jabref.logic.importer.ParseException; +import org.jabref.logic.importer.Parser; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +public class CollectionOfComputerScienceBibliographiesParser implements Parser { + @Override + public List parseEntries(InputStream inputStream) throws ParseException { + try { + Document document = buildDocumentFromInputStream(inputStream); + // uncomment to generate test case xml + // XMLUtil.printDocument(document); + + NodeList childNodes = document.getChildNodes(); + List itemElements = findItemElementsRecursively(childNodes); + List bibEntries = parseItemElements(itemElements); + + // uncomment to generate test case bib files + // System.out.println(bibEntries); + + return bibEntries; + } catch (ParserConfigurationException | SAXException | IOException exception) { + throw new ParseException(exception); + } + } + + private Document buildDocumentFromInputStream(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { + DocumentBuilder dbuild = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Reader reader = new InputStreamReader(inputStream, "UTF-8"); + InputSource is = new InputSource(reader); + return dbuild.parse(is); + } + + private List findItemElementsRecursively(NodeList nodeList) { + List itemNodes = new LinkedList(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node child = nodeList.item(i); + if (child.getNodeName().equals("item") + && child.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) child; + itemNodes.add(element); + } else { + NodeList childNodes = child.getChildNodes(); + List childItemNodes = findItemElementsRecursively(childNodes); + itemNodes.addAll(childItemNodes); + } + } + + return itemNodes; + } + + private List parseItemElements(List itemElements) { + List items = new LinkedList<>(); + for (Element itemElement : itemElements) { + BibEntry bibEntry = parseItemElement(itemElement); + items.add(bibEntry); + } + + return items; + } + + private BibEntry parseItemElement(Element item) { + BibEntry bibEntry = new BibEntry(); + setFieldFromTag(bibEntry, item, StandardField.TITLE, "dc:title"); + setFieldFromTag(bibEntry, item, StandardField.AUTHOR, "dc:creator"); + setFieldFromTag(bibEntry, item, StandardField.DATE, "dc:date"); + setFieldFromTag(bibEntry, item, StandardField.URL, "link"); + return bibEntry; + } + + private void setFieldFromTag(BibEntry bibEntry, Element item, StandardField field, String tagName) { + Node element = item.getElementsByTagName(tagName).item(0); + if (element == null) { + return; + } + + String value = element.getTextContent(); + bibEntry.setField(field, value); + } +} diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java new file mode 100644 index 00000000000..776145ada5f --- /dev/null +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java @@ -0,0 +1,67 @@ +package org.jabref.logic.importer.fetcher; + +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Collections; +import java.util.List; + +import org.jabref.logic.importer.FetcherException; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; +import org.jabref.testutils.category.FetcherTest; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@FetcherTest +class CollectionOfComputerScienceBibliographiesFetcherTest { + private CollectionOfComputerScienceBibliographiesFetcher fetcher; + private BibEntry bibEntry1; + private BibEntry bibEntry2; + + @BeforeEach + public void setUp() { + fetcher = new CollectionOfComputerScienceBibliographiesFetcher(); + + bibEntry1 = new BibEntry(); + bibEntry1.setField(StandardField.TITLE, "The relationship of code churn and architectural violations in the open source software JabRef"); + bibEntry1.setField(StandardField.AUTHOR, "Tobias Olsson, Morgan Ericsson, Anna Wingkvist"); + bibEntry1.setField(StandardField.DATE, "2017"); + bibEntry1.setField(StandardField.URL, "http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1"); + + bibEntry2 = new BibEntry(); + bibEntry2.setField(StandardField.TITLE, "Literaturverwaltungsprogramme im Überblick"); + bibEntry2.setField(StandardField.AUTHOR, "Michaele Adam, Jutta Musiat, Kathleen Hoffmann, Sandra Rahm, Matti Stöhr, Christina Wenzel"); + bibEntry2.setField(StandardField.DATE, "2018"); + bibEntry2.setField(StandardField.URL, "http://liinwww.ira.uka.de/searchbib/index?query=qrxmnfnthltrkcgnxdxtfdrhrxjnttxg&results=bibtex&mode=dup&rss=1"); + } + + @Test + public void getNameReturnsCorrectName() { + assertEquals("Collection of Computer Science Bibliographies", fetcher.getName()); + } + + @Test + public void getUrlForQueryReturnsCorrectUrl() throws MalformedURLException, URISyntaxException, FetcherException { + String query = "java jdk"; + URL url = fetcher.getURLForQuery(query); + assertEquals("http://liinwww.ira.uka.de/bibliography/rss?query=java+jdk&sort=score", url.toString()); + } + + @Test + public void performSearchReturnsMatchingMultipleEntries() throws FetcherException { + List searchResult = fetcher.performSearch("jabref"); + assertTrue(searchResult.contains(bibEntry1)); + assertTrue(searchResult.contains(bibEntry2)); + } + + @Test + public void performSearchReturnsEmptyListForEmptySearch() throws FetcherException { + List searchResult = fetcher.performSearch(""); + assertEquals(Collections.emptyList(), searchResult); + } +} diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java new file mode 100644 index 00000000000..647275b2f3d --- /dev/null +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java @@ -0,0 +1,46 @@ +package org.jabref.logic.importer.fetcher; + + +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.jabref.logic.bibtex.BibEntryAssert; +import org.jabref.logic.importer.fetcher.CollectionOfComputerScienceBibliographiesParser; +import org.jabref.model.entry.BibEntry; +import org.jabref.testutils.category.FetcherTest; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@FetcherTest +public class CollectionOfComputerScienceBibliographiesParserTest { + @Test + public void parseEntriesReturnsEmptyListIfXmlHasNoResults() throws Exception { + parseXmlAndCheckResults("collection_of_computer_science_bibliographies_empty_result.xml", Collections.emptyList()); + } + + @Test + public void parseEntriesReturnsOneBibEntryInListIfXmlHasOneResult() throws Exception { + parseXmlAndCheckResults("collection_of_computer_science_bibliographies_single_result.xml", Collections.singletonList("collection_of_computer_science_bibliographies_single_result.bib")); + } + + @Test + public void parseEntriesReturnsMultipleBibEntriesInListIfXmlHasMultipleResults() throws Exception { + parseXmlAndCheckResults("collection_of_computer_science_bibliographies_multiple_results.xml", Arrays.asList("collection_of_computer_science_bibliographies_multiple_results_first_result.bib", "collection_of_computer_science_bibliographies_multiple_results_second_result.bib")); + } + + private void parseXmlAndCheckResults(String xmlName, List resourceNames) throws Exception { + InputStream is = CollectionOfComputerScienceBibliographiesParserTest.class.getResourceAsStream(xmlName); + CollectionOfComputerScienceBibliographiesParser parser = new CollectionOfComputerScienceBibliographiesParser(); + List entries = parser.parseEntries(is); + assertNotNull(entries); + assertEquals(resourceNames.size(), entries.size()); + for (int i = 0; i < resourceNames.size(); i++) { + BibEntryAssert.assertEquals(GvkParserTest.class, resourceNames.get(i), entries.get(i)); + } + } +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_empty_result.xml b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_empty_result.xml new file mode 100644 index 00000000000..444d87fbd4a --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_empty_result.xml @@ -0,0 +1,16 @@ + + + + + + CCSB: "test string which returns no results" + http://liinwww.ira.uka.de/bibliography/#search + Search results in The Collection of Computer Science Bibliographies for query: "test string which returns no results" + en + The data is available for noncommercial or private use only, harvesting is prohibited (the data may be obtained using other means and not this RSS feed). + liinwwwa@ira.uka.de + Mon, 09 Mar 2020 03:14:28 +0100 + 5760 + + + \ No newline at end of file diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results.xml b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results.xml new file mode 100644 index 00000000000..70334112b7d --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results.xml @@ -0,0 +1,66 @@ + + + + + + CCSB: +"effective java" +"joshua bloch" +"java series" + http://liinwww.ira.uka.de/bibliography/#search + Search results in The Collection of Computer Science Bibliographies for query: +"effective java" +"joshua bloch" +"java series" + en + The data is available for noncommercial or private use only, harvesting is prohibited (the data may be obtained using other means and not this RSS feed). + liinwwwa@ira.uka.de + Mon, 09 Mar 2020 03:14:28 +0100 + 5760 + + + +

+ Author: Joshua Bloch; +
+ Title: Effective Java: Programming Language Guide; +
+ Year: 2001; +
+ Abstract available; +
+ 4 records for this title/author combination available. +

+
+ + Effective Java: Programming Language Guide + + 2001 + + Joshua Bloch + + [2001] Effective Java: Programming Language Guide (by: Joshua Bloch) + +
+ + + http://liinwww.ira.uka.de/searchbib/index?query=hpdtjrpbcpgllljdctmdkfnhqdcnrkkc&results=bibtex&mode=dup&rss=1 + + Joshua Bloch + + Effective Java + + +

+ Author: Joshua Bloch; +
+ Title: Effective Java; +
+ Year: 2001; +
+ URLs available (possible fulltext access); +
+ 2 records for this title/author combination available. +

+
+ + [2001] Effective Java (by: Joshua Bloch) + +
+ +
+
diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib new file mode 100644 index 00000000000..670d6e0a1f5 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib @@ -0,0 +1,5 @@ +@misc{ + author = {Joshua Bloch}, + date = {2001}, + title = {Effective Java: Programming Language Guide} + } diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib new file mode 100644 index 00000000000..b49e7020a07 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib @@ -0,0 +1,5 @@ +@misc{ + author = {Joshua Bloch}, + title = {Effective Java}, + url = {http://liinwww.ira.uka.de/searchbib/index?query=hpdtjrpbcpgllljdctmdkfnhqdcnrkkc&results=bibtex&mode=dup&rss=1} + } diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib new file mode 100644 index 00000000000..2b3e30ad5ef --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib @@ -0,0 +1,6 @@ +@misc{, + author = {Tobias Olsson, Morgan Ericsson, Anna Wingkvist}, + date = {2017}, + title = {The relationship of code churn and architectural violations in the open source software JabRef}, + url = {http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1} +} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml new file mode 100644 index 00000000000..a834382d7b2 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml @@ -0,0 +1,45 @@ + + + + + + CCSB: "The relationship of code churn and architectural violations in the open source software JabRef" + http://liinwww.ira.uka.de/bibliography/#search + Search results in The Collection of Computer Science Bibliographies for query: "The relationship of code churn and architectural violations in the open source software JabRef" + en + The data is available for noncommercial or private use only, harvesting is prohibited (the data may be obtained using other means and not this RSS feed). + liinwwwa@ira.uka.de + Mon, 09 Mar 2020 03:14:28 +0100 + 5760 + + + http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1 + + +

+ Author: Tobias Olsson, Morgan Ericsson, Anna Wingkvist; +
+ Title: The relationship of code churn and architectural violations in the open source software JabRef; +
+ Year: 2017; +
+ Abstract available; +
+ URLs available (possible fulltext access); +
+ 2 records for this title/author combination available. +

+
+ + The relationship of code churn and architectural violations in the open source software JabRef + + [2017] The relationship of code churn and architectural violations in the open source software JabRef (by: Tobias Olsson, Morgan Ericsson, Anna Wingkvist) + + 2017 + + Tobias Olsson, Morgan Ericsson, Anna Wingkvist + +
+ +
+
\ No newline at end of file From 70ac2e94127e9ced8a9792213879640ddc99a7d7 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Wed, 1 Jul 2020 16:08:41 +0100 Subject: [PATCH 02/12] Fix import --- .../CollectionOfComputerScienceBibliographiesFetcher.java | 1 - .../CollectionOfComputerScienceBibliographiesParser.java | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 4bd4e94a9f0..946a403fffe 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -8,7 +8,6 @@ import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; -import org.jabref.logic.importer.fetcher.CollectionOfComputerScienceBibliographiesParser; import com.microsoft.applicationinsights.core.dependencies.http.client.utils.URIBuilder; diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java index 92a05c83fa8..72ff59fa026 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java @@ -4,6 +4,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; @@ -46,13 +47,13 @@ public List parseEntries(InputStream inputStream) throws ParseExceptio private Document buildDocumentFromInputStream(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder dbuild = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Reader reader = new InputStreamReader(inputStream, "UTF-8"); + Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); InputSource is = new InputSource(reader); return dbuild.parse(is); } private List findItemElementsRecursively(NodeList nodeList) { - List itemNodes = new LinkedList(); + LinkedList itemNodes = new LinkedList(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeName().equals("item") From 05a800074c971013afe21f400ed6f72818ea869b Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Wed, 1 Jul 2020 16:24:39 +0100 Subject: [PATCH 03/12] Fix import and checkstyle --- .../CollectionOfComputerScienceBibliographiesFetcher.java | 2 +- .../CollectionOfComputerScienceBibliographiesParserTest.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 946a403fffe..ca79381a3fe 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -9,7 +9,7 @@ import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; -import com.microsoft.applicationinsights.core.dependencies.http.client.utils.URIBuilder; +import org.apache.http.client.utils.URIBuilder; public class CollectionOfComputerScienceBibliographiesFetcher implements SearchBasedParserFetcher { private static final String BASIC_SEARCH_URL = "http://liinwww.ira.uka.de/bibliography/rss?"; diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java index 647275b2f3d..85b2abf8d1d 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java @@ -1,13 +1,11 @@ package org.jabref.logic.importer.fetcher; - import java.io.InputStream; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.jabref.logic.bibtex.BibEntryAssert; -import org.jabref.logic.importer.fetcher.CollectionOfComputerScienceBibliographiesParser; import org.jabref.model.entry.BibEntry; import org.jabref.testutils.category.FetcherTest; From a8e3738677605f0a7e665786b2699d9713f8d6e4 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Wed, 1 Jul 2020 16:37:46 +0100 Subject: [PATCH 04/12] Fix test bib files --- ...ter_science_bibliographies_multiple_results_first_result.bib | 2 +- ...er_science_bibliographies_multiple_results_second_result.bib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib index 670d6e0a1f5..49fc4c555db 100644 --- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib @@ -1,4 +1,4 @@ -@misc{ +@misc{, author = {Joshua Bloch}, date = {2001}, title = {Effective Java: Programming Language Guide} diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib index b49e7020a07..ed9d6c3cb84 100644 --- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib +++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib @@ -1,4 +1,4 @@ -@misc{ +@misc{, author = {Joshua Bloch}, title = {Effective Java}, url = {http://liinwww.ira.uka.de/searchbib/index?query=hpdtjrpbcpgllljdctmdkfnhqdcnrkkc&results=bibtex&mode=dup&rss=1} From 66273f3c1904fa4d83622a0a41b7caa0aae482f2 Mon Sep 17 00:00:00 2001 From: daniel-price <64694785+daniel-price@users.noreply.github.com> Date: Wed, 1 Jul 2020 20:51:33 +0100 Subject: [PATCH 05/12] Update CHANGELOG.md Co-authored-by: Oliver Kopp --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f58a9c60e49..961e7ac05e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added -- We added a new fetcher to enable users to search "Collection of Computer Science Bibliographies". [#6638](https://github.com/JabRef/jabref/issues/6638) +- We added a new fetcher to enable users to search "[Collection of Computer Science Bibliographies](https://liinwww.ira.uka.de/bibliography/index.html)". [#6638](https://github.com/JabRef/jabref/issues/6638) - We improved responsiveness of general fields specification dialog window. [#6643](https://github.com/JabRef/jabref/issues/6604) - We added support for importing ris file and load DOI [#6530](https://github.com/JabRef/jabref/issues/6530) - We added the Library properties to a context menu on the library tabs [#6485](https://github.com/JabRef/jabref/issues/6485) From 2b7e223c6dbc86886ef4620c234c13160dd78b65 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Sun, 5 Jul 2020 22:17:02 +0100 Subject: [PATCH 06/12] Change to retrieve BibTex results --- .../jabref/logic/importer/WebFetchers.java | 3 +- ...fComputerScienceBibliographiesFetcher.java | 22 ++-- ...OfComputerScienceBibliographiesParser.java | 116 +++++++----------- ...puterScienceBibliographiesFetcherTest.java | 32 ++--- ...mputerScienceBibliographiesParserTest.java | 12 +- ...graphies_multiple_results_first_result.bib | 25 +++- ...raphies_multiple_results_second_result.bib | 15 ++- ...r_science_bibliographies_single_result.bib | 18 ++- ...r_science_bibliographies_single_result.xml | 54 ++------ 9 files changed, 138 insertions(+), 159 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/WebFetchers.java b/src/main/java/org/jabref/logic/importer/WebFetchers.java index fe9b38f4c4b..eb5f77b0298 100644 --- a/src/main/java/org/jabref/logic/importer/WebFetchers.java +++ b/src/main/java/org/jabref/logic/importer/WebFetchers.java @@ -7,6 +7,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.jabref.Globals; import org.jabref.logic.importer.fetcher.ACS; import org.jabref.logic.importer.fetcher.ApsFetcher; import org.jabref.logic.importer.fetcher.ArXiv; @@ -102,7 +103,7 @@ public static SortedSet getSearchBasedFetchers(ImportFormatP set.add(new DOAJFetcher(importFormatPreferences)); set.add(new IEEE(importFormatPreferences)); set.add(new CompositeSearchBasedFetcher(set, 30)); - set.add(new CollectionOfComputerScienceBibliographiesFetcher()); + set.add(new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences, Globals.getFileUpdateMonitor())); return set; } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index ca79381a3fe..2b4b70d1642 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -1,31 +1,39 @@ package org.jabref.logic.importer.fetcher; import java.net.MalformedURLException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; +import org.jabref.model.util.FileUpdateMonitor; import org.apache.http.client.utils.URIBuilder; public class CollectionOfComputerScienceBibliographiesFetcher implements SearchBasedParserFetcher { + private static final String BASIC_SEARCH_URL = "http://liinwww.ira.uka.de/bibliography/rss?"; + private final CollectionOfComputerScienceBibliographiesParser parser; + + public CollectionOfComputerScienceBibliographiesFetcher(ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileUpdateMonitor) { + this.parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences, fileUpdateMonitor); + } + @Override public URL getURLForQuery(String query) throws URISyntaxException, MalformedURLException, FetcherException { - URIBuilder uriBuilder = new URIBuilder(BASIC_SEARCH_URL); - uriBuilder.addParameter("query", query); - uriBuilder.addParameter("sort", "score"); - URI uri = uriBuilder.build(); - return uri.toURL(); + return new URIBuilder(BASIC_SEARCH_URL) + .addParameter("query", query) + .addParameter("sort", "score") + .build() + .toURL(); } @Override public Parser getParser() { - return new CollectionOfComputerScienceBibliographiesParser(); + return parser; } @Override diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java index 72ff59fa026..4e96cc76a71 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java @@ -2,100 +2,66 @@ import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; +import java.util.Scanner; +import java.util.regex.Pattern; +import java.util.stream.Collectors; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - +import org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.Parser; +import org.jabref.logic.importer.fileformat.BibtexParser; +import org.jabref.logic.net.URLDownload; import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.field.StandardField; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; +import org.jabref.model.util.FileUpdateMonitor; public class CollectionOfComputerScienceBibliographiesParser implements Parser { - @Override - public List parseEntries(InputStream inputStream) throws ParseException { - try { - Document document = buildDocumentFromInputStream(inputStream); - // uncomment to generate test case xml - // XMLUtil.printDocument(document); - NodeList childNodes = document.getChildNodes(); - List itemElements = findItemElementsRecursively(childNodes); - List bibEntries = parseItemElements(itemElements); + final static Pattern REGEX_FOR_LINKS = Pattern.compile("[\\s\\S]*?([\\s\\S]*?)<\\/link>[\\s\\S]*?<\\/item>"); + final static Pattern REGEX_FOR_BIBTEX = Pattern.compile("
([\\s\\S]*?)<\\/pre>");
 
-            // uncomment to generate test case bib files
-            // System.out.println(bibEntries);
+    final BibtexParser bibtexParser;
+    final HtmlToUnicodeFormatter htmlToUnicodeFormatter;
 
-            return bibEntries;
-        } catch (ParserConfigurationException | SAXException | IOException exception) {
-            throw new ParseException(exception);
-        }
-    }
-
-    private Document buildDocumentFromInputStream(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException {
-        DocumentBuilder dbuild = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
-        InputSource is = new InputSource(reader);
-        return dbuild.parse(is);
+    public CollectionOfComputerScienceBibliographiesParser(ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileUpdateMonitor) {
+        this.bibtexParser = new BibtexParser(importFormatPreferences, fileUpdateMonitor);
+        this.htmlToUnicodeFormatter = new HtmlToUnicodeFormatter();
     }
 
-    private List findItemElementsRecursively(NodeList nodeList) {
-        LinkedList itemNodes = new LinkedList();
-        for (int i = 0; i < nodeList.getLength(); i++) {
-            Node child = nodeList.item(i);
-            if (child.getNodeName().equals("item")
-                    && child.getNodeType() == Node.ELEMENT_NODE) {
-                Element element = (Element) child;
-                itemNodes.add(element);
-            } else {
-                NodeList childNodes = child.getChildNodes();
-                List childItemNodes = findItemElementsRecursively(childNodes);
-                itemNodes.addAll(childItemNodes);
-            }
+    @Override
+    public List parseEntries(InputStream inputStream) throws ParseException {
+        try {
+            List links = matchRegexFromInputStreamHtml(inputStream, REGEX_FOR_LINKS);
+            String bibtexDataString = parseBibtexStringsFromLinks(links)
+                    .stream()
+                    .collect(Collectors.joining());
+
+            return bibtexParser.parseEntries(bibtexDataString);
+        } catch (IOException e) {
+            throw new ParseException(e);
         }
-
-        return itemNodes;
     }
 
-    private List parseItemElements(List itemElements) {
-        List items = new LinkedList<>();
-        for (Element itemElement : itemElements) {
-            BibEntry bibEntry = parseItemElement(itemElement);
-            items.add(bibEntry);
+    private List matchRegexFromInputStreamHtml(InputStream inputStream, Pattern pattern) {
+        try (Scanner scanner = new Scanner(inputStream)) {
+            return scanner.findAll(pattern)
+                          .map(match -> htmlToUnicodeFormatter.format(match.group(1)))
+                          .collect(Collectors.toList());
         }
-
-        return items;
     }
 
-    private BibEntry parseItemElement(Element item) {
-        BibEntry bibEntry = new BibEntry();
-        setFieldFromTag(bibEntry, item, StandardField.TITLE, "dc:title");
-        setFieldFromTag(bibEntry, item, StandardField.AUTHOR, "dc:creator");
-        setFieldFromTag(bibEntry, item, StandardField.DATE, "dc:date");
-        setFieldFromTag(bibEntry, item, StandardField.URL, "link");
-        return bibEntry;
-    }
-
-    private void setFieldFromTag(BibEntry bibEntry, Element item, StandardField field, String tagName) {
-        Node element = item.getElementsByTagName(tagName).item(0);
-        if (element == null) {
-            return;
+    private List parseBibtexStringsFromLinks(List links) throws IOException {
+        List bibtexStringsFromAllLinks = new ArrayList();
+        for (String link : links) {
+            try (InputStream inputStream = new URLDownload(link).asInputStream()) {
+                List bibtexStringsFromLink = matchRegexFromInputStreamHtml(inputStream, REGEX_FOR_BIBTEX);
+                bibtexStringsFromAllLinks.addAll(bibtexStringsFromLink);
+            }
         }
 
-        String value = element.getTextContent();
-        bibEntry.setField(field, value);
+        return bibtexStringsFromAllLinks;
     }
 }
+
diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java
index 776145ada5f..ea2154e8b3e 100644
--- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java
+++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java
@@ -7,15 +7,20 @@
 import java.util.List;
 
 import org.jabref.logic.importer.FetcherException;
+import org.jabref.logic.importer.ImportFormatPreferences;
 import org.jabref.model.entry.BibEntry;
 import org.jabref.model.entry.field.StandardField;
+import org.jabref.model.util.DummyFileUpdateMonitor;
 import org.jabref.testutils.category.FetcherTest;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.mockito.Answers;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 @FetcherTest
 class CollectionOfComputerScienceBibliographiesFetcherTest {
@@ -25,19 +30,9 @@ class CollectionOfComputerScienceBibliographiesFetcherTest {
 
     @BeforeEach
     public void setUp() {
-        fetcher = new CollectionOfComputerScienceBibliographiesFetcher();
-
-        bibEntry1 = new BibEntry();
-        bibEntry1.setField(StandardField.TITLE, "The relationship of code churn and architectural violations in the open source software JabRef");
-        bibEntry1.setField(StandardField.AUTHOR, "Tobias Olsson, Morgan Ericsson, Anna Wingkvist");
-        bibEntry1.setField(StandardField.DATE, "2017");
-        bibEntry1.setField(StandardField.URL, "http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1");
-
-        bibEntry2 = new BibEntry();
-        bibEntry2.setField(StandardField.TITLE, "Literaturverwaltungsprogramme im Überblick");
-        bibEntry2.setField(StandardField.AUTHOR, "Michaele Adam, Jutta Musiat, Kathleen Hoffmann, Sandra Rahm, Matti Stöhr, Christina Wenzel");
-        bibEntry2.setField(StandardField.DATE, "2018");
-        bibEntry2.setField(StandardField.URL, "http://liinwww.ira.uka.de/searchbib/index?query=qrxmnfnthltrkcgnxdxtfdrhrxjnttxg&results=bibtex&mode=dup&rss=1");
+        ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS);
+        when(importFormatPreferences.getKeywordSeparator()).thenReturn(',');
+        fetcher = new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences, new DummyFileUpdateMonitor());
     }
 
     @Test
@@ -55,8 +50,13 @@ public void getUrlForQueryReturnsCorrectUrl() throws MalformedURLException, URIS
     @Test
     public void performSearchReturnsMatchingMultipleEntries() throws FetcherException {
         List searchResult = fetcher.performSearch("jabref");
-        assertTrue(searchResult.contains(bibEntry1));
-        assertTrue(searchResult.contains(bibEntry2));
+        BibEntry bibEntry = searchResult.get(0);
+        assertNotNull(bibEntry.getField(StandardField.ABSTRACT));
+        assertNotNull(bibEntry.getField(StandardField.AUTHOR));
+        assertNotNull(bibEntry.getField(StandardField.URL));
+        assertNotNull(bibEntry.getField(StandardField.YEAR));
+        assertNotNull(bibEntry.getField(StandardField.TITLE));
+        assertNotNull(bibEntry.getField(StandardField.TYPE));
     }
 
     @Test
diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java
index 85b2abf8d1d..ef12ed88ef6 100644
--- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java
+++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java
@@ -6,13 +6,18 @@
 import java.util.List;
 
 import org.jabref.logic.bibtex.BibEntryAssert;
+import org.jabref.logic.importer.ImportFormatPreferences;
 import org.jabref.model.entry.BibEntry;
+import org.jabref.model.util.DummyFileUpdateMonitor;
 import org.jabref.testutils.category.FetcherTest;
 
 import org.junit.jupiter.api.Test;
+import org.mockito.Answers;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 @FetcherTest
 public class CollectionOfComputerScienceBibliographiesParserTest {
@@ -22,7 +27,7 @@ public void parseEntriesReturnsEmptyListIfXmlHasNoResults() throws Exception {
     }
 
     @Test
-    public void parseEntriesReturnsOneBibEntryInListIfXmlHasOneResult() throws Exception {
+    public void parseEntriesReturnsOneBibEntryInListIfXmlHasSingleResult() throws Exception {
         parseXmlAndCheckResults("collection_of_computer_science_bibliographies_single_result.xml", Collections.singletonList("collection_of_computer_science_bibliographies_single_result.bib"));
     }
 
@@ -32,8 +37,11 @@ public void parseEntriesReturnsMultipleBibEntriesInListIfXmlHasMultipleResults()
     }
 
     private void parseXmlAndCheckResults(String xmlName, List resourceNames) throws Exception {
+        ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS);
+        when(importFormatPreferences.getKeywordSeparator()).thenReturn(',');
+
         InputStream is = CollectionOfComputerScienceBibliographiesParserTest.class.getResourceAsStream(xmlName);
-        CollectionOfComputerScienceBibliographiesParser parser = new CollectionOfComputerScienceBibliographiesParser();
+        CollectionOfComputerScienceBibliographiesParser parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences, new DummyFileUpdateMonitor());
         List entries = parser.parseEntries(is);
         assertNotNull(entries);
         assertEquals(resourceNames.size(), entries.size());
diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib
index 49fc4c555db..306e48e63af 100644
--- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib
+++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_first_result.bib
@@ -1,5 +1,20 @@
-@misc{,
-        author = {Joshua Bloch},
-        date = {2001},
-        title = {Effective Java: Programming Language Guide}
-        }
+@book{Bloch:2008:EJ,
+  acknowledgement = {Nelson H. F. Beebe, University of Utah, Department of Mathematics, 110 LCB, 155 S 1400 E RM 233, Salt Lake City, UT 84112-0090, USA, Tel: +1 801 581 5254, FAX: +1 801 581 4148, e-mail: \path|beebe@math.utah.edu|, \path|beebe@acm.org|, \path|beebe@computer.org| (Internet), URL: \path|http://www.math.utah.edu/~beebe/|},
+  address = {pub-AW:adr},
+  author = {Joshua Bloch},
+  bibdate = {Tue Jan 27 16:10:46 MST 2009},
+  bibsource = {http://www.math.utah.edu/pub/tex/bib/java2000.bib; z3950.loc.gov:7090/Voyager},
+  edition = {Second},
+  isbn = {0-321-35668-3 (paperback)},
+  isbn-13 = {978-0-321-35668-0 (paperback)},
+  lccn = {QA76.73.J38 B57 2008},
+  pages = {xxi + 346},
+  publisher = {Ad{\-d}i{\-s}on-Wes{\-l}ey},
+  remark = {Revised and updated for Java SE 6.},
+  series = {The Java series},
+  subject = {Java (Computer program language)},
+  tableofcontents = {Introduction \\ Creating and destroying objects \\ Methods common to all objects \\ Classes and interfaces \\ Generics \\ Enums and annotations \\ Methods \\ General programming \\ Exceptions \\ Concurrency \\ Serialization},
+  title = {Effective {Java}},
+  url = {http://www.loc.gov/catdir/toc/fy0805/2008926278.html},
+  year = {2008}
+}
diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib
index ed9d6c3cb84..ae85c92b44b 100644
--- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib
+++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_multiple_results_second_result.bib
@@ -1,5 +1,10 @@
-@misc{,
-		author = {Joshua Bloch},
-        title = {Effective Java},
-        url = {http://liinwww.ira.uka.de/searchbib/index?query=hpdtjrpbcpgllljdctmdkfnhqdcnrkkc&results=bibtex&mode=dup&rss=1}
-        }
+@book{Bloch2001,
+  added-at = {Tue Sep 16 09:14:19 2003},
+  added-by = {msteiner},
+  annote = {Good book on various rules \& conventions (e.g., what not to do and what instead) to use Java effectively},
+  author = {Joshua Bloch},
+  publisher = {Addison-Wesley},
+  series = {The Java Series},
+  title = {Effective Java},
+  year = {2001}
+}
diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib
index 2b3e30ad5ef..14134c7369f 100644
--- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib
+++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.bib
@@ -1,6 +1,14 @@
-@misc{,
-  author = {Tobias Olsson, Morgan Ericsson, Anna Wingkvist},
-  date = {2017},
-  title = {The relationship of code churn and architectural violations in the open source software JabRef},
-  url = {http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1}
+@inproceedings{conf/zeus/SimonDDK19,
+  author = {Martin K. Simon and Linus W. Dietz and Tobias Diez and Oliver Kopp},
+  bibdate = {2019-05-28},
+  bibsource = {DBLP, http://dblp.uni-trier.de/db/conf/zeus/zeus2019.html#SimonDDK19},
+  booktitle = {Proceedings of the 11th Central European Workshop on Services and their Composition, Bayreuth, Germany, February 14-15, 2019},
+  editor = {Stefan Kolb 0001 and Christian Sturm 0002},
+  pages = {47--54},
+  publisher = {CEUR-WS.org},
+  series = {CEUR Workshop Proceedings},
+  title = {Analyzing the Importance of JabRef Features from the User Perspective},
+  url = {http://ceur-ws.org/Vol-2339},
+  volume = {2339},
+  year = {2019}
 }
diff --git a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml
index a834382d7b2..b23cec5cc46 100644
--- a/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml
+++ b/src/test/resources/org/jabref/logic/importer/fetcher/collection_of_computer_science_bibliographies_single_result.xml
@@ -1,45 +1,13 @@
-
-
-    
+
+
+
     
-        
-        CCSB: "The relationship of code churn and architectural violations in the open source software JabRef"
-        http://liinwww.ira.uka.de/bibliography/#search
-        Search results in The Collection of Computer Science Bibliographies for query: "The relationship of code churn and architectural violations in the open source software JabRef"
-        en
-        The data is available for noncommercial or private use only, harvesting is prohibited (the data may be obtained using other means and not this RSS feed).
-        liinwwwa@ira.uka.de
-        Mon,  09  Mar 2020 03:14:28 +0100
-        5760
-        
-        
-            http://liinwww.ira.uka.de/searchbib/index?query=lgqcdpmrnlbbtgtqnxgpnddcrtxhcdxl&results=bibtex&mode=dup&rss=1
-            
-            
-                

- Author: Tobias Olsson, Morgan Ericsson, Anna Wingkvist; -
- Title: The relationship of code churn and architectural violations in the open source software JabRef; -
- Year: 2017; -
- Abstract available; -
- URLs available (possible fulltext access); -
- 2 records for this title/author combination available. -

-
- - The relationship of code churn and architectural violations in the open source software JabRef - - [2017] The relationship of code churn and architectural violations in the open source software JabRef (by: Tobias Olsson, Morgan Ericsson, Anna Wingkvist) - - 2017 - - Tobias Olsson, Morgan Ericsson, Anna Wingkvist - + CCSB: +"analyzing importance jabref features from user perspective"http://liinwww.ira.uka.de/bibliography/#searchSearch results in The Collection of Computer Science Bibliographies for query: +"analyzing importance jabref features from user perspective"enThe data is available for noncommercial or private use only, harvesting is prohibited (the data may be obtained using other means and not this RSS feed).liinwwwa@ira.uka.deMon, 09 Mar 2020 03:14:28 +01005760 +

Author: Martin K. Simon, Linus W. Dietz, Tobias Diez, Oliver Kopp;
Title: Analyzing the Importance of JabRef Features from the User Perspective;
Year: 2019;
URLs available (possible fulltext access);

+ 2019 + http://liinwww.ira.uka.de/searchbib/index?query=djtxnchklctrttlfbgjtcgxggdrlgphh&results=bibtex&mode=dup&rss=1 + Analyzing the Importance of JabRef Features from the User Perspective + Martin K. Simon, Linus W. Dietz, Tobias Diez, Oliver Kopp + [2019] Analyzing the Importance of JabRef Features from the User Perspective (by: Martin K. Simon, Linus W. Dietz, Tobias Diez, Oliver Kopp)
- -
-
\ No newline at end of file +
From bd26ed1132063482d295ac6c308ed3e040a05075 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Sun, 5 Jul 2020 22:47:39 +0100 Subject: [PATCH 07/12] Fix to dependency on Global --- src/main/java/org/jabref/logic/importer/WebFetchers.java | 3 +-- .../CollectionOfComputerScienceBibliographiesFetcher.java | 5 ++--- .../CollectionOfComputerScienceBibliographiesParser.java | 6 +++--- .../java/org/jabref/logic/importer/WebFetchersTest.java | 4 ++++ ...ollectionOfComputerScienceBibliographiesFetcherTest.java | 5 +---- ...CollectionOfComputerScienceBibliographiesParserTest.java | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/WebFetchers.java b/src/main/java/org/jabref/logic/importer/WebFetchers.java index eb5f77b0298..6fae6d91d33 100644 --- a/src/main/java/org/jabref/logic/importer/WebFetchers.java +++ b/src/main/java/org/jabref/logic/importer/WebFetchers.java @@ -7,7 +7,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import org.jabref.Globals; import org.jabref.logic.importer.fetcher.ACS; import org.jabref.logic.importer.fetcher.ApsFetcher; import org.jabref.logic.importer.fetcher.ArXiv; @@ -103,7 +102,7 @@ public static SortedSet getSearchBasedFetchers(ImportFormatP set.add(new DOAJFetcher(importFormatPreferences)); set.add(new IEEE(importFormatPreferences)); set.add(new CompositeSearchBasedFetcher(set, 30)); - set.add(new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences, Globals.getFileUpdateMonitor())); + set.add(new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences)); return set; } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 2b4b70d1642..19904d37c57 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -8,7 +8,6 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; -import org.jabref.model.util.FileUpdateMonitor; import org.apache.http.client.utils.URIBuilder; @@ -18,8 +17,8 @@ public class CollectionOfComputerScienceBibliographiesFetcher implements SearchB private final CollectionOfComputerScienceBibliographiesParser parser; - public CollectionOfComputerScienceBibliographiesFetcher(ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileUpdateMonitor) { - this.parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences, fileUpdateMonitor); + public CollectionOfComputerScienceBibliographiesFetcher(ImportFormatPreferences importFormatPreferences) { + this.parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences); } @Override diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java index 4e96cc76a71..0f7d3868587 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParser.java @@ -15,7 +15,7 @@ import org.jabref.logic.importer.fileformat.BibtexParser; import org.jabref.logic.net.URLDownload; import org.jabref.model.entry.BibEntry; -import org.jabref.model.util.FileUpdateMonitor; +import org.jabref.model.util.DummyFileUpdateMonitor; public class CollectionOfComputerScienceBibliographiesParser implements Parser { @@ -25,8 +25,8 @@ public class CollectionOfComputerScienceBibliographiesParser implements Parser { final BibtexParser bibtexParser; final HtmlToUnicodeFormatter htmlToUnicodeFormatter; - public CollectionOfComputerScienceBibliographiesParser(ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileUpdateMonitor) { - this.bibtexParser = new BibtexParser(importFormatPreferences, fileUpdateMonitor); + public CollectionOfComputerScienceBibliographiesParser(ImportFormatPreferences importFormatPreferences) { + this.bibtexParser = new BibtexParser(importFormatPreferences, new DummyFileUpdateMonitor()); this.htmlToUnicodeFormatter = new HtmlToUnicodeFormatter(); } diff --git a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java index f73df6dff24..003e89e1b9e 100644 --- a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java +++ b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java @@ -5,6 +5,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.jabref.logic.bibtex.FieldContentFormatterPreferences; import org.jabref.logic.importer.fetcher.ACMPortalFetcher; import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher; import org.jabref.logic.importer.fetcher.GrobidCitationFetcher; @@ -20,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; class WebFetchersTest { @@ -29,6 +31,8 @@ class WebFetchersTest { @BeforeEach void setUp() throws Exception { importFormatPreferences = mock(ImportFormatPreferences.class); + FieldContentFormatterPreferences fieldContentFormatterPreferences = mock(FieldContentFormatterPreferences.class); + when(importFormatPreferences.getFieldContentFormatterPreferences()).thenReturn(fieldContentFormatterPreferences); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java index ea2154e8b3e..796bb002aee 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java @@ -10,7 +10,6 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; -import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.BeforeEach; @@ -25,14 +24,12 @@ @FetcherTest class CollectionOfComputerScienceBibliographiesFetcherTest { private CollectionOfComputerScienceBibliographiesFetcher fetcher; - private BibEntry bibEntry1; - private BibEntry bibEntry2; @BeforeEach public void setUp() { ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.getKeywordSeparator()).thenReturn(','); - fetcher = new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences, new DummyFileUpdateMonitor()); + fetcher = new CollectionOfComputerScienceBibliographiesFetcher(importFormatPreferences); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java index ef12ed88ef6..23d69c1ae7b 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java @@ -8,7 +8,6 @@ import org.jabref.logic.bibtex.BibEntryAssert; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; -import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.Test; @@ -41,7 +40,7 @@ private void parseXmlAndCheckResults(String xmlName, List resourceNames) when(importFormatPreferences.getKeywordSeparator()).thenReturn(','); InputStream is = CollectionOfComputerScienceBibliographiesParserTest.class.getResourceAsStream(xmlName); - CollectionOfComputerScienceBibliographiesParser parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences, new DummyFileUpdateMonitor()); + CollectionOfComputerScienceBibliographiesParser parser = new CollectionOfComputerScienceBibliographiesParser(importFormatPreferences); List entries = parser.parseEntries(is); assertNotNull(entries); assertEquals(resourceNames.size(), entries.size()); From 7bb268545e430e8af9974ba4a8e665fc99dcc22d Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Tue, 7 Jul 2020 15:52:20 +0100 Subject: [PATCH 08/12] Make fetcher test more specific by checking each field explicitly --- ...puterScienceBibliographiesFetcherTest.java | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java index 796bb002aee..38b17ff6387 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java @@ -5,11 +5,15 @@ import java.net.URL; import java.util.Collections; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.field.UnknownField; +import org.jabref.model.entry.types.StandardEntryType; import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.BeforeEach; @@ -17,7 +21,7 @@ import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -47,13 +51,63 @@ public void getUrlForQueryReturnsCorrectUrl() throws MalformedURLException, URIS @Test public void performSearchReturnsMatchingMultipleEntries() throws FetcherException { List searchResult = fetcher.performSearch("jabref"); - BibEntry bibEntry = searchResult.get(0); - assertNotNull(bibEntry.getField(StandardField.ABSTRACT)); - assertNotNull(bibEntry.getField(StandardField.AUTHOR)); - assertNotNull(bibEntry.getField(StandardField.URL)); - assertNotNull(bibEntry.getField(StandardField.YEAR)); - assertNotNull(bibEntry.getField(StandardField.TITLE)); - assertNotNull(bibEntry.getField(StandardField.TYPE)); + + BibEntry firstBibEntry = new BibEntry(StandardEntryType.InProceedings) + .withCiteKey("conf/ecsa/OlssonEW17") + .withField(StandardField.AUTHOR, "Tobias Olsson and Morgan Ericsson and Anna Wingkvist") + .withField(StandardField.EDITOR, "Rog{\\~A}{\\copyright}rio de Lemos") + .withField(StandardField.ISBN, "978-1-4503-5217-8") + .withField(StandardField.PAGES, "152--158") + .withField(StandardField.PUBLISHER, "ACM") + .withField(StandardField.TITLE, "The relationship of code churn and architectural violations in the open source software JabRef") + .withField(StandardField.URL, "http://dl.acm.org/citation.cfm?id=3129790") + .withField(StandardField.YEAR, "2017") + .withField(StandardField.BOOKTITLE, "11th European Conference on Software Architecture, ECSA 2017, Companion Proceedings, Canterbury, United Kingdom, September 11-15, 2017") + .withField(new UnknownField("bibsource"), "DBLP, http://dblp.uni-trier.de/https://doi.org/10.1145/3129790.3129810; DBLP, http://dblp.uni-trier.de/db/conf/ecsa/ecsa2017c.html#OlssonEW17") + .withField(new UnknownField("bibdate"), "2018-11-06"); + + BibEntry secondBibEntry = new BibEntry(StandardEntryType.Article) + .withCiteKey("oai:DiVA.org:lnu-68408") + .withField(new UnknownField("identifier"), "urn:isbn:978-1-4503-5217-8; doi:10.1145/3129790.3129810; ISI:000426556400034") + .withField(new UnknownField("subject"), "Software Architecture; Code Churn; Open Source; Architecrual Erosion; Technical Debt; Software Engineering; Programvaruteknik") + .withField(new UnknownField("relation"), "ACM International Conference Proceeding Series; ECSA '17~Proceedings of the 11th European Conference on Software Architecture : Companion Proceedings, p. 152-158") + .withField(StandardField.ABSTRACT, "The open source application JabRef has existed since\r\n" + + "\t\t 2003. In 2015, the developers decided to make an\r\n" + + "\t\t architectural refactoring as continued development was\r\n" + + "\t\t deemed too demanding. The developers also introduced\r\n" + + "\t\t Static Architecture Conformance Checking (SACC) to\r\n" + + "\t\t prevent violations to the intended architecture.\r\n" + + "\t\t Measurements mined from source code repositories such\r\n" + + "\t\t as code churn and code ownership has been linked to\r\n" + + "\t\t several problems, for example fault proneness, security\r\n" + + "\t\t vulnerabilities, code smells, and degraded\r\n" + + "\t\t maintainability. The root cause of such problems can be\r\n" + + "\t\t architectural. To determine the impact of the\r\n" + + "\t\t refactoring of JabRef, we measure the code churn and\r\n" + + "\t\t code ownership before and after the refactoring and\r\n" + + "\t\t find that large files with violations had a\r\n" + + "\t\t significantly higher code churn than large files\r\n" + + "\t\t without violations before the refactoring. After the\r\n" + + "\t\t refactoring, the files that had violations show a more\r\n" + + "\t\t normal code churn. We find no such effect on code\r\n" + + "\t\t ownership. We conclude that files that contain\r\n" + + "\t\t violations detectable by SACC methods are connected to\r\n" + + "\t\t higher than normal code churn.") + .withField(StandardField.TYPE, "info:eu-repo/semantics/conferenceObject") + .withField(new UnknownField("description"), "Information and Software Qualtiy") + .withField(StandardField.PAGES, "152--158") + .withField(new UnknownField("bibsource"), "OAI-PMH server at www.diva-portal.org") + .withField(new UnknownField("rights"), "info:eu-repo/semantics/openAccess") + .withField(StandardField.URL, "http://urn.kb.se/resolve?urn=urn:nbn:se:lnu:diva-68408") + .withField(new UnknownField("oai"), "oai:DiVA.org:lnu-68408") + .withField(StandardField.TITLE, "The relationship of code churn and architectural violations in the open source software JabRef") + .withField(StandardField.PUBLISHER, "Linn{\\'e}universitetet, Institutionen f{\\\"o}r datavetenskap (DV); Linn{\\'e}universitetet, Institutionen f{\\\"o}r datavetenskap (DV); Linn{\\'e}universitetet, Institutionen f{\\\"o}r datavetenskap (DV); New York, NY, USA") + .withField(StandardField.LANGUAGE, "eng") + .withField(StandardField.AUTHOR, "Tobias Olsson and Morgan Ericsson and Anna Wingkvist") + .withField(StandardField.YEAR, "2017"); + + assertTrue(searchResult.contains(firstBibEntry)); + assertTrue(searchResult.contains(secondBibEntry)); } @Test From 43b94d9af6fddbeb63e1023d793f46e24383f125 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Tue, 7 Jul 2020 15:57:27 +0100 Subject: [PATCH 09/12] Fix to imports --- .../CollectionOfComputerScienceBibliographiesFetcherTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java index 38b17ff6387..48ecbdc5b3d 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java @@ -5,8 +5,6 @@ import java.net.URL; import java.util.Collections; import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; From 2b2646be26e2228636e356e315b603a59fa35e65 Mon Sep 17 00:00:00 2001 From: Daniel Price <64694785+daniel-price@users.noreply.github.com> Date: Tue, 7 Jul 2020 16:18:34 +0100 Subject: [PATCH 10/12] Update src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java Co-authored-by: Oliver Kopp --- .../CollectionOfComputerScienceBibliographiesParserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java index 23d69c1ae7b..6ea568364f7 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesParserTest.java @@ -45,7 +45,7 @@ private void parseXmlAndCheckResults(String xmlName, List resourceNames) assertNotNull(entries); assertEquals(resourceNames.size(), entries.size()); for (int i = 0; i < resourceNames.size(); i++) { - BibEntryAssert.assertEquals(GvkParserTest.class, resourceNames.get(i), entries.get(i)); + BibEntryAssert.assertEquals(CollectionOfComputerScienceBibliographiesParserTest.class, resourceNames.get(i), entries.get(i)); } } } From b9ea9b05a01efbdb4e21ba634c2be38d81d45f98 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Tue, 7 Jul 2020 18:58:02 +0100 Subject: [PATCH 11/12] Add three formatters to fix new lines in abstract and digits in editors --- .../bibtexfields/RemoveDigitsFormatter.java | 39 ++++++++++++++++ .../RemoveRedundantSpacesFormatter.java | 42 +++++++++++++++++ .../bibtexfields/RemoveTabsFormatter.java | 42 +++++++++++++++++ ...fComputerScienceBibliographiesFetcher.java | 15 +++++++ .../RemoveDigitsFormatterTest.java | 31 +++++++++++++ .../RemoveRedundantSpacesFormatterTest.java | 36 +++++++++++++++ .../bibtexfields/RemoveTabsFormatterTest.java | 32 +++++++++++++ ...puterScienceBibliographiesFetcherTest.java | 45 ++++++++++--------- 8 files changed, 260 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java create mode 100644 src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java create mode 100644 src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java create mode 100644 src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatterTest.java create mode 100644 src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatterTest.java create mode 100644 src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java new file mode 100644 index 00000000000..3f27e81aa8c --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatter.java @@ -0,0 +1,39 @@ +package org.jabref.logic.formatter.bibtexfields; + +import java.util.Objects; +import java.util.regex.Pattern; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; + +public class RemoveDigitsFormatter extends Formatter { + + private static final Pattern DIGITS = Pattern.compile("[ ]\\d+"); + + @Override + public String getName() { + return Localization.lang("Remove digits"); + } + + @Override + public String getKey() { + return "remove_digits"; + } + + @Override + public String format(String value) { + Objects.requireNonNull(value); + + return DIGITS.matcher(value).replaceAll(""); + } + + @Override + public String getDescription() { + return Localization.lang("Removes digits."); + } + + @Override + public String getExampleInput() { + return "In 012 CDMA"; + } +} diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java new file mode 100644 index 00000000000..27e911d797e --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java @@ -0,0 +1,42 @@ +package org.jabref.logic.formatter.bibtexfields; + +import java.util.Objects; +import java.util.regex.Pattern; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; + +/** + * Finds any occurrence of consecutive spaces and replaces it with a single space + */ +public class RemoveRedundantSpacesFormatter extends Formatter { + + private static final Pattern MULTIPLE_SPACES = Pattern.compile(" {2,}"); + + @Override + public String getName() { + return Localization.lang("Remove redundant spaces"); + } + + @Override + public String getKey() { + return "remove_redundant_spaces"; + } + + @Override + public String format(String value) { + Objects.requireNonNull(value); + + return MULTIPLE_SPACES.matcher(value).replaceAll(" "); + } + + @Override + public String getDescription() { + return Localization.lang("Replaces consecutive spaces with a single space in the field content."); + } + + @Override + public String getExampleInput() { + return "In CDMA"; + } +} diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java new file mode 100644 index 00000000000..12882f37d84 --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java @@ -0,0 +1,42 @@ +package org.jabref.logic.formatter.bibtexfields; + +import java.util.Objects; +import java.util.regex.Pattern; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; + +/** + * Replaces any tab with a space + */ +public class RemoveTabsFormatter extends Formatter { + + private static final Pattern TAB = Pattern.compile("\t+"); + + @Override + public String getName() { + return Localization.lang("Remove tabs"); + } + + @Override + public String getKey() { + return "remove_tabs"; + } + + @Override + public String format(String value) { + Objects.requireNonNull(value); + + return TAB.matcher(value).replaceAll(" "); + } + + @Override + public String getDescription() { + return Localization.lang("Removes tabs in the field content."); + } + + @Override + public String getExampleInput() { + return "In \t\t CDMA"; + } +} diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 19904d37c57..1bae4d42df8 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -4,10 +4,17 @@ import java.net.URISyntaxException; import java.net.URL; +import org.jabref.logic.formatter.bibtexfields.RemoveDigitsFormatter; +import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter; +import org.jabref.logic.formatter.bibtexfields.RemoveRedundantSpacesFormatter; +import org.jabref.logic.formatter.bibtexfields.RemoveTabsFormatter; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; +import org.jabref.model.cleanup.FieldFormatterCleanup; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; import org.apache.http.client.utils.URIBuilder; @@ -39,4 +46,12 @@ public Parser getParser() { public String getName() { return "Collection of Computer Science Bibliographies"; } + + @Override + public void doPostCleanup(BibEntry entry) { + new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveNewlinesFormatter()).cleanup(entry); + new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveTabsFormatter()).cleanup(entry); + new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveRedundantSpacesFormatter()).cleanup(entry); + new FieldFormatterCleanup(StandardField.EDITOR, new RemoveDigitsFormatter()).cleanup(entry); + } } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatterTest.java new file mode 100644 index 00000000000..4eed8b2c31d --- /dev/null +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveDigitsFormatterTest.java @@ -0,0 +1,31 @@ +package org.jabref.logic.formatter.bibtexfields; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RemoveDigitsFormatterTest { + + private RemoveDigitsFormatter formatter; + + @BeforeEach + public void setUp() { + formatter = new RemoveDigitsFormatter(); + } + + @Test + public void doNothingIfSingleSpace() { + assertEquals("one digit", formatter.format("one 1 digit")); + } + + @Test + public void doNothingIfNoSpace() { + assertEquals("two digits", formatter.format("two 01 digits")); + } + + @Test + public void removeAllButOneSpacesIfTwo() { + assertEquals("no digits", formatter.format("no digits")); + } +} diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatterTest.java new file mode 100644 index 00000000000..b4b4d1e2461 --- /dev/null +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatterTest.java @@ -0,0 +1,36 @@ +package org.jabref.logic.formatter.bibtexfields; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RemoveRedundantSpacesFormatterTest { + + private RemoveRedundantSpacesFormatter formatter; + + @BeforeEach + public void setUp() { + formatter = new RemoveRedundantSpacesFormatter(); + } + + @Test + public void doNothingIfSingleSpace() { + assertEquals("single space", formatter.format("single space")); + } + + @Test + public void doNothingIfNoSpace() { + assertEquals("nospace", formatter.format("nospace")); + } + + @Test + public void removeAllButOneSpacesIfTwo() { + assertEquals("two spaces", formatter.format("two spaces")); + } + + @Test + public void removeAllButOneSpacesIfThree() { + assertEquals("three spaces", formatter.format("three spaces")); + } +} diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java new file mode 100644 index 00000000000..fa76039884a --- /dev/null +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java @@ -0,0 +1,32 @@ + +package org.jabref.logic.formatter.bibtexfields; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RemoveTabsFormatterTest { + + private RemoveTabsFormatter formatter; + + @BeforeEach + public void setUp() { + formatter = new RemoveTabsFormatter(); + } + + @Test + public void removeSingleTab() { + assertEquals("single tab", formatter.format("single\ttab")); + } + + @Test + public void removeMultipleTabs() { + assertEquals("multiple tabs", formatter.format("multiple\t\ttabs")); + } + + @Test + public void doNothingIfNoTab() { + assertEquals("notab", formatter.format("notab")); + } +} diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java index 48ecbdc5b3d..3fa4637dff7 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcherTest.java @@ -69,28 +69,28 @@ public void performSearchReturnsMatchingMultipleEntries() throws FetcherExceptio .withField(new UnknownField("identifier"), "urn:isbn:978-1-4503-5217-8; doi:10.1145/3129790.3129810; ISI:000426556400034") .withField(new UnknownField("subject"), "Software Architecture; Code Churn; Open Source; Architecrual Erosion; Technical Debt; Software Engineering; Programvaruteknik") .withField(new UnknownField("relation"), "ACM International Conference Proceeding Series; ECSA '17~Proceedings of the 11th European Conference on Software Architecture : Companion Proceedings, p. 152-158") - .withField(StandardField.ABSTRACT, "The open source application JabRef has existed since\r\n" + - "\t\t 2003. In 2015, the developers decided to make an\r\n" + - "\t\t architectural refactoring as continued development was\r\n" + - "\t\t deemed too demanding. The developers also introduced\r\n" + - "\t\t Static Architecture Conformance Checking (SACC) to\r\n" + - "\t\t prevent violations to the intended architecture.\r\n" + - "\t\t Measurements mined from source code repositories such\r\n" + - "\t\t as code churn and code ownership has been linked to\r\n" + - "\t\t several problems, for example fault proneness, security\r\n" + - "\t\t vulnerabilities, code smells, and degraded\r\n" + - "\t\t maintainability. The root cause of such problems can be\r\n" + - "\t\t architectural. To determine the impact of the\r\n" + - "\t\t refactoring of JabRef, we measure the code churn and\r\n" + - "\t\t code ownership before and after the refactoring and\r\n" + - "\t\t find that large files with violations had a\r\n" + - "\t\t significantly higher code churn than large files\r\n" + - "\t\t without violations before the refactoring. After the\r\n" + - "\t\t refactoring, the files that had violations show a more\r\n" + - "\t\t normal code churn. We find no such effect on code\r\n" + - "\t\t ownership. We conclude that files that contain\r\n" + - "\t\t violations detectable by SACC methods are connected to\r\n" + - "\t\t higher than normal code churn.") + .withField(StandardField.ABSTRACT, "The open source application JabRef has existed since" + + " 2003. In 2015, the developers decided to make an" + + " architectural refactoring as continued development was" + + " deemed too demanding. The developers also introduced" + + " Static Architecture Conformance Checking (SACC) to" + + " prevent violations to the intended architecture." + + " Measurements mined from source code repositories such" + + " as code churn and code ownership has been linked to" + + " several problems, for example fault proneness, security" + + " vulnerabilities, code smells, and degraded" + + " maintainability. The root cause of such problems can be" + + " architectural. To determine the impact of the" + + " refactoring of JabRef, we measure the code churn and" + + " code ownership before and after the refactoring and" + + " find that large files with violations had a" + + " significantly higher code churn than large files" + + " without violations before the refactoring. After the" + + " refactoring, the files that had violations show a more" + + " normal code churn. We find no such effect on code" + + " ownership. We conclude that files that contain" + + " violations detectable by SACC methods are connected to" + + " higher than normal code churn.") .withField(StandardField.TYPE, "info:eu-repo/semantics/conferenceObject") .withField(new UnknownField("description"), "Information and Software Qualtiy") .withField(StandardField.PAGES, "152--158") @@ -104,6 +104,7 @@ public void performSearchReturnsMatchingMultipleEntries() throws FetcherExceptio .withField(StandardField.AUTHOR, "Tobias Olsson and Morgan Ericsson and Anna Wingkvist") .withField(StandardField.YEAR, "2017"); + // Checking entries in the set as the query is generic and returns a changing result set assertTrue(searchResult.contains(firstBibEntry)); assertTrue(searchResult.contains(secondBibEntry)); } From 837502904b181231538df8dece01ac3393363e06 Mon Sep 17 00:00:00 2001 From: Dan <64694785+daniel-price@users.noreply.github.com> Date: Tue, 7 Jul 2020 20:51:53 +0100 Subject: [PATCH 12/12] Add localisation strings and renamed formatter --- .../bibtexfields/RemoveRedundantSpacesFormatter.java | 1 - ...eTabsFormatter.java => ReplaceTabsBySpaceFormater.java} | 7 +++---- .../CollectionOfComputerScienceBibliographiesFetcher.java | 4 ++-- src/main/resources/l10n/JabRef_en.properties | 7 +++++++ ...matterTest.java => ReplaceTabsBySpaceFormaterTest.java} | 6 +++--- 5 files changed, 15 insertions(+), 10 deletions(-) rename src/main/java/org/jabref/logic/formatter/bibtexfields/{RemoveTabsFormatter.java => ReplaceTabsBySpaceFormater.java} (78%) rename src/test/java/org/jabref/logic/formatter/bibtexfields/{RemoveTabsFormatterTest.java => ReplaceTabsBySpaceFormaterTest.java} (80%) diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java index 27e911d797e..0a44f6f09fe 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveRedundantSpacesFormatter.java @@ -26,7 +26,6 @@ public String getKey() { @Override public String format(String value) { Objects.requireNonNull(value); - return MULTIPLE_SPACES.matcher(value).replaceAll(" "); } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java similarity index 78% rename from src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java rename to src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java index 12882f37d84..f6f5bd5eaa3 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormater.java @@ -9,13 +9,13 @@ /** * Replaces any tab with a space */ -public class RemoveTabsFormatter extends Formatter { +public class ReplaceTabsBySpaceFormater extends Formatter { private static final Pattern TAB = Pattern.compile("\t+"); @Override public String getName() { - return Localization.lang("Remove tabs"); + return Localization.lang("Replace tabs with space"); } @Override @@ -26,13 +26,12 @@ public String getKey() { @Override public String format(String value) { Objects.requireNonNull(value); - return TAB.matcher(value).replaceAll(" "); } @Override public String getDescription() { - return Localization.lang("Removes tabs in the field content."); + return Localization.lang("Replace tabs with space in the field content."); } @Override diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java index 1bae4d42df8..26cbaa9d9f8 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CollectionOfComputerScienceBibliographiesFetcher.java @@ -7,7 +7,7 @@ import org.jabref.logic.formatter.bibtexfields.RemoveDigitsFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter; import org.jabref.logic.formatter.bibtexfields.RemoveRedundantSpacesFormatter; -import org.jabref.logic.formatter.bibtexfields.RemoveTabsFormatter; +import org.jabref.logic.formatter.bibtexfields.ReplaceTabsBySpaceFormater; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; @@ -50,7 +50,7 @@ public String getName() { @Override public void doPostCleanup(BibEntry entry) { new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveNewlinesFormatter()).cleanup(entry); - new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveTabsFormatter()).cleanup(entry); + new FieldFormatterCleanup(StandardField.ABSTRACT, new ReplaceTabsBySpaceFormater()).cleanup(entry); new FieldFormatterCleanup(StandardField.ABSTRACT, new RemoveRedundantSpacesFormatter()).cleanup(entry); new FieldFormatterCleanup(StandardField.EDITOR, new RemoveDigitsFormatter()).cleanup(entry); } diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 30410b5a870..972be75914c 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2255,3 +2255,10 @@ Reveal\ in\ file\ explorer=Reveal in file explorer Reset=Reset Reset\ entry\ types\ and\ fields\ to\ defaults=Reset entry types and fields to defaults This\ will\ reset\ all\ entry\ types\ to\ their\ default\ values\ and\ remove\ all\ custom\ entry\ types=This will reset all entry types to their default values and remove all custom entry types + +Replace\ tabs\ with\ space=Replace tabs with space +Replace\ tabs\ with\ space\ in\ the\ field\ content.=Replace tabs with space in the field content. +Remove\ redundant\ spaces=Remove redundant spaces +Replaces\ consecutive\ spaces\ with\ a\ single\ space\ in\ the\ field\ content.=Replaces consecutive spaces with a single space in the field content. +Remove\ digits=Remove digits +Removes\ digits.=Removes digits. diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormaterTest.java similarity index 80% rename from src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java rename to src/test/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormaterTest.java index fa76039884a..cf902fdd3ee 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveTabsFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/ReplaceTabsBySpaceFormaterTest.java @@ -6,13 +6,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class RemoveTabsFormatterTest { +public class ReplaceTabsBySpaceFormaterTest { - private RemoveTabsFormatter formatter; + private ReplaceTabsBySpaceFormater formatter; @BeforeEach public void setUp() { - formatter = new RemoveTabsFormatter(); + formatter = new ReplaceTabsBySpaceFormater(); } @Test