removed empty values/structures from record/collection to es

This commit is contained in:
Enrico Ottonello 2020-07-17 17:42:08 +02:00
parent d6aafdf97d
commit 766f8199f2
4 changed files with 49 additions and 45 deletions

View File

@ -84,31 +84,29 @@ public class BulkUpload {
ace.getContributor().clear();
ace.setContributor(ace.getCreator());
}
Distribution distribution = new Distribution();
AgentInfo distrPublisher = new AgentInfo();
distrPublisher.setEmail("");
distrPublisher.setName("");
distrPublisher.setType("");
distribution.setPublisher(Arrays.asList(distrPublisher));
ace.setDistribution(Arrays.asList(distribution));
ItemMetadataStructure ims = new ItemMetadataStructure();
ace.setHasItemMetadataStructure(Arrays.asList(ims));
MetadataRecord mr = new MetadataRecord();
Dex dex = new Dex();
mr.setConformsTo(Arrays.asList(dex));
ace.setHasMetadataRecord(Arrays.asList(mr));
if (!isCollection) {
ace.setKeyword(Arrays.asList(new String("")));
}
AgentInfo sr = new AgentInfo();
ace.setScientificResponsible(Arrays.asList(sr));
AgentInfo tr = new AgentInfo();
ace.setTechnicalResponsible(Arrays.asList(tr));
// Distribution distribution = new Distribution();
// AgentInfo distrPublisher = new AgentInfo();
// distrPublisher.setEmail("");
// distrPublisher.setName("");
// distrPublisher.setType("");
// distribution.setPublisher(Arrays.asList(distrPublisher));
// ace.setDistribution(Arrays.asList(distribution));
// ItemMetadataStructure ims = new ItemMetadataStructure();
// ace.setHasItemMetadataStructure(Arrays.asList(ims));
// MetadataRecord mr = new MetadataRecord();
// Dex dex = new Dex();
// mr.setConformsTo(Arrays.asList(dex));
// ace.setHasMetadataRecord(Arrays.asList(mr));
// if (!isCollection) {
// ace.setKeyword(Arrays.asList(new String("")));
// }
// AgentInfo sr = new AgentInfo();
// ace.setScientificResponsible(Arrays.asList(sr));
// AgentInfo tr = new AgentInfo();
// ace.setTechnicalResponsible(Arrays.asList(tr));
}
AgentInfo testPublisher = new AgentInfo();
testPublisher.setName("TEST");
testPublisher.setPhone(null);
testPublisher.setEmail(null);
ace.getPublisher().add(testPublisher);
String[] splits = ace.getIdentifier().split("/");
@ -122,13 +120,7 @@ public class BulkUpload {
ace.getAatSubjects().forEach(s -> s.setId(aatSubjectId));
}
String idES;
if (isCollection) {
idES = "10000".concat(ace.getOriginalId());
}
else {
idES = splits[splits.length-1];
}
String idES = splits[splits.length-1];
request.add(new IndexRequest(elasticSearchIndexName).id(idES)
.source(ace.toJson(),XContentType.JSON));

View File

@ -39,16 +39,16 @@ public class AriadneCatalogEntry {
private List<AgentInfo> technicalResponsible;
private List<AriadneTemporal> temporal;
private String accrualPeriodicity = new String("");
private String accrualPeriodicity;// = new String("");
private String audience;// IF PRESENT, MUST CONTAIN A VALUE !!
private String contactPoint = new String("");
private String contactPoint;// = new String("");
private String extent;// IF PRESENT, MUST CONTAIN A VALUE !!
private String providerId = new String("");
private String packageId = new String("");
private String placeName = new String("");
private String postcode = new String("");
private String rdfAbout = new String("");
private String rights = new String("");
private String providerId;// = new String("");
private String packageId;// = new String("");
private String placeName;// = new String("");
private String postcode;// = new String("");
private String rdfAbout;// = new String("");
private String rights;// = new String("");
public List<AgentInfo> getContributor() {
return contributor;

View File

@ -7,13 +7,13 @@ import java.util.Map;
public class Spatial {
private String address = new String("");
private String address;// = new String("");
private String boundingBoxMaxLat;
private String boundingBoxMaxLon;
private String boundingBoxMinLat;
private String boundingBoxMinLon;
private String coordinateSystem = new String("");
private String country = new String("");
private String country;// = new String("");
private AriadneGeoPoint location;
private String placeName;
private String lat;

View File

@ -53,16 +53,28 @@ public class GraphDbReaderAndESIndexTest {
BulkUpload bulkUpload = new BulkUpload();
bulkUpload.init(appProps.getProperty("elasticsearch.hostname"),appProps.getProperty("elasticsearch.indexname"));
runSPQRLQuery.setBulkUpload(bulkUpload);
// String recordId = "https://ariadne-infrastructure.eu/aocat/Collection/ADS/849B1C0F-4C5F-3D8C-9082-CA60DBB4F557";
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/0320AA03-BED9-3F2B-AF5D-E31EE50CAE97";
String recordId;
final ClassPathResource queryTemplateResource;
boolean testRecord = false;
if (testRecord) {
recordId = "https://ariadne-infrastructure.eu/aocat/Resource/0320AA03-BED9-3F2B-AF5D-E31EE50CAE97";
queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql");
}
else {
recordId = "https://ariadne-infrastructure.eu/aocat/Collection/ADS/849B1C0F-4C5F-3D8C-9082-CA60DBB4F557";
queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql");
}
String datasource = "ads";
String collectionId = "271";
List<String> recordIds = Arrays.asList(recordId);
// final ClassPathResource queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_collection_data_template.sparql");
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, false);
// runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId, true);
if (testRecord) {
runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId, false);
}
else {
runSPQRLQuery.executeMultipleQueryGraph(queryTemplate, recordIds, datasource, collectionId, true);
}
}
@Test