Interface CitizenSpecificRepository

All Known Subinterfaces:
CitizenRepository
All Known Implementing Classes:
CitizenSpecificRepositoryImpl

public interface CitizenSpecificRepository

Contract for custom MongoDB aggregation queries on CitizenConsent collection.

Defines complex queries that cannot be auto-generated by Spring Data MongoDB, such as nested field projections and dynamic consent filtering.

Implementation: CitizenSpecificRepositoryImpl

See Also:
  • Method Details

    • findByFiscalCodeAndTppId

      reactor.core.publisher.Mono<CitizenConsent> findByFiscalCodeAndTppId(String fiscalCode, String tppId)

      Finds a specific TPP consent within a citizen's document.

      Projects only the requested consent field (consents.<tppId>) using MongoDB aggregation.

      Parameters:
      fiscalCode - citizen's fiscal code (must not be null)
      tppId - TPP identifier (must not be null)
      Returns:
      Mono emitting projected document with single consent, empty if not found or tppId is null
    • findByTppIdEnabled

      reactor.core.publisher.Flux<CitizenConsent> findByTppIdEnabled(String tppId)

      Finds all citizens with an enabled consent for a specific TPP.

      Filters documents where consents.<tppId>.tppState = true and projects only fiscal code and the matching consent.

      Parameters:
      tppId - TPP identifier (must not be null)
      Returns:
      Flux emitting projected documents with enabled consent (possibly empty)
    • findByFiscalCodeWithAtLeastOneConsent

      reactor.core.publisher.Mono<CitizenConsent> findByFiscalCodeWithAtLeastOneConsent(String fiscalCode)

      Finds a citizen with at least one enabled consent across all TPPs.

      Uses $objectToArray to flatten the consents map and filters for tppState = true.

      Parameters:
      fiscalCode - citizen's fiscal code (must not be null)
      Returns:
      Mono emitting the document if at least one consent is enabled, empty otherwise