Fix issues from static code analysis
Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
|
||||
/**
|
||||
* Encapsulates a set of filters that may be specified (optionally). Properties
|
||||
* that are not specified (e.g. <code>null</code> for simple properties) When
|
||||
* applied, these filters are AND-gated.
|
||||
*
|
||||
*/
|
||||
public class FilterParams {
|
||||
|
||||
Collection<TargetUpdateStatus> filterByStatus;
|
||||
Boolean overdueState;
|
||||
String filterBySearchText;
|
||||
Boolean selectTargetWithNoTag;
|
||||
String[] filterByTagNames;
|
||||
Long filterByDistributionId;
|
||||
|
||||
public FilterParams(Long filterByDistributionId, Collection<TargetUpdateStatus> filterByStatus,
|
||||
Boolean overdueState, String filterBySearchText, Boolean selectTargetWithNoTag,
|
||||
String... filterByTagNames) {
|
||||
this.filterByStatus = filterByStatus;
|
||||
this.overdueState = overdueState;
|
||||
this.filterBySearchText = filterBySearchText;
|
||||
this.filterByDistributionId = filterByDistributionId;
|
||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||
this.filterByTagNames = filterByTagNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets {@link DistributionSet#getId()} to filter the result. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
*
|
||||
* @return {@link DistributionSet#getId()} to filter the result
|
||||
*/
|
||||
public Long getFilterByDistributionId() {
|
||||
return filterByDistributionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link DistributionSet#getId()} to filter the result.
|
||||
*
|
||||
* @param filterByDistributionId
|
||||
*/
|
||||
public void setFilterByDistributionId(Long filterByDistributionId) {
|
||||
this.filterByDistributionId = filterByDistributionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of target states to filter for. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
*
|
||||
* @return collection of target states to filter for
|
||||
*/
|
||||
public Collection<TargetUpdateStatus> getFilterByStatus() {
|
||||
return filterByStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the collection of target states to filter for.
|
||||
*
|
||||
* @param filterByStatus
|
||||
*/
|
||||
public void setFilterByStatus(Collection<TargetUpdateStatus> filterByStatus) {
|
||||
this.filterByStatus = filterByStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag for overdue filter; if set to <code>true</code>, the
|
||||
* overdue filter is activated. Overdued targets a targets that did not
|
||||
* respond during the configured intervals: poll_itvl + overdue_itvl. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
*
|
||||
* @return flag for overdue filter activation
|
||||
*/
|
||||
public Boolean getOverdueState() {
|
||||
return overdueState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag for overdue filter; if set to <code>true</code>, the
|
||||
* overdue filter is activated.
|
||||
*
|
||||
* @param overdueState
|
||||
*/
|
||||
public void setOverdueState(Boolean overdueState) {
|
||||
this.overdueState = overdueState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the search text to filter for. This is used to find targets having
|
||||
* the text anywhere in name or description <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
*
|
||||
* @return the search text to filter for
|
||||
*/
|
||||
public String getFilterBySearchText() {
|
||||
return filterBySearchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the search text to filter for.
|
||||
*
|
||||
* @param filterBySearchText
|
||||
*/
|
||||
public void setFilterBySearchText(String filterBySearchText) {
|
||||
this.filterBySearchText = filterBySearchText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag indicating if tagging filter is used. <br>
|
||||
* If set to <code>null</code> this filter is disabled.
|
||||
*
|
||||
* @return the flag indicating if tagging filter is used
|
||||
*/
|
||||
public Boolean getSelectTargetWithNoTag() {
|
||||
return selectTargetWithNoTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag indicating if tagging filter is used.
|
||||
*
|
||||
* @param selectTargetWithNoTag
|
||||
*/
|
||||
public void setSelectTargetWithNoTag(Boolean selectTargetWithNoTag) {
|
||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags that are used to filter for. The activation of this filter
|
||||
* is done by {@link #setSelectTargetWithNoTag(Boolean)}.
|
||||
*
|
||||
* @return the tags that are used to filter for
|
||||
*/
|
||||
public String[] getFilterByTagNames() {
|
||||
return filterByTagNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tags that are used to filter for.
|
||||
*
|
||||
* @param filterByTagNames
|
||||
*/
|
||||
public void setFilterByTagNames(String[] filterByTagNames) {
|
||||
this.filterByTagNames = filterByTagNames;
|
||||
}
|
||||
}
|
||||
@@ -480,36 +480,15 @@ public interface TargetManagement {
|
||||
* the page request to page the result set
|
||||
* @param orderByDistributionId
|
||||
* {@link DistributionSet#getId()} to be ordered by
|
||||
* @param filterByDistributionId
|
||||
* {@link DistributionSet#getId()} to be filter the result. Set
|
||||
* to <code>null</code> in case this is not required.
|
||||
* @param filterByStatus
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
* @param overdueState
|
||||
* find targets that are overdue (targets that did not respond
|
||||
* during the configured intervals: poll_itvl + overdue_itvl).
|
||||
* @param filterBySearchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param filterByTagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
* @param filterParams
|
||||
* the filters to apply; only filters are enabled that have
|
||||
* non-null value; filters are AND-gated
|
||||
* @return a paged result {@link Page} of the {@link Target}s in a defined
|
||||
* order.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
||||
@NotNull Long orderByDistributionId, Long filterByDistributionId,
|
||||
Collection<TargetUpdateStatus> filterByStatus, Boolean overdueState, String filterBySearchText,
|
||||
Boolean selectTargetWithNoTag, String... filterByTagNames);
|
||||
@NotNull Long orderByDistributionId, FilterParams filterParams);
|
||||
|
||||
/**
|
||||
* retrieves a list of {@link Target}s by their controller ID with details,
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.persistence.criteria.Order;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||
@@ -281,8 +282,10 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
public Slice<Target> findTargetByFilters(final Pageable pageable, final Collection<TargetUpdateStatus> status,
|
||||
final Boolean overdueState, final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(status, overdueState, searchText,
|
||||
installedOrAssignedDistributionSetId, selectTargetWithNoTag, true, tagNames);
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
||||
selectTargetWithNoTag, tagNames),
|
||||
true);
|
||||
return findByCriteriaAPI(pageable, specList);
|
||||
}
|
||||
|
||||
@@ -290,31 +293,35 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
public Long countTargetByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
|
||||
final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(status, overdueState, searchText,
|
||||
installedOrAssignedDistributionSetId, selectTargetWithNoTag, true, tagNames);
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
||||
selectTargetWithNoTag, tagNames),
|
||||
true);
|
||||
return countByCriteriaAPI(specList);
|
||||
}
|
||||
|
||||
private static List<Specification<JpaTarget>> buildSpecificationList(final Collection<TargetUpdateStatus> status,
|
||||
final Boolean overdueState, final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoTag, final boolean fetch, final String... tagNames) {
|
||||
private static List<Specification<JpaTarget>> buildSpecificationList(final FilterParams filterParams,
|
||||
final boolean fetch) {
|
||||
final List<Specification<JpaTarget>> specList = new ArrayList<>();
|
||||
if (status != null && !status.isEmpty()) {
|
||||
specList.add(TargetSpecifications.hasTargetUpdateStatus(status, fetch));
|
||||
if (filterParams.getFilterByStatus() != null && !filterParams.getFilterByStatus().isEmpty()) {
|
||||
specList.add(TargetSpecifications.hasTargetUpdateStatus(filterParams.getFilterByStatus(), fetch));
|
||||
}
|
||||
if (overdueState != null) {
|
||||
if (filterParams.getOverdueState() != null) {
|
||||
specList.add(
|
||||
TargetSpecifications.isOverdue(new TimestampCalculator().calculateOverdueTimestamp()));
|
||||
}
|
||||
if (installedOrAssignedDistributionSetId != null) {
|
||||
if (filterParams.getFilterByDistributionId() != null) {
|
||||
specList.add(
|
||||
TargetSpecifications.hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId));
|
||||
TargetSpecifications
|
||||
.hasInstalledOrAssignedDistributionSet(filterParams.getFilterByDistributionId()));
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
||||
if (!Strings.isNullOrEmpty(filterParams.getFilterBySearchText())) {
|
||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(filterParams.getFilterBySearchText()));
|
||||
}
|
||||
if (selectTargetWithNoTag != null && (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0))) {
|
||||
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
||||
if (filterParams.getSelectTargetWithNoTag() != null && (filterParams.getSelectTargetWithNoTag()
|
||||
|| (filterParams.getFilterByTagNames() != null && filterParams.getFilterByTagNames().length > 0))) {
|
||||
specList.add(TargetSpecifications.hasTags(filterParams.getFilterByTagNames(),
|
||||
filterParams.getSelectTargetWithNoTag()));
|
||||
}
|
||||
return specList;
|
||||
}
|
||||
@@ -428,10 +435,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetsAllOrderByLinkedDistributionSet(final Pageable pageable,
|
||||
final Long orderByDistributionId, final Long filterByDistributionId,
|
||||
final Collection<TargetUpdateStatus> filterByStatus, final Boolean overdueState,
|
||||
final String filterBySearchText,
|
||||
final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
||||
final Long orderByDistributionId, final FilterParams filterParams) {
|
||||
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<JpaTarget> query = cb.createQuery(JpaTarget.class);
|
||||
final Root<JpaTarget> targetRoot = query.from(JpaTarget.class);
|
||||
@@ -454,8 +459,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
// build the specifications and then to predicates necessary by the
|
||||
// given filters
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||
buildSpecificationList(filterByStatus, overdueState, filterBySearchText, filterByDistributionId,
|
||||
selectTargetWithNoTag, true, filterByTagNames),
|
||||
buildSpecificationList(filterParams, true),
|
||||
targetRoot, query, cb);
|
||||
|
||||
// if we have some predicates then add it to the where clause of the
|
||||
@@ -529,9 +533,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
targetRoot.get(JpaTarget_.controllerId), targetRoot.get(JpaTarget_.name), targetRoot.get(sortProperty));
|
||||
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||
buildSpecificationList(filterByStatus, overdueState, filterBySearchText,
|
||||
installedOrAssignedDistributionSetId,
|
||||
selectTargetWithNoTag, false, filterByTagNames),
|
||||
buildSpecificationList(new FilterParams(installedOrAssignedDistributionSetId, filterByStatus,
|
||||
overdueState, filterBySearchText,
|
||||
selectTargetWithNoTag, filterByTagNames), false),
|
||||
targetRoot, multiselect, cb);
|
||||
|
||||
// if we have some predicates then add it to the where clause of the
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
* <p>
|
||||
* This is used in context of string replacement.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface VirtualPropertyLookup {
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,9 +50,9 @@ public class VirtualPropertyResolver implements VirtualPropertyLookup {
|
||||
public String lookup(String rhs) {
|
||||
String resolved = null;
|
||||
|
||||
if ("now_ts".equals(rhs.toLowerCase())) {
|
||||
if ("now_ts".equalsIgnoreCase(rhs)) {
|
||||
resolved = String.valueOf(Instant.now().toEpochMilli());
|
||||
} else if ("overdue_ts".equals(rhs.toLowerCase())) {
|
||||
} else if ("overdue_ts".equalsIgnoreCase(rhs)) {
|
||||
resolved = String.valueOf(getTimestampCalculator().calculateOverdueTimestamp());
|
||||
}
|
||||
return resolved;
|
||||
|
||||
@@ -16,21 +16,16 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.eclipse.hawkbit.ControllerPollProperties;
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantConfigurationManagementHolder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -39,7 +34,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Slice;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -746,7 +740,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targInstalled = sendUpdateActionStatusToTargets(ds, targInstalled, Status.FINISHED, "installed");
|
||||
|
||||
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
|
||||
null, null, null, null, Boolean.FALSE, new String[0]);
|
||||
new FilterParams(null, null, null, null, Boolean.FALSE, new String[0]));
|
||||
|
||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||
|
||||
@@ -801,7 +795,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targInstalled = sendUpdateActionStatusToTargets(ds, targInstalled, Status.FINISHED, "installed");
|
||||
|
||||
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
|
||||
null, null, Boolean.TRUE, null, Boolean.FALSE, new String[0]);
|
||||
new FilterParams(null, null, Boolean.TRUE, null, Boolean.FALSE, new String[0]));
|
||||
|
||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ package org.eclipse.hawkbit.ui.management.targettable;
|
||||
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER;
|
||||
import static org.springframework.data.domain.Sort.Direction.ASC;
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
import static org.springframework.data.domain.Sort.Direction.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -40,6 +40,7 @@ import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
||||
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.primitives.Booleans;
|
||||
|
||||
/**
|
||||
* Simple implementation of generics bean query which dynamically loads a batch
|
||||
@@ -115,7 +116,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
if (pinnedDistId != null) {
|
||||
targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet(
|
||||
new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId,
|
||||
distributionId, status, overdueState, searchText, noTagClicked, targetTags);
|
||||
new FilterParams(distributionId, status, overdueState, searchText, noTagClicked, targetTags));
|
||||
} else if (null != targetFilterQuery) {
|
||||
targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery,
|
||||
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
|
||||
@@ -185,8 +186,9 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
}
|
||||
|
||||
private Boolean anyFilterSelected() {
|
||||
if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()
|
||||
&& !isOverdueFilterEnabled()) {
|
||||
int enabledFiltersCount = Booleans.countTrue(status != null, distributionId != null,
|
||||
!Strings.isNullOrEmpty(searchText), isTagSelected(), isOverdueFilterEnabled());
|
||||
if (enabledFiltersCount == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -8,14 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.targettable;
|
||||
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_DISTRIBUTION;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TAG;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TEXT;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TAG;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TEXT;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -26,6 +19,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
@@ -63,11 +57,11 @@ import org.eclipse.hawkbit.ui.management.state.TargetTableFilters;
|
||||
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -902,26 +896,33 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
|
||||
}
|
||||
|
||||
final long size = getTargetsCountWithFilter(totalTargetsCount, status, overdueState, targetTags, distributionId,
|
||||
searchText, noTagClicked, pinnedDistId);
|
||||
final long size = getTargetsCountWithFilter(totalTargetsCount, pinnedDistId,
|
||||
new FilterParams(distributionId, status, overdueState, searchText, noTagClicked, targetTags));
|
||||
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
}
|
||||
}
|
||||
|
||||
private long getTargetsCountWithFilter(final long totalTargetsCount, final Collection<TargetUpdateStatus> status,
|
||||
final Boolean overdueState, final String[] targetTags, final Long distributionId, final String searchText,
|
||||
final Boolean noTagClicked, final Long pinnedDistId) {
|
||||
private long getTargetsCountWithFilter(final long totalTargetsCount,
|
||||
// final Collection<TargetUpdateStatus> status,
|
||||
// final Boolean overdueState, final String[] targetTags, final Long
|
||||
// distributionId, final String searchText,
|
||||
// final Boolean noTagClicked
|
||||
final Long pinnedDistId, final FilterParams filterParams) {
|
||||
final long size;
|
||||
if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) {
|
||||
size = targetManagement.countTargetByTargetFilterQuery(
|
||||
managementUIState.getTargetTableFilters().getTargetFilterQuery().get());
|
||||
} else if (!anyFilterSelected(status, pinnedDistId, noTagClicked, targetTags, searchText)) {
|
||||
} else if (!anyFilterSelected(filterParams.getFilterByStatus(), pinnedDistId,
|
||||
filterParams.getSelectTargetWithNoTag(), filterParams.getFilterByTagNames(),
|
||||
filterParams.getFilterBySearchText())) {
|
||||
size = totalTargetsCount;
|
||||
} else {
|
||||
size = targetManagement.countTargetByFilters(status, overdueState, searchText, distributionId, noTagClicked,
|
||||
targetTags);
|
||||
size = targetManagement.countTargetByFilters(filterParams.getFilterByStatus(),
|
||||
filterParams.getOverdueState(), filterParams.getFilterBySearchText(),
|
||||
filterParams.getFilterByDistributionId(), filterParams.getSelectTargetWithNoTag(),
|
||||
filterParams.getFilterByTagNames());
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user