86 lines
2.1 KiB
Java
86 lines
2.1 KiB
Java
package eu.eudat.models.data.externaldataset;
|
|
|
|
import eu.eudat.data.entities.ExternalDataset;
|
|
import eu.eudat.models.DataModel;
|
|
|
|
import java.util.Date;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* Created by ikalyvas on 9/3/2018.
|
|
*/
|
|
public class ExternalDatasetModel implements DataModel<ExternalDataset, ExternalDatasetModel> {
|
|
public UUID id;
|
|
public String label;
|
|
public String abbreviation;
|
|
public Date created;
|
|
public Date modified;
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public String getAbbreviation() {
|
|
return abbreviation;
|
|
}
|
|
|
|
public void setAbbreviation(String abbreviation) {
|
|
this.abbreviation = abbreviation;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
@Override
|
|
public ExternalDatasetModel fromDataModel(ExternalDataset entity) {
|
|
this.id = entity.getId();
|
|
this.label = entity.getLabel();
|
|
this.abbreviation = entity.getAbbreviation();
|
|
this.created = entity.getCreated();
|
|
this.modified = new Date();
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ExternalDataset toDataModel() throws Exception {
|
|
ExternalDataset externalDataset = new ExternalDataset();
|
|
externalDataset.setAbbreviation(this.abbreviation);
|
|
externalDataset.setCreated(this.created != null ? this.created : new Date());
|
|
externalDataset.setModified(new Date());
|
|
externalDataset.setId(this.id != null ? this.id : UUID.randomUUID());
|
|
externalDataset.setLabel(this.label);
|
|
externalDataset.setReference("dmpdata/" + externalDataset.getId());
|
|
return externalDataset;
|
|
}
|
|
|
|
@Override
|
|
public String getHint() {
|
|
return null;
|
|
}
|
|
}
|