forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework journal abbreviation caching (JabRef#6304)
* Rework journal abbreviation caching * Add ADR-0010 * Remove IEEE abbreviations * Convert abbreviations as part of build process * Fix tests * Update according to review feedback * Fix bug * Include feedback * Fix test * Fix localization Co-authored-by: Oliver Kopp <[email protected]>
- Loading branch information
1 parent
5758f8b
commit a123eb1
Showing
70 changed files
with
529 additions
and
1,202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile 'com.h2database:h2-mvstore:1.4.200' | ||
compile 'org.apache.commons:commons-csv:1.8' | ||
compile 'org.slf4j:slf4j-api:2.0.0-alpha1' | ||
} | ||
|
||
sourceSets{ | ||
main { | ||
java { | ||
srcDir "${project.rootDir}/../src/main/java/org/jabref/logic/journals" | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
buildSrc/src/main/groovy/org/jabref/build/JournalAbbreviationConverter.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.jabref.build | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.tasks.* | ||
import org.h2.mvstore.MVMap | ||
import org.h2.mvstore.MVStore | ||
import org.jabref.logic.journals.JournalAbbreviationLoader | ||
|
||
import java.util.stream.Collectors | ||
|
||
abstract class JournalAbbreviationConverter extends DefaultTask { | ||
@PathSensitive(PathSensitivity.NAME_ONLY) | ||
@InputDirectory | ||
abstract DirectoryProperty getInputDir() | ||
|
||
@OutputDirectory | ||
abstract DirectoryProperty getOutputDir() | ||
|
||
@TaskAction | ||
def convert() { | ||
def targetFile = outputDir.file("journalList.mv").get().asFile | ||
targetFile.delete() | ||
MVStore.open(targetFile.toString()).withCloseable { store -> | ||
MVMap<String, String> fullToAbbreviation = store.openMap("FullToAbbreviation") | ||
MVMap<String, String> abbreviationToFull = store.openMap("AbbreviationToFull") | ||
|
||
inputDir.getAsFileTree().filter({ File f -> f.name.endsWith(".csv") }).getFiles().each { file -> | ||
def abbreviations = JournalAbbreviationLoader.readJournalListFromFile(file.toPath()) | ||
fullToAbbreviation.putAll( | ||
abbreviations | ||
.stream() | ||
.collect(Collectors.toMap({ abbreviation -> abbreviation.getName() }, { abbreviation -> abbreviation.getAbbreviation() })) | ||
) | ||
|
||
abbreviations | ||
.forEach({ abbreviation -> | ||
abbreviationToFull.putIfAbsent(abbreviation.getAbbreviation(), abbreviation.getName()) | ||
}) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Use H2 as Internal SQL Database | ||
|
||
## Context and Problem Statement | ||
|
||
We need to store data internally in a structured way to gain performance. | ||
|
||
## Decision Drivers | ||
|
||
* Easy to integrate | ||
* Easy to use | ||
* Common technology | ||
|
||
## Considered Options | ||
|
||
* [H2 Database Engine](http://www.h2database.com/html/main.html) | ||
* [SQLite](https://www.sqlite.org/index.html) | ||
|
||
## Decision Outcome | ||
|
||
Chosen option: "H2 Database Engine", because it was straight-forward to use. | ||
|
||
## Links | ||
|
||
* [Comparison at SQL Workbench](https://www.sql-workbench.eu/dbms_comparison.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 13 additions & 12 deletions
25
src/main/java/org/jabref/gui/autocompleter/JournalsSuggestionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
package org.jabref.gui.autocompleter; | ||
|
||
import org.jabref.logic.journals.JournalAbbreviationLoader; | ||
import java.util.stream.Stream; | ||
|
||
import org.jabref.logic.journals.JournalAbbreviationRepository; | ||
import org.jabref.model.database.BibDatabase; | ||
import org.jabref.model.entry.field.Field; | ||
|
||
import com.google.common.collect.Streams; | ||
|
||
public class JournalsSuggestionProvider extends FieldValueSuggestionProvider { | ||
|
||
JournalsSuggestionProvider(Field field, BibDatabase database, AutoCompletePreferences preferences, | ||
JournalAbbreviationLoader abbreviationLoader) { | ||
private final JournalAbbreviationRepository repository; | ||
|
||
JournalsSuggestionProvider(Field field, BibDatabase database, JournalAbbreviationRepository repository) { | ||
super(field, database); | ||
|
||
/* | ||
TODO: Reenable | ||
this.repository = repository; | ||
} | ||
|
||
JournalAbbreviationPreferences journalAbbreviationPreferences = preferences.getJournalAbbreviationPreferences(); | ||
List<String> journals = abbreviationLoader.getRepository(journalAbbreviationPreferences) | ||
.getAbbreviations().stream() | ||
.map(Abbreviation::getName) | ||
.collect(Collectors.toList()); | ||
addPossibleSuggestions(journals); | ||
*/ | ||
@Override | ||
public Stream<String> getSource() { | ||
return Streams.concat(super.getSource(), repository.getFullNames().stream()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.