WIP: Extend the AriadnePlus KB with info about country #5
|
@ -10,7 +10,7 @@
|
|||
<groupId>eu.dnetlib</groupId>
|
||||
<artifactId>dnet-ariadneplus-graphdb-publisher</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>4.2.1-SNAPSHOT</version>
|
||||
<version>4.2.1-COUNTRY-SNAPSHOT</version>
|
||||
<scm>
|
||||
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet50/modules/dnet-ariadneplus-graphdb-publisher/trunk</developerConnection>
|
||||
<url>https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/dnet-ariadneplus-graphdb-publisher</url>
|
||||
|
|
|
@ -36,6 +36,7 @@ public class AriadnePlusEntry {
|
|||
private String wasCreated;
|
||||
private List<DigitalImage> digitalImage;
|
||||
private List<String> otherId;
|
||||
private List<CountryInfo> country;
|
||||
|
||||
private transient String uniqueIsPartOf;
|
||||
private transient String typeURI;
|
||||
|
@ -318,4 +319,12 @@ public class AriadnePlusEntry {
|
|||
}
|
||||
this.otherId.add(otherId);
|
||||
}
|
||||
|
||||
public List<CountryInfo> getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(List<CountryInfo> country) {
|
||||
this.country = country;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.dnetlib.ariadneplus.elasticsearch.model;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CountryInfo {
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public CountryInfo() {
|
||||
}
|
||||
|
||||
public static CountryInfo fromJson(String json){
|
||||
return new Gson().fromJson(json, CountryInfo.class);
|
||||
}
|
||||
}
|
|
@ -308,6 +308,21 @@ class.map.specifications={\
|
|||
}\
|
||||
}\
|
||||
},\
|
||||
"CountryInfo": {\
|
||||
"class_type": "prototype",\
|
||||
"mappings": {\
|
||||
"https://www.ariadne-infrastructure.eu/property/country": {\
|
||||
"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"\
|
||||
}\
|
||||
}\
|
||||
},\
|
||||
"AriadnePlusEntry": {\
|
||||
"class_type": "unique",\
|
||||
"mappings": {\
|
||||
|
@ -476,8 +491,12 @@ class.map.specifications={\
|
|||
"class_field": "DigitalImage",\
|
||||
"substring": "no",\
|
||||
"external_reference": "DigitalImage"\
|
||||
},\
|
||||
"https://www.ariadne-infrastructure.eu/property/country": {\
|
||||
"class_field": "Country",\
|
||||
"substring": "no",\
|
||||
"external_reference": "CountryInfo"\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,9 @@ CONSTRUCT {
|
|||
?descriptionInfo aoprop:text ?description .
|
||||
?descriptionInfo aoprop:lang ?descriptionLang .
|
||||
%record aoprop:language ?language .
|
||||
%record aoprop:country ?country .
|
||||
?country aoprop:id ?country .
|
||||
?country aoprop:name ?countryName .
|
||||
}
|
||||
where {
|
||||
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
|
||||
|
@ -121,6 +124,10 @@ where {
|
|||
optional {
|
||||
%record aocat:has_landing_page / rdfs:label ?landingPage .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_country ?country .
|
||||
?country rdfs:label ?countryName .
|
||||
}
|
||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?description)))) as ?descriptionInfo)
|
||||
BIND (LANG(?description) as ?descriptionLang)
|
||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
||||
|
|
|
@ -100,6 +100,9 @@ CONSTRUCT {
|
|||
%record aoprop:image ?primaryVisualComponent .
|
||||
?primaryVisualComponent aoprop:primaryVisualComponent ?primaryVisualComponent .
|
||||
?primaryVisualComponent aoprop:visualComponent ?visualComponent .
|
||||
%record aoprop:country ?country .
|
||||
?country aoprop:id ?country .
|
||||
?country aoprop:name ?countryName .
|
||||
}
|
||||
where {
|
||||
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
|
||||
|
@ -134,6 +137,10 @@ where {
|
|||
%record aocat:has_spatial_precision / aocat:has_unit / skos:prefLabel ?spatialPrecisionUnit .
|
||||
%record aocat:has_spatial_precision / aocat:has_value ?spatialPrecisionValue .
|
||||
}
|
||||
optional {
|
||||
%record aocat:has_country ?country .
|
||||
?country rdfs:label ?countryName .
|
||||
}
|
||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?description)))) as ?descriptionInfo)
|
||||
BIND (LANG(?description) as ?descriptionLang)
|
||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
||||
|
|
|
@ -8,16 +8,11 @@ import eu.dnetlib.ariadneplus.publisher.AriadnePlusPublisherException;
|
|||
import eu.dnetlib.ariadneplus.reader.ResourceManager;
|
||||
import eu.dnetlib.ariadneplus.reader.RunSPARQLQueryService;
|
||||
import eu.dnetlib.ariadneplus.reader.json.ParseRDFJSON;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.rdf4j.RDF4JException;
|
||||
import org.eclipse.rdf4j.model.IRI;
|
||||
import org.eclipse.rdf4j.model.Resource;
|
||||
import org.eclipse.rdf4j.model.ValueFactory;
|
||||
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.repository.Repository;
|
||||
import org.eclipse.rdf4j.repository.RepositoryConnection;
|
||||
import org.eclipse.rdf4j.repository.RepositoryResult;
|
||||
|
@ -26,18 +21,13 @@ import org.eclipse.rdf4j.repository.util.Repositories;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
* @author enrico.ottonello
|
||||
|
@ -625,6 +615,16 @@ public class GraphDbReaderAndESIndexTest {
|
|||
readAndIndexTest(isRecord, recordId, datasource, collectionId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uploadWithCountryTest() throws Exception {
|
||||
boolean isRecord = false;
|
||||
String recordId = "https://ariadne-infrastructure.eu/aocat/Collection/INFN/8AF9C287-9CBD-32DC-9B18-0C0EFD85BAFB";
|
||||
String datasource = "infn";
|
||||
String apiId = "firenze";
|
||||
readAndIndexTest(isRecord, recordId, datasource, apiId);
|
||||
|
||||
}
|
||||
|
||||
private class CollectionData {
|
||||
String URI_ID;
|
||||
String id;
|
||||
|
|
|
@ -2,17 +2,16 @@ package eu.dnetlib.ariadneplus.reader.json;
|
|||
|
||||
import eu.dnetlib.ariadneplus.elasticsearch.model.AriadnePlusEntry;
|
||||
import eu.dnetlib.ariadneplus.reader.ResourceManager;
|
||||
import eu.dnetlib.ariadneplus.reader.utils.PropertiesMap;
|
||||
import net.minidev.json.parser.ParseException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ParseRDFJsonTest {
|
||||
|
||||
|
@ -103,7 +102,7 @@ public class ParseRDFJsonTest {
|
|||
Assert.assertNotEquals(-1, res);
|
||||
mng.manage(parser);
|
||||
if(mng.hasNext())
|
||||
System.out.println(mng.next());
|
||||
System.out.println(mng.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -128,6 +127,22 @@ public class ParseRDFJsonTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountryInCollection() throws ParseException {
|
||||
String collectionJson = getFromClasspath("eu/dnetlib/ariadneplus/reader/json/collection.json");
|
||||
parser.setCollection(true);
|
||||
int res = parser.parse(collectionJson);
|
||||
Assert.assertNotEquals(-1, res);
|
||||
boolean hasCountry = false;
|
||||
while(parser.hasNextElement()){
|
||||
LinkedHashMap element = parser.getNextElement();
|
||||
System.out.println(element);
|
||||
hasCountry = element.containsKey("https://www.ariadne-infrastructure.eu/property/country");
|
||||
}
|
||||
Assert.assertTrue(hasCountry);
|
||||
|
||||
}
|
||||
|
||||
private String getFromClasspath(String s) {
|
||||
try {
|
||||
final ClassPathResource resource = new ClassPathResource(s);
|
||||
|
|
|
@ -111,6 +111,12 @@
|
|||
"type" : "uri"
|
||||
}
|
||||
],
|
||||
"https://www.ariadne-infrastructure.eu/property/country" : [
|
||||
{
|
||||
"value" : "http://www.wikidata.org/entity/Q38",
|
||||
"type" : "uri"
|
||||
}
|
||||
],
|
||||
"https://www.ariadne-infrastructure.eu/property/resourceType" : [
|
||||
{
|
||||
"value" : "Collection",
|
||||
|
@ -172,5 +178,14 @@
|
|||
"lang" : "en"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"http://www.wikidata.org/entity/Q38" : {
|
||||
"https://www.ariadne-infrastructure.eu/property/name" : [
|
||||
{
|
||||
"value" : "Italy",
|
||||
"type" : "literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -165,6 +165,13 @@
|
|||
"type" : "literal",
|
||||
"datatype" : "http://www.w3.org/2001/XMLSchema#dateTime"
|
||||
}
|
||||
],
|
||||
"https://www.ariadne-infrastructure.eu/property/rdfType" : [
|
||||
{
|
||||
"value" : "Record",
|
||||
"type" : "literal",
|
||||
"datatype" : "http://www.w3.org/2001/XMLSchema#string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -290,6 +290,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"CountryInfo": {
|
||||
"class_type": "prototype",
|
||||
"mappings": {
|
||||
"https://www.ariadne-infrastructure.eu/property/country": {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AriadnePlusEntry": {
|
||||
"class_type": "unique",
|
||||
"mappings": {
|
||||
|
@ -423,6 +438,12 @@
|
|||
"substring": "no",
|
||||
"element_type": "java.lang.String"
|
||||
},
|
||||
"https://www.ariadne-infrastructure.eu/property/otherId": {
|
||||
"class_field": "OtherId",
|
||||
"class_type": "prototype",
|
||||
"substring": "no",
|
||||
"element_type": "java.lang.String"
|
||||
},
|
||||
"https://www.ariadne-infrastructure.eu/property/temporal": {
|
||||
"class_field": "Temporal",
|
||||
"substring": "no",
|
||||
|
@ -452,6 +473,11 @@
|
|||
"class_field": "DigitalImage",
|
||||
"substring": "no",
|
||||
"external_reference": "DigitalImage"
|
||||
},
|
||||
"https://www.ariadne-infrastructure.eu/property/country": {
|
||||
"class_field": "Country",
|
||||
"substring": "no",
|
||||
"external_reference": "CountryInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,6 +204,12 @@
|
|||
"type" : "uri"
|
||||
}
|
||||
],
|
||||
"https://www.ariadne-infrastructure.eu/property/country" : [
|
||||
{
|
||||
"value" : "http://www.wikidata.org/entity/Q38",
|
||||
"type" : "uri"
|
||||
}
|
||||
],
|
||||
"https://www.ariadne-infrastructure.eu/property/rdfType" : [
|
||||
{
|
||||
"value" : "Collection",
|
||||
|
@ -317,6 +323,14 @@
|
|||
"value" : "https://ariadne-infrastructure.eu/aocat/Time-Span/25162",
|
||||
"type" : "uri"
|
||||
}
|
||||
]
|
||||
],
|
||||
"http://www.wikidata.org/entity/Q38" : {
|
||||
"https://www.ariadne-infrastructure.eu/property/name": [
|
||||
{
|
||||
"value": "Italy",
|
||||
"type": "literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue