2018-06-27 12:29:21 +02:00
|
|
|
package eu.eudat.models.data.dmp;
|
2017-12-09 23:31:07 +01:00
|
|
|
|
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-09 23:31:07 +01:00
|
|
|
|
|
|
|
import java.util.Date;
|
2020-10-23 10:48:27 +02:00
|
|
|
import java.util.HashMap;
|
2020-07-28 16:35:55 +02:00
|
|
|
import java.util.UUID;
|
2017-12-09 23:31:07 +01:00
|
|
|
|
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;
|
2017-12-09 23:31:07 +01:00
|
|
|
private String name;
|
2017-12-20 15:52:09 +01:00
|
|
|
private String id;
|
2020-01-16 12:34:12 +01:00
|
|
|
private String reference;
|
2017-12-09 23:31:07 +01:00
|
|
|
private int status;
|
2020-01-16 12:34:12 +01:00
|
|
|
private String tag; // how the external source is displayed. ex: "Cristin".
|
|
|
|
private String key; // the external source. ex: "cristin".
|
2017-12-09 23:31:07 +01:00
|
|
|
|
2017-12-20 15:52:09 +01:00
|
|
|
public String getLabel() {
|
|
|
|
return label;
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|
2017-12-20 15:52:09 +01:00
|
|
|
public void setLabel(String label) {
|
|
|
|
this.label = label;
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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-09 23:31:07 +01:00
|
|
|
}
|
2017-12-20 15:52:09 +01:00
|
|
|
public void setId(String id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2020-01-16 12:34:12 +01:00
|
|
|
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;
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|
|
|
|
|
2019-11-04 12:22:58 +01:00
|
|
|
public String getTag() {
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
public void setTag(String tag) {
|
|
|
|
this.tag = tag;
|
|
|
|
}
|
|
|
|
|
2020-01-16 12:34:12 +01:00
|
|
|
public String getKey() {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
public void setKey(String key) {
|
|
|
|
this.key = key;
|
|
|
|
}
|
|
|
|
|
2017-12-09 23:31:07 +01:00
|
|
|
@Override
|
2018-03-21 11:57:56 +01:00
|
|
|
public Organisation fromDataModel(eu.eudat.data.entities.Organisation entity) {
|
2020-01-16 12:34:12 +01:00
|
|
|
this.id = entity.getId().toString();
|
2017-12-09 23:31:07 +01:00
|
|
|
this.name = entity.getLabel();
|
2017-12-20 15:52:09 +01:00
|
|
|
this.label = entity.getUri();
|
2020-04-22 17:40:43 +02:00
|
|
|
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;
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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();
|
2020-04-22 17:40:43 +02:00
|
|
|
if (this.key != null && this.reference != null) {
|
2021-04-30 13:45:00 +02:00
|
|
|
if (this.reference.startsWith(this.key + ":")) {
|
2020-04-22 17:40:43 +02:00
|
|
|
organisationEntity.setReference(this.reference);
|
|
|
|
} else {
|
|
|
|
organisationEntity.setReference(this.key + ":" + this.reference);
|
|
|
|
}
|
2019-11-04 12:22:58 +01:00
|
|
|
}
|
2020-07-28 16:35:55 +02:00
|
|
|
if (this.id != null) {
|
|
|
|
organisationEntity.setId(UUID.fromString(this.id));
|
|
|
|
}
|
2017-12-09 23:31:07 +01:00
|
|
|
organisationEntity.setLabel(this.name);
|
2017-12-20 15:52:09 +01:00
|
|
|
organisationEntity.setUri(this.label);
|
2017-12-09 23:31:07 +01:00
|
|
|
organisationEntity.setCreated(new Date());
|
2018-02-16 11:34:02 +01:00
|
|
|
organisationEntity.setStatus((short) this.status);
|
2017-12-09 23:31:07 +01:00
|
|
|
return organisationEntity;
|
|
|
|
}
|
2020-10-23 10:48:27 +02:00
|
|
|
|
|
|
|
public static Organisation fromMap(HashMap<String, Object> map) {
|
|
|
|
Organisation model = new Organisation();
|
2020-10-26 17:03:07 +01:00
|
|
|
if (map != null) {
|
|
|
|
model.id = (String) map.get("id");
|
|
|
|
model.key = (String) map.get("key");
|
|
|
|
model.label = (String) map.get("label");
|
|
|
|
model.name = (String) map.get("name");
|
|
|
|
model.reference = (String) map.get("reference");
|
|
|
|
model.status = (int) map.get("status");
|
|
|
|
model.tag = (String) map.get("tag");
|
|
|
|
}
|
2020-10-23 10:48:27 +02:00
|
|
|
return model;
|
|
|
|
}
|
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;
|
|
|
|
}
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|