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

Integration with JabRef online #7832

Draft
wants to merge 76 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
a90cd06
add apollo graphlql stuff
Siedlerchr Jun 6, 2021
953448c
fix graphqlsource dir
Siedlerchr Jun 6, 2021
af79b80
add annotaitons and okio
Siedlerchr Jun 6, 2021
b9ca9cb
use apollo jvm
Siedlerchr Jun 6, 2021
6287d64
fix modulartiy issues
Siedlerchr Jun 6, 2021
51cbf59
Add kotlin library
tobiasdiez Jun 6, 2021
ca30630
Require kotlin standard lib
tobiasdiez Jun 6, 2021
f29ddee
Remove explicit kotlin dependency again
tobiasdiez Jun 6, 2021
5bcabab
set rootpackage
Siedlerchr Jun 6, 2021
9e0ab5b
try to set outputDir but does not work yet
Siedlerchr Jun 6, 2021
afc1f3d
Merge branch 'main' into jabrefonline
koppor Jun 7, 2021
be41827
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Jun 8, 2021
6388a41
Merge branch 'jabrefonline' of github.com:JabRef/jabref into jabrefon…
Siedlerchr Jun 8, 2021
d5d4ed6
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Jun 11, 2021
0f02a6f
try patching apollo for eclipse
Siedlerchr Jun 11, 2021
abf0a1b
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Jun 16, 2021
e7cda72
try with all unnamed
Siedlerchr Jun 16, 2021
b8c0e4d
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Jun 17, 2021
e04c535
compile custom apollo variant using shadow jar
Siedlerchr Jun 17, 2021
7586334
add apollo jar building
Siedlerchr Jun 19, 2021
866f2a3
Change jar name
Siedlerchr Jun 19, 2021
d9cbf2f
chang eeclipse output
Siedlerchr Jun 19, 2021
7edd6ab
Add mutation, move java class
Siedlerchr Jun 19, 2021
09779f5
fix checkstyle
Siedlerchr Jun 19, 2021
f7c490b
align version
Siedlerchr Jun 19, 2021
b79bf7e
add info on modules
Siedlerchr Jun 20, 2021
bd5ab5b
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Jun 22, 2021
0069ad0
cleanup
Siedlerchr Jun 22, 2021
c6def12
Add comment clarifying purpose of build file
tobiasdiez Jun 22, 2021
feb43d0
Convert to usual gradle syntax
tobiasdiez Jun 22, 2021
dcea782
Fix typo
tobiasdiez Jun 22, 2021
79c861e
Fix another typo
tobiasdiez Jun 22, 2021
16556b2
Merge branch 'main' into jabrefonline
tobiasdiez Jul 29, 2021
6bf8c37
Update Library.java
tobiasdiez Jul 29, 2021
0a7de4c
Update settings.gradle
tobiasdiez Jul 29, 2021
9d297df
Update build.gradle
tobiasdiez Jul 29, 2021
a56801a
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Aug 20, 2021
a2123c4
change to new schema
Siedlerchr Aug 20, 2021
cbbc7c4
fix mutation
Siedlerchr Aug 20, 2021
7d52088
Merge branch 'jabrefonline' of github.com:JabRef/jabref into jabrefon…
Siedlerchr Aug 20, 2021
0b9f414
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Oct 10, 2021
567a378
Add schema downloading tasks
Siedlerchr Oct 10, 2021
6aad7f2
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Nov 19, 2021
498a8e9
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Nov 30, 2021
bc04a98
Switch to 3.x dev of apollo, get rid of custom jpms hacks
Siedlerchr Nov 30, 2021
21749cd
use new builder
Siedlerchr Nov 30, 2021
2762345
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Dec 20, 2021
366ccfc
Update deps
Siedlerchr Dec 20, 2021
d5d93a5
checkstyle
Siedlerchr Dec 20, 2021
f7bd3b0
Merge remote-tracking branch 'origin/main' into jabrefonline
tobiasdiez Oct 9, 2022
253b0bd
migrate to new apollo java runtime
tobiasdiez Oct 9, 2022
1d4e527
Download schema before trying to generate apollo sources
tobiasdiez Oct 11, 2022
959ac3c
fix tests
tobiasdiez Oct 12, 2022
f9d4f11
use ZonedDateTime
tobiasdiez Oct 13, 2022
669057d
add metadata for jabrefonline
tobiasdiez Oct 13, 2022
8f1c593
add prefs and basic connect to remote account
tobiasdiez Oct 18, 2022
b73458c
Add pulling of changes
tobiasdiez Oct 20, 2022
6de67ae
implement merge
tobiasdiez Oct 21, 2022
4ea7fc1
add remote revision info
tobiasdiez Oct 21, 2022
8435d96
Extend transformer
tobiasdiez Oct 21, 2022
d8f7385
fix login check
tobiasdiez Oct 21, 2022
8c2ed8f
Add push method
tobiasdiez Oct 23, 2022
98eacae
fix build
tobiasdiez Oct 25, 2022
8f7e0dd
add tests
tobiasdiez Oct 25, 2022
34c4cab
fix tests
tobiasdiez Oct 28, 2022
9fcbf4b
Print snapshots as json
tobiasdiez Nov 3, 2022
3bf8381
Rename package to "online"
tobiasdiez Nov 13, 2022
2ac1fb0
Merge remote-tracking branch 'origin/main' into jabrefonline
tobiasdiez Nov 13, 2022
d60436c
improve transformer
tobiasdiez Nov 13, 2022
7081430
remove unnecessary tests
tobiasdiez Nov 13, 2022
e4b56e9
Merge branch 'main' into jabrefonline
Siedlerchr Dec 16, 2022
7631a53
Merge remote-tracking branch 'upstream/main' into jabrefonline
Siedlerchr Nov 4, 2023
efb6af7
fix build
Siedlerchr Nov 4, 2023
3297b0d
fix buid
Siedlerchr Nov 4, 2023
0b07797
checkstyle
Siedlerchr Nov 4, 2023
b67afb8
Merge branch 'main' into jabrefonline
Siedlerchr Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Expand Up @@ -21,7 +21,7 @@
}
},

"onCreateCommand": "gradle assemble",
"onCreateCommand": "gradle assemble || true",

// Need to connect as root otherwise we run into issues with gradle.
// default option is "vscode". More info: https://aka.ms/vscode-remote/containers/non-root.
Expand Down
32 changes: 31 additions & 1 deletion build.gradle
Expand Up @@ -27,6 +27,8 @@ plugins {
id 'project-report'

id 'idea'
// JabRef Online GraphQL client integration
id 'com.apollographql.apollo3' version '3.7.0-SNAPSHOT'
}

// Enable following for debugging
Expand Down Expand Up @@ -81,6 +83,7 @@ repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/groups/public' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://jitpack.io' }
}

Expand Down Expand Up @@ -204,6 +207,9 @@ dependencies {

implementation group: 'net.harawata', name: 'appdirs', version: '1.2.1'

implementation group: 'com.apollographql.apollo3', name: 'apollo-runtime-java', version: '3.7.0-SNAPSHOT'
implementation group: 'com.apollographql.apollo3', name: 'apollo-rx3-support-java', version: '3.7.0-SNAPSHOT'

testImplementation 'io.github.classgraph:classgraph:4.8.149'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
testImplementation 'org.junit.platform:junit-platform-launcher:1.9.1'
Expand All @@ -217,6 +223,11 @@ dependencies {
testImplementation "org.testfx:testfx-junit5:4.0.16-alpha"
testImplementation "org.hamcrest:hamcrest-library:2.2"

testImplementation 'io.github.origin-energy:java-snapshot-testing-junit5:3.2.+'
testImplementation 'io.github.origin-energy:java-snapshot-testing-plugin-jackson:3.2.+'
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.11.3'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.11.3'

checkstyle 'com.puppycrawl.tools:checkstyle:10.3.4'
// xjc needs the runtime as well for the ant task, otherwise it fails
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2'
Expand Down Expand Up @@ -264,7 +275,8 @@ task generateSource(dependsOn: ["generateBstGrammarSource",
"generateBibtexmlSource",
"generateEndnoteSource",
"generateModsSource",
"generateCitaviSource"]) {
"generateCitaviSource",
"generateApolloSources"]) {
group = 'JabRef'
description 'Generates all necessary (Java) source files.'
}
Expand Down Expand Up @@ -349,6 +361,24 @@ task generateJournalAbbreviationList(type: JournalAbbreviationConverter) {
outputDir = file("src/main/resources/journals")
}

apollo {
packageName = "org.jabref.jabrefonline"
schemaFile = file("src-gen/main/java/org/jabref/jabrefonline/graphql/schema.json")
mapScalar("DateTime", "java.time.ZonedDateTime", "org.jabref.logic.jabrefonline.JavaZonedDateTimeAdapter.INSTANCE")
generateModelBuilder = true
introspection {
endpointUrl = "https://mango-pebble-0224c3803-dev.westeurope.1.azurestaticapps.net/api"
}
}

tasks.whenTaskAdded { task ->
// Download schema before trying to generate apollo sources
if (task.name.contains("generateServiceApolloSources")) {
task.dependsOn 'downloadServiceApolloSchemaFromIntrospection'
}
}


tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Expand Down
Expand Up @@ -49,7 +49,7 @@ class XjcTask extends DefaultTask {
if (outputDirectory == null) {
return null
}
return project.file(outputDirectory)
return project.file(outputDirectory + "/" + javaPackage.replace(".", "/"))
}

void setOutputDirectory(Object outputDirectory) {
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Expand Up @@ -3,6 +3,9 @@ pluginManagement {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
gradlePluginPortal()
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/graphql/Login.graphql
@@ -0,0 +1,15 @@
mutation Login($input: LoginInput!) {
login(input: $input) {
... on UserReturned {
user {
id
}
}
... on InputValidationProblem {
problems {
path
message
}
}
}
}
88 changes: 88 additions & 0 deletions src/main/graphql/UserChanges.graphql
@@ -0,0 +1,88 @@
fragment allDetails on Entity {
... on Person {
id
family
given
suffix
nonDroppingParticle
droppingParticle
}
... on Organization {
id
name
}
}

query UserChanges($id: ID!) {
user(id: $id) {
id
changes {
edges {
node {
id
citationKeys
lastModified
added
title
subtitle
titleAddon
abstract
authors {
...allDetails
}
note
languages
publicationState
doi
keywords
... on JournalArticle {
in {
id
journal {
id
name
subtitle
titleAddon
issn
}
title
subtitle
titleAddon
number
name
series
volume
}
pageStart
pageEnd
electronicId
translated {
translators {
...allDetails
}
originalLanguages
}
published
annotators {
...allDetails
}
commentators {
...allDetails
}
}
}
revision {
generation
hash
}
}
pageInfo {
hasNextPage
endCursor {
id
lastModified
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/main/graphql/addUserDocument.graphql
@@ -0,0 +1,5 @@
mutation addUserDocument($addUserDocumentInput: AddUserDocumentInput!) {
addUserDocument(input: $addUserDocumentInput) {
id
}
}
27 changes: 27 additions & 0 deletions src/main/graphql/getDocumentById.graphql
@@ -0,0 +1,27 @@
query getDocumentById($userDocumentId: ID!) {
userDocument(id: $userDocumentId){
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
File contains tab characters (this is the first instance).

id
citationKeys
lastModified
added
title
subtitle
titleAddon
abstract
authors {
... on Person {
family
id
}
... on Organization {
id
name
}
}
note
languages
publicationState
keywords

}
}
7 changes: 7 additions & 0 deletions src/main/java/module-info.java
Expand Up @@ -115,6 +115,13 @@
requires com.fasterxml.jackson.datatype.jsr310;
requires net.harawata.appdirs;

requires com.apollographql.apollo3.api;
requires com.apollographql.apollo3.runtime.java;
requires com.apollographql.apollo3.rx3.java;
// TOOD: Remove this dependency once apollo is fully migrated
requires kotlin.stdlib;
requires io.reactivex.rxjava3;

requires org.eclipse.jgit;
uses org.eclipse.jgit.transport.SshSessionFactory;
uses org.eclipse.jgit.lib.GpgSigner;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/DefaultInjector.java
Expand Up @@ -8,6 +8,7 @@
import org.jabref.gui.theme.ThemeManager;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.importer.ImportFormatReader;
import org.jabref.logic.jabrefonline.RemoteService;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.model.entry.BibEntryTypesManager;
Expand Down Expand Up @@ -35,6 +36,8 @@ private static Object createDependency(Class<?> clazz) {
return Globals.TASK_EXECUTOR;
} else if (clazz == PreferencesService.class) {
return Globals.prefs;
} else if (clazz == RemoteService.class) {
return new RemoteService(Globals.prefs);
} else if (clazz == KeyBindingRepository.class) {
return Globals.getKeyPrefs();
} else if (clazz == JournalAbbreviationRepository.class) {
Expand Down
Expand Up @@ -28,6 +28,8 @@
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>

<Label styleClass="sectionHeader" text="%General"
Expand All @@ -41,15 +43,19 @@
<ComboBox fx:id="databaseMode" prefWidth="150.0"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2"/>

<Label styleClass="sectionHeader" text="%Override default file directories"
<Label styleClass="sectionHeader" text="%JabRef Account"
GridPane.columnSpan="3" GridPane.rowIndex="3"/>
<Button onAction="#connectJabRefAccount" text="%Connect" GridPane.columnIndex="1" GridPane.rowIndex="4"/>

<Label styleClass="sectionHeader" text="%Override default file directories"
GridPane.columnSpan="3" GridPane.rowIndex="5"/>
<Label text="%General file directory"
GridPane.columnIndex="0" GridPane.rowIndex="4"/>
GridPane.columnIndex="0" GridPane.rowIndex="6"/>
<TextField fx:id="generalFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="4"/>
GridPane.columnIndex="1" GridPane.rowIndex="6"/>
<Button onAction="#browseGeneralFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="4">
GridPane.columnIndex="2" GridPane.rowIndex="6">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
Expand All @@ -59,12 +65,12 @@
</Button>

<Label text="%User-specific file directory"
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
GridPane.columnIndex="0" GridPane.rowIndex="7"/>
<TextField fx:id="userSpecificFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="5"/>
GridPane.columnIndex="1" GridPane.rowIndex="7"/>
<Button onAction="#browseUserSpecificFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="5">
GridPane.columnIndex="2" GridPane.rowIndex="7">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
Expand All @@ -74,12 +80,12 @@
</Button>

<Label text="%LaTeX file directory"
GridPane.columnIndex="0" GridPane.rowIndex="6"/>
GridPane.columnIndex="0" GridPane.rowIndex="8"/>
<TextField fx:id="laTexFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="6"/>
GridPane.columnIndex="1" GridPane.rowIndex="8"/>
<Button onAction="#browseLatexFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="6">
GridPane.columnIndex="2" GridPane.rowIndex="8">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
Expand Down
Expand Up @@ -12,6 +12,7 @@
import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
import org.jabref.gui.libraryproperties.PropertiesTab;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.jabrefonline.RemoteService;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
Expand All @@ -30,6 +31,7 @@ public class GeneralPropertiesView extends AbstractPropertiesTabView<GeneralProp

@Inject private PreferencesService preferencesService;
@Inject private UndoManager undoManager;
@Inject private RemoteService remoteService;

public GeneralPropertiesView(BibDatabaseContext databaseContext) {
this.databaseContext = databaseContext;
Expand All @@ -45,7 +47,7 @@ public String getTabName() {
}

public void initialize() {
this.viewModel = new GeneralPropertiesViewModel(databaseContext, dialogService, preferencesService, undoManager);
this.viewModel = new GeneralPropertiesViewModel(databaseContext, dialogService, preferencesService, remoteService, undoManager);

new ViewModelListCellFactory<Charset>()
.withText(Charset::displayName)
Expand Down Expand Up @@ -81,4 +83,9 @@ public void browseUserSpecificFileDirectory() {
void browseLatexFileDirectory() {
viewModel.browseLatexDir();
}

@FXML
void connectJabRefAccount() {
viewModel.connectJabRefAccount();
}
}