Fix issue with DMP disappearing when editing Datasets
This commit is contained in:
parent
6ccdeddf65
commit
ce8b49deb0
|
@ -5,6 +5,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -287,30 +288,43 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
@Override
|
||||
public Dmp fromElasticEntity(Map<String, Object> fields) {
|
||||
this.id = UUID.fromString((String) fields.get(MapKey.ID.getName()));
|
||||
this.label = (String) fields.get(MapKey.LABEL.getName());
|
||||
this.description = (String) fields.get(MapKey.DESCRIPTION.getName());
|
||||
if (fields.get(MapKey.GROUPID.getName()) != null) {
|
||||
this.groupId = UUID.fromString((String) fields.get(MapKey.GROUPID.getName()));
|
||||
}
|
||||
this.status = Short.valueOf(fields.get(MapKey.STATUS.getName()).toString());
|
||||
if (fields.get(MapKey.TEMPLATES.getName()) != null) {
|
||||
this.templates = ((List<HashMap<String, Object>>) fields.get(MapKey.TEMPLATES.getName())).stream().map(hashMap -> new DatasetTempalate().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||
}
|
||||
if (fields.get(MapKey.COLLABORATORS.getName()) != null) {
|
||||
this.collaborators = ((List<HashMap<String, Object>>) fields.get(MapKey.COLLABORATORS.getName())).stream().map(map -> new Collaborator().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
if (fields.get(MapKey.ORGANIZATIONS.getName()) != null) {
|
||||
this.organizations = ((List<HashMap<String, Object>>) fields.get(MapKey.ORGANIZATIONS.getName())).stream().map(map -> new Organization().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
this.lastVersion = (Boolean) fields.get(MapKey.LASTVERSION.getName());
|
||||
this.lastPublicVersion = (Boolean) fields.get(MapKey.LASTPUBLICVERSION.getName());
|
||||
this.isPublic = (Boolean) fields.get(MapKey.ISPUBLIC.getName());
|
||||
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
||||
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
||||
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
||||
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
||||
if (fields.size() > 1) {
|
||||
this.label = (String) fields.get(MapKey.LABEL.getName());
|
||||
this.description = (String) fields.get(MapKey.DESCRIPTION.getName());
|
||||
if (fields.get(MapKey.GROUPID.getName()) != null) {
|
||||
this.groupId = UUID.fromString((String) fields.get(MapKey.GROUPID.getName()));
|
||||
}
|
||||
this.status = Short.valueOf(fields.get(MapKey.STATUS.getName()).toString());
|
||||
if (fields.get(MapKey.TEMPLATES.getName()) != null) {
|
||||
this.templates = ((List<HashMap<String, Object>>) fields.get(MapKey.TEMPLATES.getName())).stream().map(hashMap -> new DatasetTempalate().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||
}
|
||||
if (fields.get(MapKey.COLLABORATORS.getName()) != null) {
|
||||
this.collaborators = ((List<HashMap<String, Object>>) fields.get(MapKey.COLLABORATORS.getName())).stream().map(map -> new Collaborator().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
if (fields.get(MapKey.ORGANIZATIONS.getName()) != null) {
|
||||
this.organizations = ((List<HashMap<String, Object>>) fields.get(MapKey.ORGANIZATIONS.getName())).stream().map(map -> new Organization().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
this.lastVersion = (Boolean) fields.get(MapKey.LASTVERSION.getName());
|
||||
this.lastPublicVersion = (Boolean) fields.get(MapKey.LASTPUBLICVERSION.getName());
|
||||
this.isPublic = (Boolean) fields.get(MapKey.ISPUBLIC.getName());
|
||||
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
||||
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
||||
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
||||
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
||||
}
|
||||
this.created = Date.from(Instant.parse(fields.get(MapKey.CREATED.getName()).toString()));
|
||||
this.modified = Date.from(Instant.parse(fields.get(MapKey.MODIFIED.getName()).toString()));
|
||||
if (fields.get(MapKey.FINALIZEDAT.getName()) != null) {
|
||||
this.finalizedAt = Date.from(Instant.parse(fields.get(MapKey.FINALIZEDAT.getName()).toString()));
|
||||
}
|
||||
if (fields.get(MapKey.PUBLISHEDAT.getName()) != null) {
|
||||
this.publishedAt = Date.from(Instant.parse(fields.get(MapKey.PUBLISHEDAT.getName()).toString()));
|
||||
}
|
||||
if (fields.get(MapKey.DOI.getName()) != null) {
|
||||
this.doi = fields.get(MapKey.DOI.getName()).toString();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue