argos/dmp-backend/web/src/main/java/eu/eudat/models/data/registries/RegistryModel.java

104 lines
2.5 KiB
Java

package eu.eudat.models.data.registries;
import eu.eudat.data.entities.Registry;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.models.DataModel;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
* Created by ikalyvas on 9/3/2018.
*/
public class RegistryModel implements DataModel<Registry, RegistryModel> {
private UUID id;
private String label;
private String abbreviation;
private String uri;
private Date created;
private Date modified;
private String tag;
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 String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
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;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
@Override
public RegistryModel fromDataModel(Registry entity) {
this.id = entity.getId();
this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated();
this.label = entity.getLabel();
this.modified = entity.getModified();
this.uri = entity.getUri();
this.tag = "Internal";
return this;
}
@Override
public Registry toDataModel() throws Exception {
Registry registry = new Registry();
registry.setAbbreviation(this.abbreviation);
registry.setCreated(this.created != null ? this.created : new Date());
registry.setId(this.id != null ? this.id : UUID.randomUUID());
registry.setLabel(this.label);
registry.setUri(this.uri);
registry.setModified(new Date());
registry.setReference("dmpdata/" + registry.getId());
registry.setStatus((short)0);
registry.setCreationUser(new UserInfo());
return registry;
}
@Override
public String getHint() {
return null;
}
}