2018-06-27 12:29:21 +02:00
|
|
|
package eu.eudat.models.data.dataset;
|
2017-12-15 00:01:26 +01:00
|
|
|
|
|
|
|
import eu.eudat.models.DataModel;
|
2018-06-27 12:29:21 +02:00
|
|
|
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
2017-12-19 15:09:49 +01:00
|
|
|
|
2019-09-16 17:26:18 +02:00
|
|
|
import java.util.Date;
|
2017-12-19 15:09:49 +01:00
|
|
|
import java.util.UUID;
|
2017-12-15 00:01:26 +01:00
|
|
|
|
2018-03-21 11:57:56 +01:00
|
|
|
public class Registry implements DataModel<eu.eudat.data.entities.Registry, Registry>, LabelGenerator {
|
2018-02-16 11:34:02 +01:00
|
|
|
private UUID id;
|
|
|
|
private String label;
|
|
|
|
private String abbreviation;
|
|
|
|
private String reference;
|
|
|
|
private String uri;
|
|
|
|
private String definition;
|
2019-11-06 11:05:40 +01:00
|
|
|
private String source;
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public String generateLabel() {
|
|
|
|
return getLabel();
|
|
|
|
}
|
|
|
|
public void setAbbreviation(String abbreviation) {
|
|
|
|
this.abbreviation = abbreviation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getReference() {
|
|
|
|
return reference;
|
|
|
|
}
|
|
|
|
public void setReference(String reference) {
|
|
|
|
this.reference = reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUri() {
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
public void setUri(String uri) {
|
|
|
|
this.uri = uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getDefinition() {
|
|
|
|
return definition;
|
|
|
|
}
|
|
|
|
public void setDefinition(String definition) {
|
|
|
|
this.definition = definition;
|
|
|
|
}
|
|
|
|
|
2019-11-06 11:05:40 +01:00
|
|
|
public String getSource() {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
public void setSource(String source) {
|
|
|
|
this.source = source;
|
|
|
|
}
|
|
|
|
|
2018-03-21 11:57:56 +01:00
|
|
|
public Registry fromDataModel(eu.eudat.data.entities.Registry entity) {
|
2018-02-16 11:34:02 +01:00
|
|
|
this.id = entity.getId();
|
|
|
|
this.label = entity.getLabel();
|
|
|
|
this.abbreviation = entity.getAbbreviation();
|
|
|
|
this.reference = entity.getReference();
|
|
|
|
this.uri = entity.getUri();
|
|
|
|
this.definition = entity.getDefinition();
|
2019-11-06 11:05:40 +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 11:34:02 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-03-21 11:57:56 +01:00
|
|
|
public eu.eudat.data.entities.Registry toDataModel() {
|
|
|
|
eu.eudat.data.entities.Registry entity = new eu.eudat.data.entities.Registry();
|
2019-09-16 17:26:18 +02:00
|
|
|
entity.setId(this.id != null ? this.id : UUID.randomUUID());
|
|
|
|
entity.setLabel(this.label);
|
|
|
|
entity.setAbbreviation(this.abbreviation);
|
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()))) {
|
|
|
|
entity.setReference(this.reference);
|
|
|
|
} else {
|
2019-11-21 17:25:43 +01:00
|
|
|
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
|
2019-11-19 10:01:02 +01:00
|
|
|
}
|
|
|
|
}
|
2019-09-16 17:26:18 +02:00
|
|
|
entity.setUri(this.uri);
|
|
|
|
entity.setModified(new Date());
|
|
|
|
entity.setStatus((short)0);
|
2018-02-16 11:34:02 +01:00
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getHint() {
|
|
|
|
return null;
|
|
|
|
}
|
2017-12-15 00:01:26 +01:00
|
|
|
}
|