Refactors how reference is created on Funder, Grant and Projcect now using their unique id as a part of it instead of label.

This commit is contained in:
gkolokythas 2019-12-12 12:27:47 +02:00
parent d1d0cbd931
commit 01d6782ec7
5 changed files with 27 additions and 21 deletions

View File

@ -66,8 +66,8 @@ public class Funder implements DataEntity<Funder, UUID> {
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
//@GeneratedValue
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;

View File

@ -81,8 +81,8 @@ public class Grant implements DataEntity<Grant, UUID> {
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
//@GeneratedValue
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;

View File

@ -67,8 +67,8 @@ public class Project implements DataEntity<Project, UUID> {
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
//@GeneratedValue
//@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;

View File

@ -278,10 +278,11 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
else {
Grant grant = new Grant();
grant.setId(UUID.randomUUID());
grant.setAbbreviation("");
grant.setLabel(this.grant.getLabel());
grant.setType(Grant.GrantType.INTERNAL.getValue());
grant.setReference("dmp:" + this.grant.getLabel());
grant.setReference("dmp:" + grant.getId());
grant.setUri("");
grant.setDefinition("");
grant.setCreated(new Date());
@ -302,9 +303,10 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
} else {
if (this.funder.getLabel() != null) {
Funder funder = new Funder();
funder.setId(UUID.randomUUID());
funder.setLabel(this.funder.getLabel());
funder.setType(Funder.FunderType.INTERNAL.getValue());
funder.setReference("dmp:" + this.funder.getLabel());
funder.setReference("dmp:" + funder.getId());
funder.setDefinition("");
funder.setCreated(new Date());
funder.setStatus(Funder.Status.ACTIVE.getValue());
@ -322,10 +324,11 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
else {
Project project = new Project();
project.setId(UUID.randomUUID());
project.setAbbreviation("");
project.setLabel(this.project.getLabel());
project.setType(Project.ProjectType.INTERNAL.getValue());
project.setReference("dmp:" + this.project.getLabel());
project.setReference("dmp:" + project.getId());
project.setUri("");
project.setDefinition("");
project.setCreated(new Date());

View File

@ -182,10 +182,11 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
entity.setGrant(this.grant.getExistGrant().toDataModel());
else {
eu.eudat.data.entities.Grant grant = new eu.eudat.data.entities.Grant();
grant.setId(UUID.randomUUID());
grant.setAbbreviation("");
grant.setLabel(this.grant.getLabel());
grant.setType(eu.eudat.data.entities.Grant.GrantType.INTERNAL.getValue());
grant.setReference("dmp:" + this.grant.getLabel());
grant.setReference("dmp:" + grant.getId());
grant.setUri("");
grant.setDefinition("");
grant.setCreated(new Date());
@ -197,27 +198,28 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
}
}
if(this.funder == null && this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
entity.getGrant().setFunder(null);
}
else if (this.funder != null && this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
entity.getGrant().setFunder(null);
}
else {
if (this.funder == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else if (this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else {
if (this.funder.getLabel() != null) {
Funder funder = new Funder();
funder.setId(UUID.randomUUID());
funder.setLabel(this.funder.getLabel());
funder.setType(Funder.FunderType.INTERNAL.getValue());
funder.setReference("dmp:" + this.funder.getLabel());
funder.setReference("dmp:" + funder.getId());
funder.setDefinition("");
funder.setCreated(new Date());
funder.setStatus(Funder.Status.ACTIVE.getValue());
funder.setModified(new Date());
entity.getGrant().setFunder(funder);
}
else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
entity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
entity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
}
}
@ -226,10 +228,11 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
entity.setProject(this.project.getExistProject().toDataModel());
else {
Project project = new Project();
project.setId(UUID.randomUUID());
project.setAbbreviation("");
project.setLabel(this.project.getLabel());
project.setType(Project.ProjectType.INTERNAL.getValue());
project.setReference("dmp:" + this.project.getLabel());
project.setReference("dmp:" + project.getId());
project.setUri("");
project.setDefinition("");
project.setCreated(new Date());