Skip to content

Commit 85c673b

Browse files
committed
Core SNAPSHOT bump
Jena version bump to 6.0.0
1 parent 201665f commit 85c673b

6 files changed

Lines changed: 125 additions & 13 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM maven:3.8.4-openjdk-17 AS maven
1+
FROM maven:3.9-eclipse-temurin-21 AS maven
22

33
# download and extract Jena
44

src/main/java/com/atomgraph/linkeddatahub/client/SesameProtocolClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static MultivaluedMap<String, String> solutionMapToMultivaluedMap(QuerySo
123123
{
124124
String varName = it.next();
125125
RDFNode node = qsm.get(varName);
126-
params.add("$" + varName, NodeFmtLib.str(node.asNode()));
126+
params.add("$" + varName, NodeFmtLib.strNT(node.asNode()));
127127
}
128128

129129
return params;

src/main/java/com/atomgraph/linkeddatahub/resource/Namespace.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@
4646
import jakarta.ws.rs.core.Response.Status;
4747
import jakarta.ws.rs.core.SecurityContext;
4848
import jakarta.ws.rs.core.UriInfo;
49-
import org.apache.jena.iri.IRI;
50-
import org.apache.jena.iri.IRIFactory;
49+
import org.apache.jena.irix.IRIx;
5150
import org.apache.jena.ontology.Ontology;
5251
import org.apache.jena.query.DatasetFactory;
5352
import org.apache.jena.query.Query;
5453
import org.apache.jena.rdf.model.Model;
5554
import org.apache.jena.rdf.model.ModelFactory;
56-
import org.apache.jena.riot.system.Checker;
5755
import org.apache.jena.update.UpdateRequest;
5856
import org.slf4j.Logger;
5957
import org.slf4j.LoggerFactory;
@@ -177,15 +175,12 @@ public Response post(UpdateRequest update, @QueryParam(USING_GRAPH_URI) List<URI
177175
* @param classIRIStr URI string
178176
* @return IRI
179177
*/
180-
public static IRI checkURI(String classIRIStr)
178+
public static IRIx checkURI(String classIRIStr)
181179
{
182180
if (classIRIStr == null) throw new IllegalArgumentException("URI String cannot be null");
183181

184-
IRI classIRI = IRIFactory.iriImplementation().create(classIRIStr);
185-
// throws Exceptions on bad URIs:
186-
Checker.iriViolations(classIRI);
187-
188-
return classIRI;
182+
// IRIx.create() validates and throws IRIException on bad URIs
183+
return IRIx.create(classIRIStr);
189184
}
190185

191186
/**

src/main/java/com/atomgraph/linkeddatahub/server/filter/request/OntologyFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public Ontology getOntology(Application app, String uri)
173173
URI ontologyURI = URI.create(uri);
174174
// remove fragment and normalize
175175
URI ontDocURI = new URI(ontologyURI.getScheme(), ontologyURI.getSchemeSpecificPart(), null).normalize();
176-
Model baseModel = fileManager.loadModel(uri, ontDocURI.toString(), null);
176+
Model baseModel = fileManager.loadModel(ontDocURI.toString());
177177
OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec, baseModel);
178178
ontModel.getDocumentManager().addModel(uri, ontModel, true);
179179
}

src/main/java/com/atomgraph/linkeddatahub/server/util/OntologyModelGetter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* Application's ontology model getter.
3535
* Loads ontology model using the configured ontology query
3636
*/
37-
public class OntologyModelGetter implements org.apache.jena.rdf.model.ModelGetter
37+
public class OntologyModelGetter implements org.apache.jena.ontology.models.ModelGetter
3838
{
3939

4040
private static final Logger log = LoggerFactory.getLogger(OntologyModelGetter.class);
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2025 Martynas Jusevičius <martynas@atomgraph.com>.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.atomgraph.linkeddatahub.writer.function;
17+
18+
import java.io.StringWriter;
19+
import java.net.URI;
20+
import net.sf.saxon.s9api.Processor;
21+
import net.sf.saxon.s9api.Serializer;
22+
import net.sf.saxon.s9api.XdmAtomicValue;
23+
import net.sf.saxon.s9api.XdmMap;
24+
import net.sf.saxon.s9api.XdmValue;
25+
import org.apache.jena.query.QueryParseException;
26+
import org.apache.jena.rdf.model.Model;
27+
import org.apache.jena.rdf.model.ModelFactory;
28+
import org.apache.jena.vocabulary.RDF;
29+
import org.junit.Before;
30+
import org.junit.Test;
31+
import static org.junit.Assert.*;
32+
33+
/**
34+
* Unit tests for the {@link Construct} Saxon extension function.
35+
*
36+
* @author Martynas Jusevičius {@literal <martynas@atomgraph.com>}
37+
*/
38+
public class ConstructTest
39+
{
40+
41+
public static final String CLASS_URI = "http://test/ontology#MyClass";
42+
public static final String PROP_URI = "http://test/ontology#prop";
43+
public static final String VALUE_URI = "http://test/value";
44+
45+
public static final String CONSTRUCT_QUERY =
46+
"CONSTRUCT { ?this <" + PROP_URI + "> <" + VALUE_URI + "> } WHERE {}";
47+
48+
private Processor processor;
49+
private Construct construct;
50+
51+
@Before
52+
public void setUp()
53+
{
54+
processor = new Processor(false);
55+
construct = new Construct(processor);
56+
}
57+
58+
private XdmMap buildMap(String classUri, String... queries) throws Exception
59+
{
60+
XdmMap map = new XdmMap();
61+
XdmAtomicValue key = new XdmAtomicValue(new URI(classUri));
62+
XdmValue value = new XdmValue(java.util.Arrays.stream(queries)
63+
.map(XdmAtomicValue::new)
64+
.collect(java.util.stream.Collectors.toList()));
65+
return map.put(key, value);
66+
}
67+
68+
private Model parseResult(XdmValue result) throws Exception
69+
{
70+
StringWriter sw = new StringWriter();
71+
Serializer ser = processor.newSerializer(sw);
72+
ser.serializeXdmValue(result);
73+
Model model = ModelFactory.createDefaultModel();
74+
model.read(new java.io.StringReader(sw.toString()), null, "RDF/XML");
75+
return model;
76+
}
77+
78+
@Test
79+
public void testConstruct() throws Exception
80+
{
81+
XdmValue result = construct.call(new XdmValue[] { buildMap(CLASS_URI, CONSTRUCT_QUERY) });
82+
Model model = parseResult(result);
83+
84+
assertTrue(model.contains(null, RDF.type, model.createResource(CLASS_URI)));
85+
assertTrue(model.contains(null, model.createProperty(PROP_URI), model.createResource(VALUE_URI)));
86+
}
87+
88+
@Test
89+
public void testMultipleConstructors() throws Exception
90+
{
91+
String prop2 = "http://test/ontology#prop2";
92+
String value2 = "http://test/value2";
93+
String query2 = "CONSTRUCT { ?this <" + prop2 + "> <" + value2 + "> } WHERE {}";
94+
95+
XdmValue result = construct.call(new XdmValue[] { buildMap(CLASS_URI, CONSTRUCT_QUERY, query2) });
96+
Model model = parseResult(result);
97+
98+
assertTrue(model.contains(null, model.createProperty(PROP_URI), model.createResource(VALUE_URI)));
99+
assertTrue(model.contains(null, model.createProperty(prop2), model.createResource(value2)));
100+
}
101+
102+
@Test
103+
public void testEmptyMap() throws Exception
104+
{
105+
XdmValue result = construct.call(new XdmValue[] { new XdmMap() });
106+
Model model = parseResult(result);
107+
108+
assertTrue(model.isEmpty());
109+
}
110+
111+
@Test(expected = QueryParseException.class)
112+
public void testInvalidSparql() throws Exception
113+
{
114+
construct.call(new XdmValue[] { buildMap(CLASS_URI, "NOT VALID SPARQL") });
115+
}
116+
117+
}

0 commit comments

Comments
 (0)