@Transactional public class JpaTagPersistenceServiceImpl extends java.lang.Object implements JpaTagPersistenceService
Constructor and Description |
---|
JpaTagPersistenceServiceImpl(JpaTagRepository tagRepository)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
createTagIfNotExists(@NotBlank(message="Tag cannot be blank") java.lang.String tag)
Attempt to create a tag in the system if it doesn't already exist.
|
long |
deleteUnusedTags(@NotNull java.time.Instant createdThreshold)
Delete all tags from the database that aren't referenced which were created before the supplied created
threshold.
|
java.util.Optional<TagEntity> |
getTag(@NotBlank(message="Tag string to find can\'t be blank") java.lang.String tag)
Get a tag entity reference for the given tag string.
|
java.util.Set<TagEntity> |
getTags(@NotNull java.util.Set<java.lang.String> tags)
Get all the tag entity references that match the input set of tag strings.
|
public JpaTagPersistenceServiceImpl(JpaTagRepository tagRepository)
tagRepository
- The repository to use to perform CRUD operations on tagspublic void createTagIfNotExists(@NotBlank(message="Tag cannot be blank") @NotBlank(message="Tag cannot be blank") java.lang.String tag)
createTagIfNotExists
in interface TagPersistenceService
tag
- the tag to create. Not blank.public long deleteUnusedTags(@NotNull @NotNull java.time.Instant createdThreshold)
deleteUnusedTags
in interface TagPersistenceService
createdThreshold
- The instant in time where tags created before this time that aren't referenced
will be deleted. Inclusive@Transactional(readOnly=true) public java.util.Optional<TagEntity> getTag(@NotBlank(message="Tag string to find can\'t be blank") @NotBlank(message="Tag string to find can\'t be blank") java.lang.String tag)
getTag
in interface JpaTagPersistenceService
tag
- The tag to getOptional
or Optional.empty()
@Transactional(readOnly=true) public java.util.Set<TagEntity> getTags(@NotNull @NotNull java.util.Set<java.lang.String> tags)
getTags
in interface JpaTagPersistenceService
tags
- the tag strings to search fortags
doesn't exist in database the set returned
will consist of all other discovered tags. E.G. tags
is ("a", "b", "c") and only "b" and "c" are
in the database the returned set will contain "b" and "c". The method won't fail.