new index field to host has_identifier (https://support.d4science.org/issues/24160)

This commit is contained in:
Alessia Bardi 2022-11-22 13:47:04 +01:00
parent 4642e77a0c
commit 236f936b05
6 changed files with 54 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import eu.dnetlib.ariadneplus.reader.utils.ESUtils;
import org.apache.commons.compress.utils.Lists;
import java.util.List;
@ -34,6 +35,7 @@ public class AriadnePlusEntry {
private List<NativePeriod> nativePeriod;
private String wasCreated;
private List<DigitalImage> digitalImage;
private List<String> otherId;
private transient String uniqueIsPartOf;
private transient String typeURI;
@ -305,4 +307,15 @@ public class AriadnePlusEntry {
public void setPublisher(List<PublisherInfo> publisher) {
this.publisher = publisher;
}
public List<String> getOtherId() {
return otherId;
}
public void setOtherId(String otherId) {
if (this.otherId==null) {
this.otherId = Lists.newArrayList();
}
this.otherId.add(otherId);
}
}

View File

@ -125,13 +125,21 @@ public class ResourceManager {
if (!map.hasExternalReference()){
Method setField = c.getMethod("set" + map.getClass_field(), Class.forName(map.getElement_type()));
if (map.getClass_field().equals("Description")) {
//TODO: the current language seems not to support list of strings
if (map.getClass_field().equals("Description") ) {
setField.invoke(class_instance, values.stream().map(value -> {
return getFieldValue(value);
}).collect(Collectors.joining(" \n")));
}
else {
setField.invoke(class_instance, getFieldValue(values.get(0)));
if(map.getClass_field().equals("OtherId")){
for (Object v : values) {
setField.invoke(class_instance, getFieldValue(v));
}
}
else {
setField.invoke(class_instance, getFieldValue(values.get(0)));
}
}
}
else{

View File

@ -441,6 +441,12 @@ class.map.specifications={\
"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",\

View File

@ -11,6 +11,7 @@ CONSTRUCT {
%record aoprop:rdfType "Collection" .
%record aoprop:identifier %record .
%record aoprop:originalId ?originalId .
%record aoprop:otherId ?otherId .
%record aoprop:issued ?issued .
%record aoprop:modified ?modified .
%record aoprop:created ?created .
@ -99,6 +100,9 @@ where {
graph <https://ariadne-infrastructure.eu/api_________::ariadne_plus::%datasource::%collectionId> {
%record aocat:has_language / skos:prefLabel ?language .
%record aocat:has_original_id ?originalId .
optional {
%record aocat:has_identifier ?otherId .
}
optional {
%record aocat:is_part_of ?partOf .
}

View File

@ -11,6 +11,7 @@ CONSTRUCT {
%record aoprop:rdfType "Record" .
%record aoprop:identifier %record .
%record aoprop:originalId ?originalId .
%record aoprop:otherId ?otherId .
%record aoprop:issued ?issued .
%record aoprop:modified ?modified .
%record aoprop:created ?created .
@ -107,11 +108,13 @@ where {
%record aocat:is_part_of ?partOf .
%record aocat:has_creator ?creator .
?creator aocat:has_name ?creatorName .
%record aocat:has_title ?title .
%record aocat:has_title ?title .
%record aocat:has_type / skos:prefLabel ?resourceType .
%record aocat:has_type ?typeURI .
?typeURI skos:prefLabel ?typeLabel .
optional {
%record aocat:has_identifier ?otherId .
}
optional {
%record aocat:has_description ?description .
}

View File

@ -76,6 +76,22 @@ public class GraphDbReaderAndESIndexTest {
readAndIndexTest(true, id, datasource, apiId);
}
@Test
public void testADS276WithOtherIds() throws Exception {
String id = "https://ariadne-infrastructure.eu/aocat/Resource/HERoNI/A59B2AE2-57BF-337D-BF0D-7DA8B35AECE8";
String datasource = "ads";
String apiId = "276";
readAndIndexTest(true, id, datasource, apiId);
}
@Test
public void testSNDWithOtherId() throws Exception {
String id = "https://ariadne-infrastructure.eu/aocat/Collection/62D27ED3-20F3-355C-A7AD-3F3F4BC7457C";
String datasource = "snd";
String apiId = "zip";
readAndIndexTest(false, id, datasource, apiId);
}
@Test
public void testADS() throws Exception {