• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ReadWrite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.query.ReadWrite的典型用法代码示例。如果您正苦于以下问题:Java ReadWrite类的具体用法?Java ReadWrite怎么用?Java ReadWrite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReadWrite类属于org.apache.jena.query包,在下文中一共展示了ReadWrite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listVocabularies

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
public static Set<String> listVocabularies() {
	Set<String> tds = new HashSet<>();
	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		String q = "SELECT DISTINCT ?g WHERE { GRAPH ?g { ?o a <http://www.w3.org/2002/07/owl#Ontology> } }";
		QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
		ResultSet result = qexec.execSelect();
		while (result.hasNext()) {
			tds.add(result.next().get("g").asResource().getURI());
		}
	} catch (Exception e) {
		throw e;
	} finally {
		dataset.end();
	}

	return tds;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:21,代码来源:VocabularyUtils.java


示例2: get

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
	RESTResource resource = new RESTResource(uri.toString(),this);

	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		Model result = dataset.getNamedModel(uri.toString());
		if (!result.isEmpty()) {
			resource.contentType = "text/turtle";
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			result.write(out, "Turtle");
			resource.content = out.toString();
		} else {
			throw new RESTException();
		}
	} finally {
		dataset.end();
	}
	
	return resource;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:24,代码来源:VocabularyHandler.java


示例3: delete

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public void delete(URI uri, Map<String, String> parameters, InputStream payload) throws RESTException {
	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.WRITE);
	
	try {
		dataset.getDefaultModel().getResource(uri.toString()).removeProperties();
		dataset.removeNamedModel(uri.toString());
		deleteToAll(uri.getPath());
		dataset.commit();
	} catch (Exception e) {
		// TODO distinguish between client and server errors
		throw new RESTException();
	} finally {
		dataset.end();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:18,代码来源:VocabularyHandler.java


示例4: get

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
	RESTResource resource = new RESTResource(uri.toString(),this);

	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		String q = "SELECT ?str WHERE { <" + uri + "> <" + DC.source + "> ?str }";
		QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
		ResultSet result = qexec.execSelect();

		if (result.hasNext()) {
			resource.contentType = "application/ld+json";
			resource.content = result.next().get("str").asLiteral().getLexicalForm();
		} else {
			throw new RESTException();
		}
	} finally {
		dataset.end();
	}
	
	return resource;
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:25,代码来源:ThingDescriptionHandler.java


示例5: delete

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public void delete(URI uri, Map<String, String> parameters, InputStream payload) throws RESTException {
	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.WRITE);
	try {
		dataset.getDefaultModel().createResource(uri.toString()).removeProperties();
		dataset.removeNamedModel(uri.toString());
		deleteToAll(uri.getPath());
		dataset.commit();
		
		// Remove from priority queue
		ThingDescription td = new ThingDescription(uri.toString());
		ThingDirectory.get().tdQueue.remove(td);
		ThingDirectory.get().setTimer();
					
	} catch (Exception e) {
		// TODO distinguish between client and server errors
		throw new RESTException();
	} finally {
		dataset.end();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:23,代码来源:ThingDescriptionHandler.java


示例6: listThingDescriptions

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
public static List<String> listThingDescriptions(String query) {
List<String> tds = new ArrayList<>();
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT DISTINCT ?g WHERE { GRAPH ?g { " + query + " FILTER NOT EXISTS { ?ontology a <http://www.w3.org/2002/07/owl#Ontology> } } }";
  try (QueryExecution qexec = QueryExecutionFactory.create(q, dataset)) {
	ResultSet result = qexec.execSelect();
	while (result.hasNext()) {
	  tds.add(result.next().get("g").asResource().getURI());
	}
  }
catch (Exception e) {
  throw e;
}
} finally {
  dataset.end();
}

return tds;
 }
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:23,代码来源:ThingDescriptionUtils.java


示例7: getThingDescriptionIdFromUri

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
/**
  * Returns the ID of a thing description stored in the database given its URI.
  * @param uri URI of the thing description we want to return.
  * @return the ID of the thing description.
  */
 public static String getThingDescriptionIdFromUri(String uri) {

String query = "?td <http://iot.linkeddata.es/def/wot#baseURI> <" + uri + ">";
String id = "NOT FOUND";
  
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT ?g_id WHERE { GRAPH ?g_id { " + query + " }}";
  QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
  ResultSet result = qexec.execSelect();
  while (result.hasNext()) { 
    id = result.next().get("g_id").toString();
  }
} catch (Exception e) {
  e.printStackTrace();
  throw e;
} finally {
  dataset.end();
}

return id;
 }
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:30,代码来源:ThingDescriptionUtils.java


示例8: listThingDescriptionsUri

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
/**
  * Returns a list of the thing descriptions URIs.
  * @return a list of URIs stored in the database.
  */
 public static List<String> listThingDescriptionsUri() {

List<String> tds = new ArrayList<>();
String query = "?td <http://iot.linkeddata.es/def/wot#baseURI> ?uri";
  
Dataset dataset = ThingDirectory.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT ?uri WHERE { GRAPH ?g_id { " + query + " }}";
  try (QueryExecution qexec = QueryExecutionFactory.create(q, dataset)) {
	ResultSet result = qexec.execSelect();
	while (result.hasNext()) { 
	tds.add(result.next().get("uri").toString());
	}
  }
catch (Exception e) {
  throw e;
}
} finally {
  dataset.end();
}

return tds;
 }
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:30,代码来源:ThingDescriptionUtils.java


示例9: queryData

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
public static List<String> queryData(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);
    ResultSet results = qexec.execSelect();
    List<String> answer = new ArrayList<String>();
    while(results.hasNext()){
    	QuerySolution t = results.nextSolution();
    	RDFNode x  = t.get("x");
    	String s = x.toString();
	System.out.println(s);
    	answer.add(s.substring(7));
    }
    qexec.close();
    db.close();
    return answer;
}
 
开发者ID:kunal15595,项目名称:smart-question-answering-nlp,代码行数:20,代码来源:Database.java


示例10: begin

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public void begin() {
    if ( insideBegin ) {
        super.begin(); 
        return;
    }
    insideBegin = true;
    try {
        // For the sync, we have to assume it will write.
        // Any potential write causes a write-sync to be done in "begin".
        txnSyncHandler.accept(ReadWrite.WRITE);
        if ( transactionMode() == ReadWrite.WRITE )
            monitor.txnBegin();
    } finally {
        insideBegin = false;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:18,代码来源:DatasetGraphChanges.java


示例11: promote

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
    public boolean promote() {
        // Any potential write causes a write-sync to be done in "begin".
        // Here we are inside the transaction so calling the sync handler is not possible (nestd transaction risk). 
        if ( super.transactionMode() == ReadWrite.READ ) {
            boolean b = super.promote();
            if ( super.transactionMode() == ReadWrite.WRITE ) {
//                // Promotion.
//                if ( transactionType() == TxnType.READ_COMMITTED_PROMOTE )
//                    txnSyncHandler.accept(ReadWrite.WRITE);
                // We have gone ReadWrite.READ -> ReadWrite.WRITE
                monitor.txnBegin();
            }
            return b;
        }
        //Already WRITE.
        return super.promote();
    }
 
开发者ID:afs,项目名称:rdf-delta,代码行数:19,代码来源:DatasetGraphChanges.java


示例12: update_3

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Test
public void update_3() {
    // Create on the Delta link then setup DeltaClient
    DeltaLink dLink = getLink();
    String DS_NAME = "12345";
    
    Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_3");
    DeltaClient dClient = createDeltaClient();
    dClient.register(dsRef, LocalStorageType.MEM, TxnSyncPolicy.NONE);
    DeltaConnection dConn = dClient.get(DS_NAME);
    Quad quad = SSE.parseQuad("(_ :s :p :o)");
    DatasetGraph dsg = dConn.getDatasetGraph();

    long x0 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(0, x0);
    
    dsg.begin(ReadWrite.WRITE);
    dsg.add(quad);
    dsg.abort();
    
    long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) );
    assertEquals(0, x1);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:24,代码来源:AbstractTestDeltaClient.java


示例13: listVocabularies

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
public static Set<String> listVocabularies() {
	Set<String> tds = new HashSet<>();
	Dataset dataset = Repository.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		String q = "SELECT DISTINCT ?g WHERE { GRAPH ?g { ?o a <http://www.w3.org/2002/07/owl#Ontology> } }";
		QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
		ResultSet result = qexec.execSelect();
		while (result.hasNext()) {
			tds.add(result.next().get("g").asResource().getURI());
		}
	} catch (Exception e) {
		throw e;
	} finally {
		dataset.end();
	}

	return tds;
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:21,代码来源:VocabularyUtils.java


示例14: get

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
	RESTResource resource = new RESTResource(uri.toString(),this);

	Dataset dataset = Repository.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		Model result = dataset.getNamedModel(uri.toString());
		if (!result.isEmpty()) {
			resource.contentType = "text/turtle";
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			result.write(out, "Turtle");
			resource.content = out.toString();
		} else {
			throw new RESTException();
		}
	} finally {
		dataset.end();
	}
	
	return resource;
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:24,代码来源:VocabularyHandler.java


示例15: delete

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public void delete(URI uri, Map<String, String> parameters, InputStream payload) throws RESTException {
	Dataset dataset = Repository.get().dataset;
	dataset.begin(ReadWrite.WRITE);
	
	try {
		dataset.getDefaultModel().getResource(uri.toString()).removeProperties();
		dataset.removeNamedModel(uri.toString());
		deleteToAll(uri.getPath());
		dataset.commit();
	} catch (Exception e) {
		// TODO distinguish between client and server errors
		throw new RESTException();
	} finally {
		dataset.end();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:18,代码来源:VocabularyHandler.java


示例16: get

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
	RESTResource resource = new RESTResource(uri.toString(),this);

	Dataset dataset = Repository.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		String q = "SELECT ?str WHERE { <" + uri + "> <" + DC.source + "> ?str }";
		QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
		ResultSet result = qexec.execSelect();

		if (result.hasNext()) {
			resource.contentType = "application/ld+json";
			resource.content = result.next().get("str").asLiteral().getLexicalForm();
		} else {
			throw new RESTException();
		}
	} finally {
		dataset.end();
	}
	
	return resource;
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:25,代码来源:ThingDescriptionHandler.java


示例17: delete

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
@Override
public void delete(URI uri, Map<String, String> parameters, InputStream payload) throws RESTException {
	Dataset dataset = Repository.get().dataset;
	dataset.begin(ReadWrite.WRITE);
	try {
		dataset.getDefaultModel().createResource(uri.toString()).removeProperties();
		dataset.removeNamedModel(uri.toString());
		deleteToAll(uri.getPath());
		dataset.commit();
		
		// Remove from priority queue
		ThingDescription td = new ThingDescription(uri.toString());
		Repository.get().tdQueue.remove(td);
		Repository.get().setTimer();
					
	} catch (Exception e) {
		// TODO distinguish between client and server errors
		throw new RESTException();
	} finally {
		dataset.end();
	}
}
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:23,代码来源:ThingDescriptionHandler.java


示例18: listThingDescriptions

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
public static List<String> listThingDescriptions(String query) {
List<String> tds = new ArrayList<>();
Dataset dataset = Repository.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT DISTINCT ?g WHERE { GRAPH ?g { " + query + " FILTER NOT EXISTS { ?ontology a <http://www.w3.org/2002/07/owl#Ontology> } } }";
  try (QueryExecution qexec = QueryExecutionFactory.create(q, dataset)) {
	ResultSet result = qexec.execSelect();
	while (result.hasNext()) {
	  tds.add(result.next().get("g").asResource().getURI());
	}
  }
catch (Exception e) {
  throw e;
}
} finally {
  dataset.end();
}

return tds;
 }
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:23,代码来源:ThingDescriptionUtils.java


示例19: getThingDescriptionIdFromUri

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
/**
  * Returns the ID of a thing description stored in the database given its URI.
  * @param uri URI of the thing description we want to return.
  * @return the ID of the thing description.
  */
 public static String getThingDescriptionIdFromUri(String uri) {

String query = "?td <http://iot.linkeddata.es/def/wot#baseURI> <" + uri + ">";
String id = "NOT FOUND";
  
Dataset dataset = Repository.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT ?g_id WHERE { GRAPH ?g_id { " + query + " }}";
  QueryExecution qexec = QueryExecutionFactory.create(q, dataset);
  ResultSet result = qexec.execSelect();
  while (result.hasNext()) { 
    id = result.next().get("g_id").toString();
  }
} catch (Exception e) {
  e.printStackTrace();
  throw e;
} finally {
  dataset.end();
}

return id;
 }
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:30,代码来源:ThingDescriptionUtils.java


示例20: listThingDescriptionsUri

import org.apache.jena.query.ReadWrite; //导入依赖的package包/类
/**
  * Returns a list of the thing descriptions URIs.
  * @return a list of URIs stored in the database.
  */
 public static List<String> listThingDescriptionsUri() {

List<String> tds = new ArrayList<>();
String query = "?td <http://iot.linkeddata.es/def/wot#baseURI> ?uri";
  
Dataset dataset = Repository.get().dataset;
dataset.begin(ReadWrite.READ);

try {
  String q = "SELECT ?uri WHERE { GRAPH ?g_id { " + query + " }}";
  try (QueryExecution qexec = QueryExecutionFactory.create(q, dataset)) {
	ResultSet result = qexec.execSelect();
	while (result.hasNext()) { 
	tds.add(result.next().get("uri").toString());
	}
  }
catch (Exception e) {
  throw e;
}
} finally {
  dataset.end();
}

return tds;
 }
 
开发者ID:thingweb,项目名称:thingweb-repository,代码行数:30,代码来源:ThingDescriptionUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Source类代码示例发布时间:2022-05-22
下一篇:
Java OkHttpClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap