Adds backend validation on DMP finalization. (Issue #131)

This commit is contained in:
gkolokythas 2019-08-22 16:48:18 +03:00
parent f5866107ad
commit 2881ac5dd9
1 changed files with 16 additions and 0 deletions

View File

@ -420,6 +420,10 @@ public class DataManagementPlanManager {
}
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.");
if(dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
checkDmpValidationRules(dmp1);
}
}
DMP newDmp = dataManagementPlan.toDataModel();
@ -620,6 +624,18 @@ public class DataManagementPlanManager {
}
}
private void checkDmpValidationRules(DMP dmp) throws Exception {
if (dmp.getLabel() == null || dmp.getLabel().trim().isEmpty()) {
throw new Exception("DMP has no label.");
}
if (dmp.getAssociatedDmps().size() == 0) {
throw new Exception("DMP does not contain Dataset Templates.");
}
if (dmp.getGrant() == null) {
throw new Exception("DMP has no Grant assigned.");
}
}
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
for (Dataset dataset : newDmp.getDataset()) {