Enriches Oragnisation and Researcher references with source prefix. (Issue #187)
This commit is contained in:
parent
f1a79459a0
commit
39a81e1d28
|
@ -10,6 +10,7 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
|||
private String name;
|
||||
private String id;
|
||||
private int status;
|
||||
private String tag;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
|
@ -39,18 +40,34 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Organisation fromDataModel(eu.eudat.data.entities.Organisation entity) {
|
||||
this.id = entity.getReference();
|
||||
this.name = entity.getLabel();
|
||||
this.label = entity.getUri();
|
||||
if (entity.getReference().contains(":cristin")) {
|
||||
this.tag = "Cristin";
|
||||
} else {
|
||||
this.tag = 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();
|
||||
organisationEntity.setReference(this.id);
|
||||
if (this.tag.equals(this.id.substring(0, this.tag.length()))) {
|
||||
organisationEntity.setReference(this.id);
|
||||
} else {
|
||||
organisationEntity.setReference(this.tag + ":" + this.id);
|
||||
}
|
||||
organisationEntity.setLabel(this.name);
|
||||
organisationEntity.setUri(this.label);
|
||||
organisationEntity.setCreated(new Date());
|
||||
|
|
|
@ -58,14 +58,27 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
|
|||
this.label = entity.getUri();
|
||||
this.name = entity.getLabel();
|
||||
this.status = entity.getStatus();
|
||||
this.tag = "Internal";
|
||||
|
||||
if (entity.getReference().contains(":cristin")) {
|
||||
this.tag = "Cristin";
|
||||
} else {
|
||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||
if (source.equals("dmp"))
|
||||
this.tag = "Internal";
|
||||
else
|
||||
this.tag = source;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.data.entities.Researcher toDataModel() {
|
||||
eu.eudat.data.entities.Researcher researcher = new eu.eudat.data.entities.Researcher();
|
||||
researcher.setReference(this.id);
|
||||
if (this.tag.equals("Internal") || this.tag.equals(this.id.substring(0, this.tag.length()))) {
|
||||
researcher.setReference(this.id);
|
||||
} else {
|
||||
researcher.setReference(this.tag + ":" + this.id);
|
||||
}
|
||||
researcher.setLabel(this.name);
|
||||
researcher.setUri(this.label);
|
||||
researcher.setCreated(new Date());
|
||||
|
|
|
@ -5,4 +5,5 @@ export interface OrganizationModel {
|
|||
name: string;
|
||||
label: string;
|
||||
status: Status;
|
||||
tag: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue