From 4265e2bdb42da0fc8260b08029d5a717c4784600 Mon Sep 17 00:00:00 2001 From: Dominik Voigt Date: Tue, 22 Dec 2020 02:24:30 +0100 Subject: [PATCH 1/6] Disable composite fetcher test Signed-off-by: Dominik Voigt --- .../logic/importer/fetcher/CompositeSearchBasedFetcherTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java index b0b326c50d5..3a039749071 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java @@ -17,6 +17,7 @@ import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -28,6 +29,7 @@ import static org.mockito.Mockito.when; @FetcherTest +@Disabled("Produces to many requests on CI") public class CompositeSearchBasedFetcherTest { private static final Logger LOGGER = LoggerFactory.getLogger(CompositeSearchBasedFetcherTest.class); From 0342b7b358241befd46ee9706b8d1509ab60c629 Mon Sep 17 00:00:00 2001 From: Dominik Voigt Date: Tue, 22 Dec 2020 03:04:27 +0100 Subject: [PATCH 2/6] Fix citeseerx test Enable doi search for complex search queries Signed-off-by: Dominik Voigt --- .../importer/fetcher/ComplexSearchQuery.java | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ComplexSearchQuery.java b/src/main/java/org/jabref/logic/importer/fetcher/ComplexSearchQuery.java index ade12d2d8b9..0d1f0d39c6f 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ComplexSearchQuery.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ComplexSearchQuery.java @@ -21,8 +21,9 @@ public class ComplexSearchQuery { private final Integer toYear; private final Integer singleYear; private final String journal; + private final String doi; - private ComplexSearchQuery(List defaultField, List authors, List titlePhrases, List abstractPhrases, Integer fromYear, Integer toYear, Integer singleYear, String journal) { + private ComplexSearchQuery(List defaultField, List authors, List titlePhrases, List abstractPhrases, Integer fromYear, Integer toYear, Integer singleYear, String journal, String doi) { this.defaultField = defaultField; this.authors = authors; this.titlePhrases = titlePhrases; @@ -32,6 +33,7 @@ private ComplexSearchQuery(List defaultField, List authors, List this.toYear = toYear; this.journal = journal; this.singleYear = singleYear; + this.doi = doi; } public static ComplexSearchQuery fromTerms(List terms) { @@ -45,6 +47,7 @@ public static ComplexSearchQuery fromTerms(List terms) { case "journal" -> builder.journal(termText); case "year" -> builder.singleYear(Integer.valueOf(termText)); case "year-range" -> builder.parseYearRange(termText); + case "doi" -> builder.DOI(termText); case "default" -> builder.defaultFieldPhrase(termText); // add unknown field as default field default -> builder.defaultFieldPhrase(termText); @@ -85,6 +88,10 @@ public Optional getJournal() { return Optional.ofNullable(journal); } + public Optional getDOI() { + return Optional.ofNullable(doi); + } + public static ComplexSearchQueryBuilder builder() { return new ComplexSearchQueryBuilder(); } @@ -122,12 +129,15 @@ public boolean equals(Object o) { if (getSingleYear().isPresent() ? !getSingleYear().equals(that.getSingleYear()) : that.getSingleYear().isPresent()) { return false; } - return getJournal().isPresent() ? getJournal().equals(that.getJournal()) : !that.getJournal().isPresent(); + if (getDOI().isPresent() ? !getDOI().equals(that.getDOI()) : that.getDOI().isPresent()) { + return false; + } + return getJournal().isPresent() ? getJournal().equals(that.getJournal()) : that.getJournal().isEmpty(); } @Override public int hashCode() { - return Objects.hash(defaultField, getAuthors(), getSingleYear(), getAbstractPhrases(), getFromYear(), getToYear(), getTitlePhrases(), getJournal()); + return Objects.hash(defaultField, getAuthors(), getSingleYear(), getAbstractPhrases(), getFromYear(), getToYear(), getTitlePhrases(), getJournal(), getDOI()); } @Override @@ -138,6 +148,7 @@ public String toString() { getFromYear().ifPresent(fromYear -> stringJoiner.add(fromYear.toString())); getToYear().ifPresent(toYear -> stringJoiner.add(toYear.toString())); getJournal().ifPresent(stringJoiner::add); + getDOI().ifPresent(newElement -> stringJoiner.add("doi:" + newElement)); stringJoiner.add(String.join(" ", getTitlePhrases())) .add(String.join(" ", getDefaultFieldPhrases())) .add(String.join(" ", getAuthors())) @@ -147,11 +158,12 @@ public String toString() { } public static class ComplexSearchQueryBuilder { - private List defaultFieldPhrases = new ArrayList<>(); - private List authors = new ArrayList<>(); - private List titlePhrases = new ArrayList<>(); - private List abstractPhrases = new ArrayList<>(); + private final List defaultFieldPhrases = new ArrayList<>(); + private final List authors = new ArrayList<>(); + private final List titlePhrases = new ArrayList<>(); + private final List abstractPhrases = new ArrayList<>(); private String journal; + private String doi; private Integer fromYear; private Integer toYear; private Integer singleYear; @@ -229,6 +241,14 @@ public ComplexSearchQueryBuilder journal(String journal) { return this; } + public ComplexSearchQueryBuilder DOI(String doi) { + if (Objects.requireNonNull(doi).isBlank()) { + throw new IllegalArgumentException("Parameter must not be blank"); + } + this.doi = doi.replace("\"", ""); + return this; + } + public ComplexSearchQueryBuilder terms(Collection terms) { terms.forEach(term -> { String termText = term.text(); @@ -237,6 +257,7 @@ public ComplexSearchQueryBuilder terms(Collection terms) { case "title" -> this.titlePhrase(termText); case "abstract" -> this.abstractPhrase(termText); case "journal" -> this.journal(termText); + case "doi" -> this.DOI(termText); case "year" -> this.singleYear(Integer.valueOf(termText)); case "year-range" -> this.parseYearRange(termText); case "default" -> this.defaultFieldPhrase(termText); @@ -257,7 +278,7 @@ public ComplexSearchQuery build() throws IllegalStateException { if (textSearchFieldsAndYearFieldsAreEmpty()) { throw new IllegalStateException("At least one text field has to be set"); } - return new ComplexSearchQuery(defaultFieldPhrases, authors, titlePhrases, abstractPhrases, fromYear, toYear, singleYear, journal); + return new ComplexSearchQuery(defaultFieldPhrases, authors, titlePhrases, abstractPhrases, fromYear, toYear, singleYear, journal, doi); } void parseYearRange(String termText) { @@ -281,7 +302,7 @@ void parseYearRange(String termText) { private boolean textSearchFieldsAndYearFieldsAreEmpty() { return this.stringListIsBlank(defaultFieldPhrases) && this.stringListIsBlank(titlePhrases) && - this.stringListIsBlank(authors) && this.stringListIsBlank(abstractPhrases) && StringUtil.isBlank(journal) && yearFieldsAreEmpty(); + this.stringListIsBlank(authors) && this.stringListIsBlank(abstractPhrases) && StringUtil.isBlank(journal) && StringUtil.isBlank(doi) && yearFieldsAreEmpty(); } private boolean yearFieldsAreEmpty() { From 81a4ac8e526f7808a2f6d59147a5a521a9544808 Mon Sep 17 00:00:00 2001 From: Dominik Voigt Date: Tue, 22 Dec 2020 03:08:37 +0100 Subject: [PATCH 3/6] Fix JSTOR searchById Signed-off-by: Dominik Voigt --- .../org/jabref/logic/importer/fetcher/JstorFetcherTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java index 2124b8f73cc..7d7c39a9002 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java @@ -44,7 +44,7 @@ public class JstorFetcherTest implements SearchBasedFetcherCapabilityTest { .withCitationKey("10.1086/501484") .withField(StandardField.AUTHOR, "Johnmarshall Reeve") .withField(StandardField.TITLE, "Teachers as Facilitators: What Autonomy‐Supportive Teachers Do and Why Their Students Benefit") - .withField(StandardField.ISSN, "{00135984, 15548279") + .withField(StandardField.ISSN, "00135984, 15548279") .withField(StandardField.JOURNAL, "The Elementary School Journal") .withField(StandardField.ABSTRACT, "Abstract Students are sometimes proactive and engaged in classroom learning activities, but they are also sometimes only reactive and passive. Recognizing this, in this article I argue that students’ classroom engagement depends, in part, on the supportive quality of the classroom climate in which they learn. According to the dialectical framework within self‐determination theory, students possess inner motivational resources that classroom conditions can support or frustrate. When teachers find ways to nurture these inner resources, they adopt an autonomy‐supportive motivating style. After articulating what autonomy‐supportive teachers say and do during instruction, I discuss 3 points: teachers can learn how to be more autonomy supportive toward students; teachers most engage students when they offer high levels of both autonomy support and structure; and an autonomy‐supportive motivating style is an important element to a high‐quality teacher‐student relationship.") .withField(StandardField.PUBLISHER, "The University of Chicago Press") From b21f4125b99ce443b0455e2c4af5c4573407cc7f Mon Sep 17 00:00:00 2001 From: Dominik Voigt Date: Tue, 22 Dec 2020 03:19:55 +0100 Subject: [PATCH 4/6] Fix TitleFetcher Signed-off-by: Dominik Voigt --- .../java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java index 3a289eec9a8..9a4d229c0e2 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/TitleFetcherTest.java @@ -34,6 +34,7 @@ public void setUp() { bibEntryBischof2009.setField(StandardField.PUBLISHER, "{IEEE}"); bibEntryBischof2009.setField(StandardField.TITLE, "{BPELscript}: A Simplified Script Syntax for {WS}-{BPEL} 2.0"); bibEntryBischof2009.setField(StandardField.YEAR, "2009"); + bibEntryBischof2009.setField(StandardField.MONTH, "aug"); bibEntryBischof2009.setField(StandardField.DOI, "10.1109/seaa.2009.21"); } From 7dffb56dde6489c2a0ca26775f4bf94e95b7167f Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 22 Dec 2020 09:44:49 +0100 Subject: [PATCH 5/6] Update src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java --- .../logic/importer/fetcher/CompositeSearchBasedFetcherTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java index 3a039749071..7d4035706a8 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.when; @FetcherTest -@Disabled("Produces to many requests on CI") +@DisabledOnCIServer("Produces to many requests on CI") public class CompositeSearchBasedFetcherTest { private static final Logger LOGGER = LoggerFactory.getLogger(CompositeSearchBasedFetcherTest.class); From 48a16af72fea49b7b23970e1012819eb8c598776 Mon Sep 17 00:00:00 2001 From: Dominik Voigt Date: Tue, 22 Dec 2020 10:47:30 +0100 Subject: [PATCH 6/6] Add missing import Signed-off-by: Dominik Voigt --- .../logic/importer/fetcher/CompositeSearchBasedFetcherTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java index 7d4035706a8..b639c35cf5b 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java @@ -14,10 +14,10 @@ import org.jabref.logic.importer.SearchBasedFetcher; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; +import org.jabref.support.DisabledOnCIServer; import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments;