Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into moveFileDir
Browse files Browse the repository at this point in the history
* upstream/master:
  Save deletion of current searchquery (#2469)
  Update dev dependencies (mockito, wiremock, assertj)
  Update BouncyCastle (1.55->1.56), ANTRL4 (4.5.3->4.6), jsoup (1.10.1->1.10.2)
  Group all checker which only check the value of one field (#2437)
  Follow up #2428 (#2438)
  Fix conversion of "'n" and "\'{n}" from LaTeX to Unicode (#2464)
  Fix failing tests
  • Loading branch information
Siedlerchr committed Jan 18, 2017
2 parents a44d8e6 + 9e48a5f commit 0ca9e1d
Show file tree
Hide file tree
Showing 39 changed files with 471 additions and 463 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Backslashes in content selectors are now correctly escaped. Fixes [#2426](https://github.com/JabRef/jabref/issues/2426).
- Non-ISO timestamp settings prevented the opening of the entry editor (see [#2447](https://github.com/JabRef/jabref/issues/2447))
- When pressing <kbd>Ctrl</kbd> + <kbd>F</kbd> and the searchbar is already focused the text will be selected.
- LaTeX symbols are now displayed as Unicode for the author column in the main table. Fixes [#2458](https://github.com/JabRef/jabref/issues/2458).
- LaTeX symbols are now displayed as Unicode for the author column in the main table. "'n" and "\'{n}" are parsed correctly. Fixes [#2458](https://github.com/JabRef/jabref/issues/2458).
- If one deleted the current query it was not saved (every basepanel can have it's own query). Fixes [#2468](https://github.com/JabRef/jabref/issues/2468).

### Removed

Expand Down
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dependencies {
compile 'org.apache.pdfbox:jempbox:1.8.13'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.55'
compile 'org.bouncycastle:bcprov-jdk15on:1.56'

compile 'commons-cli:commons-cli:1.3.1'

Expand All @@ -96,8 +96,8 @@ dependencies {
antlr3 'org.antlr:antlr:3.5.2'
compile 'org.antlr:antlr-runtime:3.5.2'

antlr4 'org.antlr:antlr4:4.5.3'
compile 'org.antlr:antlr4-runtime:4.5.3'
antlr4 'org.antlr:antlr4:4.6'
compile 'org.antlr:antlr4-runtime:4.6'

// VersionEye states that 6.0.5 is the most recent version, but http://dev.mysql.com/downloads/connector/j/ shows that as "Development Release"
compile 'mysql:mysql-connector-java:5.1.40'
Expand All @@ -113,7 +113,7 @@ dependencies {

compile 'org.apache.commons:commons-lang3:3.5'

compile 'org.jsoup:jsoup:1.10.1'
compile 'org.jsoup:jsoup:1.10.2'
compile 'com.mashape.unirest:unirest-java:1.4.9'
compile 'info.debatty:java-string-similarity:0.21'

Expand All @@ -131,9 +131,10 @@ dependencies {
compile 'com.github.lgooddatepicker:LGoodDatePicker:8.3.0'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.3.0'
testCompile 'com.github.tomakehurst:wiremock:2.4.1'
testCompile 'org.assertj:assertj-swing-junit:3.4.0'
testCompile 'org.mockito:mockito-core:2.5.5'
testCompile 'com.github.tomakehurst:wiremock:2.5.0'
testCompile 'org.assertj:assertj-swing-junit:3.5.0'
testCompile 'org.reflections:reflections:0.9.10'
}

sourceSets {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe

private ContentAutoCompleters autoCompleters;

private SearchQuery currentSearchQuery;
/** the query the user searches when this basepanel is active */
private Optional<SearchQuery> currentSearchQuery = Optional.empty();


public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) {
Expand Down Expand Up @@ -2405,12 +2406,16 @@ public BibDatabaseContext getDatabaseContext() {
return bibDatabaseContext;
}

public SearchQuery getCurrentSearchQuery() {
public Optional<SearchQuery> getCurrentSearchQuery() {
return currentSearchQuery;
}

/**
* Set the query the user currently searches while this basepanel is active
* @param currentSearchQuery can be null
*/
public void setCurrentSearchQuery(SearchQuery currentSearchQuery) {
this.currentSearchQuery = currentSearchQuery;
this.currentSearchQuery = Optional.ofNullable(currentSearchQuery);
}

public CitationStyleCache getCitationStyleCache() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private JPanel createIdFetcherPanel() {
idTextField = new JTextField("");
comboBox = new JComboBox<>();

EntryFetchers.getIdFetchers().forEach(fetcher -> comboBox.addItem(fetcher.getName()));
EntryFetchers.getIdFetchers(Globals.prefs.getImportFormatPreferences()).forEach(fetcher -> comboBox.addItem(fetcher.getName()));

generateButton.addActionListener(action -> {
fetcherWorker.execute();
Expand Down Expand Up @@ -287,7 +287,7 @@ protected Optional<BibEntry> doInBackground() throws Exception {
generateButton.setText(Localization.lang("Searching..."));
});
searchID = idTextField.getText().trim();
fetcher = EntryFetchers.getIdFetchers().get(comboBox.getSelectedIndex());
fetcher = EntryFetchers.getIdFetchers(Globals.prefs.getImportFormatPreferences()).get(comboBox.getSelectedIndex());
if (!searchID.isEmpty()) {
try {
bibEntry = fetcher.performSearchById(searchID);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,9 @@ public void windowClosing(WindowEvent e) {
globalSearchBar.performSearch();
} else {
String content = "";
SearchQuery currentSearchQuery = currentBasePanel.getCurrentSearchQuery();
if ((currentSearchQuery != null) && !currentSearchQuery.getQuery().trim().isEmpty()) {
content = currentSearchQuery.getQuery();
Optional<SearchQuery> currentSearchQuery = currentBasePanel.getCurrentSearchQuery();
if (currentSearchQuery.isPresent()) {
content = currentSearchQuery.get().getQuery();
}
globalSearchBar.setSearchTerm(content, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private void setupToolBar() {
toolBar.add(writeXmp);

JPopupMenu fetcherPopup = new JPopupMenu();
for(EntryBasedFetcher fetcher : EntryFetchers.getEntryBasedFetchers()) {
for(EntryBasedFetcher fetcher : EntryFetchers.getEntryBasedFetchers(Globals.prefs.getImportFormatPreferences())) {
fetcherPopup.add(new JMenuItem(new AbstractAction(fetcher.getName()) {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.sf.jabref.Globals;
import net.sf.jabref.logic.importer.EntryBasedFetcher;
import net.sf.jabref.logic.importer.IdBasedFetcher;
import net.sf.jabref.logic.importer.ImportFormatPreferences;
import net.sf.jabref.logic.importer.WebFetcher;
import net.sf.jabref.logic.importer.fetcher.ArXiv;
import net.sf.jabref.logic.importer.fetcher.AstrophysicsDataSystem;
Expand Down Expand Up @@ -52,22 +53,23 @@ public List<EntryFetcher> getEntryFetchers() {
return Collections.unmodifiableList(this.entryFetchers);
}

public static ArrayList<IdBasedFetcher> getIdFetchers() {
public static ArrayList<IdBasedFetcher> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<IdBasedFetcher> list = new ArrayList<>();
list.add(new AstrophysicsDataSystem(Globals.prefs.getImportFormatPreferences()));
list.add(new IsbnFetcher(Globals.prefs.getImportFormatPreferences()));
list.add(new DiVA(Globals.prefs.getImportFormatPreferences()));
list.add(new DoiFetcher(Globals.prefs.getImportFormatPreferences()));
list.add(new ArXiv(importFormatPreferences));
list.add(new AstrophysicsDataSystem(importFormatPreferences));
list.add(new IsbnFetcher(importFormatPreferences));
list.add(new DiVA(importFormatPreferences));
list.add(new DoiFetcher(importFormatPreferences));
list.add(new MedlineFetcher());
list.add(new TitleFetcher(Globals.prefs.getImportFormatPreferences()));
list.add(new TitleFetcher(importFormatPreferences));
list.sort(Comparator.comparing(WebFetcher::getName));
return list;
}

public static ArrayList<EntryBasedFetcher> getEntryBasedFetchers() {
public static ArrayList<EntryBasedFetcher> getEntryBasedFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<EntryBasedFetcher> list = new ArrayList<>();
list.add(new AstrophysicsDataSystem(Globals.prefs.getImportFormatPreferences()));
list.add(new MathSciNet(Globals.prefs.getImportFormatPreferences()));
list.add(new AstrophysicsDataSystem(importFormatPreferences));
list.add(new MathSciNet(importFormatPreferences));
list.sort(Comparator.comparing(WebFetcher::getName));
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private void clearSearch(BasePanel currentBasePanel) {

if (currentBasePanel != null) {
currentBasePanel.getMainTable().getTableModel().updateSearchState(MainTableDataModel.DisplayOption.DISABLED);
currentBasePanel.setCurrentSearchQuery(null);
}

if (dontSelectSearchBar){
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.sf.jabref.logic.importer.util.OAI2Handler;
import net.sf.jabref.logic.util.DOI;
import net.sf.jabref.logic.util.io.XMLUtil;
import net.sf.jabref.model.entry.ArXivIdentifier;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.BibtexEntryTypes;
import net.sf.jabref.model.entry.FieldName;
Expand Down Expand Up @@ -106,9 +107,13 @@ private Optional<ArXivEntry> searchForEntry(String searchQuery) throws FetcherEx
}
}

private Optional<ArXivEntry> searchForEntryById(String identifier) throws FetcherException {
identifier = identifier.replaceAll("(?i)arxiv:", "");
List<ArXivEntry> entries = queryApi("", Collections.singletonList(identifier), 0, 1);
private Optional<ArXivEntry> searchForEntryById(String id) throws FetcherException {
Optional<ArXivIdentifier> identifier = ArXivIdentifier.parse(id);
if (!identifier.isPresent()) {
return Optional.empty();
}

List<ArXivEntry> entries = queryApi("", Collections.singletonList(identifier.get()), 0, 1);
if (entries.size() >= 1) {
return Optional.of(entries.get(0));
} else {
Expand All @@ -120,7 +125,7 @@ private List<ArXivEntry> searchForEntries(String searchQuery) throws FetcherExce
return queryApi(searchQuery, Collections.emptyList(), 0, 10);
}

private List<ArXivEntry> queryApi(String searchQuery, List<String> ids, int start, int maxResults)
private List<ArXivEntry> queryApi(String searchQuery, List<ArXivIdentifier> ids, int start, int maxResults)
throws FetcherException {
Document result = callApi(searchQuery, ids, start, maxResults);
List<Node> entries = XMLUtil.asList(result.getElementsByTagName("entry"));
Expand All @@ -144,7 +149,7 @@ private List<ArXivEntry> queryApi(String searchQuery, List<String> ids, int star
* @return the response from the API as a XML document (Atom 1.0)
* @throws FetcherException if there was a problem while building the URL or the API was not accessible
*/
private Document callApi(String searchQuery, List<String> ids, int start, int maxResults) throws FetcherException {
private Document callApi(String searchQuery, List<ArXivIdentifier> ids, int start, int maxResults) throws FetcherException {
if (maxResults > 2000) {
throw new IllegalArgumentException("The arXiv API limits the number of maximal results to be 2000");
}
Expand All @@ -156,7 +161,8 @@ private Document callApi(String searchQuery, List<String> ids, int start, int ma
uriBuilder.addParameter("search_query", StringUtil.stripAccents(searchQuery));
}
if (!ids.isEmpty()) {
uriBuilder.addParameter("id_list", String.join(",", ids));
uriBuilder.addParameter("id_list",
ids.stream().map(ArXivIdentifier::getNormalized).collect(Collectors.joining(",")));
}
uriBuilder.addParameter("start", String.valueOf(start));
uriBuilder.addParameter("max_results", String.valueOf(maxResults));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public Parser getParser() {
public void doPostCleanup(BibEntry entry) {
new MoveFieldCleanup("fjournal", FieldName.JOURNAL).cleanup(entry);
new MoveFieldCleanup("mrclass", FieldName.KEYWORDS).cleanup(entry);
new FieldFormatterCleanup("mrreviewer", new ClearFormatter()).cleanup(entry);
new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
package net.sf.jabref.logic.integrity;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import net.sf.jabref.logic.integrity.IntegrityCheck.Checker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibEntry;

public class AbbreviationChecker implements Checker {

private final String field;


public AbbreviationChecker(String field) {
this.field = field;
}
public class AbbreviationChecker implements ValueChecker {

@Override
public List<IntegrityMessage> check(BibEntry entry) {
Optional<String> value = entry.getField(field);
if (!value.isPresent()) {
return Collections.emptyList();
}

if (value.get().contains(".")) {
return Collections
.singletonList(new IntegrityMessage(Localization.lang("abbreviation detected"), entry, field));
public Optional<String> checkValue(String value) {
if (value.contains(".")) {
return Optional.of(Localization.lang("abbreviation detected"));
}

return Collections.emptyList();
return Optional.empty();
}
}
36 changes: 0 additions & 36 deletions src/main/java/net/sf/jabref/logic/integrity/AuthorNameChecker.java

This file was deleted.

This file was deleted.

22 changes: 5 additions & 17 deletions src/main/java/net/sf/jabref/logic/integrity/BooktitleChecker.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
package net.sf.jabref.logic.integrity;

import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Optional;

import net.sf.jabref.logic.integrity.IntegrityCheck.Checker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;

public class BooktitleChecker implements Checker {
public class BooktitleChecker implements ValueChecker {

@Override
public List<IntegrityMessage> check(BibEntry entry) {
String field = FieldName.BOOKTITLE;
Optional<String> value = entry.getField(field);
if (!value.isPresent()) {
return Collections.emptyList();
public Optional<String> checkValue(String value) {
if (value.toLowerCase(Locale.ENGLISH).endsWith("conference on")) {
return Optional.of(Localization.lang("booktitle ends with 'conference on'"));
}

if (value.get().toLowerCase(Locale.ENGLISH).endsWith("conference on")) {
return Collections.singletonList(
new IntegrityMessage(Localization.lang("booktitle ends with 'conference on'"), entry, field));
}

return Collections.emptyList();
return Optional.empty();
}
}
Loading

0 comments on commit 0ca9e1d

Please sign in to comment.