matching periodo name (if any) overwrites native period name

This commit is contained in:
Enrico Ottonello 2021-02-16 18:19:30 +01:00
parent 2d01f321d1
commit 84993ffaba
6 changed files with 87 additions and 17 deletions

View File

@ -102,6 +102,14 @@ public class BulkUpload {
} }
} }
if (ace.getTemporal()!=null) {
ace.getTemporal().stream()
.filter(t->t.getMatchingPeriodOName()!=null)
.forEach(t->{
t.setPeriodName(t.getMatchingPeriodOName());
});
}
if (!isCollection) { if (!isCollection) {
String uniqueIsPartOf = ace.getUniqueIsPartOf(); String uniqueIsPartOf = ace.getUniqueIsPartOf();
if (uniqueIsPartOf != null) { if (uniqueIsPartOf != null) {

View File

@ -10,6 +10,7 @@ public class AriadneTemporal {
private String periodName; private String periodName;
private String until; private String until;
private String uri; private String uri;
private transient String matchingPeriodOName;
public static AriadneTemporal fromRDFJson(JsonElement json) { public static AriadneTemporal fromRDFJson(JsonElement json) {
AriadneTemporal at = new AriadneTemporal(); AriadneTemporal at = new AriadneTemporal();
@ -72,4 +73,12 @@ public class AriadneTemporal {
public static AriadneTemporal fromJson(String json){ public static AriadneTemporal fromJson(String json){
return new Gson().fromJson(json, AriadneTemporal.class); return new Gson().fromJson(json, AriadneTemporal.class);
} }
public String getMatchingPeriodOName() {
return matchingPeriodOName;
}
public void setMatchingPeriodOName(String matchingPeriodOName) {
this.matchingPeriodOName = matchingPeriodOName;
}
} }

View File

@ -5,7 +5,7 @@ server.port=8281
graphdb.serverUrl=http://graphdb-test.ariadne.d4science.org:7200 graphdb.serverUrl=http://graphdb-test.ariadne.d4science.org:7200
graphdb.writer.user=writer graphdb.writer.user=writer
graphdb.writer.pwd=***** graphdb.writer.pwd=pwd
graphdb.repository=ariadneplus-ts01 graphdb.repository=ariadneplus-ts01
graphdb.baseURI=https://ariadne-infrastructure.eu/ graphdb.baseURI=https://ariadne-infrastructure.eu/
@ -26,11 +26,16 @@ class.map.specifications={\
"substring": "no",\ "substring": "no",\
"element_type": "java.lang.String"\ "element_type": "java.lang.String"\
},\ },\
"https://www.ariadne-infrastructure.eu/property/periodName": {\ "https://www.ariadne-infrastructure.eu/property/nativePeriodName": {\
"class_field": "PeriodName",\ "class_field": "PeriodName",\
"substring": "no",\ "substring": "no",\
"element_type": "java.lang.String"\ "element_type": "java.lang.String"\
},\ },\
"https://www.ariadne-infrastructure.eu/property/periodOName": {\
"class_field": "MatchingPeriodOName",\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/until": {\ "https://www.ariadne-infrastructure.eu/property/until": {\
"class_field": "Until",\ "class_field": "Until",\
"substring": "no",\ "substring": "no",\

View File

@ -42,11 +42,13 @@ CONSTRUCT {
?spatialRegionBox aoprop:boxMaxLon ?spatialLocationBBMaxLon . ?spatialRegionBox aoprop:boxMaxLon ?spatialLocationBBMaxLon .
?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat . ?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat .
?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon . ?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon .
%record aoprop:uri ?temporal .
?temporal aoprop:periodOName ?temporalPeriodName .
?temporal aoprop:from ?temporalFrom .
?temporal aoprop:until ?temporalUntil .
?temporal aoprop:uri ?temporal .
%record aoprop:uri ?temporalNative . %record aoprop:uri ?temporalNative .
?temporalNative aoprop:periodName ?temporalNativePeriodName . ?temporalNative aoprop:nativePeriodName ?temporalNativePeriodName .
?temporalNative aoprop:from ?temporalFrom .
?temporalNative aoprop:until ?temporalUntil .
?temporalNative aoprop:uri ?temporalPeriodO .
%record aoprop:archeologicalResourceType ?archeologicalResourceType . %record aoprop:archeologicalResourceType ?archeologicalResourceType .
?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName . ?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName .
%record aoprop:resourceType ?resourceType . %record aoprop:resourceType ?resourceType .

View File

@ -43,12 +43,12 @@ CONSTRUCT {
?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat . ?spatialRegionBox aoprop:boxMinLat ?spatialLocationBBMinLat .
?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon . ?spatialRegionBox aoprop:boxMinLon ?spatialLocationBBMinLon .
%record aoprop:uri ?temporal . %record aoprop:uri ?temporal .
?temporal aoprop:periodName ?temporalPeriodName . ?temporal aoprop:periodOName ?temporalPeriodName .
?temporal aoprop:from ?temporalFrom . ?temporal aoprop:from ?temporalFrom .
?temporal aoprop:until ?temporalUntil . ?temporal aoprop:until ?temporalUntil .
?temporal aoprop:uri ?temporal . ?temporal aoprop:uri ?temporal .
%record aoprop:uri ?temporalNative . %record aoprop:uri ?temporalNative .
?temporalNative aoprop:periodName ?temporalNativePeriodName . ?temporalNative aoprop:nativePeriodName ?temporalNativePeriodName .
%record aoprop:archeologicalResourceType ?archeologicalResourceType . %record aoprop:archeologicalResourceType ?archeologicalResourceType .
?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName . ?archeologicalResourceType aoprop:name ?archeologicalResourceTypeName .
%record aoprop:resourceType ?resourceType . %record aoprop:resourceType ?resourceType .

View File

@ -8,6 +8,11 @@ import eu.dnetlib.ariadneplus.reader.ResourceManager;
import eu.dnetlib.ariadneplus.reader.RunSPARQLQueryService; import eu.dnetlib.ariadneplus.reader.RunSPARQLQueryService;
import eu.dnetlib.ariadneplus.reader.json.ParseRDFJSON; import eu.dnetlib.ariadneplus.reader.json.ParseRDFJSON;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.RepositoryResult;
import org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -27,15 +32,35 @@ public class GraphDbReaderAndESIndexTest {
private RunSPARQLQueryService runSPQRLQuery; private RunSPARQLQueryService runSPQRLQuery;
@Test @Test
public void ads1093RecordTest() throws Exception { @Ignore
boolean testRecord = true; public void uploadAMCRFieldworkTest() throws Exception {
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/1B23A61E-E4DE-3647-8006-0284C729AF85"; boolean isRecord = true;
String datasource = "ads"; String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/AMCR/E61E0F4E-268F-39E4-8EDB-A431AFC505AA";
String collectionId = "1093"; String datasource = "amcr";
readAndIndexTest(testRecord, recordId, datasource, collectionId); String collectionId = "oai";
readAndIndexTest(isRecord, recordId, datasource, collectionId);
} }
private void readAndIndexTest(boolean testRecord, String recordId, String datasource, String collectionId) throws Exception { @Test
public void uploadAMCRDocumentTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Collection/AMCR/FC59581D-DC3A-31DA-922A-98DE764F3D76";
String datasource = "amcr";
String collectionId = "oai";
readAndIndexTest(isRecord, recordId, datasource, collectionId);
}
@Test
@Ignore
public void uploadADSRecordTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/34E3811A-0BAD-3832-B3A0-3139E8A0285C";
String datasource = "ads";
String collectionId = "271";
readAndIndexTest(isRecord, recordId, datasource, collectionId);
}
private void readAndIndexTest(boolean isRecord, String recordId, String datasource, String collectionId) throws Exception {
final ClassPathResource resource = new ClassPathResource("application.properties"); final ClassPathResource resource = new ClassPathResource("application.properties");
Properties appProps = new Properties(); Properties appProps = new Properties();
appProps.load(resource.getInputStream()); appProps.load(resource.getInputStream());
@ -62,7 +87,7 @@ public class GraphDbReaderAndESIndexTest {
bulkUpload.init(appProps.getProperty("elasticsearch.hostname"),appProps.getProperty("elasticsearch.indexname")); bulkUpload.init(appProps.getProperty("elasticsearch.hostname"),appProps.getProperty("elasticsearch.indexname"));
runSPQRLQuery.setBulkUpload(bulkUpload); runSPQRLQuery.setBulkUpload(bulkUpload);
final ClassPathResource queryTemplateResource; final ClassPathResource queryTemplateResource;
if (testRecord) { if (isRecord) {
queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql"); queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql");
} }
else { else {
@ -70,7 +95,7 @@ public class GraphDbReaderAndESIndexTest {
} }
List<String> recordIds = Arrays.asList(recordId); List<String> recordIds = Arrays.asList(recordId);
String queryTemplate = IOUtils.toString(queryTemplateResource.getInputStream(), StandardCharsets.UTF_8.name()); String queryTemplate = IOUtils.toString(queryTemplateResource.getInputStream(), StandardCharsets.UTF_8.name());
if (testRecord) { if (isRecord) {
runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId, false); runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId, false);
} }
else { else {
@ -103,4 +128,25 @@ public class GraphDbReaderAndESIndexTest {
System.out.println(queryTemplate); System.out.println(queryTemplate);
} }
@Test
@Ignore
public void httpsRequestTest() throws Exception {
// RemoteRepositoryManager manager = new RemoteRepositoryManager("http://graphdb-test.ariadne.d4science.org:7200");
RemoteRepositoryManager manager = new RemoteRepositoryManager("https://graphdb-test.ariadne.d4science.org");
manager.init();
manager.setUsernameAndPassword("writer", "******");
Repository repository = manager.getRepository("ariadneplus-ts01");
RepositoryConnection connection = repository.getConnection();
RepositoryResult<Resource> contexts = connection.getContextIDs();
if (contexts!=null) {
System.out.println("##### Primo context "+contexts.next().stringValue());
}
else {
System.out.println("No contexts ");
}
connection.close();
repository.shutDown();
manager.shutDown();
}
} }