package com.armstrongconsulting.acprotasks;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskRepositoryType;
import com.intellij.tasks.impl.BaseRepository;
import com.intellij.util.xmlb.annotations.Tag;

@Tag(AcproRepositoryType.NAME)
public class AcproRepository extends BaseRepository
{

    public AcproRepository(TaskRepositoryType type)
    {
        super(type);
    }

    public AcproRepository(BaseRepository other)
    {
        super(other);
    }

    public AcproRepository()
    {
    }

    @Override
    public @Nullable Task findTask(@NotNull String id) throws Exception
    {
        return new AcproTask();
    }

    @Override
    public @NotNull BaseRepository clone()
    {
        return new AcproRepository(this);
    }

    @Override
    public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed)
        throws Exception
    {
        System.out.println("Searching for issues (1): " + query);
        return new Task[]{new AcproTask()};
    }

    @Override
    public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed,
        @NotNull ProgressIndicator cancelled) throws Exception
    {
        System.out.println("Searching for issues (2): " + query);
        return new Task[]{new AcproTask()};
    }
}
