Feature target type filter (#1197)
* Added Target type filter with drag and drop support Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the unused enums and target type filter button class Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Resolved merge conflicts Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed java doc issue with the method link in the comment Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the IN query overflow for target Type assignment Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed Review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -27,9 +27,11 @@ public class FilterParams {
|
||||
private final Boolean selectTargetWithNoTag;
|
||||
private final String[] filterByTagNames;
|
||||
private final Long filterByDistributionId;
|
||||
private final Boolean selectTargetWithNoTargetType;
|
||||
private final Long filterByTargetType;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor for the filter parameters of a Simple Filter.
|
||||
*
|
||||
* @param filterByInstalledOrAssignedDistributionSetId
|
||||
* if set, a filter is added for the given
|
||||
@@ -56,6 +58,34 @@ public class FilterParams {
|
||||
this.filterByDistributionId = filterByInstalledOrAssignedDistributionSetId;
|
||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||
this.filterByTagNames = filterByTagNames;
|
||||
this.selectTargetWithNoTargetType = false;
|
||||
this.filterByTargetType = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the filter parameters of a Type Filter.
|
||||
*
|
||||
* @param filterBySearchText
|
||||
* if set, a filter is added for the given search text
|
||||
* @param filterByInstalledOrAssignedDistributionSetId
|
||||
* if set, a filter is added for the given
|
||||
* {@link DistributionSet#getId()}
|
||||
* @param selectTargetWithNoType
|
||||
* if true, a filter is added with no type
|
||||
* @param filterByType
|
||||
* if set, a filter is added for the given target type
|
||||
*/
|
||||
public FilterParams(final String filterBySearchText, final Long filterByInstalledOrAssignedDistributionSetId,
|
||||
final Boolean selectTargetWithNoType, final Long filterByType) {
|
||||
this.filterBySearchText = filterBySearchText;
|
||||
this.filterByDistributionId = filterByInstalledOrAssignedDistributionSetId;
|
||||
this.filterByStatus = null;
|
||||
this.overdueState = null;
|
||||
this.selectTargetWithNoTag = false;
|
||||
this.filterByTagNames = null;
|
||||
this.selectTargetWithNoTargetType = selectTargetWithNoType;
|
||||
this.filterByTargetType = filterByType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,4 +150,23 @@ public class FilterParams {
|
||||
public String[] getFilterByTagNames() {
|
||||
return filterByTagNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the flag indicating if no target type filter is used. <br>
|
||||
* If set to <code>false</code> this filter is disabled.
|
||||
*
|
||||
* @return the flag indicating if no target type filter is used
|
||||
*/
|
||||
public Boolean getSelectTargetWithNoTargetType() {
|
||||
return selectTargetWithNoTargetType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target type
|
||||
*
|
||||
* @return the target type that are used to filter for
|
||||
*/
|
||||
public Long getFilterByTargetType() {
|
||||
return filterByTargetType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetUpdate;
|
||||
@@ -35,12 +27,22 @@ import org.eclipse.hawkbit.repository.model.TargetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Management service for {@link Target}s.
|
||||
*
|
||||
@@ -106,11 +108,29 @@ public interface TargetManagement {
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if distribution set with given ID does not exist
|
||||
*
|
||||
* @deprecated this method {@link TargetManagement#countByFilters(FilterParams)} should be used instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long countByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
|
||||
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
|
||||
|
||||
/**
|
||||
* Count {@link Target}s for all the given filter parameters.
|
||||
*
|
||||
* @param filterParams
|
||||
* the filters to apply; only filters are enabled that have
|
||||
* non-null value; filters are AND-gated
|
||||
*
|
||||
* @return the found number {@link Target}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if distribution set with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long countByFilters(@NotNull final FilterParams filterParams);
|
||||
|
||||
/**
|
||||
* Counts number of targets with given with given distribution set Id
|
||||
*
|
||||
@@ -607,6 +627,38 @@ public interface TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> controllerIds, @NotEmpty String tagName);
|
||||
|
||||
|
||||
/**
|
||||
* Initiates {@link TargetType} assignment to given {@link Target}s. If some
|
||||
* targets in the list have the {@link TargetType} not yet assigned, they will
|
||||
* get assigned. If all targets are already of that type, there will be no
|
||||
* un-assignment.
|
||||
*
|
||||
* @param controllerIds
|
||||
* to set the type to
|
||||
* @param typeId
|
||||
* to assign targets to
|
||||
* @return {@link TargetTypeAssignmentResult} with all meta data of the
|
||||
* assignment outcome.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target type with given id does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTypeAssignmentResult assignType(@NotEmpty Collection<String> controllerIds, @NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* Initiates {@link TargetType} un-assignment to given {@link Target}s. The type
|
||||
* of the targets will be set to {@code null}
|
||||
*
|
||||
* @param controllerIds
|
||||
* to remove the type from
|
||||
* @return {@link TargetTypeAssignmentResult} with all meta data of the
|
||||
* assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTypeAssignmentResult unAssignType(@NotEmpty Collection<String> controllerIds);
|
||||
|
||||
/**
|
||||
* Un-assign a {@link TargetTag} assignment to given {@link Target}.
|
||||
*
|
||||
@@ -638,6 +690,8 @@ public interface TargetManagement {
|
||||
*
|
||||
* @param controllerID
|
||||
* to un-assign for
|
||||
* @param targetTypeId
|
||||
* Target type id
|
||||
* @return the unassigned target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
@@ -854,4 +908,5 @@ public interface TargetManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
TargetMetadata updateMetadata(@NotEmpty String controllerId, @NotNull MetaData metadata);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Result object for {@link TargetType} assignments.
|
||||
*
|
||||
*/
|
||||
public class TargetTypeAssignmentResult extends AbstractAssignmentResult<Target> {
|
||||
|
||||
private final TargetType targetType;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param alreadyAssigned
|
||||
* count of already assigned (ignored) elements
|
||||
* @param assigned
|
||||
* {@link List} of assigned {@link Target}s.
|
||||
* @param unassigned
|
||||
* {@link List} of unassigned {@link Target}s.
|
||||
* @param targetType
|
||||
* the assigned or unassigned tag
|
||||
*/
|
||||
public TargetTypeAssignmentResult(final int alreadyAssigned, final List<? extends Target> assigned,
|
||||
final List<? extends Target> unassigned, final TargetType targetType) {
|
||||
super(alreadyAssigned, assigned, unassigned);
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
public TargetType getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user