What package is GraphWrapper in?  That's what I was trying to do.    I just declared a class that implements Graph.  I didn't call GraphFactory to get one.  I can't find GraphFactory in the javadoc, either, just GraphMaker.

On 12/24/2020 1:37 PM, Andy Seaborne wrote:


On 24/12/2020 17:18, Steve Vestal wrote:
What I did as part of exploring things was

             Model baseModel = ModelFactory.createModelForGraph(myDummyGraph);              OntModel wrapperModel = ModelFactory.createOntologyModel(leafModelSpec, baseModel);

where myDummyGraph was a Graph implementation I could observe to see what calls were made, and leafModelSpec is as specified previously. A call was made to find all owl:Imports (a triple of the form <*> <owl:Imports> <*>) during execution of the call to createOntologyModel.

Not what I get: I don't get any calls to the graph:

public static void main(String... a) throws Exception {
    var leafDocMgr = new OntDocumentManager();
    leafDocMgr.setFileManager();
    leafDocMgr.setProcessImports(false);
    leafDocMgr.setCacheModels(false);
    var leafModelSpec = new OntModelSpec(OntModelSpec.OWL_MEM);
    leafModelSpec.setDocumentManager(leafDocMgr);
//OntModel leafOntModel =
// ModelFactory.createOntologyModel(leafModelSpec);

    Graph graph = GraphFactory.createDefaultGraph();
    graph = new GraphWrapper(graph) {
        @Override
        public ExtendedIterator<Triple> find(Triple triple) {
            System.out.println("findT(" + triple + ")");
            return super.find(triple);
        }

        @Override
        public ExtendedIterator<Triple> find(Node s, Node p, Node o) {
            System.out.println("findN(" + s + ", " + p + ", " + o + ")");
            return super.find(s, p, o);
        }

        @Override
        public boolean contains(Node s, Node p, Node o) {
            System.out.println("containsN(" + s + ", " + p + ", " + o + ")");
            return super.contains(s, p, o);
        }

        @Override
        public boolean contains(Triple t) {
            System.out.println("containsT(" + t + ")");
            return super.contains(t);
        }
    };

    Model baseModel = ModelFactory.createModelForGraph(graph);
    OntModel wrapperModel = ModelFactory.createOntologyModel(leafModelSpec, baseModel);

    System.out.println("DONE");
}






On 12/24/2020 10:59 AM, Andy Seaborne wrote:


On 24/12/2020 13:49, Steve Vestal wrote:
I am doing my own import closure, and I saw some behaviors that I was a bit curious about.  For my own education, I'd appreciate any observations you might have.

I call setProcessImports(false) when creating the document manager, but 1) my OntModel gets created as a UnionModel,

There is a comment in the code:

    /** The union graph that contains the imports closure - there is always one of these, which may also be _the_ graph for the model */
    protected MultiUnion m_union = new MultiUnion();

There is always a union, even if union of one.

Because imports may change as add/deletes happen 9including setSubModel), always being a union is probably a lot easier than having a special case.

The code is OntModelImpl.generateGraph

and 2) a query is made to OntModel#getGraph() to find all owl:Imports.

when does this happen? It does not seem to happen with the setup code you gave.

  I thought these would be unnecessary with setProcessImports(false). Is there any non-negligible overhead, or processing I am not anticipating, going on?

    Andy

  Are there additional properties I should be setting?  Is it the case that setProcessImports(false) has no effect on how the overall structure is assembled, but it does stop the actual creation of new sub-models and the loading of those imported documents?

As background, I am constructing the sort of tree shown in section /Compound Ontology Documents and Imports Processing/ on page https://jena.apache.org/documentation/ontology/.  I do some custom ontology management, and my code processes all imports, OWL and otherwise.  Some of the leaf (non-base) models are OntModels.  I am loading those leaf OntModels as

             leafDocMgr = new OntDocumentManager();
             leafDocMgr.setFileManager();
             leafDocMgr.setProcessImports(false);
             leafDocMgr.setCacheModels(false);
             leafModelSpec = new OntModelSpec(OntModelSpec.OWL_MEM);
leafModelSpec.setDocumentManager(leafDocMgr);
             OntModel leafOntModel = ModelFactory.createOntologyModel(leafModelSpec);



Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to