Search in sources :

Example 6 with MultiUnion

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));
}
Also used : AbstractTestGraph(org.apache.jena.graph.test.AbstractTestGraph) Graph(org.apache.jena.graph.Graph) MultiUnion(org.apache.jena.graph.compose.MultiUnion)

Example 7 with MultiUnion

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);
}
Also used : MultiUnion(org.apache.jena.graph.compose.MultiUnion)

Example 8 with MultiUnion

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();
    }
}
Also used : InfGraph(org.apache.jena.reasoner.InfGraph) Graph(org.apache.jena.graph.Graph) MultiUnion(org.apache.jena.graph.compose.MultiUnion)

Example 9 with MultiUnion

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;
}
Also used : MultiUnion(org.apache.jena.graph.compose.MultiUnion)

Example 10 with MultiUnion

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));
}
Also used : MultiUnion(org.apache.jena.graph.compose.MultiUnion)

Aggregations

MultiUnion (org.apache.jena.graph.compose.MultiUnion)15 Graph (org.apache.jena.graph.Graph)9 AbstractTestGraph (org.apache.jena.graph.test.AbstractTestGraph)8 GraphStatisticsHandler (org.apache.jena.graph.GraphStatisticsHandler)1 Model (org.apache.jena.rdf.model.Model)1 InfGraph (org.apache.jena.reasoner.InfGraph)1 Reasoner (org.apache.jena.reasoner.Reasoner)1