package com.atlassian.stash.internal.pull;

import com.atlassian.stash.internal.Dao;
import com.atlassian.stash.internal.repository.InternalRepository;

import javax.annotation.Nonnull;
import java.util.List;

/**
 * Dao for dealing with {@link InternalRescopeRequest} instances.
 * 
 * @since 1.3
 */
public interface RescopeRequestDao extends Dao<Long, InternalRescopeRequest> {

    /**
     * Deletes {@link InternalRescopeRequest requests} for the specified IDs.
     *
     * @param requestIds the IDs of the requests to delete
     */
    void deleteByIds(@Nonnull List<Long> requestIds);

    /**
     * Finds <i>all</i> {@link InternalRescopeRequest requests} for the specified repository.
     *
     * @param repositoryId the repository to find requests for
     * @return a list containing zero or more requests for the specified repository
     * @since 4.2
     */
    @Nonnull
    List<InternalRescopeRequest> findByRepository(int repositoryId);

    /**
     * Finds <i>all</i> {@link InternalRescopeRequest requests} for the specified repositories
     *
     * @param repositoryIds the repositories to find requests for
     * @return a list containing zero or more requests for the specified repository
     * @since 4.5
     */
    @Nonnull
    List<InternalRescopeRequest> findByRepositories(@Nonnull List<Integer> repositoryIds);

    /**
     * Finds the {@link InternalRepository#getId IDs} of <i>all</i> {@link InternalRepository repositories}
     * which have at least one pending {@link InternalRescopeRequest request}.
     *
     * @return a list containing zero or more IDs for repositories with pending requests
     * @since 4.2
     */
    @Nonnull
    List<Integer> findPendingRepositoryIds();
}
