本文整理汇总了Java中org.apache.jena.query.QueryExecution.execConstruct方法的典型用法代码示例。如果您正苦于以下问题:Java QueryExecution.execConstruct方法的具体用法?Java QueryExecution.execConstruct怎么用?Java QueryExecution.execConstruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.QueryExecution
的用法示例。
在下文中一共展示了QueryExecution.execConstruct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPublicModel
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public Model getPublicModel() {
String sparql = "PREFIX voting: <" + VotingSystemData.VOTE_NS + "> "
+ "CONSTRUCT { " + "?x a voting:Vote . "
+ "?x voting:sha1sum ?sha1sum . "
+ "?paper a voting:EligibleForVotingPaper . "
+ "?paper voting:paperOfTrack ?track . "
+ "?paper voting:id ?id . "
+ "?paper <" + DC_11.title.getURI() + "> ?title "
+ "} "
+ "WHERE{ "
+ "?x a voting:Vote . " + "?x voting:sha1sum ?sha1sum . "
+ "?paper a voting:EligibleForVotingPaper . "
+ "?paper voting:paperOfTrack ?track . "
+ "?paper voting:id ?id . "
+ "?paper <" + DC_11.title.getURI() + "> ?title "
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query,
adminModel);
return queryExecution.execConstruct();
}
示例2: buildRDF
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Override
public Model buildRDF(File directory) {
Model modelout = ModelFactory.createDefaultModel();
Model model = ModelFactory.createDefaultModel();
try {
model.read(new FileInputStream(directory), null, "RDF/XML");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!model.isEmpty()) {
String sparql = "PREFIX foaf: <" + FOAF.NS + "> "
+ "CONSTRUCT {?author foaf:depiction ?depiction} "
+ "WHERE{?author foaf:depiction ?depiction}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query,
model);
modelout = queryExecution.execConstruct();
}
return modelout;
}
示例3: mergeVocabularies
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static Model mergeVocabularies() {
// TODO add argument to scope the operation
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);
try {
String q = "CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?ontology a <http://www.w3.org/2002/07/owl#Ontology> . ?s ?p ?o } }";
QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
return qexec.execConstruct();
} catch (Exception e) {
throw e;
} finally {
dataset.end();
}
}
示例4: createExpModelForChallengeTask
import org.apache.jena.query.QueryExecution; //导入方法依赖的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();
}
示例5: sendConstructQuery
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Override
public Model sendConstructQuery(String query) {
if (query == null) {
LOGGER.error("The given query is null. Returning null.");
return null;
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
return qe.execConstruct();
}
示例6: testConstruct
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void testConstruct() {
QueryExecution queryExec = QueryExecutionFactory
.create("PREFIX : <http://example.org/> CONSTRUCT { :r100 ?p ?o } WHERE { :r1 ?p ?o }",
ds);
Model solution = queryExec.execConstruct();
assertTrue("Got a solution with four triples", solution.getGraph()
.size() > 0);
}
示例7: remove
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public void remove(Model model, CSVReader csvReader) {
String[] line = null;
try {
while ((line = csvReader.readNext()) != null) {
String correct = line[0];
String wrong = line[1];
System.out.println(wrong);
Resource correctPerson = model
.getResource(ns.personNs + correct);
Resource wrongPerson = model
.getResource(ns.personNs + wrong);
String sparql = "PREFIX foaf: <" + FOAF.NS + "> "
+ "CONSTRUCT {" + " <" + correctPerson
+ "> ?outgoing ?val . " + " ?obj ?ingoing <"
+ correctPerson + "> . " + "} " + "WHERE{" + " <"
+ wrongPerson + "> ?outgoing ?val . "
+ " FILTER(isIRI(?val)) . " + " ?obj ?ingoing <"
+ wrongPerson + "> . " + "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(
query, model);
Model m = queryExecution.execConstruct();
model.add(m);
model.removeAll(wrongPerson, null, (RDFNode) null);
model.removeAll(null, null, wrongPerson);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: PosterDemoHandler
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public PosterDemoHandler(Model posterDemoModel) {
this.dataModel = posterDemoModel;
String sparql = "PREFIX swrc: <http://swrc.ontoware.org/ontology#> "
+ "PREFIX fabio: <http://purl.org/spar/fabio/> "
+ "CONSTRUCT {?paper a swrc:InProceedings}"
+ "WHERE{{?paper a fabio:DemoPaper} UNION {?paper a fabio:PosterPaper}}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query,
posterDemoModel);
Model inProceedingsModel = queryExecution.execConstruct();
posterDemoModel.add(inProceedingsModel);
}
示例9: PhDSympHandler
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public PhDSympHandler(Model phDSympModel) {
this.dataModel = phDSympModel;
//TODO adjust query for phDSymp
String sparql = "PREFIX swrc: <http://swrc.ontoware.org/ontology#> " +
"PREFIX fabio: <http://purl.org/spar/fabio/> " +
"CONSTRUCT {?paper a swrc:InProceedings}" +
"WHERE{{?paper a fabio:PhDSymposiumPaper}}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, phDSympModel);
Model inProceedingsModel = queryExecution.execConstruct();
phDSympModel.add(inProceedingsModel);
}
示例10: ChallengeHandler
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public ChallengeHandler(Model phDSympModel) {
this.dataModel = phDSympModel;
// TODO adjust query for phDSymp
String sparql = "PREFIX swrc: <http://swrc.ontoware.org/ontology#> "
+ "PREFIX fabio: <http://purl.org/spar/fabio/> "
+ "CONSTRUCT {?paper a swrc:InProceedings}"
+ "WHERE{{?paper a fabio:ChallengePaper}}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query,
phDSympModel);
Model inProceedingsModel = queryExecution.execConstruct();
phDSympModel.add(inProceedingsModel);
}
示例11: test
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public void test(){
String sparql = "prefix swrc: <http://swrc.ontoware.org/ontology#> " +
"prefix bibo: <http://purl.org/ontology/bibo/> " +
"prefix cont: <http://www.ontologydesignpatterns.org/ont/conference.owl#> " +
"prefix dc: <http://purl.org/dc/elements/1.1/> " +
"prefix fun: <http://data.semanticweb.org/function/> " +
"prefix fabio: <http://purl.org/spar/fabio/> " +
"construct { " +
"?paper a fabio:ConferencePaper . " +
"?paper cont:hasAuthorList ?authorList . " +
"?paper cont:hasAuthor ?author . " +
"?author a cont:Person . " +
"?author cont:hasRole ?authorRole . " +
"?authorRole cont:atEvent <http://data.semanticweb.org/conference/eswc/2014> . " +
"<http://data.semanticweb.org/conference/eswc/2014> a cont:Conference " +
"} " +
"where{ " +
"?paper a swrc:InProceedings . " +
"?paper bibo:authorList ?authorList . " +
"?paper dc:creator ?author . " +
"bind(IRI(concat('http://data.semanticweb.org/role/author/',fun:localName(?author))) AS ?authorRole) " +
"}";
Model model = FileManager.get().loadModel("rext.rdf");
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
Model out = queryExecution.execConstruct();
out.write(System.out);
}
示例12: mergeVocabularies
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static Model mergeVocabularies() {
// TODO add argument to scope the operation
Dataset dataset = Repository.get().dataset;
dataset.begin(ReadWrite.READ);
try {
String q = "CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?ontology a <http://www.w3.org/2002/07/owl#Ontology> . ?s ?p ?o } }";
QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
return qexec.execConstruct();
} catch (Exception e) {
throw e;
} finally {
dataset.end();
}
}
示例13: test001ConstructQuery_withbinding
import org.apache.jena.query.QueryExecution; //导入方法依赖的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);
}
示例14: execConstruct
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static Model execConstruct(Model model, String sparql){
QueryExecution queryExecution = createQueryExecution(model, sparql);
return queryExecution.execConstruct();
}
示例15: generateGazeteer
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
/**
* @param args
*/
public static void generateGazeteer(String resFolder, String... service) {
GenerateNameGraph queryDBPedia = new GenerateNameGraph();
File book = new File(resFolder);
if (!book.exists())
book.mkdirs();
String prefix = GenerateNameGraph.getPREFIX();
String sparqlQueryString1;
String sparqlQueryString2;
sparqlQueryString1 = "CONSTRUCT { ?x <http://xmlns.com/foaf/0.1/name> ?name} WHERE { ?x <http://xmlns.com/foaf/0.1/name> ?name }";
sparqlQueryString2 = prefix + '\n'
+ "SELECT DISTINCT * WHERE { ?s ?p ?o } LIMIT 10";
Query query = QueryFactory.create(sparqlQueryString1);
QueryExecution qexec = QueryExecutionFactory.sparqlService(service[0],
query);
Model resultModel = qexec.execConstruct();
qexec.close();
try {
OutputStream out = new FileOutputStream("./out/names.rdf");
resultModel.write(out);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(resultModel);
// gaz1 = queryDBPedia.queryService(
// service, sparqlQueryString1, "name");
Set<String> gaz1 = null;
for (String s : service) {
gaz1 = queryDBPedia.queryService(s, sparqlQueryString2, "p");
}
System.out.println("gazeteer size: " + gaz1.size());
System.out.println(gaz1);
}