Skip to content

Commit c65ed21

Browse files
authored
Merge pull request #7 from JPL-Devin/devin/1776584030-upgrade-jena-6.0.0
Upgrade Apache Jena from 4.10.0 to 6.0.0
2 parents 03faac9 + 44a3a86 commit c65ed21

5 files changed

Lines changed: 29 additions & 15 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM openjdk:17.0.2-jdk-slim as build
1+
FROM eclipse-temurin:21-jdk as build
22
WORKDIR application
33
COPY . .
44
RUN ./gradlew installDist
55

6-
FROM openjdk:17.0.2-jdk-slim
6+
FROM eclipse-temurin:21-jre
77
WORKDIR application
88
RUN apt-get update && apt-get install -y procps
99
COPY --from=build application/build/install/org.openmbee.flexo.mms.layer1/ .

build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ repositories {
2828
mavenCentral()
2929
}
3030

31+
jacoco {
32+
toolVersion = "0.8.12"
33+
}
34+
3135
tasks.withType<Test>().configureEach {
3236
useJUnitPlatform()
3337
}
@@ -49,7 +53,7 @@ dependencies {
4953
val kotlinxJsonVersion = "1.8.1"
5054
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxJsonVersion")
5155

52-
val jenaVersion = "4.10.0"
56+
val jenaVersion = "6.0.0"
5357
implementation("org.apache.jena:jena-arq:${jenaVersion}")
5458
testImplementation("org.apache.jena:jena-rdfconnection:${jenaVersion}");
5559
testFuseki("org.apache.jena:jena-fuseki-server:$jenaVersion")
@@ -140,5 +144,5 @@ compileKotlin.compilerOptions {
140144
}
141145

142146
kotlin {
143-
jvmToolchain(17)
144-
}
147+
jvmToolchain(21)
148+
}

src/main/kotlin/org/openmbee/flexo/mms/Compressor.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.openmbee.flexo.mms
22

3-
import org.apache.jena.atlas.lib.Trie
43
import org.apache.jena.rdf.model.Model
54

65
fun c1Subject() {
@@ -10,7 +9,7 @@ fun c1Subject() {
109
private val COMPRESS_IRI = """(.*?)([^/#]*)""".toRegex()
1110

1211
class Compressor {
13-
var prefixes: Trie<Int> = Trie()
12+
var prefixes: HashMap<String, Int> = HashMap()
1413
var prefixCount = 0
1514

1615
fun load(model: Model) {
@@ -21,10 +20,10 @@ class Compressor {
2120
val subjectIri = subject.uri
2221
val (prefix, suffix) = COMPRESS_IRI.matchEntire(subjectIri)!!.destructured
2322

24-
var prefixId: Int? = prefixes.get(prefix)
23+
var prefixId: Int? = prefixes[prefix]
2524
if(prefixId == null) {
2625
prefixId = prefixCount++
27-
prefixes.add(prefix, prefixId)
26+
prefixes[prefix] = prefixId
2827
}
2928

3029
subjectC1 = ">"+prefixId.toChar().toString()+suffix
@@ -36,4 +35,4 @@ class Compressor {
3635
// prefixes[]
3736
}
3837
}
39-
}
38+
}

src/main/kotlin/org/openmbee/flexo/mms/Content.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.apache.jena.riot.Lang
1616
import org.apache.jena.riot.RDFLanguages
1717
import org.apache.jena.riot.RDFParser
1818
import org.apache.jena.riot.system.ErrorHandlerFactory
19-
import org.apache.jena.riot.system.PrefixMapAdapter
19+
import org.apache.jena.riot.system.PrefixMapFactory
2020
import java.nio.charset.StandardCharsets
2121

2222
val COMMA_SEPARATED = """\s*,\s*""".toRegex()
@@ -147,7 +147,7 @@ fun ApplicationCall.negotiateRdfResponseContentType(): ContentType {
147147
return destinationType
148148
}
149149

150-
class KModel(val prefixes: PrefixMapBuilder=PrefixMapBuilder(), setup: (KModel.() -> Unit)?=null): ModelCom(GraphMemFactory.createGraphMem()) {
150+
class KModel(val prefixes: PrefixMapBuilder=PrefixMapBuilder(), setup: (KModel.() -> Unit)?=null): ModelCom(GraphMemFactory.createDefaultGraph()) {
151151
companion object {
152152
fun fromModel(model: Model): KModel {
153153
return KModel().apply {
@@ -212,7 +212,7 @@ class KModel(val prefixes: PrefixMapBuilder=PrefixMapBuilder(), setup: (KModel.(
212212
fun parseRdf(language: Lang, body: String, model: Model, baseIri: String?=null, prefixes: PrefixMapBuilder?=null) {
213213
// parse input document
214214
RDFParser.create().apply {
215-
prefixes?.let {prefixes(PrefixMapAdapter(it.toPrefixMappings())) }
215+
prefixes?.let {prefixes(PrefixMapFactory.create(it.toPrefixMappings())) }
216216
lang(language)
217217
errorHandler(ErrorHandlerFactory.errorHandlerWarn)
218218
if(baseIri != null) base(baseIri)

src/main/kotlin/org/openmbee/flexo/mms/UpdateRewriter.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import org.apache.jena.shared.PrefixMapping
88
import org.apache.jena.shared.impl.PrefixMappingImpl
99
import org.apache.jena.sparql.core.Quad
1010
import org.apache.jena.sparql.syntax.*
11-
import org.checkerframework.checker.units.qual.Prefix
1211

1312
class RequirementsNotMetException(conditions: List<String>): Http400Exception("The following conditions failed after the transaction attempt:\n"
1413
+conditions.mapIndexed { i, v -> "${i}. $v" }.joinToString("\n"))
@@ -86,6 +85,18 @@ object NoQuadsElementVisitor: ElementVisitor {
8685
override fun visit(el: ElementLateral?) {
8786
throw SparqlFeatureNotSupportedException("LATERAL keyword not standardized")
8887
}
88+
89+
override fun visit(el: ElementUnfold?) {
90+
throw SparqlFeatureNotSupportedException("UNFOLD keyword not supported")
91+
}
92+
93+
override fun visit(el: ElementSemiJoin?) {
94+
throw SparqlFeatureNotSupportedException("SEMI JOIN not supported")
95+
}
96+
97+
override fun visit(el: ElementAntiJoin?) {
98+
throw SparqlFeatureNotSupportedException("ANTI JOIN not supported")
99+
}
89100
}
90101

91102
fun assertNoQuads(element: Element1?) {
@@ -100,7 +111,7 @@ fun assertNoQuads(elements: List<Element>?) {
100111

101112

102113
fun asSparqlGroup(mapping: PrefixMapping?=null, vararg elements: Element): String {
103-
return QueryFactory.make().apply {
114+
return QueryFactory.create().apply {
104115
setQueryAskType()
105116
if(mapping != null) prefixMapping = mapping
106117
queryPattern = ElementGroup().apply {

0 commit comments

Comments
 (0)