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

Remove unnecessary sort #5470

Merged
merged 4 commits into from
Oct 17, 2019
Merged
Changes from 1 commit
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
43 changes: 33 additions & 10 deletions src/main/java/org/jabref/logic/importer/WebFetchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import java.util.List;
import java.util.Optional;

import javafx.collections.FXCollections;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no JavaFX imports. Our logic module must not have any imports from the gui. This blocks #110

Why do our architecture tests not fail here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should i refactor to standard library SortedSet?
In case Eclipse Collections is added as dependency later on, ImmutableSortedSet can be used as drop in replacement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, SortedSet might be the better option here (because Set would be already better than List as the elements should be unique). Could you please create a follow-up PR? Sorry for the overhead, was my bad.

import javafx.collections.ObservableList;
import javafx.collections.transformation.SortedList;

import org.jabref.logic.importer.fetcher.ACMPortalFetcher;
import org.jabref.logic.importer.fetcher.ACS;
import org.jabref.logic.importer.fetcher.ArXiv;
Expand Down Expand Up @@ -76,7 +80,10 @@ public static Optional<IdFetcher<? extends Identifier>> getIdFetcherForField(Fie
return Optional.empty();
}

public static List<SearchBasedFetcher> getSearchBasedFetchers(ImportFormatPreferences importFormatPreferences) {
/**
* @return sorted list containing search based fetchers
*/
public static SortedList<SearchBasedFetcher> getSearchBasedFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<SearchBasedFetcher> list = new ArrayList<>();
list.add(new ArXiv(importFormatPreferences));
list.add(new INSPIREFetcher(importFormatPreferences));
Expand All @@ -93,10 +100,14 @@ public static List<SearchBasedFetcher> getSearchBasedFetchers(ImportFormatPrefer
list.add(new CiteSeer());
list.add(new DOAJFetcher(importFormatPreferences));
list.add(new IEEE(importFormatPreferences));
list.sort(Comparator.comparing(WebFetcher::getName));
return list;

ObservableList<SearchBasedFetcher> observableList = FXCollections.observableList(list);
return new SortedList<>(observableList, Comparator.comparing(WebFetcher::getName));
}

/**
* @return sorted list containing id based fetchers
*/
public static List<IdBasedFetcher> getIdBasedFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<IdBasedFetcher> list = new ArrayList<>();
list.add(new ArXiv(importFormatPreferences));
Expand All @@ -111,29 +122,41 @@ public static List<IdBasedFetcher> getIdBasedFetchers(ImportFormatPreferences im
list.add(new LibraryOfCongress(importFormatPreferences));
list.add(new IacrEprintFetcher(importFormatPreferences));
list.add(new RfcFetcher(importFormatPreferences));
list.sort(Comparator.comparing(WebFetcher::getName));
return list;

ObservableList<IdBasedFetcher> observableList = FXCollections.observableList(list);
return new SortedList<>(observableList, Comparator.comparing(WebFetcher::getName));
}

/**
* @return sorted list containing entry based fetchers
*/
public static List<EntryBasedFetcher> getEntryBasedFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<EntryBasedFetcher> list = new ArrayList<>();
list.add(new AstrophysicsDataSystem(importFormatPreferences));
list.add(new DoiFetcher(importFormatPreferences));
list.add(new IsbnFetcher(importFormatPreferences));
list.add(new MathSciNet(importFormatPreferences));
list.add(new CrossRef());
list.sort(Comparator.comparing(WebFetcher::getName));
return list;

ObservableList<EntryBasedFetcher> observableList = FXCollections.observableList(list);
return new SortedList<>(observableList, Comparator.comparing(WebFetcher::getName));
}

public static List<IdFetcher> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
/**
* @return sorted list containing id fetchers
*/
public static SortedList<IdFetcher> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
ArrayList<IdFetcher> list = new ArrayList<>();
list.add(new CrossRef());
list.add(new ArXiv(importFormatPreferences));
list.sort(Comparator.comparing(WebFetcher::getName));
return list;

ObservableList<IdFetcher> observableList = FXCollections.observableList(list);
return new SortedList<>(observableList, Comparator.comparing(WebFetcher::getName));
}

/**
* @return unsorted list containing fulltext fetchers
*/
public static List<FulltextFetcher> getFullTextFetchers(ImportFormatPreferences importFormatPreferences) {
List<FulltextFetcher> fetchers = new ArrayList<>();
// Original
Expand Down