/** * Creates an includes Model for a given input Model. * The includes Model is the union of the input Model will all graphs linked via * sh:include (or owl:imports), transitively. * @param model the Model to create the includes Model for * @param graphURI the URI of the named graph represented by Model * @return a Model including the semantics */ public static Model createIncludesModel(Model model, String graphURI) { Set<Graph> graphs = new HashSet<Graph>(); Graph baseGraph = model.getGraph(); addIncludes(baseGraph, graphURI, graphs, new HashSet<String>()); if(graphs.size() == 1) { return model; } else { MultiUnion union = new MultiUnion(graphs.iterator()); union.setBaseGraph(baseGraph); return ModelFactory.createModelForGraph(union); } }
/** * Creates an includes Model for a given input Model. * The includes Model is the union of the input Model will all graphs linked via * sh:include (or owl:imports), transitively. * @param model the Model to create the includes Model for * @param graphURI the URI of the named graph represented by Model * @return a Model including the semantics */ public static Model createIncludesModel(Model model, String graphURI) { Set<Graph> graphs = new HashSet<Graph>(); Graph baseGraph = model.getGraph(); addIncludes(baseGraph, graphURI, graphs, new HashSet<String>()); if(graphs.size() == 1) { return model; } else { MultiUnion union = new MultiUnion(graphs.iterator()); union.setBaseGraph(baseGraph); return ModelFactory.createModelForGraph(union); } }
/** * <p>Helper method to the constructor, which interprets the spec and generates an appropriate * graph for this model</p> * @param spec The model spec to interpret * @param base The base model, or null */ private static Graph generateGraph( OntModelSpec spec, Graph base ) { // create a empty union graph MultiUnion u = new MultiUnion(); u.addGraph( base ); u.setBaseGraph( base ); Reasoner r = spec.getReasoner(); // if we have a reasoner in the spec, bind to the union graph and return return r == null ? (Graph) u : r.bind( u ); }
/** * <p>Helper method to the constructor, which interprets the spec and generates an appropriate * graph for this model</p> * @param spec The model spec to interpret * @param base The base model, or null */ private static Graph generateGraph( OntModelSpec spec, Graph base ) { // create a empty union graph MultiUnion u = new MultiUnion(); u.addGraph( base ); u.setBaseGraph( base ); Reasoner r = spec.getReasoner(); // if we have a reasoner in the spec, bind to the union graph and return return r == null ? (Graph) u : r.bind( u ); }
union.setBaseGraph(baseGraph); return ModelFactory.createModelForGraph(union);
union.setBaseGraph(baseGraph); return ModelFactory.createModelForGraph(union);
/** * 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); }
/** * 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); }
public void testDelete() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); checkDeleteSizes( 1, 2, 3, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.setBaseGraph( g1 ); m.delete( triple( "x p z") ); checkDeleteSizes( 0, 1, 1, g0, g1, m ); m.delete( triple( "z p zz") ); checkDeleteSizes( 0, 0, 0, g0, g1, m ); }
public void testDelete() { Graph g0 = graphWith( "x p y" ); Graph g1 = graphWith( "x p z; z p zz" ); // disjoint with g0 MultiUnion m = new MultiUnion( new Graph[] {g0, g1} ); checkDeleteSizes( 1, 2, 3, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.delete( triple( "x p y") ); checkDeleteSizes( 0, 2, 2, g0, g1, m ); m.setBaseGraph( g1 ); m.delete( triple( "x p z") ); checkDeleteSizes( 0, 1, 1, g0, g1, m ); m.delete( triple( "z p zz") ); checkDeleteSizes( 0, 0, 0, g0, g1, m ); }
m.setBaseGraph( g1 ); m.setBaseGraph( g2 );
m.setBaseGraph( g1 ); m.setBaseGraph( g2 );