package com.eshore.gringotts.web.domain.repository;

import com.eshore.gringotts.web.domain.base.repository.SimpleRepository;
import com.eshore.gringotts.web.domain.entity.DataResource;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.stereotype.Repository;

@SuppressWarnings("NullableProblems")
@Repository
public interface DataResourceRepository extends SimpleRepository<DataResource, Long> {
    @Override
    @EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
    List<DataResource> findAll(Specification<DataResource> specification);

    @Override
    @EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
    List<DataResource> findAll(Specification<DataResource> specification, Sort sort);

    @EntityGraph(value = "data_resource.list", type = EntityGraph.EntityGraphType.FETCH)
    List<DataResource> findAllByConfirmationIsNull();

    @Override
    @EntityGraph(value = "data_resource.detail", type = EntityGraph.EntityGraphType.FETCH)
    Optional<DataResource> findOne(Specification<DataResource> specification);
}
