use of org.apache.jena.graph.compose.MultiUnion in project jena by apache.
the class TestMultiUnion method testEmptyGraph.
public void testEmptyGraph() {
Graph m = new MultiUnion();
Graph g0 = graphWith("x p y");
assertEquals("Empty model should have size zero", 0, m.size());
assertFalse("Empty model should not contain another graph", m.dependsOn(g0));
}
use of org.apache.jena.graph.compose.MultiUnion in project jena by apache.
the class BaseInfGraph method cloneWithPremises.
/**
* Return a new inference graph which is a clone of the current graph
* together with an additional set of data premises. The default
* implementation loses ALL partial deductions so far. Some subclasses
* may be able to a more efficient job.
*/
public InfGraph cloneWithPremises(Graph premises) {
MultiUnion union = new MultiUnion();
Graph raw = getRawGraph();
union.addGraph(raw);
union.setBaseGraph(raw);
union.addGraph(premises);
Graph schema = getSchemaGraph();
if (schema != null) {
if (schema instanceof BaseInfGraph) {
BaseInfGraph ischema = (BaseInfGraph) schema;
Graph sschema = ischema.getSchemaGraph();
if (sschema != null)
union.addGraph(sschema);
Graph rschema = ischema.getRawGraph();
if (rschema != null)
union.addGraph(rschema);
}
}
return getReasoner().bind(union);
}
use of org.apache.jena.graph.compose.MultiUnion in project jena by apache.
the class OntModelImpl method removeSubModel.
/**
* <p>
* Remove the given model as one of the sub-models of the enclosed ontology union model.
* </p>
*
* @param model A sub-model to remove
* @param rebind If true, rebind any associated inferencing engine to the new data (which
* may be an expensive operation)
*/
@Override
public void removeSubModel(Model model, boolean rebind) {
Graph subG = model.getGraph();
getUnionGraph().removeGraph(subG);
// originally
if (subG instanceof MultiUnion) {
// we need to get the base graph when removing a ontmodel
getUnionGraph().removeGraph(((MultiUnion) subG).getBaseGraph());
}
if (rebind) {
rebind();
}
}
use of org.apache.jena.graph.compose.MultiUnion in project jena by apache.
the class ImportManager method withImports.
private Model withImports(FileManager fm, Model model, Set<String> loading) {
StmtIterator oit = model.listStatements(null, OWL.imports, (RDFNode) null);
StmtIterator jit = model.listStatements(null, JA.imports, (RDFNode) null);
if (oit.hasNext() || jit.hasNext()) {
MultiUnion g = new MultiUnion(new Graph[] { model.getGraph() });
addImportedGraphs(fm, loading, oit, g);
addImportedGraphs(fm, loading, jit, g);
return ModelFactory.createModelForGraph(g);
} else
return model;
}
use of org.apache.jena.graph.compose.MultiUnion in project jena by apache.
the class TestUnionStatistics method testUnion.
/**
Asserts that the statistic obtained by probing the three-element union
with statistics <code>av</code>, <code>bv</code>, and
<code>cv</code> is <code>expected</code>.
*/
private void testUnion(int expected, int av, int bv, int cv) {
AnInteger a = new AnInteger(av), b = new AnInteger(bv), c = new AnInteger(cv);
Graph g1 = graphWithGivenStatistic(a);
Graph g2 = graphWithGivenStatistic(b);
Graph g3 = graphWithGivenStatistic(c);
Graph[] graphs = new Graph[] { g1, g2, g3 };
MultiUnion mu = new MultiUnion(graphs);
GraphStatisticsHandler gs = new MultiUnion.MultiUnionStatisticsHandler(mu);
assertEquals(expected, gs.getStatistic(Node.ANY, Node.ANY, Node.ANY));
}
Aggregations