當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。