本文整理汇总了Java中org.apache.jena.query.QueryExecution.execAsk方法的典型用法代码示例。如果您正苦于以下问题:Java QueryExecution.execAsk方法的具体用法?Java QueryExecution.execAsk怎么用?Java QueryExecution.execAsk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.QueryExecution
的用法示例。
在下文中一共展示了QueryExecution.execAsk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fuseki_stop_start
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void fuseki_stop_start() {
PatchLogServer patchLogServer = patchLogServer();
FusekiServer server1 = fuseki1();
try {
server1.stop();
RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
QueryExecution qExec = conn1.query("ASK{}");
try { qExec.execAsk(); fail(); } catch(QueryExceptionHTTP ex) {}
// Restart, same port.
server1 = fuseki1();
QueryExecution qExec1 = conn1.query("ASK{}");
qExec1.execAsk();
} finally {
server1.stop();
patchLogServer.stop();
}
}
示例2: testStringAskQuery
import org.apache.jena.query.QueryExecution; //导入方法依赖的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.QueryExecution; //导入方法依赖的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: getConcept
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public Concept getConcept(URI uri) {
Resource conceptResource = resourceFromURI(model, uri);
String sparql = "ASK WHERE { ?conceptURI a ?classURI . ?classURI rdfs:subClassOf* skos:Concept . }";
ParameterizedSparqlString findConceptSparql = new ParameterizedSparqlString(model);
findConceptSparql.setCommandText(sparql);
findConceptSparql.setParam("conceptURI", conceptResource);
Query query = QueryFactory.create(findConceptSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk() ? new Concept(model, conceptResource) : null;
}
示例5: getConceptScheme
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public ConceptScheme getConceptScheme(URI uri) {
Resource conceptSchemeResource = model.getResource(uri.toString());
String sparql = "ASK WHERE { ?conceptSchemeURI a skos:ConceptScheme . }";
ParameterizedSparqlString findConceptSchemeSparql = new ParameterizedSparqlString(model);
findConceptSchemeSparql.setCommandText(sparql);
findConceptSchemeSparql.setParam("conceptSchemeURI", conceptSchemeResource);
Query query = QueryFactory.create(findConceptSchemeSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk() ? new ConceptScheme(model, conceptSchemeResource) : null;
}
示例6: labelExistsInLanguage
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
private boolean labelExistsInLanguage(Label label) {
String sparql = "ASK WHERE { ?objectURI rdfs:label ?label . FILTER(LANG(?label) = STR(?labelLanguage)) }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("objectURI", resource);
parameterizedSparql.setParam("labelLanguage", model.createLiteral(label.getLanguageCode(), ""));
Query query = QueryFactory.create(parameterizedSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk();
}
示例7: labelExists
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
private boolean labelExists(Label label) {
String sparql = "ASK WHERE { ?objectURI rdfs:label ?label }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("objectURI", resource);
parameterizedSparql.setParam("label", model.createLiteral(label.getValue(), label.getLanguageCode()));
Query query = QueryFactory.create(parameterizedSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk();
}
示例8: labelExistsInLanguage
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
private boolean labelExistsInLanguage(Label label) {
String sparql = "ASK WHERE { ?conceptSchemeURI rdfs:label ?label . FILTER(LANG(?label) = STR(?labelLanguage)) }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("conceptSchemeURI", resource);
parameterizedSparql.setParam("labelLanguage", model.createLiteral(label.getLanguageCode(), ""));
Query query = QueryFactory.create(parameterizedSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk();
}
示例9: labelExists
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
private boolean labelExists(Label label) {
String sparql = "ASK * WHERE { ?conceptSchemeURI rdfs:label ?label }";
ParameterizedSparqlString parameterizedSparql = new ParameterizedSparqlString(model);
parameterizedSparql.setCommandText(sparql);
parameterizedSparql.setParam("conceptSchemeURI", resource);
parameterizedSparql.setParam("selectedLabel", model.createLiteral(label.getValue(), label.getLanguageCode()));
Query query = QueryFactory.create(parameterizedSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
return qexec.execAsk();
}
示例10: containsVocabulary
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static boolean containsVocabulary(String uri) {
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);
try {
String q = "ASK { GRAPH ?g { <%s> a <http://www.w3.org/2002/07/owl#Ontology> } }";
QueryExecution qexec = QueryExecutionFactory.create(String.format(q, uri), dataset);
return qexec.execAsk();
} catch (Exception e) {
throw e;
} finally {
dataset.end();
}
}
示例11: queryData2
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static Boolean queryData2(String query){
Dataset db = TDBFactory.createDataset("temp/dataset");
db.begin(ReadWrite.READ);
Model model = db.getDefaultModel();
Query q = QueryFactory.create(query);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
List<String> answer = new ArrayList<String>();
Boolean t = (qexec.execAsk());
qexec.close();
db.close();
return t;
}
示例12: fuseki_stop
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test(expected=QueryExceptionHTTP.class)
public void fuseki_stop() {
PatchLogServer patchLogServer = patchLogServer();
FusekiServer server1 = fuseki1();
try {
server1.stop();
RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
QueryExecution qExec = conn1.query("ASK{}");
qExec.execAsk();
} finally {
patchLogServer.stop();
}
}
示例13: fuseki_start
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test(expected=AssemblerException.class)
public void fuseki_start() {
// No PatchLogServer running.
//PatchLogServer patchLogServer = patchLogServer();
// AssemblerException -> HttpException -> NoHttpResponseException
FusekiServer server1 = fuseki1();
server1.stop();
RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
QueryExecution qExec = conn1.query("ASK{}");
qExec.execAsk();
}
示例14: patchserver_stop_start
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void patchserver_stop_start() {
PatchLogServer patchLogServer = patchLogServer();
FusekiServer server1 = fuseki1();
try {
patchLogServer.stop();
patchLogServer = null;
// Should fail
try {
RDFConnection conn0 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
conn0.update(PREFIX+"INSERT DATA { :s :p 'update_patchserver_stop_start' }");
Assert.fail("Should not be able to update at the moment");
} catch (HttpException ex) {
assertEquals(503, ex.getResponseCode());
}
patchLogServer = patchLogServer();
RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
QueryExecution qExec = conn1.query("ASK{}");
// 500 due to offline patchLogServer.
qExec.execAsk();
} finally {
server1.stop();
if ( patchLogServer != null )
patchLogServer.stop();
}
}
示例15: containsVocabulary
import org.apache.jena.query.QueryExecution; //导入方法依赖的package包/类
public static boolean containsVocabulary(String uri) {
Dataset dataset = Repository.get().dataset;
dataset.begin(ReadWrite.READ);
try {
String q = "ASK { GRAPH ?g { <%s> a <http://www.w3.org/2002/07/owl#Ontology> } }";
QueryExecution qexec = QueryExecutionFactory.create(String.format(q, uri), dataset);
return qexec.execAsk();
} catch (Exception e) {
throw e;
} finally {
dataset.end();
}
}