diff --git a/src/main/java/org/damap/base/domain/Dmp.java b/src/main/java/org/damap/base/domain/Dmp.java index 17d764c0..090c4e67 100644 --- a/src/main/java/org/damap/base/domain/Dmp.java +++ b/src/main/java/org/damap/base/domain/Dmp.java @@ -153,6 +153,7 @@ public class Dmp extends PanacheEntity { cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.EAGER) + @OrderBy("id") private List contributorList = new ArrayList<>(); @OneToMany( @@ -160,6 +161,7 @@ public class Dmp extends PanacheEntity { cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.EAGER) + @OrderBy("id") private List datasetList = new ArrayList<>(); @OneToMany( @@ -189,6 +191,7 @@ public class Dmp extends PanacheEntity { cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.EAGER) + @OrderBy("id") private List costs = new ArrayList<>(); private String documentation; diff --git a/src/main/java/org/damap/base/repo/DmpRepo.java b/src/main/java/org/damap/base/repo/DmpRepo.java index db0c4051..abe58956 100644 --- a/src/main/java/org/damap/base/repo/DmpRepo.java +++ b/src/main/java/org/damap/base/repo/DmpRepo.java @@ -1,6 +1,7 @@ package org.damap.base.repo; import io.quarkus.hibernate.orm.panache.PanacheRepository; +import io.quarkus.panache.common.Sort; import jakarta.enterprise.context.ApplicationScoped; import java.util.List; import org.damap.base.domain.Dmp; @@ -15,6 +16,6 @@ public class DmpRepo implements PanacheRepository { * @return a {@link java.util.List} object */ public List getAll() { - return listAll(); + return listAll(Sort.by("id")); } } diff --git a/src/main/java/org/damap/base/repo/base/RepoSearch.java b/src/main/java/org/damap/base/repo/base/RepoSearch.java index 5e3c465d..d90f3683 100644 --- a/src/main/java/org/damap/base/repo/base/RepoSearch.java +++ b/src/main/java/org/damap/base/repo/base/RepoSearch.java @@ -1,6 +1,7 @@ package org.damap.base.repo.base; import io.quarkus.hibernate.orm.panache.PanacheRepository; +import io.quarkus.panache.common.Sort; import jakarta.ws.rs.core.MultivaluedMap; import java.util.HashMap; import java.util.List; @@ -50,6 +51,6 @@ default List searchByParameters(MultivaluedMap queryParams) { counter++; } - return list(query.toString(), params); + return find(query.toString(), Sort.by("id"), params).list(); } } diff --git a/src/main/java/org/damap/base/rest/dmp/mapper/DmpDOMapper.java b/src/main/java/org/damap/base/rest/dmp/mapper/DmpDOMapper.java index 69716b28..16f2605d 100644 --- a/src/main/java/org/damap/base/rest/dmp/mapper/DmpDOMapper.java +++ b/src/main/java/org/damap/base/rest/dmp/mapper/DmpDOMapper.java @@ -1,9 +1,6 @@ package org.damap.base.rest.dmp.mapper; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import lombok.experimental.UtilityClass; import lombok.extern.jbosslog.JBossLog; import org.damap.base.domain.*; diff --git a/src/main/java/org/damap/base/rest/dmp/service/DmpService.java b/src/main/java/org/damap/base/rest/dmp/service/DmpService.java index b3fa6415..73ca0a60 100644 --- a/src/main/java/org/damap/base/rest/dmp/service/DmpService.java +++ b/src/main/java/org/damap/base/rest/dmp/service/DmpService.java @@ -5,11 +5,7 @@ import jakarta.transaction.Transactional; import jakarta.validation.Valid; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import lombok.extern.jbosslog.JBossLog; import org.damap.base.domain.Access; import org.damap.base.domain.Contributor; @@ -67,6 +63,7 @@ public List getAll() { dmpListItemDOList.add( DmpListItemDOMapper.mapEntityToDO( null, dmp, new DmpListItemDO(), versionService.getDmpVersions(dmp.id)))); + return dmpListItemDOList; } @@ -90,6 +87,9 @@ public List getDmpListByPersonId(String personId) { access.getDmp(), new DmpListItemDO(), versionService.getDmpVersions(access.getDmp().id)))); + + dmpListItemDOS.sort(Comparator.comparing(DmpListItemDO::getId)); + return dmpListItemDOS; }