fix date parsing on es record creation

This commit is contained in:
Enrico Ottonello 2020-10-13 00:31:17 +02:00
parent 8f3722da13
commit 263c1beb7e
6 changed files with 21 additions and 4 deletions

View File

@ -57,6 +57,7 @@ public class BulkUpload {
try {
Object next = manager.next();
AriadneCatalogEntry ace = ((AriadneCatalogEntry) next);
// log.warn("ready to index: "+ace.toJson());
if (isCollection) {
ace.setResourceType("collection");
if (ace.getSpatial()==null) {
@ -138,6 +139,7 @@ public class BulkUpload {
esResponseCode = -3;
}
} catch (Exception e) {
e.printStackTrace();
log.error("Indexing "+e.getMessage());
return -1;
}

View File

@ -32,6 +32,7 @@ public class AriadneCatalogEntry {
private String originalId;
private List<AgentInfo> owner;
private String resourceType;
private String rdfType;
private List<AgentInfo> scientificResponsible;
private List<Spatial> spatial;
// private List<SpatialRegion> spatialRegion;
@ -381,4 +382,12 @@ public class AriadneCatalogEntry {
public void setAudience(String audience) {
this.audience = audience;
}
public String getRdfType() {
return rdfType;
}
public void setRdfType(String rdfType) {
this.rdfType = rdfType;
}
}

View File

@ -91,6 +91,7 @@ public class ResourceManager {
if (class_name.equals("Record") || class_name.equals("Collection")) {
class_name = "AriadneCatalogEntry";
}
}
}
if (entry == null) {

View File

@ -153,6 +153,7 @@ public class RunSPARQLQueryService {
Rio.write(resultsModel, rdfRecordWriter);
parser.setCollection(isCollection);
String bufferedRecord = recordWriter.toString();
// log.debug(bufferedRecord);
int size = parser.parse(bufferedRecord);
log.debug("json elements: "+size);
if (size==-1) {

View File

@ -23,8 +23,12 @@ public class ESUtils {
LocalDate parsedDate = LocalDate.parse(originalDate, originalRecordDateFormatter);
return parsedDate.format(elasticSearchDateFormatter);
} catch (Exception e1) {
LocalDate parsedDate = LocalDate.parse(originalDate, yearOnlyDateFormatter);
return parsedDate.format(yearOnlyDateFormatter);
try {
LocalDate parsedDate = LocalDate.parse(originalDate.substring(0, 10), elasticSearchDateFormatter);
return parsedDate.format(elasticSearchDateFormatter);
} catch (Exception e2) {
return "0000";
}
}
}

View File

@ -56,7 +56,7 @@ public class GraphDbReaderAndESIndexTest {
runSPQRLQuery.setBulkUpload(bulkUpload);
String recordId;
final ClassPathResource queryTemplateResource;
boolean testRecord = false;
boolean testRecord = true;
if (testRecord) {
recordId = "https://ariadne-infrastructure.eu/aocat/Resource/3037F979-F94F-380B-A6A6-3972ED10E61C";
queryTemplateResource = new ClassPathResource("eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql");