53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
package eu.dnetlib.ariadneplus.elasticsearch.model;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.JsonElement;
|
|
|
|
import java.util.Map;
|
|
|
|
public class ArcheologicalResourceType {
|
|
private String id;
|
|
private String name;
|
|
|
|
public ArcheologicalResourceType() {
|
|
}
|
|
|
|
public static ArcheologicalResourceType fromRDFJson(JsonElement json) {
|
|
ArcheologicalResourceType art = new ArcheologicalResourceType();
|
|
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()){
|
|
switch (entry.getKey()){
|
|
case "http://www.myprefix/id" :
|
|
art.setId(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
|
|
break;
|
|
case "http://www.myprefix/name":
|
|
String tmp = entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString();
|
|
art.setName(tmp);
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
return art;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public static ArcheologicalResourceType fromJson(String json){
|
|
return new Gson().fromJson(json, ArcheologicalResourceType.class);
|
|
}
|
|
}
|