introduced paging while retrieving the target/ds tags (#1006)

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
Bondar Bogdan
2020-09-08 13:56:18 +02:00
committed by GitHub
parent 29bb9194a6
commit 7ca515fb44
4 changed files with 13 additions and 14 deletions

View File

@@ -33,8 +33,6 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
*/ */
public abstract class AbstractTagToken<T extends ProxyNamedEntity> public abstract class AbstractTagToken<T extends ProxyNamedEntity>
implements TagAssignmentListener, MasterEntityAwareComponent<T> { implements TagAssignmentListener, MasterEntityAwareComponent<T> {
protected static final int MAX_TAG_QUERY = 1000;
protected TagPanelLayout tagPanelLayout; protected TagPanelLayout tagPanelLayout;
protected final SpPermissionChecker checker; protected final SpPermissionChecker checker;

View File

@@ -24,9 +24,9 @@ import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
import org.eclipse.hawkbit.ui.common.event.EventTopics; import org.eclipse.hawkbit.ui.common.event.EventTopics;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
@@ -106,15 +106,16 @@ public class DistributionTagToken extends AbstractTagToken<ProxyDistributionSet>
@Override @Override
protected List<ProxyTag> getAllTags() { protected List<ProxyTag> getAllTags() {
return distributionSetTagManagement.findAll(PageRequest.of(0, MAX_TAG_QUERY)).getContent().stream() return HawkbitCommonUtil.getEntitiesByPageableProvider(distributionSetTagManagement::findAll).stream()
.map(tagMapper::map).collect(Collectors.toList()); .map(tagMapper::map).collect(Collectors.toList());
} }
@Override @Override
protected List<ProxyTag> getAssignedTags() { protected List<ProxyTag> getAssignedTags() {
return getMasterEntity().map(masterEntity -> distributionSetTagManagement return getMasterEntity().map(masterEntity -> HawkbitCommonUtil
.findByDistributionSet(PageRequest.of(0, MAX_TAG_QUERY), masterEntity.getId()).getContent().stream() .getEntitiesByPageableProvider(
.map(tagMapper::map).collect(Collectors.toList())).orElse(Collections.emptyList()); p -> distributionSetTagManagement.findByDistributionSet(p, masterEntity.getId()))
.stream().map(tagMapper::map).collect(Collectors.toList())).orElse(Collections.emptyList());
} }
@Override @Override

View File

@@ -24,9 +24,9 @@ import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload;
import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType; import org.eclipse.hawkbit.ui.common.event.EntityModifiedEventPayload.EntityModifiedEventType;
import org.eclipse.hawkbit.ui.common.event.EventTopics; import org.eclipse.hawkbit.ui.common.event.EventTopics;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventBus.UIEventBus;
/** /**
@@ -106,15 +106,15 @@ public class TargetTagToken extends AbstractTagToken<ProxyTarget> {
@Override @Override
protected List<ProxyTag> getAllTags() { protected List<ProxyTag> getAllTags() {
return targetTagManagement.findAll(PageRequest.of(0, MAX_TAG_QUERY)).stream() return HawkbitCommonUtil.getEntitiesByPageableProvider(targetTagManagement::findAll).stream()
.map(tag -> new ProxyTag(tag.getId(), tag.getName(), tag.getColour())).collect(Collectors.toList()); .map(tag -> new ProxyTag(tag.getId(), tag.getName(), tag.getColour())).collect(Collectors.toList());
} }
@Override @Override
protected List<ProxyTag> getAssignedTags() { protected List<ProxyTag> getAssignedTags() {
return getMasterEntity().map(masterEntity -> targetTagManagement return getMasterEntity().map(masterEntity -> HawkbitCommonUtil
.findByTarget(PageRequest.of(0, MAX_TAG_QUERY), masterEntity.getControllerId()).stream() .getEntitiesByPageableProvider(p -> targetTagManagement.findByTarget(p, masterEntity.getControllerId()))
.map(tagMapper::map).collect(Collectors.toList())).orElse(Collections.emptyList()); .stream().map(tagMapper::map).collect(Collectors.toList())).orElse(Collections.emptyList());
} }
@Override @Override

View File

@@ -20,9 +20,9 @@ import org.eclipse.hawkbit.ui.common.data.mappers.TagToProxyTagMapper;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTag;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken; import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.data.domain.PageRequest;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -60,7 +60,7 @@ public class TargetBulkTokenTags extends AbstractTagToken<ProxyTarget> {
@Override @Override
protected List<ProxyTag> getAllTags() { protected List<ProxyTag> getAllTags() {
return tagManagement.findAll(PageRequest.of(0, MAX_TAG_QUERY)).stream() return HawkbitCommonUtil.getEntitiesByPageableProvider(tagManagement::findAll).stream()
.map(tag -> new ProxyTag(tag.getId(), tag.getName(), tag.getColour())).collect(Collectors.toList()); .map(tag -> new ProxyTag(tag.getId(), tag.getName(), tag.getColour())).collect(Collectors.toList());
} }