Fixes bug on updating DMP when not containing the Dataset Templates of its Dataset Descriptions.
This commit is contained in:
parent
099efab90c
commit
f31435de94
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue