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


Java Dataset.end方法代码示例

本文整理汇总了Java中org.apache.jena.query.Dataset.end方法的典型用法代码示例。如果您正苦于以下问题:Java Dataset.end方法的具体用法?Java Dataset.end怎么用?Java Dataset.end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.query.Dataset的用法示例。


在下文中一共展示了Dataset.end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listVocabularies

import org.apache.jena.query.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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.Dataset; //导入方法依赖的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: listVocabularies

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例10: get

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例11: delete

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例12: get

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例13: delete

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例14: listThingDescriptions

import org.apache.jena.query.Dataset; //导入方法依赖的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

示例15: getThingDescriptionIdFromUri

import org.apache.jena.query.Dataset; //导入方法依赖的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


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