using Quadarax.Foundation.Core.Business.Processor.Enums;
using Quadarax.Foundation.Core.Business.Processor.Task;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Object;

namespace Quadarax.Foundation.Core.Business.Processor.Providers
{
    public interface IProcessorStorageProvider : IDisposable
    {
        /// <summary>
        /// Open storage connection if needed
        /// </summary>
        public void Open();
        /// <summary>
        /// Close storage connection if needed
        /// </summary>
        public void Close();
        /// <summary>
        /// Ensure storage is ready to use. If not exists, create it.
        /// <description>This operation doesn't use Open or Close operation to access to storage and doesn't affects Open/Close state..</description>
        /// </summary>
        /// <returns>Returns true, if storage already exists. Otherwise returns false that storage was created.</returns>
        public bool EnsureStorage();

        /// <summary>
        /// Create new task item in storage and save it.
        /// </summary>
        /// <param name="item">Item to create.</param>
        /// <returns>Identifier of new created item.</returns>
        public ITaskIdentifier Create(ITaskItemData item);
        /// <summary>
        /// Get task item from storage by identifier.
        /// </summary>
        /// <param name="ids">Storage identifiers of Task item</param>
        /// <returns>Array of Task items</returns>
        public ITaskItemData[] Get(params ITaskIdentifier[] ids);
        /// <summary>
        /// Saves task items in storage.
        /// </summary>
        /// <param name="items">Task items to save.</param>
        public void Set(params ITaskItemData[] items);
        /// <summary>
        /// Deletes task items physically in storage.
        /// </summary>
        /// <param name="ids">Storage identifiers of Task item</param>
        public void Delete(params ITaskIdentifier[] ids);

        /// <summary>
        /// Query task items from storage by status.
        /// </summary>
        /// <param name="paging">Defines paging settings to apply in storage.</param>
        /// <param name="statuses">Allowed statuses</param>
        /// <returns>Queryable collection of selected Task items.</returns>
        public IQueryable<ITaskItemData> Query(IPaging paging, params ProcessStatusEnum[] statuses);
    }
}
