archeologicalResourceType.id mapped

This commit is contained in:
Enrico Ottonello 2020-07-08 11:54:32 +02:00
parent e689623994
commit 364d25f2b7
1 changed files with 23 additions and 20 deletions

View File

@ -3,32 +3,26 @@ package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.HashMap;
import java.util.Map;
public class ArchaeologicalResourceType {
private long id = 100000;
private long id = -1;
private String name;
public ArchaeologicalResourceType() {
}
private transient HashMap<String, Long> type =new HashMap<>();
// public static ArchaeologicalResourceType fromRDFJson(JsonElement json) {
// ArchaeologicalResourceType art = new ArchaeologicalResourceType();
// for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()){
// switch (entry.getKey()){
// case "https://www.ariadne-infrastructure.eu/property/id" :
// art.setId(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
// break;
// case "https://www.ariadne-infrastructure.eu/property/name":
// String tmp = entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString();
// art.setName(tmp);
// break;
//
// }
// }
//
// return art;
// }
public ArchaeologicalResourceType() {
type.put("Scientific analysis", new Long(10));
type.put("Fieldwork", new Long(11));
type.put("Fieldwork report", new Long(12));
type.put("Scientific analysis", new Long(13));
type.put("Date", new Long(14));
type.put("Artefact", new Long(15));
type.put("Fieldwork archive", new Long(16));
type.put("Inscription", new Long(17));
type.put("Burial", new Long(18));
}
public long getId() {
return id;
@ -44,6 +38,15 @@ public class ArchaeologicalResourceType {
public void setName(String name) {
this.name = name;
if (this.name==null) {
setId(-1);
}
if (type.containsKey(this.name)) {
setId(type.get(name).longValue());
}
else {
setId(-2);
}
}
public static ArchaeologicalResourceType fromJson(String json){