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


Java QueryExecution.close方法代码示例

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


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

示例1: checkContainment

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
public static boolean checkContainment(CompanyModel c){
	String queryString = 
		"ASK" +
			// check whether any manager is an employee in any other department
			"{?dept1"        + " <" + c.MANAGER   + "> " + "?manager"         + ". " +
			" ?dept2"		 + " <" + c.EMPLOYEES + "> " + "?employees1"      + ". " +
			" ?employees1"   + " <" + RDFS.member + "> " + "?employee1"       + ". " +
			" FILTER (?manager = ?employee1) " +
			
			// check whether any employee occurs more than once
			" ?dept3 "		 + " <" + c.EMPLOYEES + "> " + "?employees2"      + ". " +
			" ?employees2"   + " <" + RDFS.member + "> " + "?employee2"       + ". " +
			" FILTER (?employee1 = ?employee2)" +
			
			// check whether any department occurs more than once
			" ?upperDept1"   + " <" + c.DEPTS     + "> " + "?dept4"           + ". " +
			" ?upperDept2"   + " <" + c.DEPTS     + "> " + "?dept5"           + ". " +
			" FILTER (?dept4 = ?dept5) " +
			"}";
	
	Query query = QueryFactory.create(queryString);
	QueryExecution qe = QueryExecutionFactory.create(query, c.getModel());
	boolean out = qe.execAsk();
	qe.close();
	return !out;
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:27,代码来源:Containment.java

示例2: testMetric_TotalBuilds

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void testMetric_TotalBuilds() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_builds.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, buildsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long buildId = solution.getLiteral("total_builds").getLong();
			System.out.printf("Total builds: %d%n",buildId);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:22,代码来源:VocabularyTest.java

示例3: sparql

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
/**
 * RDF Navigation using SPARQL Query
 * 
 * @param model
 *            the RDF model
 * @param query
 *            SPARQL Query String
 * @param field
 *            the placeholder of filed in parameter query
 */
private static void sparql(Model model, String query, String field) {
	Query q = QueryFactory.create(query);
	QueryExecution qexec = QueryExecutionFactory.create(q, model);
	System.out.println("Plan to run SPARQL query: ");
	System.out.println(BOUNDARY);
	System.out.println(query);
	System.out.println(BOUNDARY);
	ResultSet rs = qexec.execSelect();
	while (rs.hasNext()) {
		QuerySolution qs = rs.nextSolution();
		RDFNode name = qs.get(field);// using RDFNode currently
		if (name != null) {
			System.out.println("Hello to " + name);
		} else {
			System.out.println("No friends found!");
		}
	}
	qexec.close();
}
 
开发者ID:zhoujiagen,项目名称:Jena-Based-Semantic-Web-Tutorial,代码行数:30,代码来源:HelloSemanticWeb.java

示例4: testMetric_TotalExecutions_PerBuild

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void testMetric_TotalExecutions_PerBuild() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_executions_per_build.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			String buildId = shorten(solution.getResource("build").getURI());
			System.out.printf("Total executions of build %s: %d%n",buildId,total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:23,代码来源:VocabularyTest.java

示例5: testMetric_TotalSuccesfulExecutions_PerBuild

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void testMetric_TotalSuccesfulExecutions_PerBuild() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_succesful_executions_per_build.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			String buildId = shorten(solution.getResource("build").getURI());
			System.out.printf("Total succesful executions of build %s: %d%n",buildId,total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:23,代码来源:VocabularyTest.java

示例6: testMetric_TotalBrokenExecutions_Global

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
@Test
public void testMetric_TotalBrokenExecutions_Global() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_broken_executions_global.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			System.out.printf("Total broken executions: %d%n",total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:22,代码来源:VocabularyTest.java

示例7: getDbPediaLongDescription

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
public String getDbPediaLongDescription(final String uri) throws QueryException, QueryParseException {
	String labellist = "";
	try {
		final String query = "SELECT ?comment WHERE{ <" + uri
				+ "> <http://dbpedia.org/ontology/abstract> ?comment. }";
		ResultSet results = null;
		QueryExecution qexec = null;

		final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
		qexec = QueryExecutionFactory.create(cquery, this.longdescmodel);
		results = qexec.execSelect();

		if (results != null) {
			while (results.hasNext()) {
				final QuerySolution sol = results.nextSolution();
				final String desc = sol.getLiteral("comment").getLexicalForm();
				labellist = desc;
			}
			qexec.close();
		}
	} catch (QueryParseException e) {
		Logger.getRootLogger().info("Query parse Exception");
	}
	return labellist;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:26,代码来源:CreateDBpediaIndexV2.java

示例8: queryRemote

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
/**
 * RDF Navigation using remote SPARQL Query
 * 
 * @param service
 *            the SAPRQL end point URL
 * @param query
 *            SPARQL Query String
 * @param queryField
 *            the placeholder of filed in parameter query(sample: ?name)
 */
public static void queryRemote(final String service, final String query, String... queryFields) {
	if (queryFields == null || queryFields.length == 0) {
		return;
	}

	QueryExecution qexec = QueryExecutionFactory.sparqlService(service, query);

	System.out.println("Plan to run remote SPARQL query: ");
	System.out.println(BOUNDARY);
	System.out.println(query);
	System.out.println(BOUNDARY);

	ResultSet rs = qexec.execSelect();
	rendererResultSet(rs, queryFields);

	System.out.println(BOUNDARY);

	qexec.close();
}
 
开发者ID:zhoujiagen,项目名称:Jena-Based-Semantic-Web-Tutorial,代码行数:30,代码来源:SPARQLUtils.java

示例9: getDbPediaLabel

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
public List<String> getDbPediaLabel(final String uri) throws QueryException, QueryParseException {
	final List<String> labellist = new LinkedList<String>();
	try {
		final String query = "SELECT ?label WHERE{ <" + uri
				+ "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
		ResultSet results = null;
		QueryExecution qexec = null;

		final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
		qexec = QueryExecutionFactory.create(cquery, this.labelmodel);
		results = qexec.execSelect();

		if (results != null) {
			while (results.hasNext()) {
				final QuerySolution sol = results.nextSolution();
				final String label = sol.getLiteral("label").getLexicalForm();
				labellist.add(label);
			}
			qexec.close();
		}
	} catch (QueryParseException e) {
		Logger.getRootLogger().info("Query parse Exception");
	}
	return labellist;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:26,代码来源:CreateDBpediaIndexV2.java

示例10: retrieveHierarchyTwo

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
/**
 * Queries for the supertypes of the given resource
 * @param resource
 * @return
 */
private static List<Resource> retrieveHierarchyTwo(String resource){
	
	String sparqlquery= "PREFIX dbpedia-owl:<http://dbpedia.org/ontology/> \n"
+ "PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#> \n"
+ "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> \n"
+ "PREFIX foaf:<http://xmlns.com/foaf/0.1/> \n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> \n"
+ "select distinct ?super ?subclass where {" 
+ "<"+resource+"> a ?super.\n"
+ "<"+resource+">  a ?subclass.\n"
+ "?subclass rdfs:subClassOf ?super.\n"
+ "FILTER (?subclass!=?super)}";
	
	Query query = QueryFactory.create(sparqlquery);
 QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
 ResultSet results = qexec.execSelect();
 
 // Parse the result to avoid transitivity and thus repetition of types
 List<Resource> hierarchy_two = parseResult(results);
 qexec.close();
 
 return hierarchy_two;

}
 
开发者ID:Localizr,项目名称:Localizr,代码行数:30,代码来源:GeoNamesRecommendation.java

示例11: loadClassPartitionStatistics

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
public void loadClassPartitionStatistics(OntModel voidModel) {
	Query query = QueryFactory.create(classPartitionStatisticsQuery);
	QueryExecution qexec = QueryExecutionFactory.create(query, voidModel);

	try {
		ResultSet results = qexec.execSelect();
		for (; results.hasNext();) {
			QuerySolution soln = results.nextSolution();
			OntResource dataset = soln.getResource("Dataset").as(
					OntResource.class);
			OntResource clazz = soln.getResource("Class").as(
					OntResource.class);
			Integer entities = (soln.getLiteral("Entities") != null) ? soln
					.getLiteral("Entities").getInt() : null;	
			Dataset ds = this.getDataset(dataset);		
			if (ds!=null)ds.getPartitions().addClassPartition(clazz, entities);
		}
	} catch (Exception e) {
		Log.debug(
				this,
				"Unable to execute classPartitionStatisticsQuery " + query);
	} finally {
		qexec.close();
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:26,代码来源:Datasets.java

示例12: updatePropertyPartition

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
protected void updatePropertyPartition(OntModel partitionModel) {
	Query query = QueryFactory.create(propertyPartitionQuery);
	QueryExecution qexec = QueryExecutionFactory.create(query,
			partitionModel);

	try {
		ResultSet results = qexec.execSelect();
		for (; results.hasNext();) {
			QuerySolution soln = results.nextSolution();
			OntResource property = soln.getResource("property").as(
					OntResource.class);
			partitions.addPropertyPartition(property, null);
		}
	} catch (Exception e) {
		Log.debug(Dataset.class,
				"Failed to execute to execute propertyPartitionQuery");
	} finally {
		qexec.close();
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:21,代码来源:Dataset.java

示例13: loadVocabularies

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
public void loadVocabularies() {

		QuerySolutionMap binding = new QuerySolutionMap();
		binding.add("dataset", dataset);
		Query query = QueryFactory.create(datasetVocabularyQuery);
		QueryExecution qexec = QueryExecutionFactory.create(query, voidInstance.getVoidModel(),
				binding);

		try {
			ResultSet results = qexec.execSelect();
			for (; results.hasNext();) {
				QuerySolution soln = results.nextSolution();
				OntResource vocabulary = soln.getResource("vocabulary").as(
						OntResource.class);
				vocabularies.add(vocabulary);
			}
		} catch (Exception e) {
			Log.debug(Dataset.class, "Failed datasetVocabularyQuery");
			Log.debug(Dataset.class, e.getStackTrace().toString());

		} finally {
			qexec.close();
		}
	}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:25,代码来源:Dataset.java

示例14: queryClassPartitionStatistics

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
private void queryClassPartitionStatistics() {
	Query query = QueryFactory.create(classPartitionStatisticsQuery);
	QueryExecution qexec = QueryExecutionFactory.sparqlService(
			this.sparqlEndPoint.toString(), query);

	try {
		ResultSet results = qexec.execSelect();
		for (; results.hasNext();) {
			QuerySolution soln = results.nextSolution();
			OntResource clazz = soln.getResource("class").as(
					OntResource.class);
			Integer entities = (soln.getLiteral("count") != null) ? soln
					.getLiteral("count").getInt() : null;
			partitions.addClassPartition(clazz, entities);
		}
	} catch (Exception e) {
		Log.debug(
				Dataset.class,
				"Unable to connect to SPARQLEndpoint to execute classPartitionStatisticsQuery: "
						+ this.sparqlEndPoint.toString());
	} finally {
		qexec.close();
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.remediator,代码行数:25,代码来源:Dataset.java

示例15: executeTestWithFile

import com.hp.hpl.jena.query.QueryExecution; //导入方法依赖的package包/类
@Override
protected void executeTestWithFile(final String filename) throws Exception {
	final Query query = QueryFactory.create(queryString(filename + ".rq"));
	QueryExecution execution = null;
	QueryExecution inMemoryExecution = null;
	
	try {
		assertTrue(
				(execution = QueryExecutionFactory.create(query, dataset))
					.execConstruct()
					.isIsomorphicWith(
							(inMemoryExecution = QueryExecutionFactory.create(query, memoryDataset))
							.execConstruct()));
	} finally {
		// CHECKSTYLE:OFF
		if (execution != null) { execution.close(); }
		if (inMemoryExecution != null) { inMemoryExecution.close(); }
		// CHECKSTYLE:ON
	}					
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:21,代码来源:SparqlConstructIntegrationTestCase.java


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