Extension for countries (https://support.d4science.org/issues/28575): code, properties, and tests
This commit is contained in:
parent
c0d275a1b7
commit
7dd16b74ca
|
@ -10,7 +10,7 @@
|
||||||
<groupId>eu.dnetlib</groupId>
|
<groupId>eu.dnetlib</groupId>
|
||||||
<artifactId>dnet-ariadneplus-graphdb-publisher</artifactId>
|
<artifactId>dnet-ariadneplus-graphdb-publisher</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>4.2.1-SNAPSHOT</version>
|
<version>4.2.1-COUNTRY-SNAPSHOT</version>
|
||||||
<scm>
|
<scm>
|
||||||
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet50/modules/dnet-ariadneplus-graphdb-publisher/trunk</developerConnection>
|
<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>
|
<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 String wasCreated;
|
||||||
private List<DigitalImage> digitalImage;
|
private List<DigitalImage> digitalImage;
|
||||||
private List<String> otherId;
|
private List<String> otherId;
|
||||||
|
private List<CountryInfo> country;
|
||||||
|
|
||||||
private transient String uniqueIsPartOf;
|
private transient String uniqueIsPartOf;
|
||||||
private transient String typeURI;
|
private transient String typeURI;
|
||||||
|
@ -318,4 +319,12 @@ public class AriadnePlusEntry {
|
||||||
}
|
}
|
||||||
this.otherId.add(otherId);
|
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/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"\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
},\
|
||||||
"AriadnePlusEntry": {\
|
"AriadnePlusEntry": {\
|
||||||
"class_type": "unique",\
|
"class_type": "unique",\
|
||||||
"mappings": {\
|
"mappings": {\
|
||||||
|
@ -476,6 +491,11 @@ class.map.specifications={\
|
||||||
"class_field": "DigitalImage",\
|
"class_field": "DigitalImage",\
|
||||||
"substring": "no",\
|
"substring": "no",\
|
||||||
"external_reference": "DigitalImage"\
|
"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:text ?description .
|
||||||
?descriptionInfo aoprop:lang ?descriptionLang .
|
?descriptionInfo aoprop:lang ?descriptionLang .
|
||||||
%record aoprop:language ?language .
|
%record aoprop:language ?language .
|
||||||
|
%record aoprop:country ?country .
|
||||||
|
?country aoprop:id ?country .
|
||||||
|
?country aoprop:name ?countryName .
|
||||||
}
|
}
|
||||||
where {
|
where {
|
||||||
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
|
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
|
||||||
|
@ -121,6 +124,10 @@ where {
|
||||||
optional {
|
optional {
|
||||||
%record aocat:has_landing_page / rdfs:label ?landingPage .
|
%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 (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?description)))) as ?descriptionInfo)
|
||||||
BIND (LANG(?description) as ?descriptionLang)
|
BIND (LANG(?description) as ?descriptionLang)
|
||||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
||||||
|
|
|
@ -100,6 +100,9 @@ CONSTRUCT {
|
||||||
%record aoprop:image ?primaryVisualComponent .
|
%record aoprop:image ?primaryVisualComponent .
|
||||||
?primaryVisualComponent aoprop:primaryVisualComponent ?primaryVisualComponent .
|
?primaryVisualComponent aoprop:primaryVisualComponent ?primaryVisualComponent .
|
||||||
?primaryVisualComponent aoprop:visualComponent ?visualComponent .
|
?primaryVisualComponent aoprop:visualComponent ?visualComponent .
|
||||||
|
%record aoprop:country ?country .
|
||||||
|
?country aoprop:id ?country .
|
||||||
|
?country aoprop:name ?countryName .
|
||||||
}
|
}
|
||||||
where {
|
where {
|
||||||
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
|
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_unit / skos:prefLabel ?spatialPrecisionUnit .
|
||||||
%record aocat:has_spatial_precision / aocat:has_value ?spatialPrecisionValue .
|
%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 (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?description)))) as ?descriptionInfo)
|
||||||
BIND (LANG(?description) as ?descriptionLang)
|
BIND (LANG(?description) as ?descriptionLang)
|
||||||
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
BIND (IRI(concat( "https://ariadne-infrastructure.eu/TextLang/",SHA1(STR(?title)))) as ?titleInfo)
|
||||||
|
|
|
@ -625,6 +625,16 @@ public class GraphDbReaderAndESIndexTest {
|
||||||
readAndIndexTest(isRecord, recordId, datasource, collectionId);
|
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 {
|
private class CollectionData {
|
||||||
String URI_ID;
|
String URI_ID;
|
||||||
String id;
|
String id;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
public class ParseRDFJsonTest {
|
public class ParseRDFJsonTest {
|
||||||
|
|
||||||
|
@ -128,6 +129,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) {
|
private String getFromClasspath(String s) {
|
||||||
try {
|
try {
|
||||||
final ClassPathResource resource = new ClassPathResource(s);
|
final ClassPathResource resource = new ClassPathResource(s);
|
||||||
|
|
|
@ -111,6 +111,12 @@
|
||||||
"type" : "uri"
|
"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" : [
|
"https://www.ariadne-infrastructure.eu/property/resourceType" : [
|
||||||
{
|
{
|
||||||
"value" : "Collection",
|
"value" : "Collection",
|
||||||
|
@ -172,5 +178,14 @@
|
||||||
"lang" : "en"
|
"lang" : "en"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"http://www.wikidata.org/entity/Q38" : {
|
||||||
|
"https://www.ariadne-infrastructure.eu/property/name" : [
|
||||||
|
{
|
||||||
|
"value" : "Italy",
|
||||||
|
"type" : "literal"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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": {
|
"AriadnePlusEntry": {
|
||||||
"class_type": "unique",
|
"class_type": "unique",
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
@ -423,6 +438,12 @@
|
||||||
"substring": "no",
|
"substring": "no",
|
||||||
"element_type": "java.lang.String"
|
"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": {
|
"https://www.ariadne-infrastructure.eu/property/temporal": {
|
||||||
"class_field": "Temporal",
|
"class_field": "Temporal",
|
||||||
"substring": "no",
|
"substring": "no",
|
||||||
|
@ -452,6 +473,11 @@
|
||||||
"class_field": "DigitalImage",
|
"class_field": "DigitalImage",
|
||||||
"substring": "no",
|
"substring": "no",
|
||||||
"external_reference": "DigitalImage"
|
"external_reference": "DigitalImage"
|
||||||
|
},
|
||||||
|
"https://www.ariadne-infrastructure.eu/property/country": {
|
||||||
|
"class_field": "Country",
|
||||||
|
"substring": "no",
|
||||||
|
"external_reference": "CountryInfo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,12 @@
|
||||||
"type" : "uri"
|
"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" : [
|
"https://www.ariadne-infrastructure.eu/property/rdfType" : [
|
||||||
{
|
{
|
||||||
"value" : "Collection",
|
"value" : "Collection",
|
||||||
|
@ -317,6 +323,14 @@
|
||||||
"value" : "https://ariadne-infrastructure.eu/aocat/Time-Span/25162",
|
"value" : "https://ariadne-infrastructure.eu/aocat/Time-Span/25162",
|
||||||
"type" : "uri"
|
"type" : "uri"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"http://www.wikidata.org/entity/Q38" : {
|
||||||
|
"https://www.ariadne-infrastructure.eu/property/name": [
|
||||||
|
{
|
||||||
|
"value": "Italy",
|
||||||
|
"type": "literal"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue