Fixes bug on updating DMP when not containing the Dataset Templates of its Dataset Descriptions.

This commit is contained in:
gkolokythas 2019-07-19 11:55:08 +03:00
parent 099efab90c
commit f31435de94
1 changed files with 8 additions and 2 deletions

View File

@ -410,9 +410,15 @@ public class DataManagementPlanManager {
public DMP createOrUpdate(ApiContext apiContext, DataManagementPlanEditorModel dataManagementPlan, Principal principal) throws Exception {
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dataManagementPlan.getId() != null) {
if (dataManagementPlan.getId() != null) {
DMP dmp1 = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
if (dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
List<Dataset> datasetList = new ArrayList<>(dmp1.getDataset());
for (Dataset dataset : datasetList) {
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getId())).findAny().orElse(null) == null)
throw new Exception("Dataset Template for Dataest Description is missing from the DMP.");
}
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
throw new Exception("DMP is finalized, therefore cannot be edited.");
}