package com.service;

import com.entity.Task;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 *
 * Interface service for the task.
 *
 * @author Laurentiu Marcut
 */
@Service
public interface TaskService {

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

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

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

    /**
     *
     * Select all tasks by tags.
     *
     * @param project
     * @param tags
     * @return tasks
     * @throws SQLException
     */
    @Transactional(readOnly = true)
    List<Task> selectAllByTags(String project, List<String> tags) throws SQLException;

    /**
     *
     * Insert task.
     *
     * @param task
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void insert(Task task) throws SQLException;

    /**
     *
     * Delete task.
     *
     * @param project
     * @param id
     * @param priority
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void delete(String project, int id, int priority) throws SQLException;

    /**
     *
     * Insert tag.
     *
     * @param task
     * @param tag
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void insertTag(int task, String tag) throws SQLException;

    /**
     *
     * Delete tag.
     *
     * @param task
     * @param tag
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void deleteTag(int task, String tag) throws SQLException;

    /**
     *
     * Update priority.
     *
     * @param project
     * @param task
     * @param previousPriority
     * @param currentPriority
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void updatePriority(String project, int task, int previousPriority, int currentPriority) throws SQLException;

    /**
     *
     * Update points.
     *
     * @param task
     * @param points
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void updatePoints(int task, int points) throws SQLException;

    /**
     *
     * Update assigned to.
     *
     * @param task
     * @param assignTo
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void updateAssignedTo(int task, String assignTo) throws SQLException;

    /**
     *
     * Update sprint.
     *
     * @param task
     * @param sprint
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void updateSprint(int task, int sprint) throws SQLException;

    /**
     *
     * Update state.
     *
     * @param task
     * @param state
     * @throws SQLException
     */
    @Transactional(rollbackFor = Exception.class)
    void updateState(int task, String state) throws SQLException;
}
