changed PageRequest to OffsetBasedPageRequest for all of the Bean Queries (#912)

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
Bondar Bogdan
2019-11-18 11:05:35 +01:00
committed by Jeroen Laverman
parent ab009b2b4b
commit f295a98314
13 changed files with 47 additions and 60 deletions

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
@@ -94,8 +93,8 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<Artifact> {
public int size() { public int size() {
long size = 0; long size = 0;
if (baseSwModuleId != null) { if (baseSwModuleId != null) {
firstPagetArtifacts = getArtifactManagement() firstPagetArtifacts = getArtifactManagement().findBySoftwareModule(
.findBySoftwareModule(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), baseSwModuleId); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), baseSwModuleId);
size = firstPagetArtifacts.getTotalElements(); size = firstPagetArtifacts.getTotalElements();
} }
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {

View File

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter; import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
@@ -22,7 +23,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
@@ -120,7 +120,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
if (startIndex == 0 && firstPageDistributionSets != null) { if (startIndex == 0 && firstPageDistributionSets != null) {
distBeans = firstPageDistributionSets; distBeans = firstPageDistributionSets;
} else { } else {
distBeans = findDistBeans(PageRequest.of(startIndex / count, count, sort)); distBeans = findDistBeans(new OffsetBasedPageRequest(startIndex, count, sort));
} }
for (final DistributionSet distributionSet : distBeans) { for (final DistributionSet distributionSet : distBeans) {
@@ -137,7 +137,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
@Override @Override
public int size() { public int size() {
firstPageDistributionSets = findDistBeans(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort)); firstPageDistributionSets = findDistBeans(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
final long size = firstPageDistributionSets.getTotalElements(); final long size = firstPageDistributionSets.getTotalElements();
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {

View File

@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
@@ -27,7 +28,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
@@ -89,12 +89,9 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
Slice<Target> targetBeans; Slice<Target> targetBeans;
final List<ProxyTarget> proxyTargetBeans = new ArrayList<>(); final List<ProxyTarget> proxyTargetBeans = new ArrayList<>();
if (!StringUtils.isEmpty(filterQuery)) { if (!StringUtils.isEmpty(filterQuery)) {
targetBeans = targetManagement.findByRsql( targetBeans = targetManagement.findByRsql(new OffsetBasedPageRequest(startIndex, count, sort), filterQuery);
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
filterQuery);
} else { } else {
targetBeans = targetManagement targetBeans = targetManagement.findAll(new OffsetBasedPageRequest(startIndex, count, sort));
.findAll(PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
} }
for (final Target targ : targetBeans) { for (final Target targ : targetBeans) {

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -24,7 +25,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
@@ -86,11 +86,10 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
} else if (StringUtils.isEmpty(searchText)) { } else if (StringUtils.isEmpty(searchText)) {
// if no search filters available // if no search filters available
targetFilterQuery = getTargetFilterQueryManagement() targetFilterQuery = getTargetFilterQueryManagement()
.findAll(PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); .findAll(new OffsetBasedPageRequest(startIndex, count, sort));
} else { } else {
targetFilterQuery = getTargetFilterQueryManagement().findByName( targetFilterQuery = getTargetFilterQueryManagement()
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), .findByName(new OffsetBasedPageRequest(startIndex, count, sort), searchText);
searchText);
} }
for (final TargetFilterQuery tarFilterQuery : targetFilterQuery) { for (final TargetFilterQuery tarFilterQuery : targetFilterQuery) {
final ProxyTargetFilter proxyTarFilter = new ProxyTargetFilter(); final ProxyTargetFilter proxyTarFilter = new ProxyTargetFilter();
@@ -128,10 +127,10 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
public int size() { public int size() {
if (StringUtils.isEmpty(searchText)) { if (StringUtils.isEmpty(searchText)) {
firstPageTargetFilter = getTargetFilterQueryManagement() firstPageTargetFilter = getTargetFilterQueryManagement()
.findAll(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort)); .findAll(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
} else { } else {
firstPageTargetFilter = getTargetFilterQueryManagement() firstPageTargetFilter = getTargetFilterQueryManagement()
.findByName(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), searchText); .findByName(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), searchText);
} }
final long size = firstPageTargetFilter.getTotalElements(); final long size = firstPageTargetFilter.getTotalElements();

View File

@@ -15,11 +15,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.ui.management.actionhistory.ProxyAction.IsActiveDecoration; import org.eclipse.hawkbit.ui.management.actionhistory.ProxyAction.IsActiveDecoration;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
@@ -83,12 +83,12 @@ public class ActionBeanQuery extends AbstractBeanQuery<ProxyAction> {
if (startIndex == 0) { if (startIndex == 0) {
if (firstPageActions == null) { if (firstPageActions == null) {
firstPageActions = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, firstPageActions = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId,
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort)); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
} }
actionBeans = firstPageActions; actionBeans = firstPageActions;
} else { } else {
actionBeans = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, actionBeans = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId,
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); new OffsetBasedPageRequest(startIndex, count, sort));
} }
return createProxyActions(actionBeans); return createProxyActions(actionBeans);
} }

View File

@@ -15,11 +15,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
@@ -81,8 +81,7 @@ public class ActionStatusBeanQuery extends AbstractBeanQuery<ProxyActionStatus>
actionBeans = firstPageActionStates; actionBeans = firstPageActionStates;
} else { } else {
actionBeans = getDeploymentManagement().findActionStatusByAction( actionBeans = getDeploymentManagement().findActionStatusByAction(
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), new OffsetBasedPageRequest(startIndex, count, sort), currentSelectedActionId);
currentSelectedActionId);
} }
return createProxyActionStates(actionBeans); return createProxyActionStates(actionBeans);
} }
@@ -116,8 +115,8 @@ public class ActionStatusBeanQuery extends AbstractBeanQuery<ProxyActionStatus>
* .util.List, java.util.List, java.util.List) * .util.List, java.util.List, java.util.List)
*/ */
@Override @Override
protected void saveBeans(List<ProxyActionStatus> addedBeans, List<ProxyActionStatus> modifiedBeans, protected void saveBeans(final List<ProxyActionStatus> addedBeans, final List<ProxyActionStatus> modifiedBeans,
List<ProxyActionStatus> removedBeans) { final List<ProxyActionStatus> removedBeans) {
// CRUD operations on Target will be done through repository methods // CRUD operations on Target will be done through repository methods
} }
@@ -127,7 +126,7 @@ public class ActionStatusBeanQuery extends AbstractBeanQuery<ProxyActionStatus>
if (currentSelectedActionId != null) { if (currentSelectedActionId != null) {
firstPageActionStates = getDeploymentManagement().findActionStatusByAction( firstPageActionStates = getDeploymentManagement().findActionStatusByAction(
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), currentSelectedActionId); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), currentSelectedActionId);
size = firstPageActionStates.getTotalElements(); size = firstPageActionStates.getTotalElements();
} }
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {

View File

@@ -15,11 +15,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -84,8 +84,7 @@ public class ActionStatusMsgBeanQuery extends AbstractBeanQuery<ProxyMessage> {
actionBeans = firstPageMessages; actionBeans = firstPageMessages;
} else { } else {
actionBeans = getDeploymentManagement().findMessagesByActionStatusId( actionBeans = getDeploymentManagement().findMessagesByActionStatusId(
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), new OffsetBasedPageRequest(startIndex, count, sort), currentSelectedActionStatusId);
currentSelectedActionStatusId);
} }
return createProxyMessages(actionBeans); return createProxyMessages(actionBeans);
} }
@@ -129,7 +128,7 @@ public class ActionStatusMsgBeanQuery extends AbstractBeanQuery<ProxyMessage> {
if (currentSelectedActionStatusId != null) { if (currentSelectedActionStatusId != null) {
firstPageMessages = getDeploymentManagement().findMessagesByActionStatusId( firstPageMessages = getDeploymentManagement().findMessagesByActionStatusId(
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), currentSelectedActionStatusId); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), currentSelectedActionStatusId);
size = firstPageMessages.getTotalElements(); size = firstPageMessages.getTotalElements();
} }
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {

View File

@@ -26,7 +26,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -148,19 +147,19 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
firstPageDistributionSets = getDistributionSetManagement() firstPageDistributionSets = getDistributionSetManagement()
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget( .findByFilterAndAssignedInstalledDsOrderedByLinkTarget(
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilterBuilder, new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort),
pinnedTarget.getControllerId()); distributionSetFilterBuilder, pinnedTarget.getControllerId());
} else if (distributionTags.isEmpty() && StringUtils.isEmpty(searchText) && !noTagClicked) { } else if (distributionTags.isEmpty() && StringUtils.isEmpty(searchText) && !noTagClicked) {
// if no search filters available // if no search filters available
firstPageDistributionSets = getDistributionSetManagement() firstPageDistributionSets = getDistributionSetManagement()
.findByCompleted(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), true); .findByCompleted(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), true);
} else { } else {
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
.setTagNames(distributionTags).build(); .setTagNames(distributionTags).build();
firstPageDistributionSets = getDistributionSetManagement().findByDistributionSetFilter( firstPageDistributionSets = getDistributionSetManagement().findByDistributionSetFilter(
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilter); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilter);
} }
final long size = firstPageDistributionSets.getTotalElements(); final long size = firstPageDistributionSets.getTotalElements();

View File

@@ -27,7 +27,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
@@ -110,18 +109,15 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
final List<ProxyTarget> proxyTargetBeans = new ArrayList<>(); final List<ProxyTarget> proxyTargetBeans = new ArrayList<>();
if (pinnedDistId != null) { if (pinnedDistId != null) {
targetBeans = getTargetManagement().findByFilterOrderByLinkedDistributionSet( targetBeans = getTargetManagement().findByFilterOrderByLinkedDistributionSet(
new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, new OffsetBasedPageRequest(startIndex, count, sort), pinnedDistId,
new FilterParams(status, overdueState, searchText, distributionId, noTagClicked, targetTags)); new FilterParams(status, overdueState, searchText, distributionId, noTagClicked, targetTags));
} else if (null != targetFilterQueryId) { } else if (null != targetFilterQueryId) {
targetBeans = getTargetManagement().findByTargetFilterQuery(
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
targetFilterQueryId);
} else if (!isAnyFilterSelected()) {
targetBeans = getTargetManagement() targetBeans = getTargetManagement()
.findAll(PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); .findByTargetFilterQuery(new OffsetBasedPageRequest(startIndex, count, sort), targetFilterQueryId);
} else if (!isAnyFilterSelected()) {
targetBeans = getTargetManagement().findAll(new OffsetBasedPageRequest(startIndex, count, sort));
} else { } else {
targetBeans = getTargetManagement().findByFilters( targetBeans = getTargetManagement().findByFilters(new OffsetBasedPageRequest(startIndex, count, sort),
PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
new FilterParams(status, overdueState, searchText, distributionId, noTagClicked, targetTags)); new FilterParams(status, overdueState, searchText, distributionId, noTagClicked, targetTags));
} }
for (final Target targ : targetBeans) { for (final Target targ : targetBeans) {

View File

@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter; import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
@@ -25,7 +26,6 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
@@ -83,7 +83,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
distBeans = firstPageDistributionSets; distBeans = firstPageDistributionSets;
} else { } else {
distBeans = getDistributionSetManagement().findByDistributionSetFilter( distBeans = getDistributionSetManagement().findByDistributionSetFilter(
PageRequest.of(startIndex / count, count, sort), distributionSetFilter); new OffsetBasedPageRequest(startIndex, count, sort), distributionSetFilter);
} }
return createProxyDistributions(distBeans); return createProxyDistributions(distBeans);
} }
@@ -119,8 +119,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
.setIsComplete(true).build(); .setIsComplete(true).build();
firstPageDistributionSets = getDistributionSetManagement() firstPageDistributionSets = getDistributionSetManagement().findByDistributionSetFilter(
.findByDistributionSetFilter(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilter); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), distributionSetFilter);
final long size = firstPageDistributionSets.getTotalElements(); final long size = firstPageDistributionSets.getTotalElements();
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;

View File

@@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
@@ -21,7 +22,6 @@ import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererDa
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
@@ -89,8 +89,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
@Override @Override
protected List<ProxyRollout> loadBeans(final int startIndex, final int count) { protected List<ProxyRollout> loadBeans(final int startIndex, final int count) {
final Slice<Rollout> rolloutBeans; final Slice<Rollout> rolloutBeans;
final PageRequest pageRequest = PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, final PageRequest pageRequest = new OffsetBasedPageRequest(startIndex, count, sort);
SPUIDefinitions.PAGE_SIZE, sort);
if (StringUtils.isEmpty(searchText)) { if (StringUtils.isEmpty(searchText)) {
rolloutBeans = getRolloutManagement().findAllWithDetailedStatus(pageRequest, false); rolloutBeans = getRolloutManagement().findAllWithDetailedStatus(pageRequest, false);
} else { } else {

View File

@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -30,7 +31,6 @@ import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
@@ -105,7 +105,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
proxyRolloutGroupsList = firstPageRolloutGroupSets.getContent(); proxyRolloutGroupsList = firstPageRolloutGroupSets.getContent();
} else { } else {
proxyRolloutGroupsList = getRolloutGroupManagement() proxyRolloutGroupsList = getRolloutGroupManagement()
.findByRolloutWithDetailedStatus(PageRequest.of(startIndex / count, count), rolloutId) .findByRolloutWithDetailedStatus(new OffsetBasedPageRequest(startIndex, count), rolloutId)
.getContent(); .getContent();
} }
} }
@@ -156,8 +156,8 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
long size = 0; long size = 0;
if (rolloutId != null) { if (rolloutId != null) {
try { try {
firstPageRolloutGroupSets = getRolloutGroupManagement() firstPageRolloutGroupSets = getRolloutGroupManagement().findByRolloutWithDetailedStatus(
.findByRolloutWithDetailedStatus(PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutId); new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutId);
size = firstPageRolloutGroupSets.getTotalElements(); size = firstPageRolloutGroupSets.getTotalElements();
} catch (final EntityNotFoundException e) { } catch (final EntityNotFoundException e) {
LOG.error("Rollout does not exists. Redirect to Rollouts overview", e); LOG.error("Rollout does not exists. Redirect to Rollouts overview", e);

View File

@@ -14,6 +14,7 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -29,7 +30,6 @@ import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
@@ -90,7 +90,7 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
return rolloutGroup return rolloutGroup
.map(group -> getProxyRolloutGroupTargetsList( .map(group -> getProxyRolloutGroupTargetsList(
getRolloutGroupManagement().findAllTargetsOfRolloutGroupWithActionStatus( getRolloutGroupManagement().findAllTargetsOfRolloutGroupWithActionStatus(
PageRequest.of(startIndex / count, count), group.getId()).getContent())) new OffsetBasedPageRequest(startIndex, count), group.getId()).getContent()))
.orElse(Collections.emptyList()); .orElse(Collections.emptyList());
} }
@@ -137,7 +137,7 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
try { try {
firstPageTargetSets = rolloutGroup firstPageTargetSets = rolloutGroup
.map(group -> getRolloutGroupManagement().findAllTargetsOfRolloutGroupWithActionStatus( .map(group -> getRolloutGroupManagement().findAllTargetsOfRolloutGroupWithActionStatus(
PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort), group.getId())) new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), group.getId()))
.orElse(null); .orElse(null);
size = firstPageTargetSets == null ? 0 : firstPageTargetSets.getTotalElements(); size = firstPageTargetSets == null ? 0 : firstPageTargetSets.getTotalElements();