add missing grant checks

This commit is contained in:
Bernaldo Mihasi 2023-09-21 10:20:32 +03:00
parent b68070aa01
commit 79aaf23bb6
5 changed files with 15 additions and 7 deletions

View File

@ -118,7 +118,9 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
this.datasetTemplate = new DatasetProfileOverviewModel().fromDataModel(entity.getProfile());
this.users = entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
this.dmp = new DataManagementPlanOverviewModel().fromDataModel(entity.getDmp());
if (entity.getDmp().getGrant() != null) {
this.grant = new GrantOverviewModel().fromDataModel(entity.getDmp().getGrant());
}
this.description = entity.getDescription();
this.isPublic = entity.getDmp().isPublic();
this.modified = entity.getModified();

View File

@ -232,10 +232,12 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.version = entity.getVersion();
this.groupId = this.groupId == null ? null : entity.getGroupId();
this.label = entity.getLabel();
this.grant = new GrantDMPEditorModel();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
if (entity.getGrant() != null) {
this.grant = new GrantDMPEditorModel();
this.grant.getExistGrant().fromDataModel(entity.getGrant());
this.grant.getExistGrant().setSource("");
}
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId();
this.lockable = entity.getDataset().stream().findAny().isPresent();

View File

@ -144,7 +144,7 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
this.label = entity.getLabel();
this.created = entity.getCreated();
this.modified = entity.getModified();
this.grant = entity.getDmp() != null ? entity.getDmp().getGrant().getLabel() : "";
this.grant = (entity.getDmp() != null && entity.getDmp().getGrant() != null) ? entity.getDmp().getGrant().getLabel() : "";
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
this.profile = entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null;

View File

@ -126,7 +126,9 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DMP entity) {
this.fromDataModel(entity);
this.version = entity.getVersion();
if (entity.getGrant() != null) {
this.grant = entity.getGrant().getLabel();
}
this.createdAt = entity.getCreated();
this.modifiedAt = entity.getModified();
try {

View File

@ -176,7 +176,9 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
public DataManagementPlanPublicModel fromDataModelDatasets(DMP entity) {
this.fromDataModel(entity);
this.version = entity.getVersion();
if (entity.getGrant() != null) {
this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant());
}
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
this.createdAt = entity.getCreated();
this.modifiedAt = entity.getModified();