2018-06-27 12:29:21 +02:00
|
|
|
package eu.eudat.models.data.externaldataset;
|
2018-01-17 13:03:51 +01:00
|
|
|
|
2023-10-18 12:04:53 +02:00
|
|
|
import eu.eudat.data.old.ExternalDataset;
|
2018-01-17 13:03:51 +01:00
|
|
|
import eu.eudat.models.DataModel;
|
2023-11-28 11:54:08 +01:00
|
|
|
import eu.eudat.model.publicapi.datasetwizard.ExternalDatasetType;
|
2018-01-17 13:03:51 +01:00
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public class ExternalDatasetListingModel implements DataModel<ExternalDataset, ExternalDatasetListingModel> {
|
2018-01-17 13:03:51 +01:00
|
|
|
|
|
|
|
private UUID id;
|
2019-11-19 10:01:02 +01:00
|
|
|
private String name;
|
2018-01-17 13:03:51 +01:00
|
|
|
private String abbreviation;
|
|
|
|
private String reference;
|
|
|
|
private Date created;
|
|
|
|
private Date modified;
|
2018-05-28 11:50:42 +02:00
|
|
|
private String info;
|
|
|
|
private ExternalDatasetType type;
|
2019-11-19 10:01:02 +01:00
|
|
|
private String pid;
|
2023-05-17 12:45:12 +02:00
|
|
|
private String pidTypeField;
|
2019-11-19 10:01:02 +01:00
|
|
|
private String uri;
|
|
|
|
private String tag; // Api fetching the data
|
|
|
|
private String source; // Actual harvested source
|
2018-01-17 13:03:51 +01:00
|
|
|
|
|
|
|
public UUID getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2019-11-19 10:01:02 +01:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
2018-01-17 13:03:51 +01:00
|
|
|
}
|
2019-11-19 10:01:02 +01:00
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
2018-01-17 13:03:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getAbbreviation() {
|
|
|
|
return abbreviation;
|
|
|
|
}
|
|
|
|
public void setAbbreviation(String abbreviation) {
|
|
|
|
this.abbreviation = abbreviation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getReference() {
|
|
|
|
return reference;
|
|
|
|
}
|
|
|
|
public void setReference(String reference) {
|
|
|
|
this.reference = reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Date getModified() {
|
|
|
|
return modified;
|
|
|
|
}
|
|
|
|
public void setModified(Date modified) {
|
|
|
|
this.modified = modified;
|
|
|
|
}
|
|
|
|
|
2018-05-28 11:50:42 +02:00
|
|
|
public Integer getType() {
|
|
|
|
return type != null ? type.getValue() : null;
|
|
|
|
}
|
|
|
|
public void setType(Integer type) {
|
|
|
|
this.type = ExternalDatasetType.fromInteger(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getInfo() {
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
public void setInfo(String info) {
|
|
|
|
this.info = info;
|
|
|
|
}
|
|
|
|
|
2019-11-19 10:01:02 +01:00
|
|
|
public String getPid() {
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
public void setPid(String pid) {
|
|
|
|
this.pid = pid;
|
|
|
|
}
|
|
|
|
|
2023-05-17 12:45:12 +02:00
|
|
|
public String getPidTypeField() {
|
|
|
|
return pidTypeField;
|
|
|
|
}
|
|
|
|
public void setPidTypeField(String pidTypeField) {
|
|
|
|
this.pidTypeField = pidTypeField;
|
|
|
|
}
|
|
|
|
|
2019-11-19 10:01:02 +01:00
|
|
|
public String getUri() {
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
public void setUri(String uri) {
|
|
|
|
this.uri = uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTag() {
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
public void setTag(String tag) {
|
|
|
|
this.tag = tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSource() {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
public void setSource(String source) {
|
|
|
|
this.source = source;
|
|
|
|
}
|
|
|
|
|
2018-01-17 13:03:51 +01:00
|
|
|
@Override
|
2018-02-16 11:34:02 +01:00
|
|
|
public ExternalDatasetListingModel fromDataModel(ExternalDataset entity) {
|
2018-01-17 13:03:51 +01:00
|
|
|
this.id = entity.getId();
|
|
|
|
this.abbreviation = entity.getAbbreviation();
|
2019-11-19 10:01:02 +01:00
|
|
|
this.name = entity.getLabel();
|
2018-01-17 13:03:51 +01:00
|
|
|
this.modified = entity.getModified();
|
|
|
|
this.created = entity.getCreated();
|
|
|
|
this.reference = entity.getReference();
|
2019-11-19 10:01:02 +01:00
|
|
|
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
|
|
|
if (source1.equals("dmp")) {
|
|
|
|
this.source = "Internal";
|
|
|
|
} else {
|
|
|
|
this.source = source1;
|
|
|
|
}
|
2018-02-16 08:45:18 +01:00
|
|
|
return this;
|
2018-01-17 13:03:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ExternalDataset toDataModel() throws Exception {
|
|
|
|
ExternalDataset externalDataset = new ExternalDataset();
|
|
|
|
externalDataset.setAbbreviation(this.abbreviation);
|
|
|
|
externalDataset.setCreated(this.created != null ? this.created : new Date());
|
2019-11-19 10:01:02 +01:00
|
|
|
externalDataset.setLabel(this.name);
|
2018-01-17 13:03:51 +01:00
|
|
|
externalDataset.setId(this.id);
|
|
|
|
externalDataset.setModified(this.modified);
|
2019-11-19 10:01:02 +01:00
|
|
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
|
|
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
|
|
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
|
|
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
|
|
|
externalDataset.setReference(this.reference);
|
|
|
|
} else {
|
2019-11-21 17:25:43 +01:00
|
|
|
externalDataset.setReference(this.source.toLowerCase() + ":" + this.reference);
|
2019-11-19 10:01:02 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-13 16:10:21 +01:00
|
|
|
if (externalDataset.getReference() == null) {
|
|
|
|
externalDataset.setReference(this.pid);
|
|
|
|
}
|
2019-11-19 10:01:02 +01:00
|
|
|
externalDataset.setModified(new Date());
|
2018-01-17 13:03:51 +01:00
|
|
|
return externalDataset;
|
|
|
|
}
|
2018-01-19 10:31:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getHint() {
|
|
|
|
return null;
|
|
|
|
}
|
2018-01-17 13:03:51 +01:00
|
|
|
}
|