Adds backend validation on DMP finalization. (Issue #131)
This commit is contained in:
parent
f5866107ad
commit
2881ac5dd9
|
@ -420,6 +420,10 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
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.");
|
throw new Exception("DMP is finalized, therefore cannot be edited.");
|
||||||
|
|
||||||
|
if(dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
|
checkDmpValidationRules(dmp1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
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) {
|
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
||||||
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
||||||
for (Dataset dataset : newDmp.getDataset()) {
|
for (Dataset dataset : newDmp.getDataset()) {
|
||||||
|
|
Loading…
Reference in New Issue