Class MongoNodeRepositoryImpl
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.data.mongodb.repository.MongoRepository<NodeEntity,,String> org.springframework.data.repository.CrudRepository<NodeEntity,,String> org.springframework.data.repository.ListCrudRepository<NodeEntity,,String> org.springframework.data.repository.ListPagingAndSortingRepository<NodeEntity,,String> org.springframework.data.repository.PagingAndSortingRepository<NodeEntity,,String> org.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>,org.springframework.data.repository.Repository<NodeEntity,String>
- Direct Known Subclasses:
EncryptedMongoNodeRepositoryImpl
NodeEntity entities in MongoDB.
Implements the MongoRepository interface using MongoOperations
to perform database operations.
Activation of this repository is controlled by the
application.service.vault.encryption.enabled property: the bean is
instantiated when the value is false or the property is missing.
Provides CRUD operations including insertion, saving, batch operations, and
queries by Example, Sort or Pageable. It also supports
counting and removal of entities.
The findBy(Example, Function) method is not implemented and always
throws an UnsupportedOperationException.
This class extends BaseComponent and is intended for scenarios
where node encryption is disabled at the application level. It relies on
MongoOperations for thread-safe persistence of NodeEntity
documents.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcount()<S extends NodeEntity>
longcount(@NonNull org.springframework.data.domain.Example<S> example) longCounts notarized nodes (nodes with non-null notarization transaction id).voiddelete(@NonNull NodeEntity entity) voidvoiddeleteAll(@NonNull Iterable<? extends NodeEntity> entities) voiddeleteAllById(@NonNull Iterable<? extends String> ids) voiddeleteById(@NonNull String id) <S extends NodeEntity>
booleanexists(@NonNull org.springframework.data.domain.Example<S> example) booleanexistsById(@NonNull String id) @NonNull List<NodeEntity> findAll()<S extends NodeEntity>
@NonNull List<S> findAll(@NonNull org.springframework.data.domain.Example<S> example) <S extends NodeEntity>
@NonNull org.springframework.data.domain.Page<S> findAll(@NonNull org.springframework.data.domain.Example<S> example, @NonNull org.springframework.data.domain.Pageable pageable) <S extends NodeEntity>
@NonNull List<S> findAll(@NonNull org.springframework.data.domain.Example<S> example, @NonNull org.springframework.data.domain.Sort sort) @NonNull org.springframework.data.domain.Page<NodeEntity> findAll(@NonNull org.springframework.data.domain.Pageable pageable) @NonNull List<NodeEntity> findAll(@NonNull org.springframework.data.domain.Sort sort) @NonNull List<NodeEntity> findAllById(@NonNull Iterable<String> ids) <S extends NodeEntity,R>
RfindBy(@NonNull org.springframework.data.domain.Example<S> example, @NonNull Function<org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery<S>, R> queryFunction) org.springframework.data.domain.Page<NodeEntity> findByArchiveDateRange(Instant from, Instant to, org.springframework.data.domain.Pageable pageable) Retrieves node wrappers archived within the specified date range using pagination.@NonNull Optional<NodeEntity> findByKv(int kv) Retrieves node wrappers by encryption key version.Retrieves node wrappers by notarization transaction ID.org.springframework.data.domain.Page<NodeEntity> findNotarized(org.springframework.data.domain.Pageable pageable) Retrieves notarized node wrappers where the transaction id is not null.findNotarizedRandom(int size) Retrieves a random sample of notarized nodes.<S extends NodeEntity>
@NonNull Optional<S> findOne(@NonNull org.springframework.data.domain.Example<S> example) voidinit()Called after dependency injection is complete.<S extends NodeEntity>
@NonNull List<S> <S extends NodeEntity>
Sinsert(S entity) <S extends NodeEntity>
Ssave(S entity) <S extends NodeEntity>
@NonNull List<S> Methods inherited from class org.saidone.component.BaseComponent
setApplicationContext, shutDown, stop
-
Constructor Details
-
MongoNodeRepositoryImpl
public MongoNodeRepositoryImpl()
-
-
Method Details
-
init
@PostConstruct public void init()Called after dependency injection is complete. Logs a startup message indicating that the component is ready.The method verifies that the MongoDB connection is available at start-up. If the connection cannot be established the application is shut down to avoid running in an inconsistent state.
- Overrides:
initin classBaseComponent
-
insert
- Specified by:
insertin interfaceorg.springframework.data.mongodb.repository.MongoRepository<NodeEntity,String>
-
insert
@NonNull public <S extends NodeEntity> @NonNull List<S> insert(@NonNull @NonNull Iterable<S> entities) - Specified by:
insertin interfaceorg.springframework.data.mongodb.repository.MongoRepository<NodeEntity,String>
-
save
- Specified by:
savein interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
saveAll
@NonNull public <S extends NodeEntity> @NonNull List<S> saveAll(@NonNull @NonNull Iterable<S> entities) - Specified by:
saveAllin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String> - Specified by:
saveAllin interfaceorg.springframework.data.repository.ListCrudRepository<NodeEntity,String>
-
findOne
@NonNull public <S extends NodeEntity> @NonNull Optional<S> findOne(@NonNull @NonNull org.springframework.data.domain.Example<S> example) - Specified by:
findOnein interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-
findAll
@NonNull public <S extends NodeEntity> @NonNull List<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example) - Specified by:
findAllin interfaceorg.springframework.data.mongodb.repository.MongoRepository<NodeEntity,String> - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-
findAll
@NonNull public <S extends NodeEntity> @NonNull List<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull org.springframework.data.domain.Sort sort) - Specified by:
findAllin interfaceorg.springframework.data.mongodb.repository.MongoRepository<NodeEntity,String> - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-
findAll
@NonNull public <S extends NodeEntity> @NonNull org.springframework.data.domain.Page<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull org.springframework.data.domain.Pageable pageable) - Specified by:
findAllin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-
findBy
@NonNull public <S extends NodeEntity,R> R findBy(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull Function<org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery<S>, R> queryFunction) - Specified by:
findByin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>- Throws:
UnsupportedOperationException- always thrown as this method is not implemented
-
findById
- Specified by:
findByIdin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
existsById
- Specified by:
existsByIdin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
findAll
- Specified by:
findAllin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String> - Specified by:
findAllin interfaceorg.springframework.data.repository.ListCrudRepository<NodeEntity,String>
-
findByArchiveDateRange
public org.springframework.data.domain.Page<NodeEntity> findByArchiveDateRange(Instant from, Instant to, org.springframework.data.domain.Pageable pageable) Retrieves node wrappers archived within the specified date range using pagination.When both
fromandtoarenull, this method delegates tofindAll(Pageable).If the supplied
Pageabledoes not define a sort order, results are ordered by archive date in ascending order.- Parameters:
from- lower bound of the archive date range, inclusive.nullfor no lower bound.to- upper bound of the archive date range, inclusive.nullfor no upper bound.pageable- pagination information- Returns:
- page of matching nodes
-
findNotarized
public org.springframework.data.domain.Page<NodeEntity> findNotarized(org.springframework.data.domain.Pageable pageable) Retrieves notarized node wrappers where the transaction id is not null.- Parameters:
pageable- pagination information- Returns:
- page of notarized nodes
-
countNotarized
public long countNotarized()Counts notarized nodes (nodes with non-null notarization transaction id).- Returns:
- number of notarized nodes
-
findNotarizedRandom
Retrieves a random sample of notarized nodes.- Parameters:
size- maximum number of nodes to sample- Returns:
- random list of notarized nodes
-
findByNtx
Retrieves node wrappers by notarization transaction ID. Anullvalue matches nodes without a transaction ID.- Parameters:
ntx- the transaction ID to filter by- Returns:
- list of matching nodes
-
findByKv
Retrieves node wrappers by encryption key version.- Parameters:
kv- the encryption key version to filter by- Returns:
- list of nodes encrypted with the specified key version
-
findAllById
- Specified by:
findAllByIdin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String> - Specified by:
findAllByIdin interfaceorg.springframework.data.repository.ListCrudRepository<NodeEntity,String>
-
count
public long count()- Specified by:
countin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
deleteById
- Specified by:
deleteByIdin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
delete
- Specified by:
deletein interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
deleteAllById
- Specified by:
deleteAllByIdin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
deleteAll
- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
deleteAll
public void deleteAll()- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<NodeEntity,String>
-
findAll
@NonNull public @NonNull List<NodeEntity> findAll(@NonNull @NonNull org.springframework.data.domain.Sort sort) - Specified by:
findAllin interfaceorg.springframework.data.repository.ListPagingAndSortingRepository<NodeEntity,String> - Specified by:
findAllin interfaceorg.springframework.data.repository.PagingAndSortingRepository<NodeEntity,String>
-
findAll
@NonNull public @NonNull org.springframework.data.domain.Page<NodeEntity> findAll(@NonNull @NonNull org.springframework.data.domain.Pageable pageable) - Specified by:
findAllin interfaceorg.springframework.data.repository.PagingAndSortingRepository<NodeEntity,String>
-
count
public <S extends NodeEntity> long count(@NonNull @NonNull org.springframework.data.domain.Example<S> example) - Specified by:
countin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-
exists
public <S extends NodeEntity> boolean exists(@NonNull @NonNull org.springframework.data.domain.Example<S> example) - Specified by:
existsin interfaceorg.springframework.data.repository.query.QueryByExampleExecutor<NodeEntity>
-