/** * Given a query result from a SPARQL query, check if the given variable has * a value or not * * @param resultRow the result from a SPARQL query * @param variableName the name of the variable to obtain * @return true if the variable has a value, false otherwise */ public static boolean isVariableSet(QuerySolution resultRow, String variableName) { if (resultRow != null) { return resultRow.contains(variableName); } return false; }
/** * Obtain the type of Match. The bindings indicate the relationship between the destination and the origin * That is, the subclasses of 'origin' will have a true value at binding 'sub' * * @param soln * @return */ private MatchType getMatchType(QuerySolution soln) { if (soln.contains(EXACT_VAR)) return LogicConceptMatchType.Exact; if (soln.contains(SUPER_VAR)) return LogicConceptMatchType.Plugin; if (soln.contains(SUB_VAR)) return LogicConceptMatchType.Subsume; return LogicConceptMatchType.Fail; }
final QuerySolution solution = results.next(); if ( solution.contains( ProfilesPerson.PROFILES_URI_VARIABLE ) ) { profilesUri = solution.getLiteral( ProfilesPerson.PROFILES_URI_VARIABLE ).getString(); } else { if ( solution.contains( ProfilesPerson.PERSON_URI_VARIABLE ) ) { personUri = solution.getResource( ProfilesPerson.PERSON_URI_VARIABLE ).toString(); } else { if ( solution.contains( ProfilesPerson.LAB_URI_VARIABLE ) ) { labUri = solution.getResource( ProfilesPerson.LAB_URI_VARIABLE ).toString(); labLink = linkPrefix + labUri; if ( solution.contains( ProfilesPerson.LAB_NAME_VARIABLE ) ) { labName = solution.getLiteral( ProfilesPerson.LAB_NAME_VARIABLE ).getString(); } else {
String st = iterator.next(); if (s.contains(st)) { initialBinding.add(st, s.get(st));
String st = iterator.next(); if (s.contains(st)) { initialBinding.add(st, s.get(st));
public final Literal literal(String binding) { if(!this.solution.contains(binding)) { return null; } RDFNode node = this.solution.get(binding); if(!node.canAs(Literal.class)) { throw new IllegalStateException("Binding '"+binding+"' is not a literal"); } return node.asLiteral(); }
public Resource resource(String binding) { if(!this.solution.contains(binding)) { return null; } RDFNode node = this.solution.get(binding); if(!node.canAs(Resource.class)) { throw new IllegalStateException("Binding '"+binding+"' is not a resource"); } return node.asResource(); }
@Override public List<String> getAllStoredGraphs() { String queryString = "SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }"; QueryExecution qexec; if (configurationService.hasProperty(RDFUtil.STORAGE_SPARQL_LOGIN_KEY) && configurationService.hasProperty(RDFUtil.STORAGE_SPARQL_PASSWORD_KEY)) { HttpAuthenticator httpAuthenticator = new SimpleAuthenticator( configurationService.getProperty(RDFUtil.STORAGE_SPARQL_LOGIN_KEY), configurationService.getProperty(RDFUtil.STORAGE_GRAPHSTORE_PASSWORD_KEY).toCharArray()); qexec = QueryExecutionFactory.sparqlService(getSparqlEndpoint(), queryString, httpAuthenticator); } else { qexec = QueryExecutionFactory.sparqlService(getSparqlEndpoint(), queryString); } ResultSet rs = qexec.execSelect(); List<String> graphs = Collections.synchronizedList(new ArrayList<String>()); while (rs.hasNext()) { QuerySolution solution = rs.next(); if (solution.contains("g")) { graphs.add(solution.get("g").asResource().getURI()); } } qexec.close(); return graphs; }
final Resource res = soln.getResource("res"); String name = ""; if(soln.contains("name")) { name = soln.getLiteral("name").getString();
if(soln.contains("dimensions")) { dimensions = soln.getLiteral("dimensions").getString(); if(soln.contains("extension")) { extension = soln.getLiteral("extension").getString(); if(soln.contains("author")) { author = soln.getLiteral("author").getString(); if(soln.contains("place_publication")) { publicPlace = soln.getLiteral("place_publication").getString(); if(soln.contains("date_publication")) { publicDate = soln.getLiteral("date_publication").getString(); if(soln.contains("edition")) { edition = soln.getLiteral("edition").getString();