Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix IEE fetcher #4999

Merged
merged 6 commits into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the RIS import would overwite the article date with the value of the acessed date [#4816](https://github.com/JabRef/jabref/issues/4816)
- We fixed an issue where an NullPointer exception was thrown when a referenced entry in an Open/Libre Office document was no longer present in the library. Now an error message with the reference marker of the missing entry is shown. [#4932](https://github.com/JabRef/jabref/issues/4932)
- We fixed an issue where a database exception related to a missing timezone was too big. [#4827](https://github.com/JabRef/jabref/issues/4827)
- We fixed an issue where the IEEE fetcher returned an error if no keywords were present in the result from the IEEE website [#4997](https://github.com/JabRef/jabref/issues/4997)
- We fixed an issue where the command line help text had several errors, and arguments and descriptions have been rewritten to simplify and detail them better. [#4932](https://github.com/JabRef/jabref/issues/2016)
- We fixed an issue where the same menu for changing entry type had two different sizes and weights. [#4977](https://github.com/JabRef/jabref/issues/4977)
- We fixed an issue where the "Attach file" dialog, in the right-click menu for an entry, started on the working directory instead of the user's main directory. [#4995](https://github.com/JabRef/jabref/issues/4995)




### Removed
- The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group.
- The number column was removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class WebSearchPane extends SidePaneComponent {
public WebSearchPane(SidePaneManager sidePaneManager, JabRefPreferences preferences, JabRefFrame frame) {
super(sidePaneManager, IconTheme.JabRefIcons.WWW, Localization.lang("Web search"));
this.preferences = preferences;
this.viewModel = new WebSearchPaneViewModel(preferences.getImportFormatPreferences(), frame, preferences);
this.viewModel = new WebSearchPaneViewModel(preferences.getImportFormatPreferences(), frame, preferences, frame.getDialogService());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.importer.ImportEntriesDialog;
import org.jabref.gui.util.BackgroundTask;
Expand All @@ -25,21 +26,19 @@
import org.jabref.preferences.JabRefPreferences;

import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebSearchPaneViewModel {

private static final Logger LOGGER = LoggerFactory.getLogger(WebSearchPaneViewModel.class);

private final ObjectProperty<SearchBasedFetcher> selectedFetcher = new SimpleObjectProperty<>();
private final ListProperty<SearchBasedFetcher> fetchers = new SimpleListProperty<>(FXCollections.observableArrayList());
private final StringProperty query = new SimpleStringProperty();
private final JabRefFrame frame;
private final DialogService dialogService;

public WebSearchPaneViewModel(ImportFormatPreferences importPreferences, JabRefFrame frame, JabRefPreferences preferences) {
public WebSearchPaneViewModel(ImportFormatPreferences importPreferences, JabRefFrame frame, JabRefPreferences preferences, DialogService dialogService) {
// TODO: Rework so that we don't rely on JabRefFrame and not the complete preferences
this.frame = frame;
this.dialogService = dialogService;

List<SearchBasedFetcher> allFetchers = WebFetchers.getSearchBasedFetchers(importPreferences);
allFetchers.sort(Comparator.comparing(WebFetcher::getName));
Expand Down Expand Up @@ -84,12 +83,12 @@ public StringProperty queryProperty() {

public void search() {
if (StringUtil.isBlank(getQuery())) {
frame.getDialogService().notify(Localization.lang("Please enter a search string"));
dialogService.notify(Localization.lang("Please enter a search string"));
return;
}

if (frame.getCurrentBasePanel() == null) {
frame.getDialogService().notify(Localization.lang("Please open or start a new library before searching"));
dialogService.notify(Localization.lang("Please open or start a new library before searching"));
return;
}

Expand All @@ -98,6 +97,8 @@ public void search() {
BackgroundTask<List<BibEntry>> task = BackgroundTask.wrap(() -> activeFetcher.performSearch(getQuery().trim()))
.withInitialMessage(Localization.lang("Processing %0", getQuery()));

task.onFailure(ex -> dialogService.showErrorDialogAndWait(ex));

ImportEntriesDialog dialog = new ImportEntriesDialog(frame.getCurrentBasePanel().getBibDatabaseContext(), task);
dialog.setTitle(activeFetcher.getName());
dialog.showAndWait();
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/org/jabref/logic/importer/fetcher/IEEE.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,28 @@ private static BibEntry parseJsonRespone(JSONObject jsonEntry, Character keyword
final List<String> authors = new ArrayList<>();
JSONObject authorsContainer = jsonEntry.optJSONObject("authors");
authorsContainer.getJSONArray("authors").forEach(authorPure -> {
JSONObject author = (JSONObject) authorPure;
authors.add(author.optString("full_name"));
}
);
JSONObject author = (JSONObject) authorPure;
authors.add(author.optString("full_name"));
});
entry.setField(FieldName.AUTHOR, authors.stream().collect(Collectors.joining(" and ")));
entry.setField(FieldName.LOCATION, jsonEntry.optString("conference_location"));
entry.setField(FieldName.DOI, jsonEntry.optString("doi"));
entry.setField(FieldName.PAGES, jsonEntry.optString("start_page") + "--" + jsonEntry.optString("end_page"));

JSONObject keywordsContainer = jsonEntry.optJSONObject("index_terms");
if (keywordsContainer != null) {
keywordsContainer.getJSONObject("ieee_terms").getJSONArray("terms").forEach(data -> {
String keyword = (String) data;
entry.addKeyword(keyword, keywordSeparator);
});
keywordsContainer.getJSONObject("author_terms").getJSONArray("terms").forEach(data -> {
String keyword = (String) data;
entry.addKeyword(keyword, keywordSeparator);
});
if (keywordsContainer.has("ieee_terms")) {
keywordsContainer.getJSONObject("ieee_terms").getJSONArray("terms").forEach(data -> {
String keyword = (String) data;
entry.addKeyword(keyword, keywordSeparator);
});
}
if (keywordsContainer.has("author_terms")) {
keywordsContainer.getJSONObject("author_terms").getJSONArray("terms").forEach(data -> {
String keyword = (String) data;
entry.addKeyword(keyword, keywordSeparator);
});
}
}

entry.setField(FieldName.ISBN, jsonEntry.optString("isbn"));
Expand Down
66 changes: 41 additions & 25 deletions src/test/java/org/jabref/logic/importer/fetcher/IEEETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import java.util.List;
import java.util.Optional;

import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
import org.jabref.model.entry.FieldName;
import org.jabref.support.DisabledOnCIServer;
import org.jabref.testutils.category.FetcherTest;

Expand Down Expand Up @@ -38,50 +40,40 @@ void setUp() {
void findByDOI() throws IOException {
entry.setField("doi", "10.1109/ACCESS.2016.2535486");

assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931&ref=")),
fetcher.findFullText(entry));
}

@Test
void findByDocumentUrl() throws IOException {
entry.setField("url", "https://ieeexplore.ieee.org/document/7421926/");
assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931&ref=")),
fetcher.findFullText(entry));
}

@Test
void findByURL() throws IOException {
entry.setField("url", "https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7421926");
entry.setField("url", "https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7421926&ref=");

assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931&ref=")),
fetcher.findFullText(entry));
}

@Test
void findByOldURL() throws IOException {
entry.setField("url", "https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=7421926");

assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931&ref=")),
fetcher.findFullText(entry));
}

@Test
void findByDOIButNotURL() throws IOException {
entry.setField("doi", "10.1109/ACCESS.2016.2535486");
entry.setField("url", "http://dx.doi.org/10.1109/ACCESS.2016.2535486");

assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931&ref=")),
fetcher.findFullText(entry));
}

@Test
Expand All @@ -99,23 +91,47 @@ void notFoundByDOI() throws IOException {
assertEquals(Optional.empty(), fetcher.findFullText(entry));
}

@Test
void searchResultHasNoKeywordTerms() throws FetcherException {
BibEntry expected = new BibEntry(BibtexEntryTypes.ARTICLE);

expected.setField("author", "Shatakshi Jha and Ikhlaq Hussain and Bhim Singh and Sukumar Mishra");
expected.setField("date", "25 2 2019");
expected.setField("doi", "10.1049/iet-rpg.2018.5648");
expected.setField("file", ":https\\://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8636659:PDF");
expected.setField("issn", "1752-1416");
expected.setField("issue", "3");
expected.setField("journaltitle", "IET Renewable Power Generation");
expected.setField("pages", "418--426");
expected.setField("publisher", "IET");
expected.setField("title", "Optimal operation of PV-DG-battery based microgrid with power quality conditioner");
expected.setField("volume", "13");

List<BibEntry> fetchedEntries = fetcher.performSearch("8636659"); //article number
fetchedEntries.stream().forEach(entry -> entry.clearField(FieldName.ABSTRACT)); //Remove abstract due to copyright);
assertEquals(Collections.singletonList(expected), fetchedEntries);

}

@Test
void searchByQueryFindsEntry() throws Exception {
BibEntry expected = new BibEntry(BibtexEntryTypes.INPROCEEDINGS);
expected.setField("author", "Igor Steinmacher and Tayana Uchoa Conte and Christoph Treude and Marco Aurélio Gerosa");
expected.setField("date", "14-22 May 2016");
expected.setField("eventdate", "14-22 May 2016");
expected.setField("eventtitleaddon", "Austin, TX");
expected.setField("location", "Austin, TX");
expected.setField("doi", "10.1145/2884781.2884806");
expected.setField("isbn", "New-2005_Electronic_978-1-4503-3900-1");
expected.setField("isbn", "978-1-4503-3900-1");
expected.setField("issn", "1558-1225");
expected.setField("journaltitle", "2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE)");
expected.setField("pages", "273--284");
expected.setField("publisher", "IEEE");
expected.setField("keywords", "Computer bugs, Documentation, Industries, Joining processes, Open source software, Portals, Barriers, Beginners, Joining Process, Newbies, Newcomers, Novices, Obstacles, Onboarding, Open Source Software");
expected.setField("keywords", "Portals, Documentation, Computer bugs, Joining processes, Industries, Open source software, Newcomers, Newbies, Novices, Beginners, Open Source Software, Barriers, Obstacles, Onboarding, Joining Process");
expected.setField("title", "Overcoming Open Source Project Entry Barriers with a Portal for Newcomers");
expected.setField("file", ":https\\://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=7886910:PDF");
expected.setField("file", ":https\\://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7886910:PDF");
expected.setField("abstract", "Community-based Open Source Software (OSS) projects are usually self-organized and dynamic, receiving contributions from distributed volunteers. Newcomer are important to the survival, long-term success, and continuity of these communities. However, newcomers face many barriers when making their first contribution to an OSS project, leading in many cases to dropouts. Therefore, a major challenge for OSS projects is to provide ways to support newcomers during their first contribution. In this paper, we propose and evaluate FLOSScoach, a portal created to support newcomers to OSS projects. FLOSScoach was designed based on a conceptual model of barriers created in our previous work. To evaluate the portal, we conducted a study with 65 students, relying on qualitative data from diaries, self-efficacy questionnaires, and the Technology Acceptance Model. The results indicate that FLOSScoach played an important role in guiding newcomers and in lowering barriers related to the orientation and contribution process, whereas it was not effective in lowering technical barriers. We also found that FLOSScoach is useful, easy to use, and increased newcomers' confidence to contribute. Our results can help project maintainers on deciding the points that need more attention in order to help OSS project newcomers overcome entry barriers.");
List<BibEntry> fetchedEntries = fetcher.performSearch("JabRef Social Barriers Steinmacher Redmiles Austin");
List<BibEntry> fetchedEntries = fetcher.performSearch("Overcoming Open Source Project Entry Barriers with a Portal for Newcomers");
assertEquals(Collections.singletonList(expected), fetchedEntries);
}
}