Revision 53390
Added by Alessia Bardi about 6 years ago
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/virtuoso/ExampleIO_01.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.apache.jena.rdf.model.Model; |
7 | 7 |
import org.apache.jena.rdf.model.ModelFactory; |
8 |
import org.apache.jena.rdf.model.Property; |
|
9 |
import org.apache.jena.rdf.model.ResourceFactory; |
|
8 | 10 |
import org.apache.jena.riot.RDFDataMgr; |
9 | 11 |
import org.apache.jena.riot.RDFFormat; |
10 | 12 |
import org.apache.jena.riot.RIOT; |
... | ... | |
60 | 62 |
|
61 | 63 |
} |
62 | 64 |
|
65 |
@Test |
|
66 |
public void testPropertyNamespace(){ |
|
67 |
Property p = ResourceFactory.createProperty("dnet:", "transformedInDate"); |
|
68 |
System.out.println(p.toString()); |
|
69 |
} |
|
63 | 70 |
|
64 | 71 |
private InputStream getResourceAsStream(final String classpath) throws IOException { |
65 | 72 |
final ClassPathResource resource = new ClassPathResource(classpath); |
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoClientTest.java | ||
---|---|---|
55 | 55 |
VirtModel.openDatabaseModel("x", connectionString, testUser, testPwd); |
56 | 56 |
} |
57 | 57 |
|
58 |
|
|
59 |
|
|
58 | 60 |
@Test |
59 | 61 |
public void testFeedProvenance(){ |
60 | 62 |
long res = client.feedProvenance("ariadne_____::0002b8b77eb2d6c62f61c6e1a1ce6891", "2017-05-14T12:06:38.152+02:00" , "2017-05-14T12:11:55.573", "ARIADNE", "ariadne_api"); |
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoTest.java | ||
---|---|---|
175 | 175 |
String queryForGraphs = |
176 | 176 |
"SELECT DISTINCT ?g \n" |
177 | 177 |
+ "WHERE {\n" |
178 |
+ " { ?g <dnetcollectedFrom> <http://parthenos.d4science.org/handle/api_________::parthenos___::clarin::p_1271859438164> }\n" |
|
178 |
+ " { ?g <dnet:collectedFrom> <http://parthenos.d4science.org/handle/api_________::parthenos___::clarin::p_1271859438164> }\n"
|
|
179 | 179 |
+ "}"; |
180 | 180 |
Query query = QueryFactory.create(queryForGraphs); |
181 | 181 |
final QueryEngineHTTP serviceRequest = QueryExecutionFactory.createServiceRequest(sparqlUrl, query); |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoReadAPI.java | ||
---|---|---|
70 | 70 |
String fullTypeName = typeNamespace + typeName; |
71 | 71 |
log.debug(String.format("Getting subjects of type %s for API %s limit %d offset %d", fullTypeName, api, limit, offset)); |
72 | 72 |
//if I add the ORDER BY the query is too slow: let's hope we are not getting the same subjects over and over again |
73 |
String queryForSubjectsTemplate = "DEFINE input:inference 'parthenos_rules' SELECT DISTINCT ?s WHERE { GRAPH ?g {?s a <%s> .} . GRAPH <provenance> {?g <dnetcollectedFrom> <%s> .}} LIMIT %d OFFSET %d";
|
|
73 |
String queryForSubjectsTemplate = "DEFINE input:inference 'parthenos_rules' SELECT DISTINCT ?s WHERE { GRAPH ?g {?s a <%s> .} . GRAPH <dnet:graph> {?g <dnet:collectedFrom> <%s> .}} LIMIT %d OFFSET %d";
|
|
74 | 74 |
String q = String.format(queryForSubjectsTemplate, fullTypeName, defaultBaseURI+api, limit, offset); |
75 | 75 |
final QueryEngineHTTP serviceRequest = new QueryEngineHTTP(sparqlUrl, q); |
76 | 76 |
ResultSet subjects = serviceRequest.execSelect(); |
... | ... | |
94 | 94 |
public List<String> getSubjectsForApi(@RequestParam final String api, @RequestParam final int limit, @RequestParam final int offset){ |
95 | 95 |
log.debug(String.format("Getting subjects for API %s, limit %d offset %d", api, limit, offset)); |
96 | 96 |
//if I add the ORDER BY the query is too slow: let's hope we are not getting the same subjects over and over again |
97 |
String queryForSubjectsTemplate = "DEFINE input:inference 'parthenos_rules' SELECT DISTINCT ?s WHERE { GRAPH ?g {?s a ?t . FILTER (?t != <%s> && ?t != <%s>)} . GRAPH <provenance> {?g <dnetcollectedFrom> <%s> .}} LIMIT %d OFFSET %d ";
|
|
97 |
String queryForSubjectsTemplate = "DEFINE input:inference 'parthenos_rules' SELECT DISTINCT ?s WHERE { GRAPH ?g {?s a ?t . FILTER (?t != <%s> && ?t != <%s>)} . GRAPH <dnet:graph> {?g <dnet:collectedFrom> <%s> .}} LIMIT %d OFFSET %d ";
|
|
98 | 98 |
String q = String.format(queryForSubjectsTemplate, CRM.E55_Type.getURI(), CRM.E41_Appellation.getURI(), defaultBaseURI+api, limit, offset); |
99 | 99 |
final QueryEngineHTTP serviceRequest = new QueryEngineHTTP(sparqlUrl, q); |
100 | 100 |
ResultSet subjects = serviceRequest.execSelect(); |
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoClient.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
private static final Log log = LogFactory.getLog(VirtuosoClient.class); |
21 | 21 |
|
22 |
public static final String PROVENANCE_GRAPH = "provenance";
|
|
23 |
public static Property IS_API_OF = ResourceFactory.createProperty("dnet", "isApiOf"); |
|
24 |
public static Property COLL_FROM = ResourceFactory.createProperty("dnet", "collectedFrom"); |
|
25 |
public static Property COLL_IN_DATE = ResourceFactory.createProperty("dnet", "collectedInDate"); |
|
26 |
public static Property TRANS_IN_DATE = ResourceFactory.createProperty("dnet", "transformedInDate"); |
|
22 |
public static final String PROVENANCE_GRAPH = "dnet:graph";
|
|
23 |
public static Property IS_API_OF = ResourceFactory.createProperty("dnet:", "isApiOf");
|
|
24 |
public static Property COLL_FROM = ResourceFactory.createProperty("dnet:", "collectedFrom");
|
|
25 |
public static Property COLL_IN_DATE = ResourceFactory.createProperty("dnet:", "collectedInDate");
|
|
26 |
public static Property TRANS_IN_DATE = ResourceFactory.createProperty("dnet:", "transformedInDate");
|
|
27 | 27 |
|
28 | 28 |
private RecordParserHelper recordParserHelper; |
29 | 29 |
|
Also available in: Unified diff
Fixes #11240#note-21: changed names of provenance graph and properties to be URLs instead of plain strings.