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


Java QuerySolution类代码示例

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


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

示例1: getAgentUri

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
public Resource getAgentUri(VirtGraph graphOrgs, String vatId) {
	
	Resource agentUri = null;
	
	String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " +
				"SELECT ?org ?vatId " +
				"FROM <" + QueryConfiguration.queryGraphOrganizations + "> " +
				"WHERE { " +
				"?org gr:vatID ?vatId . " +
				"FILTER ( ?vatId = \"" + vatId + "\"^^<http://www.w3.org/2001/XMLSchema#string> ) " +
				"}";

	VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs);		
	ResultSet resultsUri = vqeUri.execSelect();
	
	if (resultsUri.hasNext()) {
		QuerySolution result = resultsUri.nextSolution();
		agentUri = result.getResource("org");
	}
	
	vqeUri.close();
	
	return agentUri;
}
 
开发者ID:YourDataStories,项目名称:harvesters,代码行数:25,代码来源:Queries.java

示例2: getAllTestLists

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
@Parameters(name="{index}: {0}")
public static Collection<Object[]> getAllTestLists() {
	Collection<Object[]> results = new ArrayList<Object[]>();
	for (File dir: new File(TEST_SUITE_DIR).listFiles()) {
		if (!dir.isDirectory() || !new File(dir.getAbsolutePath() + "/manifest.ttl").exists()) continue;
		String absolutePath = dir.getAbsolutePath();
		Model model = FileManager.get().loadModel(absolutePath + "/manifest.ttl");
		ResultSet resultSet = QueryExecutionFactory.create(QUERY, model).execSelect();
		while (resultSet.hasNext()) {
			QuerySolution solution = resultSet.nextSolution();
			if (Arrays.asList(D2RQTestUtil.SKIPPED_R2RML_TESTS).contains(solution.getResource("s").getLocalName())) continue;
			results.add(new Object[]{
					PrettyPrinter.toString(solution.getResource("s")),
					absolutePath + "/create.sql",
					absolutePath + "/" + solution.getLiteral("rml").getLexicalForm(),
					(solution.get("nquad") == null) ? 
							null : 
							absolutePath + "/" + solution.getLiteral("nquad").getLexicalForm()
			});
		}
	}
	return results;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:24,代码来源:R2RMLTest.java

示例3: getAgentUriNoVat

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
public Resource getAgentUriNoVat(VirtGraph graphOrgs, String vatId) {
	
	Resource agentUri = null;
	
	String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " +
				"SELECT DISTINCT ?org " +
				"FROM <" + QueryConfiguration.queryGraphOrganizations + "> " +
				"WHERE { " +
				"?org rdf:type foaf:Organization . " +
				"FILTER (STR(?org) = \"http://linkedeconomy.org/resource/Organization/" + vatId + "\") . " +
				"}";

	VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs);		
	ResultSet resultsUri = vqeUri.execSelect();
	
	if (resultsUri.hasNext()) {
		QuerySolution result = resultsUri.nextSolution();
		agentUri = result.getResource("org");
	}
	
	vqeUri.close();
	
	return agentUri;
}
 
开发者ID:YourDataStories,项目名称:harvesters,代码行数:25,代码来源:Queries.java

示例4: main

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
public static void main(String[] args) {
	ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
	String sparql = 
		"PREFIX dc: <http://purl.org/dc/elements/1.1/>" +
		"PREFIX foaf: <http://xmlns.com/foaf/0.1/>" +
		"SELECT ?paperTitle ?authorName WHERE {" +
		"    ?paper dc:title ?paperTitle . " +
		"    ?paper dc:creator ?author ." +
		"    ?author foaf:name ?authorName ." +
		"}";
	Query q = QueryFactory.create(sparql); 
	ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
	while (rs.hasNext()) {
		QuerySolution row = rs.nextSolution();
		System.out.println("Title: " + row.getLiteral("paperTitle").getString());
		System.out.println("Author: " + row.getLiteral("authorName").getString());
	}
	m.close();
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:20,代码来源:SPARQLExample.java

示例5: getTestListFromManifest

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

示例6: getTestLists

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

示例7: solutionToMap

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
public static Map<String,RDFNode> solutionToMap(QuerySolution solution, List<String> variables) {
	Map<String,RDFNode> result = new HashMap<String,RDFNode>();
	Iterator<String> it = solution.varNames();
	while (it.hasNext()) {
	    String variableName = it.next();
	    if (!variables.contains(variableName)) {
	    	continue;
	    }
	    RDFNode value = solution.get(variableName);
		int size = value.toString().length();
		if (size>250) {
			bigStringInResultLogger.debug("Big string (" + size + ") in resultBinding:\n" + value);
		}
		result.put(variableName,value);
	}
	return result;
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:18,代码来源:QueryLanguageTestFramework.java

示例8: getTypesFromSPARQL

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
private Set<String> getTypesFromSPARQL(String sparqlQueryString) {

        Query query = QueryFactory.create(sparqlQueryString);
        QueryExecution qexec = QueryExecutionFactory.sparqlService(this.endpoint, query);
        Set<String> types = new HashSet<>();

        ResultSet results = qexec.execSelect();
        while(results.hasNext()) {
            QuerySolution qs = results.next();
            Resource type = qs.getResource("?type");
            types.add(type.getURI());
        }

        qexec.close();
        return types;
    }
 
开发者ID:freme-project,项目名称:freme-ner,代码行数:17,代码来源:SPARQLProcessor.java

示例9: readOwlFile

import com.hp.hpl.jena.query.QuerySolution; //导入依赖的package包/类
static void readOwlFile (String pathToOwlFile) {
        OntModel ontologyModel =
                ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
        ontologyModel.read(pathToOwlFile, "RDF/XML-ABBREV");
       // OntClass myClass = ontologyModel.getOntClass("namespace+className");

        OntClass myClass = ontologyModel.getOntClass(ResourcesUri.nwr+"domain-ontology#Motion");
        System.out.println("myClass.toString() = " + myClass.toString());
        System.out.println("myClass.getSuperClass().toString() = " + myClass.getSuperClass().toString());

        //List list =
              //  namedHierarchyRoots(ontologyModel);


       Iterator i = ontologyModel.listHierarchyRootClasses()
                .filterDrop( new Filter() {
                    public boolean accept( Object o ) {
                        return ((Resource) o).isAnon();
                    }} ); ///get all top nodes and excludes anonymous classes

       // Iterator i = ontologyModel.listHierarchyRootClasses();
        while (i.hasNext()) {
            System.out.println(i.next().toString());
/*            OntClass ontClass = ontologyModel.getOntClass(i.next().toString());
            if (ontClass.hasSubClass()) {

            }*/
        }

        String q = createSparql("event", "<http://www.newsreader-project.eu/domain-ontology#Motion>");
        System.out.println("q = " + q);
        QueryExecution qe = QueryExecutionFactory.create(q,
                ontologyModel);
        for (ResultSet rs = qe.execSelect() ; rs.hasNext() ; ) {
            QuerySolution binding = rs.nextSolution();
            System.out.println("binding = " + binding.toString());
            System.out.println("Event: " + binding.get("event"));
        }

        ontologyModel.close();
    }
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:42,代码来源:OwlReader.java

示例10: testMetric_TotalBuilds

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

示例11: testMetric_TotalExecutions_Global

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

示例12: testMetric_TotalExecutions_PerBuild

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

示例13: testMetric_TotalSuccesfulExecutions_Global

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

示例14: testMetric_TotalSuccesfulExecutions_Global_Period

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

示例15: testMetric_TotalSuccesfulExecutions_PerBuild

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


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