本文整理匯總了Java中com.hp.hpl.jena.query.ResultSet.nextSolution方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.nextSolution方法的具體用法?Java ResultSet.nextSolution怎麽用?Java ResultSet.nextSolution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.query.ResultSet
的用法示例。
在下文中一共展示了ResultSet.nextSolution方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAgentUri
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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;
}
示例2: getAllTestLists
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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;
}
示例3: getAgentUriNoVat
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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;
}
示例4: main
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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();
}
示例5: queryDbPediaCategoryLabel_GER
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private static String queryDbPediaCategoryLabel_GER(final String catUri) {
String res = null;
final Model model = DisambiguationMainService.getInstance()
.getDBPediaCategoryLabels_GER();
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();
// RDFHack ToDo: Inform how to resolve the dbpedia tql files correctly
res = name;
}
} catch (final QueryException e) {
Logger.getRootLogger().error(e.getStackTrace());
}
return res;
}
示例6: testMetric_TotalBuilds
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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();
}
}
}
示例7: queryYagoCategoryLabel
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private static String queryYagoCategoryLabel(final String catUri) {
String res = null;
final Model model = DisambiguationMainService.getInstance()
.getYagoCategoryLabels();
final String query = "SELECT ?label WHERE{ <" + catUri
+ "> <http://www.w3.org/2004/02/skos/core#> ?label. }";
try {
final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
final QueryExecution qexec = QueryExecutionFactory.create(que,
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;
}
示例8: getRDFTypesFromEntity
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public static Set<Type> getRDFTypesFromEntity(final String entityUri) {
Set<Type> set = new HashSet<Type>();
final Model model = DisambiguationMainService.getInstance().getDBPediaInstanceTypes();
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, model);
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(new Type("", type, true, 0));
}
}
}
return set;
}
示例9: testMetric_TotalSuccesfulExecutions_PerBuild
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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();
}
}
}
示例10: testMetric_TotalBrokenExecutions_PerBuild
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMetric_TotalBrokenExecutions_PerBuild() {
Query query =
QueryFactory.
create(
loadResource("/metrics/total_broken_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 broken executions of build %s: %d%n",buildId,total_executions);
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
}
示例11: getDbPediaLongDescription
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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;
}
示例12: querySubCategories
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public Set<String> querySubCategories(final String uri) {
final Set<String> types = new HashSet<String>();
final String query = "SELECT ?sub WHERE { <"+uri+"> <http://www.w3.org/2004/02/skos/core#broader> ?sub }";
try {
final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
final QueryExecution qexec = QueryExecutionFactory.create(que,
categorySkosModel);
final ResultSet results = qexec.execSelect();
while (results.hasNext()) {
final QuerySolution sol = results.nextSolution();
final String name = sol.getResource("sub").toString();
types.add(new String(name));
}
} catch (final QueryException e) {
Logger.getRootLogger().error(e.getStackTrace());
}
return types;
}
示例13: getGeoLocation
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
/**
* Gets and returns the geolocation of a POI
* @param resource
* @return
*/
private static Literal getGeoLocation(String resource){
Literal geoLocation;
String sparqlquery= "PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#> \n"
+ "select distinct ?geolocation where {"
+ "<"+resource+"> geo:geometry ?geolocation.}\n"
+ "LIMIT 1 ";
Query query = QueryFactory.create(sparqlquery);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
ResultSet results = qexec.execSelect();
if (results.hasNext() ){
QuerySolution soln = results.nextSolution();
geoLocation = soln.getLiteral("geolocation");
qexec.close();
return geoLocation;
}
else {
qexec.close();
return null;
}
}
示例14: queryEntitiesFromCategory
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的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;
}
示例15: addSomeMorePersonNames
import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private HashSet<String> addSomeMorePersonNames(final String uri) {
HashSet<String> names = new HashSet<String>();
try {
final String query = "SELECT ?name WHERE{ <" + uri + "> <http://xmlns.com/foaf/0.1/name> ?name. }";
ResultSet results = null;
QueryExecution qexec = null;
final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
qexec = QueryExecutionFactory.create(cquery, this.persondata);
results = qexec.execSelect();
if (results != null) {
while (results.hasNext()) {
final QuerySolution sol = results.nextSolution();
final String surname = sol.getLiteral("name").getLexicalForm();
names.add(surname.toLowerCase());
}
qexec.close();
}
} catch (QueryParseException e) {
Logger.getRootLogger().info("Query parse Exception");
}
String reducedUri = uri.replaceAll("http://dbpedia.org/resource/", "");
String splitter[] = reducedUri.split("_");
if(splitter.length == 2) {
names.add((splitter[0]+" "+splitter[1]).toLowerCase());
names.add((splitter[1]+" "+splitter[0]).toLowerCase());
}
return names;
}