Add support for target tag retrieval via REST (#1782)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-07-24 14:01:40 +03:00
committed by GitHub
parent c253a4fccd
commit 3189531162
8 changed files with 102 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.persistence.EntityManager;
@@ -178,6 +179,13 @@ public class JpaTargetManagement implements TargetManagement {
return targetRepository.count();
}
@Override
public Set<TargetTag> getTagsByControllerId(@NotEmpty String controllerId) {
// the method has PreAuthorized by itself
return getByControllerID(controllerId).map(JpaTarget.class::cast).map(JpaTarget::getTags)
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
}
@Override
@Transactional
@Retryable(include = {