|
|
|
|
@@ -53,7 +53,6 @@ import org.hibernate.validator.constraints.NotEmpty;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.data.domain.Slice;
|
|
|
|
|
import org.springframework.data.domain.SliceImpl;
|
|
|
|
|
@@ -155,7 +154,7 @@ public class TargetManagement {
|
|
|
|
|
* @return List of found{@link Target}s
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
|
|
|
public List<Target> findTargetsByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
|
|
|
|
public List<Target> findTargetByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
|
|
|
|
return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -331,10 +330,10 @@ public class TargetManagement {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
|
|
|
|
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
|
|
|
|
* details, i.e. NO {@link Target#getTags()} and
|
|
|
|
|
* {@link Target#getActiveActions()} possible including the filtering based
|
|
|
|
|
* on the given {@code spec}.
|
|
|
|
|
* {@link Target#getActiveActions()} possible including additional filtering
|
|
|
|
|
* based on the given {@code spec}.
|
|
|
|
|
*
|
|
|
|
|
* @param distributionSetID
|
|
|
|
|
* the ID of the {@link DistributionSet}
|
|
|
|
|
@@ -374,7 +373,8 @@ public class TargetManagement {
|
|
|
|
|
/**
|
|
|
|
|
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
|
|
|
|
* details, i.e. NO {@link Target#getTags()} and
|
|
|
|
|
* {@link Target#getActiveActions()} possible.
|
|
|
|
|
* {@link Target#getActiveActions()} possible including additional filtering
|
|
|
|
|
* based on the given {@code spec}.
|
|
|
|
|
*
|
|
|
|
|
* @param distributionSetId
|
|
|
|
|
* the ID of the {@link DistributionSet}
|
|
|
|
|
@@ -490,7 +490,7 @@ public class TargetManagement {
|
|
|
|
|
if (!Strings.isNullOrEmpty(searchText)) {
|
|
|
|
|
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
|
|
|
|
}
|
|
|
|
|
if (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0)) {
|
|
|
|
|
if (selectTargetWithNoTag != null && (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0))) {
|
|
|
|
|
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
|
|
|
|
}
|
|
|
|
|
return specList;
|
|
|
|
|
@@ -810,14 +810,12 @@ public class TargetManagement {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* finds all {@link Target#getControllerId()} for all the given parameters.
|
|
|
|
|
* Finds all targets for all the given parameters but returns not the full
|
|
|
|
|
* target but {@link TargetIdName}.
|
|
|
|
|
*
|
|
|
|
|
* @param pageRequest
|
|
|
|
|
* the pageRequest to enhance the query for paging and sorting
|
|
|
|
|
* @param filterByDistributionId
|
|
|
|
|
* to find targets having the {@link DistributionSet} as
|
|
|
|
|
* installed or assigned. 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.
|
|
|
|
|
@@ -825,28 +823,38 @@ public class TargetManagement {
|
|
|
|
|
* 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
|
|
|
|
|
*
|
|
|
|
|
* @return the found {@link Target}s
|
|
|
|
|
* @return the found {@link TargetIdName}s
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
|
|
|
public List<TargetIdName> findAllTargetIdsByFilters(final PageRequest pageRequest,
|
|
|
|
|
final Long filterByDistributionId, final Collection<TargetUpdateStatus> filterByStatus,
|
|
|
|
|
final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
|
|
|
|
public List<TargetIdName> findAllTargetIdsByFilters(@NotNull final Pageable pageRequest,
|
|
|
|
|
final Collection<TargetUpdateStatus> filterByStatus, final String filterBySearchText,
|
|
|
|
|
final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag,
|
|
|
|
|
final String... filterByTagNames) {
|
|
|
|
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
|
|
|
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
|
|
|
|
final Root<Target> targetRoot = query.from(Target.class);
|
|
|
|
|
List<Object[]> resultList;
|
|
|
|
|
|
|
|
|
|
String sortProperty = Target_.id.getName();
|
|
|
|
|
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
|
|
|
|
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
|
|
|
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
|
|
|
|
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
|
|
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
|
|
|
|
|
|
|
|
|
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
|
|
|
|
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
|
|
|
|
buildSpecificationList(filterByStatus, filterBySearchText, installedOrAssignedDistributionSetId,
|
|
|
|
|
selectTargetWithNoTag, false, filterByTagNames),
|
|
|
|
|
targetRoot, multiselect, cb);
|
|
|
|
|
|
|
|
|
|
@@ -862,24 +870,29 @@ public class TargetManagement {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Finds all {@link Target#getControllerId()} for all the given parameter
|
|
|
|
|
* {@link TargetFilterQuery}.
|
|
|
|
|
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
|
|
|
|
* and returns not the full target but {@link TargetIdName}.
|
|
|
|
|
*
|
|
|
|
|
* @param pageRequest
|
|
|
|
|
* the pageRequest to enhance the query for paging and sorting
|
|
|
|
|
* @param targetFilterQuery
|
|
|
|
|
* {@link TargetFilterQuery}
|
|
|
|
|
* @return the found {@link Target}s
|
|
|
|
|
* @return the found {@link TargetIdName}s
|
|
|
|
|
*/
|
|
|
|
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
|
|
|
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest,
|
|
|
|
|
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
|
|
|
|
|
@NotNull final TargetFilterQuery targetFilterQuery) {
|
|
|
|
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
|
|
|
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
|
|
|
|
final Root<Target> targetRoot = query.from(Target.class);
|
|
|
|
|
|
|
|
|
|
String sortProperty = Target_.id.getName();
|
|
|
|
|
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
|
|
|
|
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
|
|
|
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
|
|
|
|
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
|
|
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
|
|
|
|
|
|
|
|
|
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
|
|
|
|
final List<Specification<Target>> specList = new ArrayList<>();
|
|
|
|
|
@@ -1072,7 +1085,7 @@ public class TargetManagement {
|
|
|
|
|
return targetRepository.count(specs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Object[]> getTargetIdNameResultSet(final PageRequest pageRequest, final CriteriaBuilder cb,
|
|
|
|
|
private List<Object[]> getTargetIdNameResultSet(final Pageable pageRequest, final CriteriaBuilder cb,
|
|
|
|
|
final Root<Target> targetRoot, final CriteriaQuery<Object[]> multiselect) {
|
|
|
|
|
List<Object[]> resultList;
|
|
|
|
|
if (pageRequest.getSort() != null) {
|
|
|
|
|
|