Add support for efficient tagging and BIG set of targets (#1844)
Adding a method with: * optimized payload - just controller ids * no response payload - not needed for that use-case * targeting - thousands of targets tagged at once Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -569,6 +569,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<Target> assignTag(final Collection<String> controllerIds, final long tagId) {
|
||||
final JpaTargetTag tag = targetTagRepository.findById(tagId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, tagId));
|
||||
|
||||
final List<JpaTarget> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithTagsInJoin(controllerIds));
|
||||
if (allTargets.size() < controllerIds.size()) {
|
||||
@@ -579,9 +582,6 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
targetRepository.getAccessController()
|
||||
.ifPresent(acm -> acm.assertOperationAllowed(AccessController.Operation.UPDATE, allTargets));
|
||||
|
||||
final JpaTargetTag tag = targetTagRepository.findById(tagId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, tagId));
|
||||
|
||||
allTargets.forEach(target -> target.addTag(tag));
|
||||
|
||||
final List<Target> result = allTargets.stream().map(targetRepository::save).map(Target.class::cast).toList();
|
||||
|
||||
Reference in New Issue
Block a user