package com.repository;

import com.entity.Task;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 *
 * Interface repository for the tasks.
 *
 * @author Laurentiu Marcut
 */
@Repository
public interface TaskRepository {

    /**
     *
     * Select task by id.
     *
     * @param task
     * @return task
     * @throws SQLException
     */
    Task select(int task) throws SQLException;

    /**
     *
     * Select all tasks.
     *
     * @param project
     * @return tasks
     * @throws SQLException
     */
    List<Task> selectAll(String project) throws SQLException;

    /**
     *
     * Select all tasks without sprint.
     *
     * @param project
     * @return tasks
     * @throws SQLException
     */
    List<Task> selectAllWithoutSprint(String project) throws SQLException;

    /**
     *
     * Select all sprints by tags.
     *
     * @param project
     * @param tags
     * @return sprints
     * @throws SQLException
     */
    List<Task> selectAllByTags(String project, List<String> tags) throws SQLException;

    /**
     *
     * Select all task tags.
     *
     * @param task
     * @return tags
     * @throws SQLException
     */
    List<String> selectAllTags(int task) throws SQLException;

    /**
     *
     * Insert task.
     *
     * @param task
     * @return task id
     * @throws SQLException
     */
    int insert(Task task) throws SQLException;

    /**
     *
     * Delete task.
     *
     * @param id
     * @throws SQLException
     */
    void delete(int id) throws SQLException;

    /**
     *
     * Insert tag.
     *
     * @param task
     * @param tag
     * @throws SQLException
     */
    void insertTag(int task, String tag) throws SQLException;

    /**
     *
     * Delete tag.
     *
     * @param task
     * @param tag
     * @throws SQLException
     */
    void deleteTag(int task, String tag) throws SQLException;

    /**
     *
     * Increase priorities.
     *
     * @param project
     * @param previousPriority
     * @param currentPriority
     * @throws SQLException
     */
    void increasePriorities(String project, int previousPriority, int currentPriority) throws SQLException;

    /**
     *
     * Decrease priorities.
     *
     * @param project
     * @param previousPriority
     * @param currentPriority
     * @throws SQLException
     */
    void decreasePriorities(String project, int previousPriority, int currentPriority) throws SQLException;

    /**
     *
     * Decrease priorities before delete task.
     *
     * @param project
     * @param priority
     * @throws SQLException
     */
    void decreasePrioritiesBeforeDeleteTask(String project, int priority) throws SQLException;

    /**
     *
     * Update priority.
     *
     * @param task
     * @param currentPriority
     * @throws SQLException
     */
    void updatePriority(int task, int currentPriority) throws SQLException;

    /**
     *
     * Update points.
     *
     * @param task
     * @param points
     * @throws SQLException
     */
    void updatePoints(int task, int points) throws SQLException;

    /**
     *
     * Update assigned to.
     *
     * @param task
     * @param assignedTo
     * @throws SQLException
     */
    void updateAssignedTo(int task, String assignedTo) throws SQLException;

    /**
     *
     * Update state.
     *
     * @param task
     * @param state
     * @throws SQLException
     */
    void updateState(int task, String state) throws SQLException;

    /**
     *
     * Update sprint.
     *
     * @param task
     * @param sprint
     * @throws SQLException
     */
    void updateSprint(int task, int sprint) throws SQLException;

    /**
     *
     * Select total priorities.
     *
     * @param project
     * @return total priorities
     * @throws SQLException
     */
    int selectTotalPriorities(String project) throws SQLException;
}
