Project

General

Profile

« Previous | Next » 

Revision 50928

For almost every graph we used to return also "concept URLs" like "http://parthenos.d4science.org/handle/Parthenos/REG/Concept/datasettype/metadata"...let's try to avoid them skipping non URL resources and resources whose type is not in the parthenos namespace.

View differences:

VirtuosoReadAPI.java
6 6

  
7 7
import com.google.common.collect.Iterators;
8 8
import com.google.common.collect.Lists;
9
import eu.dnetlib.parthenos.CRMpe;
9 10
import org.apache.commons.logging.Log;
10 11
import org.apache.commons.logging.LogFactory;
11 12
import org.apache.jena.query.Query;
......
62 63

  
63 64
	@RequestMapping(value = "/virtuoso/subjects", produces = { "application/json" }, method = RequestMethod.GET)
64 65
	public List<String> getSubjectsForGraph(@RequestParam final String graph) {
65
		// To filter out all subjects that do not start with 'http' use the following query
66
		// String queryForSubjectsTemplate = "SELECT DISTINCT ?s WHERE {GRAPH <%s> {?s ?p ?o . FILTER regex(str(?s),'^http')}}";
67
		// Based on FORTH observation, those without a URL should not be interesting by themselves, but looking at Nakala data it seems this is not the case:
68
		String queryForSubjectsTemplate = "SELECT DISTINCT ?s WHERE {GRAPH <%s> {?s ?p ?o }}";
69
		String q = String.format(queryForSubjectsTemplate, graph);
66
		// Based on FORTH observation, resources without a URL should not be interesting by themselves.
67
		// Here we filter out those + resources whose type is not in the parthenos namespace.
68

  
69
		//old query selecting any subjects in the given graph
70
		//String queryForSubjectsTemplate = "SELECT DISTINCT ?s WHERE {GRAPH <%s> {?s ?p ?o .}}";
71

  
72
		String queryForSubjectsTemplate = "SELECT DISTINCT ?s WHERE {GRAPH <%s> {?s ?p ?o . ?s a ?t. FILTER (isURI(?s) && STRSTARTS(str(?t), str('%s'))) }}";
73
		String q = String.format(queryForSubjectsTemplate, graph, CRMpe.NS);
70 74
		log.debug(q);
75

  
71 76
		final QueryEngineHTTP serviceRequest =
72 77
				QueryExecutionFactory.createServiceRequest(sparqlUrl, QueryFactory.create(q));
73 78
		ResultSet subjects = serviceRequest.execSelect();

Also available in: Unified diff