Skip to content

Commit 997da52

Browse files
namedgraphclaude
andauthored
Jena 6 ont-api (#316)
* Migrate vocabularies to Jena ontapi; add ontology characterization tests - Bump client dependency to 4.3.1-SNAPSHOT (pulls jena-ontapi transitively via Core) - Migrate 19 vocabularies off the deprecated-for-removal org.apache.jena.ontology API to org.apache.jena.ontapi (OntModelFactory/OntSpecification), with a top-of-class static JenaSystem.init() guard (ontapi NPEs if a vocab class is the first Jena touch) - Add characterization tests pinning current ontology behavior so the migration can be proven to retain it: imports closure + RDFS materialization, dual-key cache (addDocumentModel), SPARQL-first resolution (OntologyModelGetter), vocab triples Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Phase D: dissolve DataManager + migrate ontology pipeline to ontapi Completes the dissolution in LinkedDataHub (0 [removal] warnings, was ~90): - DataManagerImpl -> SameSiteSourceResolver (RDFSourceResolver subclass, same-site restriction) - OntologyModelGetter -> OntologyRepository (SPARQL-first PrefixGraphRepository subclass) - DataManagerFactory -> SourceResolverFactory (provides request-scoped RDFSourceResolver) - Application: per-app OntModelSpec/OntDocumentManager -> per-app OntologyRepository; global repository + resolver; remove PrefixMapper/LocationMapper/OntDocumentManager wiring - OntologyFilter/ClearOntology: ontapi OntModelFactory.createModel with OWL2_DL_MEM_RDFS_INF + materialize into OWL2_DL_MEM cached in the repository; dual-key import-closure caching preserved - request ontology property Optional<Ontology> -> Optional<OntModel> (ontapi) across OntologyFactory + ~8 consumers (.getOntModel() dropped) - Validator, ProxyRequestFilter, ValidatingModelProvider, Install/UninstallPackage: DataManager/OntModelSpec cache ops -> repository - characterization tests adapted to new API (OntologyRepositoryTest, OntologyFilterTest); 69 tests green Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix OntologyFilter: flatten owl:imports closure manually, not via ontapi union-graph repository OntModelFactory.createModel(graph, spec, repository) registers graphs in an OntUnionGraphRepository keyed by ontology ID, which collided with the same graph already in our flat PrefixGraphRepository cache (OntJenaException: 'Another graph with name <...#> is already in the hierarchy', thrown at runtime on the first /ns request). Replace it with explicit owl:imports closure traversal (loadClosure) that unions the base + imports into one graph, runs RDFS inference over that, and materializes — so createModel is only ever called WITHOUT a repository (no union-hierarchy registration). Encapsulates the duplicated OntologyFilter/ClearOntology load logic into OntologyFilter.loadOntology. OntologyImportsCharacterizationTest now exercises loadOntology and asserts the materialized closure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix empty constructed response: use OWL1_FULL_MEM so rdfs:Class is recognized GET /ns?forClass=...#Item returned an empty graph: dh:Item is declared 'a rdfs:Class' (dh.ttl), and the ontapi OWL2_DL_MEM profile I'd used does not recognize rdfs:Class as an OntClass, so Namespace's getOntClass(uri) returned null and no SPIN constructor ran. Legacy OntModelSpec.OWL_MEM is OWL 1 Full (recognizes rdfs:Class); the correct ontapi mapping is OWL1_FULL_MEM, not OWL2_DL_MEM. Applied across OntologyFilter pipeline + all vocab holders. OntologyImportsCharacterizationTest now guards getOntClass(rdfs:Class) != null. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Use twirl 1.2.0-SNAPSHOT; drop redundant SPIN personality registration twirl 1.2.0 re-bases the constraint model onto its own SPIN personality, so the ontapi ontology model can be passed straight to SPINConstraints.check; LDH no longer needs to register SPIN into the global personality. - twirl 1.1.0 -> 1.2.0-SNAPSHOT - Remove SP.init(BuiltinPersonalities.model) from Application (Web-Client Constructor reads sp:text directly; nothing else needed the global registration) - Add SPINConstraintValidationTest: guards the Validator path and the raw-ontapi-via-twirl-rebase path Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: re-run against deployed twirl/core snapshots * ci: re-run against deployed twirl/core snapshots * Normalize ontologies to owl:Class; use OWL2_FULL_MEM profile The document/LDT/ACL ontology classes were declared bare rdfs:Class, which no OWL2 ontapi profile recognizes as an OntClass — forcing OWL1_FULL_MEM (which in turn bans named individuals, breaking SD). Declare them owl:Class (dual with rdfs:Class) and switch all OntSpecification usages from OWL1_FULL_MEM to OWL2_FULL_MEM, so getOntClass/forClass works and named individuals are allowed. - dh.ttl/ldt.ttl/lacl.ttl: class declarations now 'a rdfs:Class, owl:Class' - vocab holders + OntologyFilter + ConstructForClass: OWL1_FULL_MEM -> OWL2_FULL_MEM - remove dead 'import com.atomgraph.client.locator.PrefixMapper' (deleted in Web-Client) - OntologyImportsCharacterizationTest: assert owl:Class (not rdfs:Class) is recognized Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add debug output to add-property-constraint and GET-proxied-ontology-ns tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Removed debug output * Tests for RDFS ontology imports * Promote rdfs:Class to owl:Class during ontology materialization OWL2 profiles do not recognise bare rdfs:Class as OntClass, so third-party vocab terms declared only as rdfs:Class (e.g. sp:Describe in sp.ttl) were invisible to getOntClass() lookups, returning empty forClass constructor responses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Repoint PrefixGraphRepository import to Web-Client; replace deprecated Model.write with RDFWriter - Update imports to com.atomgraph.client.util.jena.PrefixGraphRepository (moved out of Core): Application, OntologyFilter, OntologyRepository, SourceResolverFactory, SameSiteSourceResolver + tests - XSLTWriterBase: use RDFWriter instead of deprecated Model.write, keeping plain RDF/XML Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * SNAPSHOT bump --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1bff739 commit 997da52

51 files changed

Lines changed: 1264 additions & 828 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
initialize_dataset "$END_USER_BASE_URL" "$TMP_END_USER_DATASET" "$END_USER_ENDPOINT_URL"
5+
initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL"
6+
purge_cache "$END_USER_VARNISH_SERVICE"
7+
purge_cache "$ADMIN_VARNISH_SERVICE"
8+
purge_cache "$FRONTEND_VARNISH_SERVICE"
9+
10+
# sp:Describe is declared only as rdfs:Class (not owl:Class) in sp.ttl.
11+
# OntologyFilter must promote rdfs:Class to owl:Class during materialization so
12+
# that OWL2 profiles recognise third-party vocab terms and return their SPIN constructors.
13+
14+
response=$(curl -k -f -s \
15+
-G \
16+
-E "$OWNER_CERT_FILE":"$OWNER_CERT_PWD" \
17+
-H "Accept: application/rdf+xml" \
18+
--data-urlencode "forClass=http://spinrdf.org/sp#Describe" \
19+
"${END_USER_BASE_URL}ns")
20+
21+
# response must be non-empty: sp:Describe must be recognised as an OntClass
22+
echo "$response" | grep -q "http://spinrdf.org/sp#Describe"

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.atomgraph</groupId>
55
<artifactId>linkeddatahub</artifactId>
6-
<version>5.5.4-SNAPSHOT</version>
6+
<version>5.6.0-SNAPSHOT</version>
77
<packaging>${packaging.type}</packaging>
88

99
<name>AtomGraph LinkedDataHub</name>
@@ -146,7 +146,7 @@
146146
<dependency>
147147
<groupId>${project.groupId}</groupId>
148148
<artifactId>twirl</artifactId>
149-
<version>1.1.0</version>
149+
<version>1.2.0-SNAPSHOT</version>
150150
<exclusions>
151151
<!-- exclude slf4j-reload4j 1.7.x binding; replaced below with 2.0.x matching slf4j-api from Jena -->
152152
<exclusion>
@@ -163,13 +163,13 @@
163163
<dependency>
164164
<groupId>${project.groupId}</groupId>
165165
<artifactId>client</artifactId>
166-
<version>4.3.0</version>
166+
<version>4.4.0-SNAPSHOT</version>
167167
<classifier>classes</classifier>
168168
</dependency>
169169
<dependency>
170170
<groupId>${project.groupId}</groupId>
171171
<artifactId>client</artifactId>
172-
<version>4.3.0</version>
172+
<version>4.4.0-SNAPSHOT</version>
173173
<type>war</type>
174174
</dependency>
175175
<dependency>

src/main/java/com/atomgraph/linkeddatahub/Application.java

Lines changed: 68 additions & 87 deletions
Large diffs are not rendered by default.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import jakarta.ws.rs.core.Response.Status;
4343
import jakarta.ws.rs.core.UriBuilder;
4444
import jakarta.ws.rs.core.UriInfo;
45-
import org.apache.jena.ontology.Ontology;
45+
import org.apache.jena.ontapi.model.OntModel;
4646
import org.apache.jena.query.ParameterizedSparqlString;
4747
import org.apache.jena.query.Query;
4848
import org.apache.jena.query.QueryFactory;
@@ -69,7 +69,7 @@ public class Generate
6969
private final UriInfo uriInfo;
7070
private final MediaTypes mediaTypes;
7171
private final Application application;
72-
private final Ontology ontology;
72+
private final OntModel ontology;
7373
private final Optional<AgentContext> agentContext;
7474
private final com.atomgraph.linkeddatahub.Application system;
7575
private final ResourceContext resourceContext;
@@ -88,7 +88,7 @@ public class Generate
8888
*/
8989
@Inject
9090
public Generate(@Context Request request, @Context UriInfo uriInfo, MediaTypes mediaTypes,
91-
com.atomgraph.linkeddatahub.apps.model.Application application, Optional<Ontology> ontology, Optional<AgentContext> agentContext,
91+
com.atomgraph.linkeddatahub.apps.model.Application application, Optional<OntModel> ontology, Optional<AgentContext> agentContext,
9292
com.atomgraph.linkeddatahub.Application system, @Context ResourceContext resourceContext)
9393
{
9494
if (ontology.isEmpty()) throw new InternalServerErrorException("Ontology is not specified");
@@ -134,7 +134,7 @@ public Response post(Model model)
134134
if (queryRes == null) throw new BadRequestException("Container query string (spin:query) not provided");
135135

136136
// Lookup query in ontology
137-
Resource queryResource = getOntology().getOntModel().getResource(queryRes.getURI());
137+
Resource queryResource = getOntology().getResource(queryRes.getURI());
138138
if (queryResource == null || !queryResource.hasProperty(SP.text))
139139
throw new BadRequestException("Query resource not found in ontology: " + queryRes.getURI());
140140

@@ -265,7 +265,7 @@ public Application getApplication()
265265
*
266266
* @return the ontology
267267
*/
268-
public Ontology getOntology()
268+
public OntModel getOntology()
269269
{
270270
return ontology;
271271
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import com.atomgraph.core.model.impl.dataset.ServiceImpl;
3232
import com.atomgraph.linkeddatahub.apps.model.Application;
3333
import com.atomgraph.linkeddatahub.apps.model.EndUserApplication;
34-
import com.atomgraph.linkeddatahub.server.util.OntologyModelGetter;
34+
import com.atomgraph.linkeddatahub.server.util.OntologyRepository;
3535
import java.net.URI;
3636
import java.util.List;
3737
import java.util.Optional;
@@ -47,7 +47,7 @@
4747
import jakarta.ws.rs.core.SecurityContext;
4848
import jakarta.ws.rs.core.UriInfo;
4949
import org.apache.jena.irix.IRIx;
50-
import org.apache.jena.ontology.Ontology;
50+
import org.apache.jena.ontapi.model.OntModel;
5151
import org.apache.jena.query.DatasetFactory;
5252
import org.apache.jena.query.Query;
5353
import org.apache.jena.query.QueryFactory;
@@ -70,7 +70,7 @@ public class Namespace extends com.atomgraph.core.model.impl.SPARQLEndpointImpl
7070
private final URI uri;
7171
private final UriInfo uriInfo;
7272
private final Application application;
73-
private final Ontology ontology;
73+
private final OntModel ontology;
7474
private final com.atomgraph.linkeddatahub.Application system;
7575

7676
/**
@@ -86,10 +86,10 @@ public class Namespace extends com.atomgraph.core.model.impl.SPARQLEndpointImpl
8686
*/
8787
@Inject
8888
public Namespace(@Context Request request, @Context UriInfo uriInfo,
89-
Application application, Optional<Ontology> ontology, MediaTypes mediaTypes,
89+
Application application, Optional<OntModel> ontology, MediaTypes mediaTypes,
9090
@Context SecurityContext securityContext, com.atomgraph.linkeddatahub.Application system)
9191
{
92-
super(request, new ServiceImpl(DatasetFactory.create(ontology.get().getOntModel()), mediaTypes), mediaTypes);
92+
super(request, new ServiceImpl(DatasetFactory.create(ontology.get()), mediaTypes), mediaTypes);
9393
this.uri = uriInfo.getAbsolutePath();
9494
this.uriInfo = uriInfo;
9595
this.application = application;
@@ -128,7 +128,7 @@ public Response get(@QueryParam(QUERY) Query query,
128128
Model instances = ModelFactory.createDefaultModel();
129129

130130
forClasses.stream().
131-
map(forClass -> Optional.ofNullable(getOntology().getOntModel().getOntClass(checkURI(forClass).toString()))).
131+
map(forClass -> Optional.ofNullable(getOntology().getOntClass(checkURI(forClass).toString()))).
132132
flatMap(Optional::stream).
133133
forEach(forClass -> new Constructor().construct(forClass, instances, getApplication().getBase().getURI()));
134134

@@ -141,8 +141,8 @@ public Response get(@QueryParam(QUERY) Query query,
141141
String ontologyURI = getApplication().getOntology().getURI();
142142
if (log.isDebugEnabled()) log.debug("Returning namespace ontology from OntDocumentManager: {}", ontologyURI);
143143
// not returning the injected in-memory ontology because it has inferences applied to it
144-
OntologyModelGetter modelGetter = new OntologyModelGetter(getApplication().as(EndUserApplication.class), getSystem(), getSystem().getOntModelSpec(), getSystem().getOntologyQuery());
145-
return getResponseBuilder(modelGetter.getModel(ontologyURI)).build();
144+
OntologyRepository repository = new OntologyRepository(getApplication().as(EndUserApplication.class), getSystem(), com.atomgraph.linkeddatahub.client.GraphStoreClient.create(getSystem().getClient(), getSystem().getMediaTypes()), getSystem().getOntologyQuery());
145+
return getResponseBuilder(org.apache.jena.rdf.model.ModelFactory.createModelForGraph(repository.get(ontologyURI))).build();
146146
}
147147
else throw new BadRequestException("SPARQL query string not provided");
148148
}
@@ -223,7 +223,7 @@ public Application getApplication()
223223
*
224224
* @return application ontology
225225
*/
226-
public Ontology getOntology()
226+
public OntModel getOntology()
227227
{
228228
return ontology;
229229
}

src/main/java/com/atomgraph/linkeddatahub/resource/admin/ClearOntology.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818

1919
import com.atomgraph.linkeddatahub.apps.model.AdminApplication;
2020
import com.atomgraph.linkeddatahub.apps.model.EndUserApplication;
21-
import static com.atomgraph.linkeddatahub.server.filter.request.OntologyFilter.addDocumentModel;
2221
import com.atomgraph.linkeddatahub.server.filter.response.CacheInvalidationFilter;
23-
import com.atomgraph.linkeddatahub.server.util.OntologyModelGetter;
22+
import com.atomgraph.linkeddatahub.server.util.OntologyRepository;
2423
import java.net.URI;
2524
import jakarta.inject.Inject;
2625
import jakarta.ws.rs.BadRequestException;
@@ -31,8 +30,7 @@
3130
import jakarta.ws.rs.core.MediaType;
3231
import jakarta.ws.rs.core.Response;
3332
import jakarta.ws.rs.core.UriBuilder;
34-
import org.apache.jena.ontology.OntModel;
35-
import org.apache.jena.ontology.OntModelSpec;
33+
import com.atomgraph.linkeddatahub.server.filter.request.OntologyFilter;
3634
import org.apache.jena.rdf.model.Model;
3735
import org.apache.jena.rdf.model.ModelFactory;
3836
import org.apache.jena.rdf.model.Resource;
@@ -82,11 +80,11 @@ public Response post(@FormParam("uri") String ontologyURI, @HeaderParam("Referer
8280
if (ontologyURI == null) throw new BadRequestException("Ontology URI not specified");
8381

8482
EndUserApplication endUserApp = getApplication().as(AdminApplication.class).getEndUserApplication(); // we're assuming the current app is admin
85-
OntModelSpec ontModelSpec = new OntModelSpec(getSystem().getOntModelSpec(endUserApp));
86-
if (ontModelSpec.getDocumentManager().getFileManager().hasCachedModel(ontologyURI))
83+
OntologyRepository repository = getSystem().getRepository(endUserApp);
84+
if (repository.isCached(ontologyURI))
8785
{
8886
if (log.isDebugEnabled()) log.debug("Clearing ontology with URI '{}' from memory", ontologyURI);
89-
ontModelSpec.getDocumentManager().getFileManager().removeCacheModel(ontologyURI);
87+
repository.remove(ontologyURI);
9088

9189
URI ontologyDocURI = UriBuilder.fromUri(ontologyURI).fragment(null).build(); // skip fragment from the ontology URI to get its graph URI
9290
// frontend proxy still uses URL-pattern BAN for direct document GETs (until Stage 3 brings xkey tagging to varnish-frontend).
@@ -116,19 +114,7 @@ public Response post(@FormParam("uri") String ontologyURI, @HeaderParam("Referer
116114
}
117115

118116
// !!! we need to reload the ontology model before returning a response, to make sure the next request already gets the new version !!!
119-
// same logic as in OntologyFilter. TO-DO: encapsulate?
120-
OntologyModelGetter modelGetter = new OntologyModelGetter(endUserApp, getSystem(), ontModelSpec, getSystem().getOntologyQuery());
121-
ontModelSpec.setImportModelGetter(modelGetter);
122-
if (log.isDebugEnabled()) log.debug("Started loading ontology with URI '{}' from the admin dataset", ontologyURI);
123-
Model baseModel = modelGetter.getModel(ontologyURI);
124-
OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec, baseModel);
125-
// materialize OntModel inferences to avoid invoking rules engine on every request
126-
OntModel materializedModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // no inference
127-
materializedModel.add(ontModel);
128-
ontModel.getDocumentManager().addModel(ontologyURI, materializedModel, true); // make immutable and add as OntModel so that imports do not need to be reloaded during retrieval
129-
// make sure to cache imported models not only by ontology URI but also by document URI
130-
ontModel.listImportedOntologyURIs(true).forEach((String importURI) -> addDocumentModel(ontModel.getDocumentManager(), importURI));
131-
if (log.isDebugEnabled()) log.debug("Finished loading ontology with URI '{}' from the admin dataset", ontologyURI);
117+
OntologyFilter.loadOntology(repository, ontologyURI);
132118
}
133119

134120
if (referer != null) return Response.seeOther(referer).build();

src/main/java/com/atomgraph/linkeddatahub/resource/admin/SignUp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
import jakarta.ws.rs.core.UriInfo;
7373
import jakarta.ws.rs.ext.Providers;
7474
import static org.apache.jena.datatypes.xsd.XSDDatatype.XSDhexBinary;
75-
import org.apache.jena.ontology.Ontology;
75+
import org.apache.jena.ontapi.model.OntModel;
7676
import org.apache.jena.query.ParameterizedSparqlString;
7777
import org.apache.jena.query.Query;
7878
import org.apache.jena.query.ResultSet;
@@ -144,7 +144,7 @@ public class SignUp extends DocumentHierarchyGraphStoreImpl
144144
// TO-DO: move to AuthenticationExceptionMapper and handle as state instead of URI resource?
145145
@Inject
146146
public SignUp(@Context Request request, @Context UriInfo uriInfo, MediaTypes mediaTypes,
147-
com.atomgraph.linkeddatahub.apps.model.Application application, Optional<Ontology> ontology, Optional<Service> service,
147+
com.atomgraph.linkeddatahub.apps.model.Application application, Optional<OntModel> ontology, Optional<Service> service,
148148
@Context SecurityContext securityContext, Optional<AgentContext> agentContext,
149149
@Context Providers providers, com.atomgraph.linkeddatahub.Application system, @Context ServletConfig servletConfig)
150150
{

src/main/java/com/atomgraph/linkeddatahub/resource/admin/pkg/InstallPackage.java

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.atomgraph.linkeddatahub.resource.admin.pkg;
1818

1919
import static com.atomgraph.client.MediaType.TEXT_XSL;
20-
import com.atomgraph.client.util.DataManager;
2120
import com.atomgraph.linkeddatahub.apps.model.AdminApplication;
2221
import com.atomgraph.linkeddatahub.apps.model.EndUserApplication;
2322
import com.atomgraph.linkeddatahub.client.GraphStoreClient;
@@ -60,7 +59,6 @@
6059
import org.apache.jena.ontology.ConversionException;
6160
import org.apache.jena.update.UpdateFactory;
6261
import org.apache.jena.update.UpdateRequest;
63-
import org.apache.jena.util.FileManager;
6462
import com.atomgraph.linkeddatahub.vocabulary.DH;
6563
import com.atomgraph.linkeddatahub.vocabulary.FOAF;
6664
import com.atomgraph.linkeddatahub.vocabulary.SIOC;
@@ -88,7 +86,6 @@ public class InstallPackage
8886

8987
private final com.atomgraph.linkeddatahub.apps.model.Application application;
9088
private final com.atomgraph.linkeddatahub.Application system;
91-
private final DataManager dataManager;
9289
private final Optional<AgentContext> agentContext;
9390

9491
@Context ServletContext servletContext;
@@ -105,12 +102,10 @@ public class InstallPackage
105102
@Inject
106103
public InstallPackage(com.atomgraph.linkeddatahub.apps.model.Application application,
107104
com.atomgraph.linkeddatahub.Application system,
108-
DataManager dataManager,
109105
Optional<AgentContext> agentContext)
110106
{
111107
this.application = application;
112108
this.system = system;
113-
this.dataManager = dataManager;
114109
this.agentContext = agentContext;
115110
}
116111

@@ -242,12 +237,12 @@ private com.atomgraph.linkeddatahub.apps.model.Package getPackage(String package
242237
final Model model;
243238

244239
// check if we have the model in the cache first and if yes, return it from there instead making an HTTP request
245-
if (((FileManager)getDataManager()).hasCachedModel(packageURI) ||
246-
(getDataManager().isResolvingMapped() && getDataManager().isMapped(packageURI))) // read mapped URIs (such as system ontologies) from a file
240+
if (getSystem().getRepository().isCached(packageURI) ||
241+
(getSystem().getRepository().isMapped(packageURI))) // read mapped URIs (such as system ontologies) from a file
247242
{
248-
if (log.isDebugEnabled()) log.debug("hasCachedModel({}): {}", packageURI, ((FileManager)getDataManager()).hasCachedModel(packageURI));
249-
if (log.isDebugEnabled()) log.debug("isMapped({}): {}", packageURI, getDataManager().isMapped(packageURI));
250-
model = getDataManager().loadModel(packageURI);
243+
if (log.isDebugEnabled()) log.debug("hasCachedModel({}): {}", packageURI, getSystem().getRepository().isCached(packageURI));
244+
if (log.isDebugEnabled()) log.debug("isMapped({}): {}", packageURI, getSystem().getRepository().isMapped(packageURI));
245+
model = ModelFactory.createModelForGraph(getSystem().getRepository().get(packageURI));
251246
}
252247
else
253248
{
@@ -284,12 +279,12 @@ private Model downloadOntology(String uri)
284279
if (log.isDebugEnabled()) log.debug("Downloading ontology from: {}", uri);
285280

286281
// check if we have the model in the cache first and if yes, return it from there instead making an HTTP request
287-
if (((FileManager)getDataManager()).hasCachedModel(uri) ||
288-
(getDataManager().isResolvingMapped() && getDataManager().isMapped(uri))) // read mapped URIs (such as system ontologies) from a file
282+
if (getSystem().getRepository().isCached(uri) ||
283+
(getSystem().getRepository().isMapped(uri))) // read mapped URIs (such as system ontologies) from a file
289284
{
290-
if (log.isDebugEnabled()) log.debug("hasCachedModel({}): {}", uri, ((FileManager)getDataManager()).hasCachedModel(uri));
291-
if (log.isDebugEnabled()) log.debug("isMapped({}): {}", uri, getDataManager().isMapped(uri));
292-
return getDataManager().loadModel(uri);
285+
if (log.isDebugEnabled()) log.debug("hasCachedModel({}): {}", uri, getSystem().getRepository().isCached(uri));
286+
if (log.isDebugEnabled()) log.debug("isMapped({}): {}", uri, getSystem().getRepository().isMapped(uri));
287+
return ModelFactory.createModelForGraph(getSystem().getRepository().get(uri));
293288
}
294289
else
295290
{
@@ -522,15 +517,6 @@ public ServletContext getServletContext()
522517
return servletContext;
523518
}
524519

525-
/**
526-
* Returns RDF data manager.
527-
*
528-
* @return RDF data manager
529-
*/
530-
public DataManager getDataManager()
531-
{
532-
return dataManager;
533-
}
534520

535521
/**
536522
* Returns JAX-RS resource context.

0 commit comments

Comments
 (0)