diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/Funder.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/Funder.java index 39b66382f..f505c489d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/Funder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/Funder.java @@ -86,7 +86,7 @@ public class Funder implements DataModel } @Override - public eu.eudat.data.entities.Funder toDataModel() throws Exception { + public eu.eudat.data.entities.Funder toDataModel() { eu.eudat.data.entities.Funder entity = new eu.eudat.data.entities.Funder(); entity.setId(this.id); entity.setLabel(this.label); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/FunderDMPEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/FunderDMPEditorModel.java new file mode 100644 index 000000000..28738ed61 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/funder/FunderDMPEditorModel.java @@ -0,0 +1,20 @@ +package eu.eudat.models.data.funder; + +public class FunderDMPEditorModel { + private Funder existFunder; + private String label; + + public Funder getExistFunder() { + return existFunder; + } + public void setExistFunder(Funder existFunder) { + this.existFunder = existFunder; + } + + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/grant/Grant.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/grant/Grant.java index 5c4682149..1b936d449 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/grant/Grant.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/grant/Grant.java @@ -1,9 +1,11 @@ package eu.eudat.models.data.grant; +import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.UserInfo; import eu.eudat.models.DataModel; import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.files.ContentFile; +import eu.eudat.models.data.funder.FunderDMPEditorModel; import java.util.Arrays; import java.util.Date; @@ -14,42 +16,27 @@ import java.util.UUID; public class Grant implements DataModel { private UUID id; - private List dmps; - private String label; - private int type; - private String abbreviation; - private String reference; - private String uri; - private String definition; - private Date startDate; - private Date endDate; - private eu.eudat.data.entities.Grant.Status status; - private UserInfo creationUser; - private Date created; - private Date modified; - private String description; - private List files; + private FunderDMPEditorModel funder; public UUID getId() { return id; } - public void setId(UUID id) { this.id = id; } @@ -57,7 +44,6 @@ public class Grant implements DataModel { public int getType() { return type; } - public void setType(int type) { this.type = type; } @@ -65,7 +51,6 @@ public class Grant implements DataModel { public List getDmps() { return dmps; } - public void setDmps(List dmps) { this.dmps = dmps; } @@ -73,7 +58,6 @@ public class Grant implements DataModel { public String getLabel() { return label; } - public void setLabel(String label) { this.label = label; } @@ -81,7 +65,6 @@ public class Grant implements DataModel { public String getAbbreviation() { return abbreviation; } - public void setAbbreviation(String abbreviation) { this.abbreviation = abbreviation; } @@ -89,7 +72,6 @@ public class Grant implements DataModel { public String getReference() { return reference; } - public void setReference(String reference) { this.reference = reference; } @@ -97,7 +79,6 @@ public class Grant implements DataModel { public String getUri() { return uri; } - public void setUri(String uri) { this.uri = uri; } @@ -105,7 +86,6 @@ public class Grant implements DataModel { public String getDefinition() { return definition; } - public void setDefinition(String definition) { this.definition = definition; } @@ -113,7 +93,6 @@ public class Grant implements DataModel { public Date getStartDate() { return startDate; } - public void setStartDate(Date startDate) { this.startDate = startDate; } @@ -121,7 +100,6 @@ public class Grant implements DataModel { public Date getEndDate() { return endDate; } - public void setEndDate(Date endDate) { this.endDate = endDate; } @@ -129,7 +107,6 @@ public class Grant implements DataModel { public short getStatus() { return status.getValue(); } - public void setStatus(Short status) { this.status = eu.eudat.data.entities.Grant.Status.fromInteger(status); } @@ -137,7 +114,6 @@ public class Grant implements DataModel { public UserInfo getCreationUser() { return creationUser; } - public void setCreationUser(UserInfo creationUser) { this.creationUser = creationUser; } @@ -145,7 +121,6 @@ public class Grant implements DataModel { public Date getCreated() { return created; } - public void setCreated(Date created) { this.created = created; } @@ -153,7 +128,6 @@ public class Grant implements DataModel { public Date getModified() { return modified; } - public void setModified(Date modified) { this.modified = modified; } @@ -161,7 +135,6 @@ public class Grant implements DataModel { public String getDescription() { return description; } - public void setDescription(String description) { this.description = description; } @@ -169,11 +142,17 @@ public class Grant implements DataModel { public List getFiles() { return files; } - public void setFiles(List files) { this.files = files; } + public FunderDMPEditorModel getFunder() { + return funder; + } + public void setFunder(FunderDMPEditorModel funder) { + this.funder = funder; + } + @Override public Grant fromDataModel(eu.eudat.data.entities.Grant entity) { this.id = entity.getId(); @@ -190,6 +169,10 @@ public class Grant implements DataModel { 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.funder = new FunderDMPEditorModel(); + if (entity.getFunder() != null) + this.funder.getExistFunder().fromDataModel(entity.getFunder()); + return this; } @@ -209,6 +192,22 @@ public class Grant implements DataModel { entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue()); entity.setModified(new Date()); entity.setDescription(this.description); + if (this.funder != null) { + if (this.funder.getExistFunder() != null && this.funder.getLabel() == null) + entity.setFunder(this.funder.getExistFunder().toDataModel()); + else { + Funder funder = new Funder(); + funder.setLabel(this.funder.getLabel()); + funder.setType(Funder.FunderType.INTERNAL.getValue()); + funder.setReference("dmp:" + this.funder.getLabel()); + funder.setDefinition(""); + funder.setCreated(new Date()); + funder.setStatus(Funder.Status.ACTIVE.getValue()); + funder.setModified(new Date()); + + entity.setFunder(funder); + } + } return entity; }