Fixes bug on exposing private Datasets on published DMP listing due to some old Datasets not being "Canceled".

This commit is contained in:
gkolokythas 2020-01-14 13:29:11 +02:00
parent 3aa7dc0481
commit 1b7d118861
2 changed files with 13 additions and 6 deletions

View File

@ -28,7 +28,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
private String description;
private List<DatasetListingModel> datasets;
private List<AssociatedProfile> profiles;
private eu.eudat.models.data.grant.Grant grant;
private Grant grant;
private List<Organisation> organisations;
private List<Researcher> researchers;
private List<UserListingModel> associatedUsers;
@ -218,7 +218,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
this.version = entity.getVersion();
this.groupId = this.groupId == null ? null : this.groupId;
this.groupId = this.groupId == null ? null : entity.getGroupId();
this.label = entity.getLabel();
this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
@ -243,9 +243,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.profiles.add(associatedProfile);
}
}
this.datasets = entity.getDataset().stream()
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
.map(x-> new DatasetListingModel().fromDataModel(x)).collect(Collectors.toList());
if (entity.isPublic()) {
this.datasets = entity.getDataset().stream()
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()) && !dataset.getStatus().equals(Dataset.Status.SAVED.getValue()))
.map(x-> new DatasetListingModel().fromDataModel(x)).collect(Collectors.toList());
} else {
this.datasets = entity.getDataset().stream()
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
.map(x-> new DatasetListingModel().fromDataModel(x)).collect(Collectors.toList());
}
this.modified = entity.getModified();
this.created = entity.getCreated();
this.description = entity.getDescription();

View File

@ -218,11 +218,12 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
this.version = entity.getVersion();
this.groupId = this.groupId == null ? null : this.groupId;
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;
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();