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 @Id
@GeneratedValue //@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2") //@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;

View File

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

View File

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

View File

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

View File

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