package at.procon.dip.domain.document.repository;

import at.procon.dip.domain.access.DocumentVisibility;
import at.procon.dip.domain.document.DocumentFamily;
import at.procon.dip.domain.document.DocumentStatus;
import at.procon.dip.domain.document.DocumentType;
import at.procon.dip.domain.document.entity.Document;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;

public interface DocumentRepository extends JpaRepository<Document, UUID> {

    Optional<Document> findByBusinessKey(String businessKey);

    Optional<Document> findByDedupHash(String dedupHash);

    List<Document> findAllByDedupHash(String dedupHash);

    boolean existsByDedupHash(String dedupHash);

    List<Document> findByDocumentType(DocumentType documentType);

    List<Document> findByDocumentFamily(DocumentFamily documentFamily);

    List<Document> findByStatus(DocumentStatus status);

    List<Document> findByVisibility(DocumentVisibility visibility);

    List<Document> findByOwnerTenant_TenantKey(String tenantKey);

    List<Document> findByOwnerTenant_TenantKeyIn(Collection<String> tenantKeys);
}
