Fixes bug on not storing Funder Id on Grant table.

This commit is contained in:
gkolokythas 2019-08-27 17:00:09 +03:00
parent b13bfb4527
commit bca715d52b
5 changed files with 15 additions and 10 deletions

View File

@ -154,10 +154,12 @@ public class Funder implements DataEntity<Funder, UUID> {
@Override
public void update(Funder entity) {
this.label = entity.getLabel();
this.created = entity.getCreated();
this.reference = entity.getReference();
this.definition = entity.getDefinition();
this.modified = new Date();
this.status = entity.getStatus();
this.created = entity.getCreated();
this.modified = new Date();
this.type = entity.getType();
}
@Override

View File

@ -457,11 +457,14 @@ public class DataManagementPlanManager {
if (newDmp.getGrant().getId() != null) {
Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(newDmp.getGrant().getId());
if ( !grant.getFunder().getId().equals(newDmp.getGrant().getFunder().getId()) && !newDmp.getGrant().getCreationUser().getId().equals(user.getId())){
throw new Exception("User is not the owner of the Grant therefore, cannot edit it");
if (grant.getFunder() != null
&& !grant.getFunder().getId().equals(newDmp.getGrant().getFunder().getId())
&& !grant.getCreationUser().getId().equals(user.getId())){
throw new Exception("User is not the owner of the Grant, therefore, cannot edit it");
}
}
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
// Dataset manipulation for when the DMP is set to be finalized.

View File

@ -293,7 +293,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
}
}
if (this.funder != null) {
if (this.funder != null && this.funder.getExistFunder() != null) {
if (this.funder.getExistFunder() != null && this.funder.getLabel() == null)
dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
else {

View File

@ -198,8 +198,8 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue());
entity.setModified(new Date());
entity.setDescription(this.description);
entity.setFunder(new Funder());
if (this.funderId != null) {
entity.setFunder(new Funder());
entity.getFunder().setId(this.funderId);
}

View File

@ -22,7 +22,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
private String definition;
private Date startDate;
private Date endDate;
private eu.eudat.data.entities.Project.Status status;
private Short status;
private UserInfo creationUser;
private Date created;
private Date modified;
@ -99,11 +99,11 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
this.endDate = endDate;
}
public short getStatus() {
return status.getValue();
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = eu.eudat.data.entities.Project.Status.fromInteger(status);
this.status = status;
}
public UserInfo getCreationUser() {