org.apache.jena.sparql.graph.GraphFactory Java Examples
The following examples show how to use
org.apache.jena.sparql.graph.GraphFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 6 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, Expr sourceExpr) { String sourceURI = evalSourceURI(binding, context, sourceExpr); final String absURI = baseURI(sourceURI, baseURI); Dataset dataset = ContextUtils.getDataset(context); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } // default: check the dataset if (dataset.containsNamedModel(absURI)) { Graph dg = dataset.getNamedModel(absURI).getGraph(); GraphUtil.addInto(g, dg); return; } // fallback: load as RDF graph StreamRDF dest = StreamRDFLib.graph(g); ContextUtils.loadGraph(context, sourceURI, absURI, dest); }
Example #2
Source File: QueryExecutionTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
protected Model loadModel( String filename ) { final String fullFilename = getClass().getResource("/TurtleStar/"+filename).getFile(); final Graph g = new GraphWrapperStar( GraphFactory.createDefaultGraph() ); final Model m = ModelFactory.createModelForGraph(g); RDFDataMgr.read(m, fullFilename); return m; }
Example #3
Source File: TestRDFChangesDataset.java From rdf-delta with Apache License 2.0 | 5 votes |
@Test public void record_add_graph_1() { Txn.executeWrite(dsg, ()->dsg.add(quad1)); Graph data = GraphFactory.createDefaultGraph(); Node gn = quad1.getGraph(); data.add(triple1); Txn.executeWrite(dsg, ()-> { dsg.addGraph(gn, data); }); DatasetGraph dsg2 = replay(); check(dsg2, Quad.create(gn, triple1)); }
Example #4
Source File: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 5 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, SPARQLExtQuery generate, Expr name) { String sourceURI = evalSourceURI(binding, context, name); final String absURI = baseURI(sourceURI, baseURI); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } loadGraph(binding, context, generate, g); }
Example #5
Source File: PredicateMappingsDataSet.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public void writeHashingFunctionToDataset(Set<String> predicates, boolean isDirect, IHashingFamily family) { String type = isDirect ? "direct" : "reverse"; Node predicateNode = NodeFactory.createURI(Constants.ibmns + Constants.COLUMN_PREDICATE); Graph[] hashingGraphs = new Graph[numberOfHashFunctions]; for (int i = 0; i < numberOfHashFunctions; i++) { hashingGraphs[i] = GraphFactory.createPlainGraph(); } Iterator<String> predicateIterator = predicates.iterator(); while (predicateIterator.hasNext()) { String entry = predicateIterator.next(); family.computeHash(entry); int[] hashes = family.getHash(entry); for (int i = 0; i < numberOfHashFunctions; i++) { Triple triple = new Triple(NodeFactory.createURI(entry), predicateNode, intToNode(hashes[i])); hashingGraphs[i].add(triple); } } for (int i = 0; i < numberOfHashFunctions; i++) { dataset.addNamedModel(Constants.ibmns + Constants.HASHING_FUNCTION + type + (i + 1), ModelFactory.createModelForGraph(hashingGraphs[i])); Node hashFunction = NodeFactory.createURI(Constants.ibmns + Constants.HASHING_FUNCTION + type + (i + 1)); Triple deftriple3 = new Triple(hashFunction, NodeFactory.createURI(Constants.ibmns + Constants.FUNCTION_TYPE_PREDICATE), NodeFactory.createLiteral("hashing"));//, "", "")); dataset.getDefaultModel().getGraph().add(deftriple3); dataset.getDefaultModel() .getGraph() .add(new Triple(hashFunction, NodeFactory.createURI(Constants.ibmns + Constants.FUNCTION_PRIORITY), intToNode(numberOfColorFunctions + i + 1))); dataset.getDefaultModel() .getGraph() .add(new Triple( hashFunction, NodeFactory.createURI(Constants.ibmns + Constants.COLORING_FUNCTION_TUPE_PREDICATE), NodeFactory.createLiteral(type)));//, "", ""))); } }
Example #6
Source File: ResultSetWritersSPARQLStarTest.java From RDFstarTools with Apache License 2.0 | votes |
public RDFStarAwareModel() { this( GraphFactory.createDefaultGraph() ); }