Fixes how "Reference" is created on Grand, Funder and Project.

This commit is contained in:
gkolokythas 2019-11-25 11:48:59 +02:00
parent 0b573e4256
commit 247aac72fe
3 changed files with 45 additions and 6 deletions

View File

@ -90,7 +90,12 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
this.status = entity.getStatus();
this.created = entity.getCreated();
this.modified = entity.getModified();
this.source = "Internal";
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
if (source.equals("dmp")) {
this.source = "Internal";
} else {
this.source = source;
}
return this;
}
@ -100,7 +105,15 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
entity.setId(this.id);
entity.setLabel(this.label);
entity.setType(this.type);
entity.setReference(this.reference == null ? "dmp:" + this.label : this.source.toLowerCase() + ":" + this.reference);
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 {
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
}
}
entity.setDefinition(this.definition);
entity.setCreated(this.created == null ? new Date() : this.created);
entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue());

View File

@ -177,7 +177,12 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
if (entity.getFunder() != null)
this.funderId = entity.getFunder().getId();
this.source = "Internal";
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
if (source.equals("dmp")) {
this.source = "Internal";
} else {
this.source = source;
}
return this;
}
@ -189,7 +194,15 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
entity.setAbbreviation(this.abbreviation);
entity.setLabel(this.label);
entity.setType(this.type);
entity.setReference(this.reference == null ? "dmp:" + this.label : this.source.toLowerCase() + ":" + this.reference);
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 {
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
}
}
entity.setUri(this.uri);
entity.setDefinition(this.definition);
entity.setStartdate(this.startDate);

View File

@ -165,7 +165,12 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
this.modified = entity.getModified();
this.description = entity.getDescription();
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
this.source = "Internal";
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
if (source.equals("dmp")) {
this.source = "Internal";
} else {
this.source = source;
}
return this;
}
@ -176,7 +181,15 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
entity.setAbbreviation(this.abbreviation);
entity.setLabel(this.label);
entity.setType(this.type);
entity.setReference(this.reference == null ? "dmp:" + this.label : this.source.toLowerCase() + ":" + this.reference);
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 {
entity.setReference(this.source.toLowerCase() + ":" + this.reference);
}
}
entity.setUri(this.uri);
entity.setDefinition(this.definition);
entity.setStartdate(this.startDate);