@Override public boolean isEmpty() { return inner.isEmpty(); }
private void loadFirstTimeFiles(ServletContext ctx, String modelPath, OntModel baseModel) { RDFFilesLoader.loadFirstTimeFiles(modelPath, baseModel, baseModel.isEmpty()); }
if ( !model.isEmpty() && baseModel != null ) { baseModel.addSubModel(model); log.debug("Attached file graph as " + type + " submodel " + p.getFileName());
@Override protected QueryExecutionFactory initQueryFactory() { // When we load the referenced schemata we do rdfs reasoning to avoid false errors // Many ontologies skip some domain / range statements and this way we add them OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_RDFS_INF, ModelFactory.createDefaultModel()); try { // load the data only when the model is empty in case it is initialized with the "copy constructor" // This sppeds up the process on very big in-memory datasets if (dumpModel.isEmpty()) { // load the data only when the model is empty in case it is initialized with the "copy constructor" dumpReader.read(dumpModel); } //if (dumpModel.isEmpty()) { // throw new IllegalArgumentException("Dump is empty"); //} //Load all the related ontologies as well (for more consistent querying for (SchemaSource src : getReferencesSchemata()) { ontModel.add(src.getModel()); } // Here we add the ontologies in the dump mode // Note that the ontologies have reasoning enabled but not the dump source dumpModel.add(ontModel); } catch (Exception e) { log.error("Cannot read dump URI: " + getUri() + " Reason: " + e.getMessage()); throw new IllegalArgumentException("Cannot read dump URI: " + getUri() + " Reason: " + e.getMessage(), e); } return masqueradeQEF(new QueryExecutionFactoryModel(dumpModel), this); }
@Override protected QueryExecutionFactory initQueryFactory() { // When we load the referenced schemata we do rdfs reasoning to avoid false errors // Many ontologies skip some domain / range statements and this way we add them OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_RDFS_INF, ModelFactory.createDefaultModel()); try { // load the data only when the model is empty in case it is initialized with the "copy constructor" // This sppeds up the process on very big in-memory datasets if (dumpModel.isEmpty()) { // load the data only when the model is empty in case it is initialized with the "copy constructor" dumpReader.read(dumpModel); } //if (dumpModel.isEmpty()) { // throw new IllegalArgumentException("Dump is empty"); //} //Load all the related ontologies as well (for more consistent querying for (SchemaSource src : getReferencesSchemata()) { ontModel.add(src.getModel()); } // Here we add the ontologies in the dump mode // Note that the ontologies have reasoning enabled but not the dump source dumpModel.add(ontModel); } catch (Exception e) { log.error("Cannot read dump URI: " + getUri() + " Reason: " + e.getMessage()); throw new IllegalArgumentException("Cannot read dump URI: " + getUri() + " Reason: " + e.getMessage(), e); } return masqueradeQEF(new QueryExecutionFactoryModel(dumpModel), this); }
/** * The reasoner contract for bind(data) is not quite precise. It allows for * reasoners which have state so that reusing the same reasoner on a second data * model might lead to interference. This in fact used to happen with the transitive * reasoner. This is a test to check the top level symptoms of this which can be * solved just be not reusing reasoners. * @todo this test might be better moved to OntModel tests somewhere */ public void testTransitiveSpecReuse() { OntModel om1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF); Resource c1 = om1.createResource(PrintUtil.egNS + "Class1"); Resource c2 = om1.createResource(PrintUtil.egNS + "Class2"); Resource c3 = om1.createResource(PrintUtil.egNS + "Class3"); om1.add(c1, RDFS.subClassOf, c2); om1.add(c2, RDFS.subClassOf, c3); om1.prepare(); assertFalse(om1.isEmpty()); OntModel om2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF); StmtIterator si = om2.listStatements(); boolean ok = ! si.hasNext(); si.close(); assertTrue("Transitive reasoner state leak", ok); }
/** * The reasoner contract for bind(data) is not quite precise. It allows for * reasoners which have state so that reusing the same reasoner on a second data * model might lead to interference. This in fact used to happen with the transitive * reasoner. This is a test to check the top level symptoms of this which can be * solved just be not reusing reasoners. * @todo this test might be better moved to OntModel tests somewhere */ public void testTransitiveSpecReuse() { OntModel om1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF); Resource c1 = om1.createResource(PrintUtil.egNS + "Class1"); Resource c2 = om1.createResource(PrintUtil.egNS + "Class2"); Resource c3 = om1.createResource(PrintUtil.egNS + "Class3"); om1.add(c1, RDFS.subClassOf, c2); om1.add(c2, RDFS.subClassOf, c3); om1.prepare(); assertFalse(om1.isEmpty()); OntModel om2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF); StmtIterator si = om2.listStatements(); boolean ok = ! si.hasNext(); si.close(); assertTrue("Transitive reasoner state leak", ok); }