model classes according to new es mapping; creation and indexing of a record with geopoint data

This commit is contained in:
Enrico Ottonello 2021-06-15 23:34:59 +02:00
parent 06f20f7a8d
commit e91d82f32c
25 changed files with 738 additions and 897 deletions

View File

@ -12,13 +12,13 @@ import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;
@ -58,7 +58,7 @@ public class BulkUpload {
try {
Object next = manager.next();
AriadneCatalogEntry ace = ((AriadneCatalogEntry) next);
AriadnePlusEntry ace = ((AriadnePlusEntry) next);
if (isCollection) {
ace.setResourceType("collection");
if (ace.getSpatial()==null) {
@ -68,16 +68,26 @@ public class BulkUpload {
else {
ace.setResourceType("dataset");
if (ace.getSpatial()!=null) {
ace.getSpatial()
.stream()
.filter(s -> Objects.nonNull(s.getLat()) && Objects.nonNull(s.getLon()))
.forEach(s -> {
double lat = Double.parseDouble(s.getLat());
double lon = Double.parseDouble(s.getLon());
GeoPoint geopoint = new GeoPoint(lat, lon);
s.setGeopoint(geopoint);
});
// TODO update following check according to new model definition
if (ace.getSpatial().size()==2) {
Spatial uniqueSpatial = new Spatial();
boolean uniquePlaceNameFound = ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).count()==1;
boolean uniqueLocationFound = ace.getSpatial().stream().filter(s -> s.getLocation()!=null).count()==1;
boolean uniqueLocationFound = ace.getSpatial().stream().filter(s -> s.getGeopoint()!=null).count()==1;
if (uniquePlaceNameFound&&uniqueLocationFound) {
ace.getSpatial().stream().filter(s -> s.getPlaceName()!=null).forEach(s -> {
uniqueSpatial.setPlaceName(s.getPlaceName());
});
ace.getSpatial().stream().filter(s -> s.getLocation()!=null).forEach(s -> {
uniqueSpatial.setLocation(s.getLocation());
ace.getSpatial().stream().filter(s -> s.getGeopoint()!=null).forEach(s -> {
uniqueSpatial.setGeopoint(s.getGeopoint());
});
ace.getSpatial().clear();
ace.setSpatial(Arrays.asList(uniqueSpatial));
@ -98,9 +108,10 @@ public class BulkUpload {
ace.getSpatial().clear();
ace.setSpatial(dedupSpatials);
if (ace.getSpatial().size()>1) {
ace.getSpatial().removeIf(s -> (s.getPlaceName()!=null&&s.getPlaceName().equals("Name not provided")&&Objects.isNull(s.getLocation())));
}
// TODO update following check according to new model definition
// if (ace.getSpatial().size()>1) {
// ace.getSpatial().removeIf(s -> (s.getPlaceName()!=null&&s.getPlaceName().equals("Name not provided")&&Objects.isNull(s.getLocation())));
// }
}
else {
ace.setSpatial(Arrays.asList(new Spatial()));
@ -124,41 +135,19 @@ 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));
}
// AgentInfo testPublisher = new AgentInfo();
// testPublisher.setName("TEST");
// ace.getPublisher().add(testPublisher);
String[] splits = ace.getIdentifier().split("/");
if (ace.getAatSubjects() != null && ace.getDerivedSubject() != null) {
String aatSource = ace.getAatSubjects().get(0).getId();
ace.getDerivedSubject().forEach(d -> {
d.setSource(aatSource);
});
String [] aatSourceSplit = aatSource.split("/");
String aatSubjectId = aatSourceSplit[aatSourceSplit.length-1];
ace.getAatSubjects().forEach(s -> s.setId(aatSubjectId));
}
// if (ace.getAatSubjects() != null && ace.getDerivedSubject() != null) {
// String aatSource = ace.getAatSubjects().get(0).getId();
// ace.getDerivedSubject().forEach(d -> {
// d.setSource(aatSource);
// });
// String [] aatSourceSplit = aatSource.split("/");
// String aatSubjectId = aatSourceSplit[aatSourceSplit.length-1];
// ace.getAatSubjects().forEach(s -> s.setId(aatSubjectId));
// }
String idES = splits[splits.length-1];
request.add(new IndexRequest(elasticSearchIndexName).id(idES)
@ -209,9 +198,9 @@ public class BulkUpload {
}
String lat = "";
String lon = "";
if (!Objects.isNull(spatial.getLocation())) {
lat = Float.toString(spatial.getLocation().getLat());
lon = Float.toString(spatial.getLocation().getLon());
if (!Objects.isNull(spatial.getGeopoint())) {
lat = Double.toString(spatial.getGeopoint().getLat());
lon = Double.toString(spatial.getGeopoint().getLon());
}
String uniqueAttribute = (name) + (lat) + (lon);
return uniqueAttribute;

View File

@ -1,39 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.*;
public class AatSubject {
private String id;
private String label;
private String lang;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public AatSubject() {
}
public static AatSubject fromJson(String json){
return new Gson().fromJson(json, AatSubject.class);
}
}

View File

@ -1,15 +1,13 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.Map;
public class AgentInfo {
private String email = new String("");
private String name = new String("");
private String phone = new String("");
private String type = new String("");
private String homepage = new String("");
private String institution = new String("");
private String name = new String("");
private String agentIdentifier = new String("");
public AgentInfo() {
@ -31,45 +29,31 @@ public class AgentInfo {
this.name = name;
}
public String getPhone() {
return phone;
public String getHomepage() {
return homepage;
}
public void setPhone(String phone) {
this.phone = phone;
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public String getType() {
return type;
public String getInstitution() {
return institution;
}
public void setType(String type) {
this.type = type;
public void setInstitution(String institution) {
this.institution = institution;
}
public String getAgentIdentifier() {
return agentIdentifier;
}
public void setAgentIdentifier(String agentIdentifier) {
this.agentIdentifier = agentIdentifier;
}
public static AgentInfo fromJson(String json){
return new Gson().fromJson(json, AgentInfo.class);
}
public static AgentInfo fromRDFJson(JsonElement json){
AgentInfo pi = new AgentInfo();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()){
switch (entry.getKey()){
case "https://www.ariadne-infrastructure.eu/property/name" :
pi.setName(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/type":
pi.setType(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/email":
pi.setEmail(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/phone":
pi.setPhone(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
}
}
return pi;
}
}

View File

@ -1,56 +0,0 @@
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 = -1;
private String name;
private transient HashMap<String, Long> type =new HashMap<>();
public ArchaeologicalResourceType() {
type.put("Site/monument", 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));
type.put("Rock Art", new Long(19));
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
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){
return new Gson().fromJson(json, ArchaeologicalResourceType.class);
}
}

View File

@ -1,393 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import eu.dnetlib.ariadneplus.reader.utils.ESUtils;
import java.util.List;
public class AriadneCatalogEntry {
private List<AatSubject> aatSubjects;
private String accessPolicy;
private String accessRights;
private ArchaeologicalResourceType archaeologicalResourceType;
private List<AgentInfo> contributor;
private List<AgentInfo> creator;
private List<DerivedSubject> derivedSubject;
private String description;
private List <Distribution> distribution;
private List<AgentInfo> publisher;
private String title;
private List<ItemMetadataStructure> hasItemMetadataStructure;
private List<MetadataRecord> hasMetadataRecord;
private String identifier;
private List<String> isPartOf;
private transient String uniqueIsPartOf;
private String issued;
private List<String> keyword;
private String landingPage;
private String language;
private List<AgentInfo> legalResponsible;
private String modified;
private List<NativeSubject> nativeSubject;
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;
// private List<SpatialRegionPoint> spatialRegionPoint;
private List<AgentInfo> technicalResponsible;
private List<AriadneTemporal> temporal;
private String accrualPeriodicity;// = new String("");
private String audience;// IF PRESENT, MUST CONTAIN A VALUE !!
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("");
public List<AgentInfo> getContributor() {
return contributor;
}
public void setContributor(List<AgentInfo> contributor) {
this.contributor = contributor;
}
public List<AatSubject> getAatSubjects() {
return aatSubjects;
}
public void setAatSubjects(List<AatSubject> aatSubjects) {
this.aatSubjects = aatSubjects;
}
public String getAccessPolicy() {
return accessPolicy;
}
public void setAccessPolicy(String accessPolicy) {
this.accessPolicy = accessPolicy;
}
public String getAccessRights() {
return accessRights;
}
public void setAccessRights(String accessRights) {
this.accessRights = accessRights;
}
public ArchaeologicalResourceType getArchaeologicalResourceType() {
return archaeologicalResourceType;
}
public void setArchaeologicalResourceType(ArchaeologicalResourceType archaeologicalResourceType) {
this.archaeologicalResourceType = archaeologicalResourceType;
}
public String getContactPoint() {
return contactPoint;
}
public void setContactPoint(String contactPoint) {
this.contactPoint = contactPoint;
}
public List<AgentInfo> getCreator() {
return creator;
}
public void setCreator(List<AgentInfo> creator) {
this.creator = creator;
}
public List<DerivedSubject> getDerivedSubject() {
return derivedSubject;
}
public void setDerivedSubject(List<DerivedSubject> derivedSubject) {
this.derivedSubject = derivedSubject;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Distribution> getDistribution() {
return distribution;
}
public void setDistribution(List<Distribution> distribution) {
this.distribution = distribution;
}
public List<AgentInfo> getPublisher() {
return publisher;
}
public void setPublisher(List<AgentInfo> publisher) {
this.publisher = publisher;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getExtent() {
return extent;
}
public void setExtent(String extent) {
this.extent = extent;
}
public List<ItemMetadataStructure> getHasItemMetadataStructure() {
return hasItemMetadataStructure;
}
public void setHasItemMetadataStructure(List<ItemMetadataStructure> hasItemMetadataStructure) {
this.hasItemMetadataStructure = hasItemMetadataStructure;
}
public List<MetadataRecord> getHasMetadataRecord() {
return hasMetadataRecord;
}
public void setHasMetadataRecord(List<MetadataRecord> hasMetadataRecord) {
this.hasMetadataRecord = hasMetadataRecord;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public List<String> getIsPartOf() {
return isPartOf;
}
public void setIsPartOf(List<String> isPartOf) {
this.isPartOf = isPartOf;
}
public String getIssued() {
return issued;
}
public void setIssued(String issued) {
this.issued = ESUtils.getESFormatDate(issued);
}
public List<String> getKeyword() {
return keyword;
}
public void setKeyword(List<String> keyword) {
this.keyword = keyword;
}
public String getLandingPage() {
return landingPage;
}
public void setLandingPage(String landingPage) {
this.landingPage = landingPage;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
if (language!=null && language.equals("eng")) {
this.language = "en";
}
else {
this.language = language;
}
}
public List<AgentInfo> getLegalResponsible() {
return legalResponsible;
}
public void setLegalResponsible(List<AgentInfo> legalResponsible) {
this.legalResponsible = legalResponsible;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = ESUtils.getESFormatDate(modified);
}
public List<NativeSubject> getNativeSubject() {
return nativeSubject;
}
public void setNativeSubject(List<NativeSubject> nativeSubject) {
this.nativeSubject = nativeSubject;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(String originalId) {
this.originalId = originalId;
}
public List<AgentInfo> getOwner() {
return owner;
}
public void setOwner(List<AgentInfo> owner) {
this.owner = owner;
}
public String getPackageId() {
return packageId;
}
public void setPackageId(String packageId) {
this.packageId = packageId;
}
public String getPlaceName() {
return placeName;
}
public void setPlaceName(String placeName) {
this.placeName = placeName;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public String getProviderId() {
return providerId;
}
public void setProviderId(String providerId) {
this.providerId = providerId;
}
public String getRdfAbout() {
return rdfAbout;
}
public void setRdfAbout(String rdfAbout) {
this.rdfAbout = rdfAbout;
}
public String getResourceType() {
return resourceType;
}
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
public String getRights() {
return rights;
}
public void setRights(String rights) {
this.rights = rights;
}
public List<AgentInfo> getScientificResponsible() {
return scientificResponsible;
}
public void setScientificResponsible(List<AgentInfo> scientificResponsible) {
this.scientificResponsible = scientificResponsible;
}
public List<Spatial> getSpatial() {
return spatial;
}
public void setSpatial(List<Spatial> spatial) {
if (this.spatial==null) {
this.spatial = spatial;
}
else {
this.spatial.addAll(spatial);
}
}
public List<AgentInfo> getTechnicalResponsible() {
return technicalResponsible;
}
public void setTechnicalResponsible(List<AgentInfo> technicalResponsible) {
this.technicalResponsible = technicalResponsible;
}
public List<AriadneTemporal> getTemporal() {
return temporal;
}
public void setTemporal(List<AriadneTemporal> temporal) {
this.temporal = temporal;
}
public String getUniqueIsPartOf() {
return uniqueIsPartOf;
}
public void setUniqueIsPartOf(String uniqueIsPartOf) {
this.uniqueIsPartOf = uniqueIsPartOf;
}
public static AriadneCatalogEntry fromJson(String json){
return new Gson().fromJson(json, AriadneCatalogEntry.class);
}
public String toJson(){
return new Gson().toJson(this);
}
public void setAccrualPeriodicity(String accrualPeriodicity) {
this.accrualPeriodicity = accrualPeriodicity;
}
public void setAudience(String audience) {
this.audience = audience;
}
public String getRdfType() {
return rdfType;
}
public void setRdfType(String rdfType) {
this.rdfType = rdfType;
}
}

View File

@ -1,9 +1,6 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.Map;
public class AriadneGeoPoint {
private float lat;

View File

@ -0,0 +1,46 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class AriadneGeoShape {
private float lat;
private float lon;
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLon() {
return lon;
}
public void setLon(float lon) {
this.lon = lon;
}
public AriadneGeoShape() {
}
public static AriadneGeoShape fromJson (String json){
return new Gson().fromJson(json, AriadneGeoShape.class);
}
// public static AriadneGeoPoint fromRDFJson(JsonElement json){
// AriadneGeoPoint agp = new AriadneGeoPoint();
// for (Map.Entry<String, JsonElement> stringJsonElementEntry : json.getAsJsonObject().entrySet()) {
// switch (stringJsonElementEntry.getKey()){
// case "https://www.ariadne-infrastructure.eu/property/lat":
// agp.setLat(stringJsonElementEntry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
// break;
// case "https://www.ariadne-infrastructure.eu/property/lon":
// agp.setLon(stringJsonElementEntry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
// break;
// }
// }
// return agp;
// }
}

View File

@ -0,0 +1,296 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import eu.dnetlib.ariadneplus.reader.utils.ESUtils;
import java.util.List;
public class AriadnePlusEntry {
private List<DerivedSubject> derivedSubject;
private String accessPolicy;
private String accessRights;
private List<AriadneSubject> ariadneSubject;
private List<AgentInfo> contributor;
private List<AgentInfo> creator;
private Description description;
private String extent;
private String identifier;
private List<String> isPartOf;
private String issued;
private String landingPage;
private String language;
private String modified;
private List<NativeSubject> nativeSubject;
private String originalId;
private List<AgentInfo> owner;
private List<AgentInfo> publisher;
private AriadneURI is_about;
private String resourceType;
private AriadneURI has_type;
private List<AgentInfo> responsible;
private List<Spatial> spatial;
private List<Temporal> temporal;
private String title;
private NativePeriod nativePeriod;
private String wasCreated;
private DigitalImage digitalImage;
private transient String uniqueIsPartOf;
public List<AgentInfo> getContributor() {
return contributor;
}
public void setContributor(List<AgentInfo> contributor) {
this.contributor = contributor;
}
public String getAccessPolicy() {
return accessPolicy;
}
public void setAccessPolicy(String accessPolicy) {
this.accessPolicy = accessPolicy;
}
public String getAccessRights() {
return accessRights;
}
public void setAccessRights(String accessRights) {
this.accessRights = accessRights;
}
public List<AgentInfo> getCreator() {
return creator;
}
public void setCreator(List<AgentInfo> creator) {
this.creator = creator;
}
public List<DerivedSubject> getDerivedSubject() {
return derivedSubject;
}
public void setDerivedSubject(List<DerivedSubject> derivedSubject) {
this.derivedSubject = derivedSubject;
}
public List<AgentInfo> getPublisher() {
return publisher;
}
public void setPublisher(List<AgentInfo> publisher) {
this.publisher = publisher;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getExtent() {
return extent;
}
public void setExtent(String extent) {
this.extent = extent;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public List<String> getIsPartOf() {
return isPartOf;
}
public void setIsPartOf(List<String> isPartOf) {
this.isPartOf = isPartOf;
}
public String getIssued() {
return issued;
}
public void setIssued(String issued) {
this.issued = ESUtils.getESFormatDate(issued);
}
public String getLandingPage() {
return landingPage;
}
public void setLandingPage(String landingPage) {
this.landingPage = landingPage;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
if (language!=null && language.equals("eng")) {
this.language = "en";
}
else {
this.language = language;
}
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = ESUtils.getESFormatDate(modified);
}
public List<NativeSubject> getNativeSubject() {
return nativeSubject;
}
public void setNativeSubject(List<NativeSubject> nativeSubject) {
this.nativeSubject = nativeSubject;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(String originalId) {
this.originalId = originalId;
}
public List<AgentInfo> getOwner() {
return owner;
}
public void setOwner(List<AgentInfo> owner) {
this.owner = owner;
}
public String getResourceType() {
return resourceType;
}
public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
public List<Spatial> getSpatial() {
return spatial;
}
public void setSpatial(List<Spatial> spatial) {
if (this.spatial==null) {
this.spatial = spatial;
}
else {
this.spatial.addAll(spatial);
}
}
public List<Temporal> getTemporal() {
return temporal;
}
public void setTemporal(List<Temporal> temporal) {
this.temporal = temporal;
}
public void setDescription(Description description) {
this.description = description;
}
public void setIs_about(AriadneURI is_about) {
this.is_about = is_about;
}
public void setHas_type(AriadneURI has_type) {
this.has_type = has_type;
}
public void setResponsible(List<AgentInfo> responsible) {
this.responsible = responsible;
}
public void setWasCreated(String wasCreated) {
this.wasCreated = wasCreated;
}
public String getUniqueIsPartOf() {
return uniqueIsPartOf;
}
public void setUniqueIsPartOf(String uniqueIsPartOf) {
this.uniqueIsPartOf = uniqueIsPartOf;
}
public static AriadnePlusEntry fromJson(String json){
return new Gson().fromJson(json, AriadnePlusEntry.class);
}
public Description getDescription() {
return description;
}
public AriadneURI getIs_about() {
return is_about;
}
public AriadneURI getHas_type() {
return has_type;
}
public List<AgentInfo> getResponsible() {
return responsible;
}
public String getWasCreated() {
return wasCreated;
}
public List<AriadneSubject> getAriadneSubject() {
return ariadneSubject;
}
public void setAriadneSubject(List<AriadneSubject> ariadneSubject) {
this.ariadneSubject = ariadneSubject;
}
public NativePeriod getNativePeriod() {
return nativePeriod;
}
public void setNativePeriod(NativePeriod nativePeriod) {
this.nativePeriod = nativePeriod;
}
public DigitalImage getDigitalImage() {
return digitalImage;
}
public void setDigitalImage(DigitalImage digitalImage) {
this.digitalImage = digitalImage;
}
public String toJson(){
return new Gson().toJson(this);
}
public void setDescription(String description) {
Description descr = new Description();
descr.setText(description);
this.description = descr;
}
}

View File

@ -0,0 +1,36 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import java.util.HashMap;
public class AriadneSubject {
private String prefLabel;
public String getPrefLabel() {
return prefLabel;
}
public void setPrefLabel(String prefLabel) {
this.prefLabel = prefLabel;
}
private transient HashMap<String, Long> typeValues =new HashMap<>();
public AriadneSubject() {
typeValues.put("Site/monument", new Long(10));
typeValues.put("Fieldwork", new Long(11));
typeValues.put("Fieldwork report", new Long(12));
typeValues.put("Scientific analysis", new Long(13));
typeValues.put("Date", new Long(14));
typeValues.put("Artefact", new Long(15));
typeValues.put("Fieldwork archive", new Long(16));
typeValues.put("Inscription", new Long(17));
typeValues.put("Burial", new Long(18));
typeValues.put("Rock Art", new Long(19));
}
public static AriadneSubject fromJson(String json){
return new Gson().fromJson(json, AriadneSubject.class);
}
}

View File

@ -1,84 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.Map;
public class AriadneTemporal {
private String from;
private String periodName;
private String until;
private String uri;
private transient String matchingPeriodOName;
public static AriadneTemporal fromRDFJson(JsonElement json) {
AriadneTemporal at = new AriadneTemporal();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet()){
switch (entry.getKey()){
case "https://www.ariadne-infrastructure.eu/property/from" :
at.setFrom(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/periodName":
at.setPeriodName(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/until":
at.setUntil(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
case "https://www.ariadne-infrastructure.eu/property/uri":
at.setUri(entry.getValue().getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString());
break;
}
}
return at;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getPeriodName() {
return periodName;
}
public void setPeriodName(String periodName) {
this.periodName = periodName;
}
public String getUntil() {
return until;
}
public void setUntil(String until) {
this.until = until;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public AriadneTemporal() {
}
public static AriadneTemporal fromJson(String json){
return new Gson().fromJson(json, AriadneTemporal.class);
}
public String getMatchingPeriodOName() {
return matchingPeriodOName;
}
public void setMatchingPeriodOName(String matchingPeriodOName) {
this.matchingPeriodOName = matchingPeriodOName;
}
}

View File

@ -0,0 +1,31 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class AriadneURI {
private String label;
private String uri;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public AriadneURI() {
}
public static AriadneURI fromJson(String json){
return new Gson().fromJson(json, AriadneURI.class);
}
}

View File

@ -4,7 +4,9 @@ import com.google.gson.Gson;
public class DerivedSubject {
private String prefLabel;
private String source;
private String source;
private String id;
private String lang;
public String getPrefLabel() {
return prefLabel;
@ -22,6 +24,22 @@ public class DerivedSubject {
this.source = source;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public DerivedSubject() {
}

View File

@ -0,0 +1,31 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class Description {
private String text;
private String language;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public Description() {
}
public static Description fromJson(String json){
return new Gson().fromJson(json, Description.class);
}
}

View File

@ -1,31 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class Dex {
private String characterSet = new String("");
private String description = new String("");
public String getCharacterSet() {
return characterSet;
}
public void setCharacterSet(String characterSet) {
this.characterSet = characterSet;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Dex() {
}
public static Dex fromJson(String json){
return new Gson().fromJson(json,Dex.class);
}
}

View File

@ -0,0 +1,41 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class DigitalImage {
private String ariadneUri;
private String primary;
private String providerUri;
public String getAriadneUri() {
return ariadneUri;
}
public void setAriadneUri(String ariadneUri) {
this.ariadneUri = ariadneUri;
}
public String getPrimary() {
return primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
public String getProviderUri() {
return providerUri;
}
public void setProviderUri(String providerUri) {
this.providerUri = providerUri;
}
public DigitalImage() {
}
public static DigitalImage fromJson(String json){
return new Gson().fromJson(json, DigitalImage.class);
}
}

View File

@ -1,69 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import java.util.List;
public class Distribution {
private String accessURL = new String("");
private String description = new String("");
private String issued = new String("9999");
private String modified = new String("9999");
private List<AgentInfo> publisher;
private String title = new String("");
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<AgentInfo> getPublisher() {
return publisher;
}
public void setPublisher(List<AgentInfo> publisher) {
this.publisher = publisher;
}
public String getAccessURL() {
return accessURL;
}
public void setAccessURL(String accessURL) {
this.accessURL = accessURL;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIssued() {
return issued;
}
public void setIssued(String issued) {
this.issued = issued;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
public Distribution() {
}
public static Distribution fromJson(String json){
return new Gson().fromJson(json,Distribution.class);
}
}

View File

@ -1,22 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class ItemMetadataStructure {
private String characterSet = new String("");
public String getCharacterSet() {
return characterSet;
}
public void setCharacterSet(String characterSet) {
this.characterSet = characterSet;
}
public ItemMetadataStructure() {
}
private static ItemMetadataStructure fromJson(String json){
return new Gson().fromJson(json, ItemMetadataStructure.class);
}
}

View File

@ -1,33 +0,0 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import java.util.List;
public class MetadataRecord {
private List<Dex> conformsTo;
private String xmlDoc = new String("");
public List<Dex> getConformsTo() {
return conformsTo;
}
public void setConformsTo(List<Dex> conformsTo) {
this.conformsTo = conformsTo;
}
public String getXmlDoc() {
return xmlDoc;
}
public void setXmlDoc(String xmlDoc) {
this.xmlDoc = xmlDoc;
}
public MetadataRecord() {
}
public static MetadataRecord fromJson(String json){
return new Gson().fromJson(json, MetadataRecord.class);
}
}

View File

@ -0,0 +1,41 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
public class NativePeriod {
private String from;
private String periodName;
private String until;
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getPeriodName() {
return periodName;
}
public void setPeriodName(String periodName) {
this.periodName = periodName;
}
public String getUntil() {
return until;
}
public void setUntil(String until) {
this.until = until;
}
public NativePeriod() {
}
public static NativePeriod fromJson(String json){
return new Gson().fromJson(json, NativePeriod.class);
}
}

View File

@ -9,8 +9,6 @@ public class NativeSubject {
private String prefLabel;
private String rdfAbout;
public String getPrefLabel() {
return prefLabel;
}

View File

@ -1,24 +1,25 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.Map;
import org.apache.lucene.spatial3d.geom.GeoShape;
import org.elasticsearch.common.geo.GeoPoint;
public class Spatial {
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 AriadneGeoPoint location;
private String placeName;
private String lat;
private String lon;
private String postcode = new String("");
private String address;
private GeoPoint geopoint;
private GeoShape boundingbox;
private GeoShape polygon;
private String spatialPrecision;
private transient String coordinatePrecision;
private transient String boundingBoxMaxLat;
private transient String boundingBoxMaxLon;
private transient String boundingBoxMinLat;
private transient String boundingBoxMinLon;
private transient String lat;
private transient String lon;
public String getAddress() {
return address;
@ -60,30 +61,6 @@ public class Spatial {
this.boundingBoxMinLon = boundingBoxMinLon;
}
public String getCoordinateSystem() {
return coordinateSystem;
}
public void setCoordinateSystem(String coordinateSystem) {
this.coordinateSystem = coordinateSystem;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public AriadneGeoPoint getLocation() {
return location;
}
public void setLocation(AriadneGeoPoint location) {
this.location = location;
}
public String getPlaceName() {
return placeName;
}
@ -92,22 +69,60 @@ public class Spatial {
this.placeName = placeName;
}
public GeoShape getBoundingbox() {
return boundingbox;
}
public void setBoundingbox(GeoShape boundingbox) {
this.boundingbox = boundingbox;
}
public GeoShape getPolygon() {
return polygon;
}
public void setPolygon(GeoShape polygon) {
this.polygon = polygon;
}
public String getSpatialPrecision() {
return spatialPrecision;
}
public void setSpatialPrecision(String spatialPrecision) {
this.spatialPrecision = spatialPrecision;
}
public String getCoordinatePrecision() {
return coordinatePrecision;
}
public void setCoordinatePrecision(String coordinatePrecision) {
this.coordinatePrecision = coordinatePrecision;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
if (this.getLocation()==null) {
this.setLocation(new AriadneGeoPoint());
}
if (lat!=null) {
this.getLocation().setLat(Float.parseFloat(lat));
}
this.lat = lat;
}
public String getLon() {
return lon;
}
public void setLon(String lon) {
if (this.getLocation()==null) {
this.setLocation(new AriadneGeoPoint());
}
if (lon!=null) {
this.getLocation().setLon(Float.parseFloat(lon));
}
this.lon = lon;
}
public GeoPoint getGeopoint() {
return geopoint;
}
public void setGeopoint(GeoPoint geopoint) {
this.geopoint = geopoint;
}
public Spatial() {

View File

@ -0,0 +1,61 @@
package eu.dnetlib.ariadneplus.elasticsearch.model;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.util.Map;
public class Temporal {
private String from;
private String periodName;
private String until;
private String uri;
private transient String matchingPeriodOName;
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getPeriodName() {
return periodName;
}
public void setPeriodName(String periodName) {
this.periodName = periodName;
}
public String getUntil() {
return until;
}
public void setUntil(String until) {
this.until = until;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public Temporal() {
}
public static Temporal fromJson(String json){
return new Gson().fromJson(json, Temporal.class);
}
public String getMatchingPeriodOName() {
return matchingPeriodOName;
}
public void setMatchingPeriodOName(String matchingPeriodOName) {
this.matchingPeriodOName = matchingPeriodOName;
}
}

View File

@ -90,7 +90,7 @@ public class ResourceManager {
class_name = (String)tmp.get("value");
//TODO: Use rdf:type instead of these values that are added statically by the CONSTRUCT queries (that need to be changed as well to include the rdf:type
if (class_name.equals("Record") || class_name.equals("Collection")) {
class_name = "AriadneCatalogEntry";
class_name = "AriadnePlusEntry";
}
}

View File

@ -18,7 +18,7 @@ general.classpath=eu.dnetlib.ariadneplus.elasticsearch.model.
type.path=https://www.ariadne-infrastructure.eu/property/rdfType
exclude.predicates=["https://www.ariadne-infrastructure.eu/property/resourceType", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "https://www.ariadne-infrastructure.eu/property/rdfType"]
class.map.specifications={\
"AriadneTemporal": {\
"Temporal": {\
"class_type": "prototype",\
"mappings": {\
"https://www.ariadne-infrastructure.eu/property/from": {\
@ -121,16 +121,11 @@ class.map.specifications={\
"element_type": "java.lang.String"\
}}\
},\
"ArchaeologicalResourceType": {\
"class_type": "unique",\
"AriadneSubject": {\
"class_type": "prototype",\
"mappings": {\
"https://www.ariadne-infrastructure.eu/property/id": {\
"class_field": "Id",\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/name": {\
"class_field": "Name",\
"class_field": "PrefLabel",\
"substring": "no",\
"element_type": "java.lang.String"\
}\
@ -154,8 +149,13 @@ class.map.specifications={\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/phone": {\
"class_field": "Phone",\
"https://www.ariadne-infrastructure.eu/property/homepage": {\
"class_field": "Homepage",\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/institution": {\
"class_field": "Institution",\
"substring": "no",\
"element_type": "java.lang.String"\
}\
@ -188,19 +188,14 @@ class.map.specifications={\
"class_field": "Source",\
"substring": "yes",\
"element_type": "java.lang.String"\
}\
}\
},\
"AatSubject": {\
"class_type": "prototype",\
"mappings": {\
"https://www.ariadne-infrastructure.eu/property/id": {\
"class_field": "Id",\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/label": {\
"class_field": "Label",\
"class_field": "PrefLabel",\
"substring": "yes",\
"element_type": "java.lang.String"\
},\
@ -211,7 +206,7 @@ class.map.specifications={\
}\
}\
},\
"AriadneCatalogEntry": {\
"AriadnePlusEntry": {\
"class_type": "unique",\
"mappings": {\
"https://www.ariadne-infrastructure.eu/property/accessPolicy": {\
@ -230,8 +225,8 @@ class.map.specifications={\
"substring": "no"\
},\
"https://www.ariadne-infrastructure.eu/property/archeologicalResourceType": {\
"class_field": "ArchaeologicalResourceType",\
"external_reference": "ArchaeologicalResourceType",\
"class_field": "AriadneSubject",\
"external_reference": "AriadneSubject",\
"substring": "no"\
},\
"https://www.ariadne-infrastructure.eu/property/issued": {\
@ -259,11 +254,6 @@ class.map.specifications={\
"substring": "no",\
"external_reference": "DerivedSubject"\
},\
"https://www.ariadne-infrastructure.eu/property/aatSubjects": {\
"class_field": "AatSubjects",\
"substring": "no",\
"external_reference": "AatSubject"\
},\
"https://www.ariadne-infrastructure.eu/property/spatialRegion": {\
"class_field": "Spatial",\
"substring": "no",\
@ -284,11 +274,6 @@ class.map.specifications={\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/placeName": {\
"class_field": "PlaceName",\
"substring": "no",\
"element_type": "java.lang.String"\
},\
"https://www.ariadne-infrastructure.eu/property/title": {\
"class_field": "Title",\
"substring": "no",\
@ -315,7 +300,7 @@ class.map.specifications={\
"external_reference": "AgentInfo"\
},\
"https://www.ariadne-infrastructure.eu/property/legalResponsible": {\
"class_field": "LegalResponsible",\
"class_field": "Responsible",\
"substring": "no",\
"external_reference": "AgentInfo"\
},\
@ -332,7 +317,7 @@ class.map.specifications={\
"https://www.ariadne-infrastructure.eu/property/temporal": {\
"class_field": "Temporal",\
"substring": "no",\
"external_reference": "AriadneTemporal"\
"external_reference": "Temporal"\
},\
"https://www.ariadne-infrastructure.eu/property/language": {\
"class_field": "Language",\

View File

@ -72,7 +72,6 @@ public class GraphDbReaderAndESIndexTest {
}
@Test
@Ignore
public void uploadADSRecordTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/34E3811A-0BAD-3832-B3A0-3139E8A0285C";
@ -192,7 +191,7 @@ public class GraphDbReaderAndESIndexTest {
}
@Test
// @Ignore
@Ignore
public void uploadROADTest() throws Exception {
boolean isRecord = true;
String recordId = "https://ariadne-infrastructure.eu/aocat/Resource/FC70B370-C489-31C5-B1D4-339CFD28CF2B";