本文整理汇总了Java中org.apache.jena.query.DatasetFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java DatasetFactory.create方法的具体用法?Java DatasetFactory.create怎么用?Java DatasetFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.DatasetFactory
的用法示例。
在下文中一共展示了DatasetFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
// For some reason, this is necessary after upgrating to Camel 2.19.
// Otherwise, it looks like the context doesn't start(!??)
context.start();
dataset = DatasetFactory.create();
// Create two named graphs with triples. Verify that they're non-empty from the start.
final Model a = ModelFactory.createDefaultModel();
final Model b = ModelFactory.createDefaultModel();
a.add(a.getResource("test:something"), a.getProperty("test:prop"), a.getResource("test:whatever"));
b.add(b.getResource("test:somethingElse"), b.getProperty("test:prop"), b.getResource("test:whatever"));
dataset.addNamedModel("test:unaffected", a);
dataset.addNamedModel(SERVICE_DOC_URI, b);
}
示例2: testStringAskQuery
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void testStringAskQuery() {
String file = datasource + "tigers.ttl";
// Read triples into dataset
RDFDataMgr.read(markLogicDatasetGraph, file);
markLogicDatasetGraph.sync();
dataSet = DatasetFactory.create(markLogicDatasetGraph);
String query1 = "PREFIX bb: <http://marklogic.com/baseball/players#>" + " ASK " + " WHERE" + " {" + " ?id bb:lastname ?name ."
+ " FILTER EXISTS { ?id bb:country ?countryname }" + " }";
QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
Boolean result = queryExec.execAsk();
assertFalse(result);
String query2 = "PREFIX bb: <http://marklogic.com/baseball/players#>" + "PREFIX r: <http://marklogic.com/baseball/rules#>"
+ " ASK WHERE" + " {" + " ?id bb:team r:Tigers." + " ?id bb:position \"pitcher\"." + " }";
queryExec = QueryExecutionFactory.create(query2, dataSet);
assertTrue(queryExec.execAsk());
markLogicDatasetGraph.close();
markLogicDatasetGraph = MarkLogicDatasetGraphFactory.createDatasetGraph(writerClient);
}
示例3: testStringAskQuery2
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void testStringAskQuery2() {
String file = datasource + "tigers.ttl";
// Read triples into dataset
RDFDataMgr.read(markLogicDatasetGraph, file);
markLogicDatasetGraph.sync();
Graph g = markLogicDatasetGraph.getDefaultGraph();
Node newgraph = NodeFactory.createURI("http://marklogic.com/Graph1");
markLogicDatasetGraph.addGraph(newgraph, g);
dataSet = DatasetFactory.create(markLogicDatasetGraph);
String query1 = "ASK FROM <http://marklogic.com/Graph1>" + " WHERE" + " {" + " ?player ?team <#Tigers>." + " }";
QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
Boolean result = queryExec.execAsk();
assertFalse(result);
String query2 = "PREFIX bb: <http://marklogic.com/baseball/players#>" + "PREFIX r: <http://marklogic.com/baseball/rules#>"
+ " ASK WHERE" + " {" + " ?id bb:team r:Tigers." + " ?id bb:position \"pitcher\"." + " }";
queryExec = QueryExecutionFactory.create(query2, dataSet);
assertTrue(queryExec.execAsk());
}
示例4: setUp
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
Model defaultModel = ModelFactory.createDefaultModel();
defaultModel.add(
ResourceFactory.createResource("http://rdfunit.aksw.org"),
OWL.sameAs,
ResourceFactory.createResource("http://dbpedia.org/resource/Cool")
);
Model namedModel = ModelFactory.createDefaultModel();
namedModel.add(
ResourceFactory.createResource("http://rdfunit.aksw.org"),
OWL.sameAs,
ResourceFactory.createResource("http://dbpedia.org/resource/Super")
);
dataset = DatasetFactory.create(defaultModel);
dataset.addNamedModel("http://rdfunit.aksw.org", namedModel);
}
示例5: ServiceNodeWriter
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
/**
* ServiceNodeWriter.
*
* @param serviceURI String
* @param servicePredicate String
* @param serviceType String
*/
ServiceNodeWriter(final String serviceURI, final String servicePredicate,
final String serviceType) {
final Model model = ModelFactory.createDefaultModel();
final Resource s = model.createResource(getIdentitySubject());
final Property p = model.createProperty(servicePredicate);
final Resource o = model.createResource(serviceURI);
model.add(s, p, o);
final Dataset dataset = DatasetFactory.create(model);
dataset.addNamedModel("http://iiif.service", model);
this.serviceNode = new ByteArrayOutputStream();
RDFDataMgr.write(this.serviceNode, model, Lang.NTRIPLES);
}
示例6: createExpModelForChallengeTask
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
private Model createExpModelForChallengeTask(Model model, String challengeTaskUri, String systemUri) {
Dataset dataset = DatasetFactory.create();
dataset.addNamedModel("http://temp.org/challenge", model);
String query = SparqlQueries.getCreateExperimentFromTaskQuery(Constants.NEW_EXPERIMENT_URI, challengeTaskUri,
systemUri, "http://temp.org/challenge");
if (query == null) {
LOGGER.error("Couldn't load SPARQL query to create an RDF model for a new experiment. Returning null.");
return null;
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
return qe.execConstruct();
}
示例7: DummyStorage
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
public DummyStorage(String configGraphFile, String privateGraphFile, String publicGraphFile) {
super(null);
dataset = DatasetFactory.create();
Model model = configGraphFile != null ? loadModel(configGraphFile) : ModelFactory.createDefaultModel();
dataset.addNamedModel(Constants.CHALLENGE_DEFINITION_GRAPH_URI, model);
model = privateGraphFile != null ? loadModel(privateGraphFile) : ModelFactory.createDefaultModel();
dataset.addNamedModel(Constants.PRIVATE_RESULT_GRAPH_URI, model);
model = publicGraphFile != null ? loadModel(publicGraphFile) : ModelFactory.createDefaultModel();
dataset.addNamedModel(Constants.PUBLIC_RESULT_GRAPH_URI, model);
}
示例8: exec
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public final Model exec() {
Dataset inputDataset = DatasetFactory.create();
QuerySolution initialBindings = new QuerySolutionMap();
Model initialModel = ModelFactory.createDefaultModel();
StreamRDF outputStream = new StreamRDFModel(initialModel);
exec(inputDataset, initialBindings, outputStream);
return initialModel;
}
示例9: testSelectQuery_withbinding
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void testSelectQuery_withbinding() {
markLogicDatasetGraph.clear();
String file = datasource + "property-paths.ttl";
RDFDataMgr.read(markLogicDatasetGraph, file);
markLogicDatasetGraph.sync();
dataSet = DatasetFactory.create(markLogicDatasetGraph);
StringBuilder queryBuilder = new StringBuilder(128);
queryBuilder.append(" prefix : <http://learningsparql.com/ns/papers#> ");
queryBuilder.append(" prefix c: <http://learningsparql.com/ns/citations#>");
queryBuilder.append(" SELECT ?s");
queryBuilder.append(" WHERE { ");
queryBuilder.append(" ?s ^c:cites :paperK2 . ");
queryBuilder.append(" FILTER (?s != :paperK2)");
queryBuilder.append(" } ");
queryBuilder.append(" ORDER BY ?s ");
String query = queryBuilder.toString();
QuerySolutionMap binding = new QuerySolutionMap();
binding.add("whatcode", ResourceFactory.createPlainLiteral("33333"));
QueryExecution queryExec = QueryExecutionFactory.create(query, dataSet, binding);
ResultSet results = queryExec.execSelect();
assertNotNull(results);
assertTrue(results.hasNext());
while (results.hasNext()) {
QuerySolution qs = results.next();
System.out.println(qs.toString());
assertTrue(qs.contains("s"));
String obtained = qs.get("s").asNode().getURI();
System.out.println(obtained);
assertTrue("Expecting subject node to be::http://learningsparql.com/ns/papers#paperJ ",
qs.get("s").asNode().getURI().equals("http://learningsparql.com/ns/papers#paperJ"));
}
}
示例10: testStringCriteriaQuery
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void testStringCriteriaQuery() {
markLogicDatasetGraph.clear();
String file = datasource + "tigers.ttl";
// Read triples into dataset
RDFDataMgr.read(markLogicDatasetGraph, file);
markLogicDatasetGraph.sync();
dataSet = DatasetFactory.create(markLogicDatasetGraph);
queryManager = writerClient.newQueryManager();
String query1 = "ASK WHERE {?s ?p \"Nathan\" .}";
String query2 = "SELECT ?s ?p ?o WHERE {?s ?p ?o .}";
StringQueryDefinition stringDef = queryManager.newStringDefinition().withCriteria("lastname");
markLogicDatasetGraph.setConstrainingQueryDefinition(stringDef);
QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
System.out.println(queryExec);
assertTrue(queryExec.execAsk());
StringQueryDefinition stringDef1 = queryManager.newStringDefinition().withCriteria("Alex");
markLogicDatasetGraph.setConstrainingQueryDefinition(stringDef1);
queryExec = QueryExecutionFactory.create(query2, dataSet);
ResultSet results = queryExec.execSelect();
assertNotNull(results);
assertTrue(results.hasNext());
while (results.hasNext()) {
QuerySolution qs = results.next();
System.out.println(qs.toString());
assertTrue(qs.contains("s"));
assertTrue(qs.contains("p"));
assertTrue(qs.contains("o"));
}
}
示例11: readDataset
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
default Dataset readDataset() throws RdfReaderException {
try {
Dataset dataset = DatasetFactory.create();
readDataset(dataset);
return dataset;
} catch (Exception e) {
throw new RdfReaderException(e);
}
}
示例12: test001ConstructQuery_withbinding
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void test001ConstructQuery_withbinding() {
markLogicDatasetGraph.clear();
Node newgraph = NodeFactory.createURI("http://marklogic.com/graph1");
dataSet = DatasetFactory.create(markLogicDatasetGraph);
markLogicDatasetGraph.add(null, NodeFactory.createURI("john"), NodeFactory.createURI("fname"), NodeFactory.createURI("johnfname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("john"), NodeFactory.createURI("fname"),
NodeFactory.createURI("johnfname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("john"), NodeFactory.createURI("lname"),
NodeFactory.createURI("johnlname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("john"), NodeFactory.createURI("homeTel"),
NodeFactory.createURI("111111111D"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("john"), NodeFactory.createURI("email"),
NodeFactory.createURI("[email protected]"));
markLogicDatasetGraph
.add(newgraph, NodeFactory.createURI("http://Joe"), NodeFactory.createURI("http://fname"), NodeFactory.createURI("http://Joefname"));
markLogicDatasetGraph
.add(newgraph, NodeFactory.createURI("http://Joe"), NodeFactory.createURI("http://lname"), NodeFactory.createURI("http://Joelname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("http://Joe"), NodeFactory.createURI("http://homeTel"),
NodeFactory.createURI("http://222222222D"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("http://Joe"), NodeFactory.createURI("http://email"),
NodeFactory.createURI("http://[email protected]"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("jerry"), NodeFactory.createURI("fname"),
NodeFactory.createURI("jerryfname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("jerry"), NodeFactory.createURI("lname"),
NodeFactory.createURI("jerrylname"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("jerry"), NodeFactory.createURI("homeTel"),
NodeFactory.createURI("333333333D"));
markLogicDatasetGraph.add(newgraph, NodeFactory.createURI("jerry"), NodeFactory.createURI("email"),
NodeFactory.createURI("[email protected]"));
String query = "CONSTRUCT{ ?person <http://homeTel> ?o .} FROM <http://marklogic.com/graph1> WHERE {"
+ " ?person <http://homeTel> ?o . ?person <http://fname> ?firstname .} ";
QuerySolutionMap binding = new QuerySolutionMap();
binding.add("firstname", ResourceFactory.createResource("http://Joefname"));
QueryExecution queryExec = QueryExecutionFactory.create(query, dataSet, binding);
Model results = queryExec.execConstruct();
assertTrue(results.getGraph().size() == 1);
assertTrue(results.getGraph().contains(Node.ANY, Node.ANY, NodeFactory.createURI("http://222222222D")));
// Query wihtout base URI, bcs of the default base URI in query we should get empty result set Git issue #23
String query1 = "CONSTRUCT{ ?person <homeTel> ?o .} FROM <http://marklogic.com/graph1> WHERE {"
+ " ?person <homeTel> ?o . ?person <fname> ?firstname .} ";
QuerySolutionMap binding1 = new QuerySolutionMap();
binding1.add("firstname", ResourceFactory.createResource("jerryfname"));
QueryExecution queryExec1 = QueryExecutionFactory.create(query1, dataSet, binding1);
Model results1 = queryExec1.execConstruct();
assertTrue(results1.getGraph().size() == 0);
}
示例13: testRawCombinedQueryQuery
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
@Test
public void testRawCombinedQueryQuery() {
markLogicDatasetGraph.clear();
String file = datasource + "tigers.ttl";
// Read triples into dataset
RDFDataMgr.read(markLogicDatasetGraph, file);
markLogicDatasetGraph.sync();
dataSet = DatasetFactory.create(markLogicDatasetGraph);
queryManager = writerClient.newQueryManager();
String query1 = "ASK WHERE {?s ?p \"Nathan\" .}";
String query2 = "SELECT ?s ?p ?o WHERE {?s ?p ?o .}";
// case one, rawcombined
String combinedQuery = "{\"search\":" + "{\"qtext\":\"lastname\"}}";
String combinedQuery2 = "{\"search\":" + "{\"qtext\":\"Alex\"}}";
RawCombinedQueryDefinition rawCombined = queryManager.newRawCombinedQueryDefinition(new StringHandle().with(combinedQuery)
.withFormat(Format.JSON));
RawCombinedQueryDefinition rawombined2 = queryManager.newRawCombinedQueryDefinition(new StringHandle().with(combinedQuery2)
.withFormat(Format.JSON));
markLogicDatasetGraph.setConstrainingQueryDefinition(rawCombined);
QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
System.out.println(queryExec);
assertTrue(queryExec.execAsk());
markLogicDatasetGraph.setConstrainingQueryDefinition(rawombined2);
queryExec = QueryExecutionFactory.create(query2, dataSet);
ResultSet results = queryExec.execSelect();
assertNotNull(results);
assertTrue(results.hasNext());
while (results.hasNext()) {
QuerySolution qs = results.next();
System.out.println(qs.toString());
assertTrue(qs.contains("s"));
assertTrue(qs.contains("p"));
assertTrue(qs.contains("o"));
}
}
示例14: DatasetTestSource
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
DatasetTestSource(SourceConfig sourceConfig, QueryingConfig queryingConfig, Collection<SchemaSource> referenceSchemata, RdfReader dumpReader) {
this(sourceConfig, queryingConfig, referenceSchemata, dumpReader, DatasetFactory.create()); //OntModelSpec.RDFS_MEM_RDFS_INF
}
示例15: createQueryExecution
import org.apache.jena.query.DatasetFactory; //导入方法依赖的package包/类
/**
* Creates a QueryExecution for a given Query in a given Model, with
* some given initial bindings.
* The implementation basically uses Jena's QueryExecutionFactory
* but with the option to use different Dataset as specified by
* <code>getDataset(model)</code>.
* @param query the Query
* @param model the Model to query
* @param initialBinding the initial variable bindings or null
* @return a QueryExecution
*/
public QueryExecution createQueryExecution(Query query, Model model, QuerySolution initialBinding) {
Dataset dataset = getDataset(model);
if(dataset == null) {
dataset = DatasetFactory.create(model);
}
return createQueryExecution(query, dataset, initialBinding);
}