Fixes bug on create DMP created by the refactor.
This commit is contained in:
parent
611aeb0094
commit
ab63ea34d1
|
@ -403,12 +403,11 @@ public class DataManagementPlanManager {
|
||||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
||||||
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
|
||||||
|
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
|
||||||
newDmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataManagementPlan.getId());
|
||||||
|
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
||||||
|
newDmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
||||||
newDmp.setCreated(dmp.getCreated());
|
newDmp.setCreated(dmp.getCreated());
|
||||||
if (dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
if (dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
|
||||||
.collect(Collectors.toList()).size() == 0) {
|
.collect(Collectors.toList()).size() == 0) {
|
||||||
|
@ -421,13 +420,9 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
newDmp.setCreated(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
|
|
||||||
if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
|
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
||||||
|
@ -441,6 +436,49 @@ public class DataManagementPlanManager {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
||||||
|
} else {
|
||||||
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
|
for (Dataset dataset : dmp.getDataset()) {
|
||||||
|
if (!dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())) {
|
||||||
|
datasetsToBeCanceled.add(dataset.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
|
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
newDmp.setCreated(new Date());
|
||||||
|
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
|
|
||||||
|
if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
|
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
|
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
||||||
|
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
||||||
|
|
||||||
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
|
for (DatasetListingModel dataset : dataManagementPlan.getDatasets()) {
|
||||||
|
if (!(dataset.getStatus() == (int) Dataset.Status.FINALISED.getValue()) && !dataManagementPlan.getDatasetsToBeFinalized().contains(UUID.fromString(dataset.getId()))) {
|
||||||
|
datasetsToBeCanceled.add(UUID.fromString(dataset.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
|
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
||||||
|
} else {
|
||||||
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
|
for (DatasetListingModel dataset : dataManagementPlan.getDatasets()) {
|
||||||
|
if (!(dataset.getStatus() == (int) Dataset.Status.FINALISED.getValue())) {
|
||||||
|
datasetsToBeCanceled.add(UUID.fromString(dataset.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
|
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||||
|
|
Loading…
Reference in New Issue