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


Java QueryExecutionFactory.create方法代码示例

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


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

示例1: checkContainment

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的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: expandSubClasses

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private List<Statement> expandSubClasses(Model model){
	List<Statement> stmts = new ArrayList<Statement>();
	
	
	String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
			+ "SELECT DISTINCT ?class ?synonym "
			+ "WHERE { "
			+ "?class rdfs:subClassOf+ ?subClass . "
			+ "?subClass <" + synonym + "> ?synonym"
			+ "}";
	
	Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
	QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
	ResultSet resultSet = queryExecution.execSelect();
	resultSet.forEachRemaining(querySolution -> {
		stmts.add(new StatementImpl(querySolution.getResource("class"), synonym, querySolution.getLiteral("synonym")));
	});
	return stmts;
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:20,代码来源:IndexingJob.java

示例3: expandSubProperties

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private List<Statement> expandSubProperties(Model model){
	List<Statement> stmts = new ArrayList<Statement>();
	
	String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
			+ "SELECT DISTINCT ?property ?synonym "
			+ "WHERE { "
			+ "?property rdfs:subPropertyOf+ ?subProperty . "
			+ "?subProperty <" + synonym + "> ?synonym"
			+ "}";
	
	Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
	QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
	ResultSet resultSet = queryExecution.execSelect();
	resultSet.forEachRemaining(querySolution -> {
		stmts.add(new StatementImpl(querySolution.getResource("property"), synonym, querySolution.getLiteral("synonym")));
	});
	return stmts;
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:19,代码来源:IndexingJob.java

示例4: getTestListFromManifest

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
public static Collection<Object[]> getTestListFromManifest(String manifestFileURL) {
		// We'd like to use FileManager.loadModel() but it doesn't work on jar: URLs
//		Model m = FileManager.get().loadModel(manifestFileURL);
		Model m = ModelFactory.createDefaultModel();
		m.read(manifestFileURL, "TURTLE");

		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource mapping = qs.getResource("mapping");
			Resource schema = qs.getResource("schema");
//			if (!mapping.getLocalName().equals("constant-object.ttl")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{baseIRI.relativize(mapping.getURI()).toString(), mapping.getURI(), 
					schema.getURI(), expectedTriples});
		}
		return result;
	}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:23,代码来源:ProcessorTestBase.java

示例5: getTestLists

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
@Parameters(name="{index}: {0}")
	public static Collection<Object[]> getTestLists() {
		Model m = D2RQTestUtil.loadTurtle(MANIFEST_FILE);
		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource testCase = qs.getResource("case");
//			if (!case.getLocalName().equals("expression")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{
					baseIRI.relativize(testCase.getURI()).toString(), 
					qs.getLiteral("sql").getLexicalForm(), 
					expectedTriples});
		}
		return result;
	}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:21,代码来源:MappingGeneratorTest.java

示例6: getDbPediaLongDescription

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的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

示例7: testMetric_TotalExecutions_Global

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
@Test
public void testMetric_TotalExecutions_Global() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_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 executions: %d%n",total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:22,代码来源:VocabularyTest.java

示例8: getRDFTypesFromEntity

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
public Set<String> getRDFTypesFromEntity(final String entityUri) {
	Set<String> set = new HashSet<String>();
	final String query = "SELECT ?types WHERE{ <" + entityUri
			+ "> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?types. }";
	ResultSet results = null;
	QueryExecution qexec = null;
	try {
		final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
		qexec = QueryExecutionFactory.create(cquery, instancemappingtypes);
		results = qexec.execSelect();
	} catch (final QueryException e) {
		Logger.getRootLogger().error(e.getStackTrace());
	} finally {
		if (results != null) {
			while (results.hasNext()) {
				final QuerySolution sol = results.nextSolution();
				final String type = sol.getResource("types").toString();
				set.add(type);
			}
		}
	}
	return set;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:24,代码来源:CreateDBpediaIndexV2.java

示例9: testMetric_TotalSuccesfulExecutions_Global_Period

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
@Test
public void testMetric_TotalSuccesfulExecutions_Global_Period() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_succesful_executions_global_period.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 day = solution.getLiteral("day").getString();
			System.out.printf("Total succesful executions [%s]: %d%n",day,total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:23,代码来源:VocabularyTest.java

示例10: queryDbPediaCategoryLabel

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private static String queryDbPediaCategoryLabel(final String catUri) {
	String res = null;
	final Model model = DisambiguationMainService.getInstance()
			.getDBPediaCategoryLabels();

	final String query = "SELECT ?label WHERE{ <" + catUri
			+ "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
	try {
		final com.hp.hpl.jena.query.Query cquery = QueryFactory
				.create(query);
		final QueryExecution qexec = QueryExecutionFactory.create(cquery,
				model);
		final ResultSet results = qexec.execSelect(); // NOPMD by quh on
														// 18.02.14 15:05
		while (results.hasNext()) {
			final QuerySolution sol = results.nextSolution();
			final String name = sol.getLiteral("label").getLexicalForm();
			res = name;
		}
	} catch (final QueryException e) {
		Logger.getRootLogger().error(e.getStackTrace());
	}
	return res;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:25,代码来源:RDFGraphOperations.java

示例11: sparqlConstruct

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
@Override
public ClosableIterable<Statement> sparqlConstruct(String query)
		throws ModelRuntimeException, MalformedQueryException {
	Query jenaQuery = QueryFactory.create(query);
	QueryExecution qexec = QueryExecutionFactory.create(jenaQuery,
			this.dataset);

	if (jenaQuery.isConstructType()) {
		com.hp.hpl.jena.rdf.model.Model m = qexec.execConstruct();
		Model resultModel = new ModelImplJena(null, m, Reasoning.none);
		resultModel.open();
		return resultModel;
	} else {
		throw new RuntimeException(
				"Cannot handle this type of query! Please use CONSTRUCT.");
	}

}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:19,代码来源:ModelSetImplJena.java

示例12: queryEntitiesFromCategory

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private String queryEntitiesFromCategory(final String catUri) {
	String res = null;

	final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
			+ catUri + ">. }";
	try {
		final com.hp.hpl.jena.query.Query cquery = QueryFactory
				.create(query);
		final QueryExecution qexec = QueryExecutionFactory
				.create(cquery, m);
		final ResultSet results = qexec.execSelect();
		List<String> entities = new LinkedList<String>();
		while (results.hasNext()) {
			final QuerySolution sol = results.nextSolution();
			entities.add(sol.getResource("entities").getURI());
		}
		if (entities.size() != 0) {
			int randomNr = this.random.nextInt(entities.size());
			return entities.get(randomNr);
		}

	} catch (final QueryException e) {
		Logger.getRootLogger().error(e.getStackTrace());
	}
	return res;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:27,代码来源:Sampling.java

示例13: getNumberOfDimensionsInCategory

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
public static Map<String, Integer> getNumberOfDimensionsInCategory(){
	Map<String, Integer> dimensionPerCategory = new HashMap<String, Integer>();
	Model m = InternalModelConf.getFlatModel();
	
	String whereClause = "?categoryURI a " + SPARQLHelper.toSPARQL(DAQ.Category) + 
			" . ?categoryURI ?hasDimensionProperty ?dimensionURI . " +
			"?hasMetricProperty " + SPARQLHelper.toSPARQL(RDFS.subPropertyOf) + SPARQLHelper.toSPARQL(DAQ.hasDimension) + " .";
	
	String variables = "?categoryURI COUNT(?dimensionURI) as ?count";
	
	String query = SPARQLHelper.SELECT_STATEMENT.replace("[variables]", variables).replace("[whereClauses]", whereClause);
	Query qry = QueryFactory.create(query);
    QueryExecution qe = QueryExecutionFactory.create(qry, m);
    ResultSet rs = qe.execSelect();
    
    while (rs.hasNext()){
    	QuerySolution qs = rs.next();
    	String cat = qs.get("categoryURI").asResource().getURI();
    	Integer count = qs.get("count").asLiteral().getInt();
    	dimensionPerCategory.put(cat, count);
    }
	
    return dimensionPerCategory;
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:25,代码来源:DAQHelper.java

示例14: getCountResult

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private int getCountResult(String queryStr, SparqlifyDataset dataset) {
	int count = 0;
	Query query = QueryFactory.create(queryStr);
	QueryExecution qe;
	if (dataset.isSparqlService() && dataset.getSparqlServiceUri() != null) {
		qe = QueryExecutionFactory.sparqlService(dataset.getSparqlServiceUri(), query);
	} else {
		qe = QueryExecutionFactory.create(query, dataset);
	}
	ResultSet res = qe.execSelect();
	
	while(res.hasNext())
	{
		QuerySolution solution = res.nextSolution();
		RDFNode solNode = solution.get("count");
		count += solNode.asLiteral().getInt();
	}
	qe.close(); 
	
	return count;
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:22,代码来源:InterlinkingCompleteness.java

示例15: askcontainsStatement

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
public boolean askcontainsStatement(Statement st, Model m)
{
	String q = "ASK{?subject ?predicate ?object.";
	if (st.getSubject().isAnon())
		q += " FILTER isBlank(?subject)";
	if (st.getObject().isAnon())
		q += " FILTER isBlank(?object)";
	q += "}";

	QuerySolutionMap args = new QuerySolutionMap();
	if (!st.getSubject().isAnon())
		args.add("subject", st.getSubject());
	if (!st.getObject().isAnon())
		args.add("object", st.getObject());
	// QueryExecution qe = QueryExecutionFactory.create(q, m, args);

	Query query = QueryFactory.create(q);
	QueryExecution qe = QueryExecutionFactory.create(query, m, args);

	return qe.execAsk();
}
 
开发者ID:emir-munoz,项目名称:uraptor,代码行数:22,代码来源:ChallengeValidator.java


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