package ru.yandex.webmaster3.storage.download.urls;

import com.fasterxml.jackson.annotation.JsonProperty;
import ru.yandex.webmaster3.core.data.WebmasterHostId;
import ru.yandex.webmaster3.core.download.FileFormat;
import ru.yandex.webmaster3.core.worker.task.WorkerTaskData;
import ru.yandex.webmaster3.core.worker.task.WorkerTaskType;
import ru.yandex.webmaster3.storage.download.DownloadTaskData;
import ru.yandex.webmaster3.storage.searchurl.ExcludedUrlFilter;
import ru.yandex.webmaster3.storage.searchurl.download.ExcludedUrlCsvRow;

import java.util.List;
import java.util.UUID;

/**
 * Created by ifilippov5 on 10.02.17.
 */
public class DownloadExcludedUrlsTaskData extends DownloadTaskData<ExcludedUrlCsvRow> {
    private final List<ExcludedUrlFilter> parameterFilters;

    public DownloadExcludedUrlsTaskData(
            @JsonProperty("taskId") UUID taskId,
            @JsonProperty("hostId") WebmasterHostId hostId,
            @JsonProperty("parameterFilters") List<ExcludedUrlFilter> parameterFilters,
            @JsonProperty("nodeId") Long nodeId,
            @JsonProperty("exportFormat") FileFormat exportFormat,
            @JsonProperty("fileName") String fileName,
            @JsonProperty("hash") Long hash
    ) {
        super(taskId, hostId, nodeId, exportFormat, fileName, hash, ExcludedUrlCsvRow.class);
        this.parameterFilters = parameterFilters;
    }

    private DownloadExcludedUrlsTaskData(WebmasterHostId hostId, List<ExcludedUrlFilter> parameterFilters, Long nodeId,
                                         FileFormat exportFormat, String fileName, Long hash) {
        super(hostId, nodeId, exportFormat, fileName, hash, ExcludedUrlCsvRow.class);
        this.parameterFilters = parameterFilters;
    }

    public static WorkerTaskData createTaskData(WebmasterHostId hostId, List<ExcludedUrlFilter> parameterFilters,
                                                Long nodeId, FileFormat exportFormat, String fileName, Long hash) {
        return new DownloadExcludedUrlsTaskData(hostId, parameterFilters, nodeId, exportFormat, fileName, hash);
    }

    public List<ExcludedUrlFilter> getParameterFilters() {
        return parameterFilters;
    }

    @Override
    public WorkerTaskType getTaskType() {
        return WorkerTaskType.DOWNLOAD_EXCLUDED_URLS;
    }

    @Override
    public String getShortDescription() {
        return "Download excluded urls";
    }
}
