当前位置: 首页>>代码示例>>Java>>正文


Java QueryExecution.execAsk方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:TestDeltaFusekiBad.java

示例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);

}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:23,代码来源:JenaSPARQLUpdateTests.java

示例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());

}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:24,代码来源:JenaSPARQLUpdateTests.java

示例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;
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:13,代码来源:SemaphoreModel.java

示例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;
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:15,代码来源:SemaphoreModel.java

示例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();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:13,代码来源:ObjectWithURI.java

示例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();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:13,代码来源:ObjectWithURI.java

示例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();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:13,代码来源:Concept.java

示例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();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:13,代码来源:Concept.java

示例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();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:15,代码来源:VocabularyUtils.java

示例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;
}
 
开发者ID:kunal15595,项目名称:smart-question-answering-nlp,代码行数:13,代码来源:Database.java

示例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();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:14,代码来源:TestDeltaFusekiBad.java

示例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();
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:14,代码来源:TestDeltaFusekiBad.java

示例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();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:30,代码来源:TestDeltaFusekiBad.java

示例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();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:15,代码来源:VocabularyUtils.java


注:本文中的org.apache.jena.query.QueryExecution.execAsk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。