@Override public ExtendedIterator<OntModel> listSubModels() { return inner.listSubModels(); }
@Override public ExtendedIterator<OntModel> listSubModels(boolean withImports) { return inner.listSubModels(withImports); }
/** Remove a sub model (imported model) */ public void testremoveSubModel0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ); m.read( "file:testing/ontology/testImport3/a.owl" ); assertEquals( 2, m.getSubGraphs().size() ); for (Iterator<OntModel> it = m.listSubModels(); it.hasNext();) { m.removeSubModel( it.next() ); } assertEquals( 0, m.getSubGraphs().size() ); }
/** Remove a sub model (imported model) */ public void testremoveSubModel0() { OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ); m.read( "file:testing/ontology/testImport3/a.owl" ); assertEquals( 2, m.getSubGraphs().size() ); for (Iterator<OntModel> it = m.listSubModels(); it.hasNext();) { m.removeSubModel( it.next() ); } assertEquals( 0, m.getSubGraphs().size() ); }
public void testListSubModels0() { OntModel m = ModelFactory.createOntologyModel(); m.read( "file:testing/ontology/testImport6/a.owl" ); assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) ); List<OntModel> importModels = new ArrayList<>(); for (Iterator<OntModel> j = m.listSubModels(); j.hasNext(); ) { importModels.add( j.next() ); } assertEquals( "n import models should be ", 3, importModels.size() ); int nImports = 0; for ( OntModel x : importModels ) { // count the number of imports of each sub-model nImports += x.countSubModels(); } // listSubModels' default behaviour is *not* to include imports of sub-models assertEquals( "Wrong number of sub-model imports", 0, nImports ); }
public void testListSubModels1() { OntModel m = ModelFactory.createOntologyModel(); m.read( "file:testing/ontology/testImport6/a.owl" ); assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) ); List<OntModel> importModels = new ArrayList<>(); for (Iterator<OntModel> j = m.listSubModels( true ); j.hasNext(); ) { importModels.add( j.next() ); } assertEquals( "n import models should be ", 3, importModels.size() ); int nImports = 0; for ( OntModel x : importModels ) { // count the number of imports of each sub-model nImports += x.countSubModels(); } assertEquals( "Wrong number of sub-model imports", 2, nImports ); }
public void testListSubModels1() { OntModel m = ModelFactory.createOntologyModel(); m.read( "file:testing/ontology/testImport6/a.owl" ); assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) ); List<OntModel> importModels = new ArrayList<>(); for (Iterator<OntModel> j = m.listSubModels( true ); j.hasNext(); ) { importModels.add( j.next() ); } assertEquals( "n import models should be ", 3, importModels.size() ); int nImports = 0; for ( OntModel x : importModels ) { // count the number of imports of each sub-model nImports += x.countSubModels(); } assertEquals( "Wrong number of sub-model imports", 2, nImports ); }
public void testListSubModels0() { OntModel m = ModelFactory.createOntologyModel(); m.read( "file:testing/ontology/testImport6/a.owl" ); assertEquals( "Marker count not correct", 4, TestOntDocumentManager.countMarkers( m ) ); List<OntModel> importModels = new ArrayList<>(); for (Iterator<OntModel> j = m.listSubModels(); j.hasNext(); ) { importModels.add( j.next() ); } assertEquals( "n import models should be ", 3, importModels.size() ); int nImports = 0; for ( OntModel x : importModels ) { // count the number of imports of each sub-model nImports += x.countSubModels(); } // listSubModels' default behaviour is *not* to include imports of sub-models assertEquals( "Wrong number of sub-model imports", 0, nImports ); }
System.out.println("jenaOntModel"); int subModelCount = memoryModel.listSubModels().toList().size(); System.out.println("Submodels: "+subModelCount); try {
public void testSubModels() { final Model baseModel = model( "a P b" ); Assembler a = new OntModelAssembler(); Assembler aa = new ModelAssembler() { @Override protected Model openEmptyModel( Assembler a, Resource root, Mode irrelevant ) { assertEquals( resource( "y" ), root ); return baseModel; } }; Object m = a.open( aa, resourceInModel( "x rdf:type ja:OntModel; x ja:subModel y" ) ); assertInstanceOf( OntModel.class, m ); OntModel om = (OntModel) m; List<OntModel> subModels = om.listSubModels().toList(); assertEquals( 1, subModels.size() ); assertSame( baseModel.getGraph(), subModels.get( 0 ).getBaseModel().getGraph() ); }
public void testSubModels() { final Model baseModel = model( "a P b" ); Assembler a = new OntModelAssembler(); Assembler aa = new ModelAssembler() { @Override protected Model openEmptyModel( Assembler a, Resource root, Mode irrelevant ) { assertEquals( resource( "y" ), root ); return baseModel; } }; Object m = a.open( aa, resourceInModel( "x rdf:type ja:OntModel; x ja:subModel y" ) ); assertInstanceOf( OntModel.class, m ); OntModel om = (OntModel) m; List<OntModel> subModels = om.listSubModels().toList(); assertEquals( 1, subModels.size() ); assertSame( baseModel.getGraph(), subModels.get( 0 ).getBaseModel().getGraph() ); }
/** * Ensure that sub-model imports are not re-used after clearing the cache. */ public void testClearCache1() { OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_MEM); spec.getDocumentManager().reset(); spec.getDocumentManager().setCacheModels(false); spec.getDocumentManager().addAltEntry( "http://incubator.apache.org/jena/2011/10/testont/a", "file:testing/ontology/testImport8/a.owl" ); OntModel m0 = ModelFactory.createOntologyModel(spec, null); m0.read( "http://incubator.apache.org/jena/2011/10/testont/a" ); Model subModel0 = m0.listSubModels().next(); long count0 = subModel0.size(); OntClass ontClass = m0.getOntClass( "http://incubator.apache.org/jena/2011/10/testont/a#A" ); subModel0.add( ontClass, RDF.type, OWL.DeprecatedClass ); assertEquals( count0 + 1, subModel0.size() ); // TODO this workaround to be removed SimpleGraphMaker sgm = (SimpleGraphMaker) ((ModelMakerImpl) spec.getImportModelMaker()).getGraphMaker(); List<String> toGo = new ArrayList<>(); for (Iterator<String> i = sgm.listGraphs(); i.hasNext(); toGo.add( i.next() )) {/**/} for (Iterator<String> i = toGo.iterator(); i.hasNext(); sgm.removeGraph( i.next() )) {/**/} spec.getDocumentManager().clearCache(); OntModel m1 = ModelFactory.createOntologyModel(spec, null); m1.read( "http://incubator.apache.org/jena/2011/10/testont/a" ); Model subModel1 = m1.listSubModels().next(); assertNotSame( m1, m0 ); assertNotSame( subModel1, subModel0 ); assertEquals( count0, subModel1.size() ); }
/** * Ensure that sub-model imports are not re-used after clearing the cache. */ public void testClearCache1() { OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_MEM); spec.getDocumentManager().reset(); spec.getDocumentManager().setCacheModels(false); spec.getDocumentManager().addAltEntry( "http://incubator.apache.org/jena/2011/10/testont/a", "file:testing/ontology/testImport8/a.owl" ); OntModel m0 = ModelFactory.createOntologyModel(spec, null); m0.read( "http://incubator.apache.org/jena/2011/10/testont/a" ); Model subModel0 = m0.listSubModels().next(); long count0 = subModel0.size(); OntClass ontClass = m0.getOntClass( "http://incubator.apache.org/jena/2011/10/testont/a#A" ); subModel0.add( ontClass, RDF.type, OWL.DeprecatedClass ); assertEquals( count0 + 1, subModel0.size() ); // TODO this workaround to be removed SimpleGraphMaker sgm = (SimpleGraphMaker) ((ModelMakerImpl) spec.getImportModelMaker()).getGraphMaker(); List<String> toGo = new ArrayList<>(); for (Iterator<String> i = sgm.listGraphs(); i.hasNext(); toGo.add( i.next() )) {/**/} for (Iterator<String> i = toGo.iterator(); i.hasNext(); sgm.removeGraph( i.next() )) {/**/} spec.getDocumentManager().clearCache(); OntModel m1 = ModelFactory.createOntologyModel(spec, null); m1.read( "http://incubator.apache.org/jena/2011/10/testont/a" ); Model subModel1 = m1.listSubModels().next(); assertNotSame( m1, m0 ); assertNotSame( subModel1, subModel0 ); assertEquals( count0, subModel1.size() ); }