105 lines
2.8 KiB
Java
105 lines
2.8 KiB
Java
package eu.eudat.models.data.dmp;
|
|
|
|
import eu.eudat.models.DataModel;
|
|
import eu.eudat.logic.utilities.helpers.LabelGenerator;
|
|
|
|
import java.util.Date;
|
|
|
|
public class Organisation implements DataModel<eu.eudat.data.entities.Organisation, Organisation>, LabelGenerator {
|
|
private String label;
|
|
private String name;
|
|
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".
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getReference() {
|
|
return reference;
|
|
}
|
|
public void setReference(String reference) {
|
|
this.reference = reference;
|
|
}
|
|
|
|
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
|
|
public Organisation fromDataModel(eu.eudat.data.entities.Organisation entity) {
|
|
this.id = entity.getId().toString();
|
|
this.name = entity.getLabel();
|
|
this.label = entity.getUri();
|
|
if (entity.getReference() != null) {
|
|
this.reference = entity.getReference();
|
|
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
|
}
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
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);
|
|
organisationEntity.setUri(this.label);
|
|
organisationEntity.setCreated(new Date());
|
|
organisationEntity.setStatus((short) this.status);
|
|
return organisationEntity;
|
|
}
|
|
|
|
@Override
|
|
public String generateLabel() {
|
|
return this.getName();
|
|
}
|
|
|
|
@Override
|
|
public String getHint() {
|
|
return null;
|
|
}
|
|
}
|