added query to retrieve record ids collection; datasource, collection id and record id are now paramters on a query template from file
This commit is contained in:
parent
b80274fff3
commit
064f298329
|
@ -5,10 +5,7 @@ import eu.dnetlib.ariadneplus.reader.ResourceManager;
|
|||
import eu.dnetlib.ariadneplus.reader.json.ParseRDFJSON;
|
||||
import org.eclipse.rdf4j.model.Model;
|
||||
import org.eclipse.rdf4j.model.Statement;
|
||||
import org.eclipse.rdf4j.query.GraphQuery;
|
||||
import org.eclipse.rdf4j.query.GraphQueryResult;
|
||||
import org.eclipse.rdf4j.query.QueryLanguage;
|
||||
import org.eclipse.rdf4j.query.QueryResults;
|
||||
import org.eclipse.rdf4j.query.*;
|
||||
import org.eclipse.rdf4j.repository.Repository;
|
||||
import org.eclipse.rdf4j.repository.RepositoryConnection;
|
||||
import org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager;
|
||||
|
@ -19,7 +16,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RunSPARQLQueryService {
|
||||
|
@ -65,177 +65,19 @@ public class RunSPARQLQueryService {
|
|||
manager.shutDown();
|
||||
}
|
||||
|
||||
public String executeQueryGraph(){
|
||||
query = "PREFIX aocat: <https://www.ariadne-infrastructure.eu/resource/ao/cat/1.1/> \n" +
|
||||
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
|
||||
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \n" +
|
||||
"PREFIX aoprop: <https://www.ariadne-infrastructure.eu/property/> \n" +
|
||||
"PREFIX onto: <http://www.ontotext.com/>\n" +
|
||||
"PREFIX ariadneplus: <https://ariadne-infrastructure.eu/aocat/>\n" +
|
||||
"PREFIX time: <http://www.w3.org/2006/time#>\n" +
|
||||
"\n" +
|
||||
"CONSTRUCT { \n" +
|
||||
"%s aoprop:identifier %s . \n" +
|
||||
"%s aoprop:originalId ?originalId . \n" +
|
||||
"%s aoprop:issued ?issued .\n" +
|
||||
"%s aoprop:modified ?modified .\n" +
|
||||
"%s aoprop:partOf ?partOf .\n" +
|
||||
"%s aoprop:creator ?creator . \n" +
|
||||
"?creator aoprop:name ?creatorName .\n" +
|
||||
"?creator aoprop:email ?creatorEmail . \n" +
|
||||
"%s aoprop:contributor ?contributor . \n" +
|
||||
"?contributor aoprop:name ?contributorName .\n" +
|
||||
"?contributor aoprop:email ?contributorEmail .\n" +
|
||||
"%s aoprop:legalResponsible ?legalResponsible . \n" +
|
||||
"?legalResponsible aoprop:name ?legalResponsibleName .\n" +
|
||||
"?legalResponsible aoprop:email ?legalResponsibleEmail . \n" +
|
||||
"%s aoprop:owner ?owner . \n" +
|
||||
"?owner aoprop:name ?ownerName .\n" +
|
||||
"?owner aoprop:email ?ownerEmail . \n" +
|
||||
"%s aoprop:publisher ?publisher . \n" +
|
||||
"?publisher aoprop:name ?publisherName . \n" +
|
||||
"?publisher aoprop:email ?publisherEmail . \n" +
|
||||
"%s aoprop:accessPolicy ?accessPolicy . \n" +
|
||||
"%s aoprop:accessRights ?accessRights .\n" +
|
||||
"%s aoprop:landingPage ?landingPage .\n" +
|
||||
"%s aoprop:spatialRegion ?spatialRegion . \n" +
|
||||
"?spatialRegion aoprop:placeName ?spatialPlaceName .\n" +
|
||||
"?spatialRegion aoprop:spatialCoordinateSystem ?spatialCoordinateSystem . \n" +
|
||||
"%s aoprop:spatialRegionPoint ?spatialRegionPoint . \n" +
|
||||
"?spatialRegionPoint aoprop:lat ?spatialLocationLat . \n" +
|
||||
"?spatialRegionPoint aoprop:lon ?spatialLocationLon .\n" +
|
||||
"%s aoprop:spatialRegionBox ?spatialRegionBox . \n" +
|
||||
"?spatialRegionBox aoprop:boxMaxLat ?spatialLocationBBMaxLat .\n" +
|
||||
"?spatialRegionBox aoprop:boxMaxLon ?spatialLocationBBMaxLon .\n" +
|
||||
"?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat .\n" +
|
||||
"?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon .\n" +
|
||||
"%s aoprop:uri ?temporal .\n" +
|
||||
"?temporal aoprop:periodName ?temporalPeriodName .\n" +
|
||||
"?temporal aoprop:from ?temporalFrom .\n" +
|
||||
"?temporal aoprop:until ?temporalUntil .\n" +
|
||||
"%s aoprop:uri ?temporalNative .\n" +
|
||||
"?temporalNative aoprop:periodName ?temporalNativePeriodName .\n" +
|
||||
"%s aoprop:archeologicalResourceType ?archeologicalResourceType . \n" +
|
||||
"?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName . \n" +
|
||||
"%s aoprop:resourceType ?resourceType . \n" +
|
||||
"%s aoprop:nativeSubject ?nativeSubject . \n" +
|
||||
"?nativeSubject aoprop:prefLabel ?nativeSubjectPrefLabel .\n" +
|
||||
"?nativeSubject aoprop:rdfAbout ?nativeSubject .\n" +
|
||||
"%s aoprop:derivedSubject ?derivedSubject .\n" +
|
||||
"?derivedSubject aoprop:prefLabel ?derivedSubjectPrefLabel .\n" +
|
||||
"?derivedSubject aoprop:source \"Getty AAT\" .\n" +
|
||||
"%s aoprop:aatSubjects ?derivedSubject .\n" +
|
||||
"?derivedSubject aoprop:id ?derivedSubject . \n" +
|
||||
"?derivedSubject aoprop:label ?derivedSubjectPrefLabel .\n" +
|
||||
"?derivedSubject aoprop:lang ?aatSubjectsLang .\n" +
|
||||
"%s aoprop:title ?title . \n" +
|
||||
"%s aoprop:description ?description . \n" +
|
||||
"%s aoprop:language ?language . \n" +
|
||||
"}\n" +
|
||||
"from <https://ariadne-infrastructure.eu/api_________::ariadne_plus::ads::aat>\n" +
|
||||
"from <https://ariadne-infrastructure.eu/ariadneplus::ads::aatplus>\n" +
|
||||
"from <https://ariadne-infrastructure.eu/ariadneplus::ads::periodo>\n" +
|
||||
"from <https://ariadne-infrastructure.eu/ariadneplus::ads::periodoplus>\n" +
|
||||
"from <https://ariadne-infrastructure.eu/api_________::ariadne_plus::ads::271>\n" +
|
||||
"where { \n" +
|
||||
" \t%s\taocat:has_language / skos:prefLabel ?language .\n" +
|
||||
" \t%s\taocat:has_original_id ?originalId .\n" +
|
||||
" \t%s aocat:is_part_of ?partOf .\n" +
|
||||
" \t%s\taocat:has_creator ?creator .\n" +
|
||||
" ?creator aocat:has_name ?creatorName .\n" +
|
||||
"\t %s aocat:has_title ?title .\n" +
|
||||
" \t%s aocat:has_type / skos:prefLabel ?resourceType .\t\n" +
|
||||
" \t%s aocat:has_native_subject ?nativeSubject .\n" +
|
||||
" ?nativeSubject skos:prefLabel ?nativeSubjectPrefLabel .\n" +
|
||||
" optional {\n" +
|
||||
"\t\t\t%s aocat:has_derived_subject ?derivedSubject .\n" +
|
||||
" \t?derivedSubject skos:prefLabel ?derivedSubjectPrefLabel .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
"\t ?creator aocat:has_email ?creatorEmail .\n" +
|
||||
" \t}\n" +
|
||||
" optional {\n" +
|
||||
" %s aocat:has_description ?description .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" %s aocat:has_access_policy / rdfs:label ?accessPolicy . \n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" \t%s aocat:has_landing_page / rdfs:label ?landingPage .\n" +
|
||||
" }\n" +
|
||||
" \toptional {\n" +
|
||||
" \t%s aocat:has_temporal_coverage ?temporalNative .\n" +
|
||||
" \t?temporalNative aocat:has_native_period / skos:prefLabel ?temporalNativePeriodName .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" \t%s aocat:has_temporal_coverage ?temporal .\n" +
|
||||
" \t?temporal aocat:has_period / skos:prefLabel ?temporalPeriodName .\n" +
|
||||
" \toptional {\n" +
|
||||
" ?temporal aocat:from ?temporalFrom .\n" +
|
||||
" ?temporal aocat:until ?temporalUntil .\n" +
|
||||
" \t}\n" +
|
||||
" }\n" +
|
||||
" \t\n" +
|
||||
" \t{ \n" +
|
||||
"\t\tselect * \n" +
|
||||
" where {\n" +
|
||||
" %s aocat:is_part_of ?collection .\n" +
|
||||
" %s aocat:was_issued ?issued .\n" +
|
||||
" %s aocat:was_modified ?modified .\n" +
|
||||
" %s aocat:has_contributor ?contributor .\n" +
|
||||
" ?contributor aocat:has_name ?contributorName .\n" +
|
||||
" %s aocat:has_responsible ?legalResponsible .\n" +
|
||||
" ?legalResponsible aocat:has_name ?legalResponsibleName .\n" +
|
||||
" %s aocat:has_owner ?owner .\n" +
|
||||
" ?owner aocat:has_name ?ownerName .\n" +
|
||||
" %s aocat:has_publisher ?publisher . \n" +
|
||||
" ?publisher aocat:has_name ?publisherName .\n" +
|
||||
" %s aocat:has_access_rights ?accessRights .\n" +
|
||||
" %s aocat:has_ARIADNE_subject ?archeologicalResourceType . \n" +
|
||||
" ?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .\n" +
|
||||
" optional {\n" +
|
||||
" ?contributor aocat:has_email ?contributorEmail .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" ?legalResponsible aocat:has_email ?legalResponsibleEmail .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" ?owner aocat:has_email ?ownerEmail . \n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" ?publisher aocat:has_email ?publisherEmail .\n" +
|
||||
" }\n" +
|
||||
" \t}\n" +
|
||||
" \t}\n" +
|
||||
" \n" +
|
||||
" \t{\n" +
|
||||
" select * \n" +
|
||||
" where {\n" +
|
||||
" \t%s\taocat:has_spatial_coverage ?spatialRegion .\n" +
|
||||
" ?spatialRegion aocat:has_place_name ?spatialPlaceName .\n" +
|
||||
" optional {\n" +
|
||||
" ?spatialRegion aocat:has_coordinate_system ?spatialCoordinateSystem .\n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" %s\taocat:has_spatial_coverage ?spatialRegionPoint .\n" +
|
||||
" ?spatialRegionPoint aocat:has_latitude ?spatialLocationLat ; \n" +
|
||||
" \t\t aocat:has_longitude ?spatialLocationLon . \n" +
|
||||
" }\n" +
|
||||
" optional {\n" +
|
||||
" %s\taocat:has_spatial_coverage ?spatialRegionBox .\n" +
|
||||
" ?spatialRegionBox aocat:has_bounding_box_max_lat ?spatialLocationBBMaxLat ; \n" +
|
||||
" \t\t aocat:has_bounding_box_max_lon ?spatialLocationBBMaxLon ;\n" +
|
||||
" \t\t aocat:has_bounding_box_min_lat ?spatialLocationBBMinLat ;\n" +
|
||||
" \t aocat:has_bounding_box_min_lon ?spatialLocationBBMinLon ;\n" +
|
||||
" }\n" +
|
||||
" }\t\n" +
|
||||
" \t}\n" +
|
||||
" BIND (lang(?derivedSubjectPrefLabel) as ?aatSubjectsLang)\n" +
|
||||
"}";
|
||||
|
||||
if (query.equals("undefined"))
|
||||
public String executeMultipleQueryGraph(String queryTemplate, List<String> recordIds, String datasource, String collectionId){
|
||||
if (queryTemplate==null)
|
||||
return null;
|
||||
query = query.replaceAll("%s", "<https://ariadne-infrastructure.eu/aocat/Resource/02E4F4B5-24B7-3AD7-B460-CFA8B1F0BD1F>");
|
||||
final String selectQueryTemplate = queryTemplate.replaceAll("%datasource", datasource).replaceAll("%collectionId", collectionId);
|
||||
recordIds.forEach(recordId -> {
|
||||
executeQueryGraph(selectQueryTemplate, recordId);
|
||||
});
|
||||
return "ok";
|
||||
}
|
||||
|
||||
private String executeQueryGraph(String selectQueryTemplate, String recordId){
|
||||
query = selectQueryTemplate.replaceAll("%record", recordId);
|
||||
System.out.println("execute query "+query);
|
||||
openConnection();
|
||||
StringWriter recordWriter = null;
|
||||
Model resultsModel = null;
|
||||
|
@ -248,6 +90,9 @@ public class RunSPARQLQueryService {
|
|||
graphQueryResult.close();
|
||||
System.out.println("End connection Time: "+Calendar.getInstance().getTime().toString());
|
||||
System.out.println("count statements: " + resultsModel.size());
|
||||
if (resultsModel.size()==0) {
|
||||
return "noresult";
|
||||
}
|
||||
recordWriter = new StringWriter();
|
||||
RDFWriter rdfRecordWriter = Rio.createWriter(RDFFormat.RDFJSON, recordWriter);
|
||||
Rio.write(resultsModel, rdfRecordWriter);
|
||||
|
@ -333,4 +178,39 @@ public class RunSPARQLQueryService {
|
|||
public static void setGraphDBRepository(String graphDBRepository) {
|
||||
RunSPARQLQueryService.graphDBRepository = graphDBRepository;
|
||||
}
|
||||
|
||||
public List<String> selectRecordIds(){
|
||||
query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
|
||||
"select * \n" +
|
||||
"from <https://ariadne-infrastructure.eu/api_________::ariadne_plus::ads::271>\n" +
|
||||
"where { \n" +
|
||||
"\t?recordId rdf:type <https://www.ariadne-infrastructure.eu/resource/ao/cat/1.1/AO_Individual_Data_Resource> .\n" +
|
||||
"} \n";
|
||||
if (query.equals("undefined"))
|
||||
return null;
|
||||
// query = query.replaceAll("%s", "<https://ariadne-infrastructure.eu/aocat/Resource/02E4F4B5-24B7-3AD7-B460-CFA8B1F0BD1F>");
|
||||
openConnection();
|
||||
String jsonRecord = null;
|
||||
List<String> recordIds = new ArrayList<>();
|
||||
try {
|
||||
System.out.println("Start connection Time: "+Calendar.getInstance().getTime().toString());
|
||||
TupleQuery selectQuery = connection.prepareTupleQuery(QueryLanguage.SPARQL, query);
|
||||
TupleQueryResult selectQueryResult = selectQuery.evaluate();
|
||||
int counter = 0;
|
||||
while (selectQueryResult.hasNext()) {
|
||||
BindingSet recordSet = selectQueryResult.next();
|
||||
org.eclipse.rdf4j.model.Value recordIdValue = recordSet.getValue("recordId");
|
||||
System.out.println(recordIdValue.stringValue());
|
||||
recordIds.add(recordIdValue.stringValue());
|
||||
counter++;
|
||||
}
|
||||
System.out.println("Total records: "+counter);
|
||||
System.out.println("End connection Time: "+Calendar.getInstance().getTime().toString());
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
closeConnection();
|
||||
}
|
||||
return recordIds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ server.port=8281
|
|||
|
||||
graphdb.serverUrl=http://localhost:7200/
|
||||
graphdb.writer.user=writer
|
||||
graphdb.writer.pwd=****
|
||||
graphdb.writer.pwd=Writer01
|
||||
graphdb.repository=ariadneplus-ts01
|
||||
graphdb.sparqlUrl = http://localhost:7200/sparql
|
||||
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
PREFIX aocat: <https://www.ariadne-infrastructure.eu/resource/ao/cat/1.1/>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
||||
PREFIX aoprop: <https://www.ariadne-infrastructure.eu/property/>
|
||||
PREFIX onto: <http://www.ontotext.com/>
|
||||
PREFIX ariadneplus: <https://ariadne-infrastructure.eu/aocat/>
|
||||
PREFIX time: <http://www.w3.org/2006/time#>
|
||||
|
||||
CONSTRUCT {
|
||||
%record aoprop:identifier %record .
|
||||
%record aoprop:originalId ?originalId .
|
||||
%record aoprop:issued ?issued .
|
||||
%record aoprop:modified ?modified .
|
||||
%record aoprop:partOf ?partOf .
|
||||
%record aoprop:creator ?creator .
|
||||
?creator aoprop:name ?creatorName .
|
||||
?creator aoprop:email ?creatorEmail .
|
||||
%record aoprop:contributor ?contributor .
|
||||
?contributor aoprop:name ?contributorName .
|
||||
?contributor aoprop:email ?contributorEmail .
|
||||
%record aoprop:legalResponsible ?legalResponsible .
|
||||
?legalResponsible aoprop:name ?legalResponsibleName .
|
||||
?legalResponsible aoprop:email ?legalResponsibleEmail .
|
||||
%record aoprop:owner ?owner .
|
||||
?owner aoprop:name ?ownerName .
|
||||
?owner aoprop:email ?ownerEmail .
|
||||
%record aoprop:publisher ?publisher .
|
||||
?publisher aoprop:name ?publisherName .
|
||||
?publisher aoprop:email ?publisherEmail .
|
||||
%record aoprop:accessPolicy ?accessPolicy .
|
||||
%record aoprop:accessRights ?accessRights .
|
||||
%record aoprop:landingPage ?landingPage .
|
||||
%record aoprop:spatialRegion ?spatialRegion .
|
||||
?spatialRegion aoprop:placeName ?spatialPlaceName .
|
||||
?spatialRegion aoprop:spatialCoordinateSystem ?spatialCoordinateSystem .
|
||||
%record aoprop:spatialRegionPoint ?spatialRegionPoint .
|
||||
?spatialRegionPoint aoprop:lat ?spatialLocationLat .
|
||||
?spatialRegionPoint aoprop:lon ?spatialLocationLon .
|
||||
%record aoprop:spatialRegionBox ?spatialRegionBox .
|
||||
?spatialRegionBox aoprop:boxMaxLat ?spatialLocationBBMaxLat .
|
||||
?spatialRegionBox aoprop:boxMaxLon ?spatialLocationBBMaxLon .
|
||||
?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat .
|
||||
?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon .
|
||||
%record aoprop:uri ?temporal .
|
||||
?temporal aoprop:periodName ?temporalPeriodName .
|
||||
?temporal aoprop:from ?temporalFrom .
|
||||
?temporal aoprop:until ?temporalUntil .
|
||||
%record aoprop:uri ?temporalNative .
|
||||
?temporalNative aoprop:periodName ?temporalNativePeriodName .
|
||||
%record aoprop:archeologicalResourceType ?archeologicalResourceType .
|
||||
?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName .
|
||||
%record aoprop:resourceType ?resourceType .
|
||||
%record aoprop:nativeSubject ?nativeSubject .
|
||||
?nativeSubject aoprop:prefLabel ?nativeSubjectPrefLabel .
|
||||
?nativeSubject aoprop:rdfAbout ?nativeSubject .
|
||||
%record aoprop:derivedSubject ?derivedSubject .
|
||||
?derivedSubject aoprop:prefLabel ?derivedSubjectPrefLabel .
|
||||
?derivedSubject aoprop:source "Getty AAT" .
|
||||
%record aoprop:aatSubjects ?derivedSubject .
|
||||
?derivedSubject aoprop:id ?derivedSubject .
|
||||
?derivedSubject aoprop:label ?derivedSubjectPrefLabel .
|
||||
?derivedSubject aoprop:lang ?aatSubjectsLang .
|
||||
%record aoprop:title ?title .
|
||||
%record aoprop:description ?description .
|
||||
%record aoprop:language ?language .
|
||||
}
|
||||
from <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::aat>
|
||||
from <https://ariadne-infrastructure.eu/ariadneplus::%datasource::aatplus>
|
||||
from <https://ariadne-infrastructure.eu/ariadneplus::%datasource::periodo>
|
||||
from <https://ariadne-infrastructure.eu/ariadneplus::%datasource::periodoplus>
|
||||
from <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId>
|
||||
where {
|
||||
%record aocat:has_language / skos:prefLabel ?language .
|
||||
%record aocat:has_original_id ?originalId .
|
||||
%record aocat:is_part_of ?partOf .
|
||||
%record aocat:has_creator ?creator .
|
||||
?creator aocat:has_name ?creatorName .
|
||||
%record aocat:has_title ?title .
|
||||
%record aocat:has_type / skos:prefLabel ?resourceType .
|
||||
%record aocat:has_native_subject ?nativeSubject .
|
||||
?nativeSubject skos:prefLabel ?nativeSubjectPrefLabel .
|
||||
optional {
|
||||
%record aocat:has_derived_subject ?derivedSubject .
|
||||
?derivedSubject skos:prefLabel ?derivedSubjectPrefLabel .
|
||||
}
|
||||
optional {
|
||||
?creator aocat:has_email ?creatorEmail .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_description ?description .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_access_policy / rdfs:label ?accessPolicy .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_landing_page / rdfs:label ?landingPage .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_temporal_coverage ?temporalNative .
|
||||
?temporalNative aocat:has_native_period / skos:prefLabel ?temporalNativePeriodName .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_temporal_coverage ?temporal .
|
||||
?temporal aocat:has_period / skos:prefLabel ?temporalPeriodName .
|
||||
optional {
|
||||
?temporal aocat:from ?temporalFrom .
|
||||
?temporal aocat:until ?temporalUntil .
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
select *
|
||||
where {
|
||||
%record aocat:is_part_of ?collection .
|
||||
%record aocat:was_issued ?issued .
|
||||
%record aocat:was_modified ?modified .
|
||||
%record aocat:has_contributor ?contributor .
|
||||
?contributor aocat:has_name ?contributorName .
|
||||
%record aocat:has_responsible ?legalResponsible .
|
||||
?legalResponsible aocat:has_name ?legalResponsibleName .
|
||||
%record aocat:has_owner ?owner .
|
||||
?owner aocat:has_name ?ownerName .
|
||||
%record aocat:has_publisher ?publisher .
|
||||
?publisher aocat:has_name ?publisherName .
|
||||
%record aocat:has_access_rights ?accessRights .
|
||||
%record aocat:has_ARIADNE_subject ?archeologicalResourceType .
|
||||
?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .
|
||||
optional {
|
||||
?contributor aocat:has_email ?contributorEmail .
|
||||
}
|
||||
optional {
|
||||
?legalResponsible aocat:has_email ?legalResponsibleEmail .
|
||||
}
|
||||
optional {
|
||||
?owner aocat:has_email ?ownerEmail .
|
||||
}
|
||||
optional {
|
||||
?publisher aocat:has_email ?publisherEmail .
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
select *
|
||||
where {
|
||||
%record aocat:has_spatial_coverage ?spatialRegion .
|
||||
?spatialRegion aocat:has_place_name ?spatialPlaceName .
|
||||
optional {
|
||||
?spatialRegion aocat:has_coordinate_system ?spatialCoordinateSystem .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_spatial_coverage ?spatialRegionPoint .
|
||||
?spatialRegionPoint aocat:has_latitude ?spatialLocationLat ;
|
||||
aocat:has_longitude ?spatialLocationLon .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_spatial_coverage ?spatialRegionBox .
|
||||
?spatialRegionBox aocat:has_bounding_box_max_lat ?spatialLocationBBMaxLat ;
|
||||
aocat:has_bounding_box_max_lon ?spatialLocationBBMaxLon ;
|
||||
aocat:has_bounding_box_min_lat ?spatialLocationBBMinLat ;
|
||||
aocat:has_bounding_box_min_lon ?spatialLocationBBMinLon ;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIND (lang(?derivedSubjectPrefLabel) as ?aatSubjectsLang)
|
||||
}
|
|
@ -7,10 +7,14 @@ import eu.dnetlib.ariadneplus.elasticsearch.BulkUpload;
|
|||
import eu.dnetlib.ariadneplus.reader.ResourceManager;
|
||||
import eu.dnetlib.ariadneplus.reader.RunSPARQLQueryService;
|
||||
import eu.dnetlib.ariadneplus.reader.json.ParseRDFJSON;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +26,7 @@ public class GraphDbReaderAndESIndexTest {
|
|||
private RunSPARQLQueryService runSPQRLQuery;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// @Ignore
|
||||
public void readAndIndexTest() throws Exception {
|
||||
final ClassPathResource resource = new ClassPathResource("application.properties");
|
||||
Properties appProps = new Properties();
|
||||
|
@ -49,7 +53,38 @@ public class GraphDbReaderAndESIndexTest {
|
|||
BulkUpload bulkUpload = new BulkUpload();
|
||||
bulkUpload.init();
|
||||
runSPQRLQuery.setBulkUpload(bulkUpload);
|
||||
runSPQRLQuery.executeQueryGraph();
|
||||
String recordId = "<https://ariadne-infrastructure.eu/aocat/Resource/02E4F4B5-24B7-3AD7-B460-CFA8B1F0BD1F>";
|
||||
String datasource = "ads";
|
||||
String collectionId = "271";
|
||||
List<String> recordIds = Arrays.asList(recordId);
|
||||
final ClassPathResource queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql");
|
||||
String queryTemplate = IOUtils.toString(queryTemplateResource.getInputStream(), StandardCharsets.UTF_8.name());
|
||||
runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void selectRecordsTest() throws Exception {
|
||||
final ClassPathResource resource = new ClassPathResource("application.properties");
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(resource.getInputStream());
|
||||
|
||||
runSPQRLQuery = new RunSPARQLQueryService();
|
||||
runSPQRLQuery.setupConnection(
|
||||
appProps.getProperty("graphdb.writer.user"),
|
||||
appProps.getProperty("graphdb.writer.pwd"),
|
||||
appProps.getProperty("repository.url"),
|
||||
appProps.getProperty("graphdb.repository"));
|
||||
runSPQRLQuery.selectRecordIds();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void loadQueryTest() throws Exception {
|
||||
final ClassPathResource resource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql");
|
||||
String queryTemplate = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8.name());
|
||||
System.out.println(queryTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,319 +0,0 @@
|
|||
#server.contextPath=/ariadneplus-graphdb
|
||||
#update due to springboot 2.1.3
|
||||
server.servlet.context-path=/ariadneplus-graphdb
|
||||
server.port=8281
|
||||
|
||||
graphdb.serverUrl=http://localhost:7200/
|
||||
graphdb.writer.user=writer
|
||||
graphdb.writer.pwd=*****
|
||||
graphdb.repository=ariadneplus-ts01
|
||||
graphdb.sparqlUrl = http://localhost:7200/sparql
|
||||
|
||||
graphdb.baseURI=https://ariadne-infrastructure.eu/
|
||||
|
||||
repository.url=http://graphdb-test.ariadne.d4science.org:7200
|
||||
|
||||
catalog.entry.path=$[*][?(@['https://www.ariadne-infrastructure.eu/property/resourceType'][0]['value']=='provided record')]
|
||||
general.classpath=eu.dnetlib.ariadneplus.elasticsearch.model.
|
||||
type.path=https://www.ariadne-infrastructure.eu/property/resourceType
|
||||
exclude.predicates=["https://www.ariadne-infrastructure.eu/property/resourceType", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
||||
class.map.specifications={\
|
||||
"AriadneTemporal": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/from": {\
|
||||
"class_field": "From",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/periodName": {\
|
||||
"class_field": "PeriodName",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/until": {\
|
||||
"class_field": "Until",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/uri": {\
|
||||
"class_field": "Uri",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"AriadneGeoPoint": {\
|
||||
"class_type": "unique",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/lat": {\
|
||||
"class_field": "Lat",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/lon": {\
|
||||
"class_field": "Lon",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"Spatial": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings":{"https://www.ariadne-infrastructure.eu/property/address": {\
|
||||
"class_field": "Address",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/coordinateSystem": {\
|
||||
"class_field": "CoordinateSystem",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/country": {\
|
||||
"class_field": "Country",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/location": {\
|
||||
"class_field": "Location",\
|
||||
"external_reference": "AriadneGeoPoint",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/lat": {\
|
||||
"class_field": "Lat",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/lon": {\
|
||||
"class_field": "Lon",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/placeName": {\
|
||||
"class_field": "PlaceName",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}}\
|
||||
},\
|
||||
"ArcheologicalResourceType": {\
|
||||
"class_type": "unique",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/id": {\
|
||||
"class_field": "Id",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/name": {\
|
||||
"class_field": "Name",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"AgentInfo": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/name": {\
|
||||
"class_field": "Name",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/type": {\
|
||||
"class_field": "Type",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/email": {\
|
||||
"class_field": "Email",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/phone": {\
|
||||
"class_field": "Phone",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"NativeSubject": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/prefLabel": {\
|
||||
"class_field": "PrefLabel",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/rdfAbout": {\
|
||||
"class_field": "RdfAbout",\
|
||||
"substring": "yes",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"DerivedSubject": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/prefLabel": {\
|
||||
"class_field": "PrefLabel",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/source": {\
|
||||
"class_field": "Source",\
|
||||
"substring": "yes",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"AatSubject": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/id": {\
|
||||
"class_field": "Id",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/label": {\
|
||||
"class_field": "Label",\
|
||||
"substring": "yes",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/lang": {\
|
||||
"class_field": "Lang",\
|
||||
"substring": "yes",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"AriadneCatalogEntry": {\
|
||||
"class_type": "unique",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/accessPolicy": {\
|
||||
"class_field": "AccessPolicy",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/identifier": {\
|
||||
"class_field": "Identifier",\
|
||||
"substring": "yes",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/publisher": {\
|
||||
"class_field": "Publisher",\
|
||||
"external_reference": "AgentInfo",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/archeologicalResourceType": {\
|
||||
"class_field": "ArcheologicalResourceType",\
|
||||
"external_reference": "ArcheologicalResourceType",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/issued": {\
|
||||
"class_field": "Issued",\
|
||||
"element_type": "java.lang.String",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/resourceType": {\
|
||||
"class_field": "ResourceType",\
|
||||
"element_type": "java.lang.String",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/modified": {\
|
||||
"class_field": "Modified",\
|
||||
"element_type": "java.lang.String",\
|
||||
"substring": "no"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/nativeSubject": {\
|
||||
"class_field": "NativeSubject",\
|
||||
"substring": "no",\
|
||||
"external_reference": "NativeSubject"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/derivedSubject": {\
|
||||
"class_field": "DerivedSubject",\
|
||||
"substring": "no",\
|
||||
"external_reference": "DerivedSubject"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/aatSubjects": {\
|
||||
"class_field": "AatSubjects",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AatSubject"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/spatialRegion": {\
|
||||
"class_field": "Spatial",\
|
||||
"substring": "no",\
|
||||
"external_reference": "Spatial"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/spatialRegionPoint": {\
|
||||
"class_field": "Spatial",\
|
||||
"substring": "no",\
|
||||
"external_reference": "Spatial"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/landingPage": {\
|
||||
"class_field": "LandingPage",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/placeName": {\
|
||||
"class_field": "PlaceName",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/title": {\
|
||||
"class_field": "Title",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/accessRights": {\
|
||||
"class_field": "AccessRights",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/description": {\
|
||||
"class_field": "Description",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/creator": {\
|
||||
"class_field": "Creator",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AgentInfo"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/contributor": {\
|
||||
"class_field": "Contributor",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AgentInfo"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/legalResponsible": {\
|
||||
"class_field": "LegalResponsible",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AgentInfo"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/owner": {\
|
||||
"class_field": "Owner",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AgentInfo"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/originalId": {\
|
||||
"class_field": "OriginalId",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/uri": {\
|
||||
"class_field": "Temporal",\
|
||||
"substring": "no",\
|
||||
"external_reference": "AriadneTemporal"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/language": {\
|
||||
"class_field": "Language",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/partOf": {\
|
||||
"class_field": "IsPartOf",\
|
||||
"substring": "no",\
|
||||
"element_type": "java.lang.String"\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}
|
Loading…
Reference in New Issue