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

105 lines
2.8 KiB
Java
Raw Normal View History

2018-06-27 12:29:21 +02:00
package eu.eudat.models.data.dmp;
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;
import java.util.Date;
2018-03-21 11:57:56 +01:00
public class Organisation implements DataModel<eu.eudat.data.entities.Organisation, Organisation>, LabelGenerator {
2017-12-20 15:52:09 +01:00
private String label;
private String name;
2017-12-20 15:52:09 +01:00
private String id;
private String reference;
private int status;
private String tag; // how the external source is displayed. ex: "Cristin".
private String key; // the external source. ex: "cristin".
2017-12-20 15:52:09 +01:00
public String getLabel() {
return label;
}
2017-12-20 15:52:09 +01:00
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
2017-12-20 15:52:09 +01:00
public String getId() {
return id;
}
2017-12-20 15:52:09 +01:00
public void setId(String id) {
this.id = id;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
2017-12-20 15:52:09 +01:00
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
2018-03-21 11:57:56 +01:00
public Organisation fromDataModel(eu.eudat.data.entities.Organisation entity) {
this.id = entity.getId().toString();
this.name = entity.getLabel();
2017-12-20 15:52:09 +01:00
this.label = entity.getUri();
if (entity.getReference() != null) {
this.reference = entity.getReference();
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
}
2018-02-16 08:45:18 +01:00
return this;
}
@Override
2018-03-21 11:57:56 +01:00
public eu.eudat.data.entities.Organisation toDataModel() {
eu.eudat.data.entities.Organisation organisationEntity = new eu.eudat.data.entities.Organisation();
if (this.key != null && this.reference != null) {
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
organisationEntity.setReference(this.reference);
} else {
organisationEntity.setReference(this.key + ":" + this.reference);
}
}
organisationEntity.setLabel(this.name);
2017-12-20 15:52:09 +01:00
organisationEntity.setUri(this.label);
organisationEntity.setCreated(new Date());
2018-02-16 11:34:02 +01:00
organisationEntity.setStatus((short) this.status);
return organisationEntity;
}
2017-12-19 15:09:49 +01:00
@Override
public String generateLabel() {
return this.getName();
}
2018-01-19 10:31:05 +01:00
@Override
public String getHint() {
return null;
}
}