When deleting a DMP that has more than one versions then show the previous version of that DMP on the list (no ghost Datasets)

This commit is contained in:
George Kalampokis 2020-02-06 10:56:03 +02:00
parent ebb9617aa6
commit 4da5f54362
1 changed files with 3 additions and 2 deletions

View File

@ -43,8 +43,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
if (!criteria.getAllVersions())
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
builder1.notEqual(nestedRoot.get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
if (criteria.getStatus() != null) {