Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global: Add sorting to DMPs, Storage, Datasets and other entities by ID to preserve order #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/damap/base/domain/Dmp.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ public class Dmp extends PanacheEntity {
cascade = {CascadeType.ALL},
orphanRemoval = true,
fetch = FetchType.EAGER)
@OrderBy("id")
private List<Contributor> contributorList = new ArrayList<>();

@OneToMany(
mappedBy = "dmp",
cascade = {CascadeType.ALL},
orphanRemoval = true,
fetch = FetchType.EAGER)
@OrderBy("id")
private List<Dataset> datasetList = new ArrayList<>();

@OneToMany(
Expand Down Expand Up @@ -189,6 +191,7 @@ public class Dmp extends PanacheEntity {
cascade = {CascadeType.ALL},
orphanRemoval = true,
fetch = FetchType.EAGER)
@OrderBy("id")
private List<Cost> costs = new ArrayList<>();

private String documentation;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/damap/base/repo/DmpRepo.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,6 +16,6 @@ public class DmpRepo implements PanacheRepository<Dmp> {
* @return a {@link java.util.List} object
*/
public List<Dmp> getAll() {
return listAll();
return listAll(Sort.by("id"));
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/damap/base/repo/base/RepoSearch.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -50,6 +51,6 @@ default List<T> searchByParameters(MultivaluedMap<String, Object> queryParams) {
counter++;
}

return list(query.toString(), params);
return find(query.toString(), Sort.by("id"), params).list();
}
}
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/damap/base/rest/dmp/service/DmpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,6 +63,7 @@ public List<DmpListItemDO> getAll() {
dmpListItemDOList.add(
DmpListItemDOMapper.mapEntityToDO(
null, dmp, new DmpListItemDO(), versionService.getDmpVersions(dmp.id))));

return dmpListItemDOList;
}

Expand All @@ -90,6 +87,9 @@ public List<DmpListItemDO> getDmpListByPersonId(String personId) {
access.getDmp(),
new DmpListItemDO(),
versionService.getDmpVersions(access.getDmp().id))));

dmpListItemDOS.sort(Comparator.comparing(DmpListItemDO::getId));

return dmpListItemDOS;
}

Expand Down
Loading