You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "namedgraph (via GitHub)" <gi...@apache.org> on 2026/06/19 20:25:28 UTC

[I] LocationMapper in the new ont-api [jena]

namedgraph opened a new issue, #4006:
URL: https://github.com/apache/jena/issues/4006

   ### Version
   
   6.1.0
   
   ### Feature
   
   Hi,
   
   How can a `LocationMapper` [1] be passed to the new ontology API?
   
   Previously `FileManager` supported it. Now it looks like `(Document)GraphRepository` would be the natural consumer of the `LocationMapper` but no such methods are provided.
   
   Is that intentional or just a gap in the API?
   
   [1] https://jena.apache.org/documentation/javadoc/jena/org.apache.jena.core/org/apache/jena/util/LocationMapper.html
   [2] https://jena.apache.org/documentation/javadoc/ontapi/org.apache.jena.ontapi/org/apache/jena/ontapi/impl/repositories/DocumentGraphRepository.html
   
   ### Are you interested in contributing a solution yourself?
   
   Perhaps?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "sszuev (via GitHub)" <gi...@apache.org>.
sszuev commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4760032246

   > [@sszuev](https://github.com/sszuev) if `DocumentGraphRepository` were to parse the location-mapping RDF structure (e.g. in your proposed `addMappings` method) it would require a dependency at least on [`LocationMappingVocab`](https://jena.apache.org/documentation/javadoc/jena/org.apache.jena.core/org/apache/jena/vocabulary/LocationMappingVocab.html)?
   > 
   > The migration to the new ont-api left a gap for existing location-mapper users, so I think a proper bridge to close that gap is a fair request.
   
   Yes, OntAPI depends on `org.apache.jena.vocabulary`, including OWL, and LocationMappingVocab. This dependency cannot be avoided.
   
   There is a method `LocationMapping#toModel`, so code may look like `dgr.addMappings(lm.toModel())`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "sszuev (via GitHub)" <gi...@apache.org>.
sszuev commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4759965420

   As for me, I am against the idea of ​​making OntAPI dependent on yet another component - LocationMapping. But this is matter of discussion. Maybe.
   The second option seems overly complicated, especially when taking prefixes into account.
   And I don’t insist on the option with `DocumentGraphRepository#addMappings(Model mapping)`, although I don't see a hack here.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "sszuev (via GitHub)" <gi...@apache.org>.
sszuev commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4757542759

   Hi
   
   Could you provide an example of how you use `LocationMapper`?
   
   `DocumentGraphRepository` has the `addMapping` method that resembles the functionality of `LocationMapper`; I thought that would be sufficient.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "sszuev (via GitHub)" <gi...@apache.org>.
sszuev commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4758476997

   Perhaps we could add the `DocumentGraphRepository#addMappings(Model mapping)` method. Would such a method be convenient? The only problem here is prefixes.
   
   BTW, it seems the file https://github.com/AtomGraph/LinkedDataHub/blob/master/src/main/resources/prefix-mapping.ttl is not fully correct. Probably `[ lm:prefix "https://w3id.org/atomgraph/linkeddatahub" ;                      lm:altName "com/atomgraph/linkeddatahub/ldh.ttl" ] ` should be replaced with `[ lm:prefix "https://w3id.org/atomgraph/linkeddatahub/" ;
     lm:altPrefix "com/atomgraph/linkeddatahub/" ]`(correct predicate is `lm:altPrefix`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4759987241

   @sszuev if `DocumentGraphRepository` were to parse the location-mapping RDF structure (e.g. in your proposed `addMappings` method) it would require a dependency at least on [`LocationMappingVocab`](https://jena.apache.org/documentation/javadoc/jena/org.apache.jena.core/org/apache/jena/vocabulary/LocationMappingVocab.html)?
   
   The migration to the new ont-api left a gap for existing location-mapper users, so I think a proper bridge to close that gap is a fair request.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4767830182

   Fair enough. `addMappings` does the job.
   
   For me though it's more about the concept of Jena: is it a collection of modules, or is it an integrated framework? In the latter case, inter-dependencies shouldn't be an issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4757570552

   The advantage of `LocationMapper` is that it has an RDF vocabulary that allows to define then mapping as data. For example: https://github.com/AtomGraph/LinkedDataHub/blob/master/src/main/resources/location-mapping.ttl
   
   A mapping in a file is much more convenient that code because it can be overridden with a simple Docker mount etc.
   
   I also have a custom prefix mapping implementation for vocabs that use a document per term (as opposed to a whole vocab in a single document), such as DCTerms.
   
   https://github.com/AtomGraph/LinkedDataHub/blob/master/src/main/resources/prefix-mapping.ttl


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #4006: LocationMapper in the new ont-api
URL: https://github.com/apache/jena/issues/4006


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4754875464

   Just noticed this comment in the Javadoc:
   > Use `StreamManager` and `LocationMapper` from `org.apache.jena.riot.system.stream`.
   
   Which makes it more confusing. Is the new `LocationMapper` a drop-in replacement?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "namedgraph (via GitHub)" <gi...@apache.org>.
namedgraph commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4759906043

   > Perhaps we could add the `DocumentGraphRepository#addMappings(Model mapping)` method. Would such a method be convenient? The only problem here is prefixes.
   
   That would work but feels like a hack. My gut feeling is that a location mapper interface is missing for a proper refactoring - and Claude seems to agree.
   
   # Option A — adapter
   
   Wrap rather than subclass. Implement `GraphRepository`, delegate resolution to a `LocationMapper`, and delegate materialization back into a `DocumentGraphRepository` by registering the resolved location on the fly:
   
   ```java
   public final class MappedGraphRepository implements GraphRepository {
       private final LocationMapper resolver;
       private final DocumentGraphRepository store; // does the loading + caching
   
       public MappedGraphRepository(LocationMapper resolver, Supplier<Graph> factory) {
           this.resolver = resolver;
           this.store = new DocumentGraphRepository(factory);
       }
   
       @Override public Graph get(String id) {
           String loc = resolver.altMapping(id, id);   // exact + prefix, identity fallback
           if (!store.contains(loc))
               store.addMapping(loc, loc);              // register resolved source
           return store.get(loc);                       // load/cache/throw handled by DGR
       }
       // ids()/contains()/remove()/clear()/count()/loadedGraphs() delegate to store,
       // keyed by resolved location; keep an id→loc table if you want ids() to report logical ids.
   }
   ```
   
   # Option B — the upstream refactor (the "right" fix)
   
   Give DGR a pluggable resolution SPI and make `LocationMapper` one implementation of it. The cleanest version collapses DGR's private exact map into a `LocationMapper`, since `addMapping` is just another exact-entry layer:
   
   ```java
   interface LocationResolver { String resolve(String id); }   // null/id == no remap
   
   // DGR holds a LocationResolver; default impl is backed by a LocationMapper:
   addMapping(id, loc)  ->  lm.addAltEntry(id, loc);            // write path unchanged in behavior
   get(id):  String loc = lm.altMapping(id, id);  /* then materialize+cache keyed by loc */
   ```
   
   The new `LocationMapper` class is this: https://jena.apache.org/documentation/javadoc/arq/org.apache.jena.arq/org/apache/jena/riot/system/streammgr/LocationMapper.html
   
   @afs WDYT about option B?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] LocationMapper in the new ont-api [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #4006:
URL: https://github.com/apache/jena/issues/4006#issuecomment-4760135482

   > and Claude seems to agree.
   
   more likely shows an implicit implication in the task description! and/or the numerical weight of evidence
   
   > @afs WDYT about option B?
   
   @sszuev knows the need of the jena-ontapi better than I do. His point about avoiding too much dependency seems relevant.
   
   The LocationMapping  model parser can be made to return a convenient java data structure that can played into `LocationMapper` or `DocumentGraphRepository` (better to parse completely rather than stream to ensure the RDF and vocab use is valid).
   
   `LocationMapping#toModel` can be used for going from an existing Location Mapper or by adding a "LocationMapping#toConvenientJavaDatastructure()" (i.e. in-JVM dump)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org