Skip to content

The functionality copyOntology(..) does not work correctly in case of cyclic imports and OntologyCopy.SHALLOW #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sszuev opened this issue Feb 2, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@sszuev
Copy link
Contributor

sszuev commented Feb 2, 2020

The testcase:

    public static void main(String ... args) {
        OntologyManager m1 = OntManagers.createONT();
        Ontology a = m1.createOntology(IRI.create("A"));
        Ontology b = m1.createOntology(IRI.create("B"));
        a.asGraphModel().addImport(b.asGraphModel());
        b.asGraphModel().addImport(a.asGraphModel());

        testManager(m1);

        OntologyManager m2 = OntManagers.createONT();
        m1.ontologies().forEach(x -> m2.copyOntology(x, OntologyCopy.SHALLOW));

        testManager(m2);
    }

    private static void testManager(OntologyManager m) {
        Assert.assertEquals(2, m.ontologies().peek(x -> {
            System.out.println("TEST: " + x);
            Assert.assertEquals(2, Graphs.baseGraphs(((Ontology)x).asGraphModel().getGraph()).count());
        }).count());
    }

Additional info:
The method copyOntology with OntologyCopy.SHALLOW is used in RDF Protege.
The example of ontology with cyclic imports is http://www.w3.org/TR/owl-guide/wine.rdf

@sszuev sszuev added the bug Something isn't working label Feb 2, 2020
sszuev added a commit that referenced this issue Feb 2, 2020
… functionality for OntologyCopy.SHALLOW (issue #9) + add tests
@sszuev
Copy link
Contributor Author

sszuev commented Feb 2, 2020

fixed

@sszuev sszuev closed this as completed Feb 2, 2020
@sszuev
Copy link
Contributor Author

sszuev commented Feb 22, 2020

Reopen: fix causes an error when the manager contains anonymous ontologies:

java.lang.NullPointerException: Must be named ontology

	at java.util.Objects.requireNonNull(Objects.java:228)
	at com.github.owlcs.ontapi.jena.utils.OntModels.insert(OntModels.java:91)
	at com.github.owlcs.ontapi.OntologyManagerImpl.lambda$syncImports$28(OntologyManagerImpl.java:1142)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.concurrent.ConcurrentHashMap$ValueSpliterator.forEachRemaining(ConcurrentHashMap.java:3566)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at com.github.owlcs.ontapi.OntologyManagerImpl.syncImports(OntologyManagerImpl.java:1142)
	at com.github.owlcs.ontapi.OntologyManagerImpl.copyOntology(OntologyManagerImpl.java:1411)

@sszuev sszuev reopened this Feb 22, 2020
sszuev added a commit that referenced this issue Feb 22, 2020
@sszuev sszuev closed this as completed Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant