/** * Diff a Model against a stream of triples * * @param replacement the replacement * @param original the original */ public GraphDifferencingIterator(final Model replacement, final Iterator<Triple> original) { this(replacement.getGraph(), original); }
protected void addToCache(Model model) { // Assume MRSW - no synchronized needed. cache.put(model.getGraph(), model) ; }
/** Read triples into a Model from the given location. * The syntax is detemined from input source URI (content negotiation or extension). * @param model Destination for the RDF read. * @param uri URI to read from (includes file: and a plain file name). * @throws RiotNotFoundException if the location is not found - the model is unchanged. * @see #read(Model,String,Lang,Context) */ public static void read(Model model, String uri) { read(model.getGraph(), uri) ; }
/** Read triples into a Model from the given location, with hint of language * and with some parameters for the reader. * Throws parse errors depending on the language and reader; the model may be partially updated. * @param model Destination for the RDF read. * @param uri URI to read from (includes file: and a plain file name). * @param base Base URI (defaults to uri). * @param hintLang Hint for the syntax * @param context Content object to control reading process. * @throws RiotNotFoundException if the location is not found - the model is unchanged. */ public static void read(Model model, String uri, String base, Lang hintLang, Context context) { read(model.getGraph(), uri, base, hintLang, context) ; }
/** Read triples into a Model with bytes from an InputStream. * A base URI and a syntax can be provided. * The base URI defualts to "no base" in which case the data should have no relative URIs. * The lang gives the syntax of the stream. * @param model Destination for the RDF read. * @param in InputStream * @param base Base URI * @param lang Language syntax */ public static void read(Model model, InputStream in, String base, Lang lang) { read(model.getGraph(), in, base, lang) ; }
/** Write the model to the output stream in the default serialization for the language. * @param out OutputStream * @param model Model to write * @param serialization Serialization format */ public static void write(OutputStream out, Model model, RDFFormat serialization) { write(out, model.getGraph(), serialization) ; }
/** Sync a Model if it provides the underlying graph provides sync . Do nothing otherwise. */ public static void sync(Model model) { sync(model.getGraph()) ; }
public DatasetImpl(Model model) { defaultModel = model ; this.dsg = DatasetGraphFactory.create(model.getGraph()) ; }
@Deprecated @Override public Model add( Model m, boolean suppressReifications ) { // suppressReifications is a no-op. GraphUtil.addInto( getGraph(), m.getGraph() ); return this; }
public DataSourceImpl(Model model) { addToCache(model) ; // TODO Is this right? this sort of DatasetGraph can't auto-add graphs. this.dsg = DatasetGraphFactory.create(model.getGraph()) ; }
@Override public void write(Model model, Writer out, String base) { if ( base != null && base.equals("") ) base = null ; Graph graph = model.getGraph() ; writer().write(out, graph, RiotLib.prefixMap(graph), base, context) ; }
private Graph getGraph(File tcDir) { Dataset dataset = TDBFactory.createDataset(tcDir.getAbsolutePath()); Model model = dataset.getDefaultModel(); //Model model = TDBFactory.createModel(tcDir.getAbsolutePath()); final com.hp.hpl.jena.graph.Graph jenaGraph = model.getGraph(); dir2JenaGraphMap.put(tcDir, jenaGraph); //dataset. synchronized (dir2Dataset) { dir2Dataset.put(tcDir, dataset); } return new PrivilegedGraphWrapper(new JenaGraphAdaptor(jenaGraph)); }
static private NodeIterator walkBackwards(final Model model, RDFNode rdfNode, Path path) { Iterator<Node> iter = evalInverse(model.getGraph(), rdfNode.asNode(), path) ; return convertGraphNodeToRDFNode(model, iter) ; }
@Override public ExtendedIterator<Triple> find(KnowledgeBase kb, PelletInfGraph pellet, Node s, Node p, Node o) { ModelExtractor me = new ModelExtractor( kb ); me.setSelector( StatementType.ALL_STATEMENTS ); Graph graph = me.extractModel().getGraph(); return graph.find( Triple.ANY ); } }
public void setDefaultModel(Model model) { removeFromCache(dsg.getDefaultGraph()) ; addToCache(model) ; dsg.setDefaultGraph(model.getGraph()) ; }
@Override public void setDefaultModel(Model model) { if ( model == null ) model = ModelFactory.createDefaultModel() ; // Assumes single writer. removeFromCache(dsg.getDefaultGraph()) ; addToCache(model) ; dsg.setDefaultGraph(model.getGraph()) ; }
@Override protected final void exec() { GraphStore graphStore = modGraphStore.getGraphStore() ; if ( graphStore.getDefaultGraph() == null ) graphStore.setDefaultGraph(ModelFactory.createDefaultModel().getGraph()); execUpdate(graphStore) ; }
private void addSubModels( Assembler a, Resource root, MultiUnion union, Mode mode ) { for (StmtIterator it = root.listProperties( JA.subModel ); it.hasNext();) { Resource resource = getResource( it.nextStatement() ); union.addGraph( a.openModel( resource, mode ).getGraph() ); } }
public void replaceNamedModel(String uri, Model model) { Node n = Node.createURI(uri) ; removeFromCache(dsg.getGraph(n)) ; dsg.removeGraph(n) ; addToCache(model) ; dsg.addGraph(n, model.getGraph() ) ; }