001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.service.registry;
017
018import org.gbif.api.model.common.paging.Pageable;
019import org.gbif.api.model.common.paging.PagingResponse;
020import org.gbif.api.model.crawler.DatasetProcessStatus;
021
022import java.util.UUID;
023
024import javax.annotation.Nullable;
025import javax.validation.Valid;
026import javax.validation.constraints.NotNull;
027
028/**
029 * Interface to access and persist information about dataset processing statuses.
030 */
031@SuppressWarnings("unused")
032public interface DatasetProcessStatusService {
033
034  /**
035   * Persists the {@link DatasetProcessStatus} object.
036   */
037  void createDatasetProcessStatus(@NotNull @Valid DatasetProcessStatus datasetProcessStatus);
038
039  /**
040   * Persists the {@link DatasetProcessStatus} object which must exist.
041   */
042  void updateDatasetProcessStatus(@NotNull @Valid DatasetProcessStatus datasetProcessStatus);
043
044  /**
045   * Retrieves a {@link DatasetProcessStatus} by its datasetKey and attempt.
046   */
047  DatasetProcessStatus getDatasetProcessStatus(@NotNull UUID datasetKey, int attempt);
048
049  /**
050   * Retrieves a pageable result of all the dataset processing statuses.
051   */
052  PagingResponse<DatasetProcessStatus> listDatasetProcessStatus(@Nullable Pageable page);
053
054  /**
055   * Lists the {@link DatasetProcessStatus} of a dataset. The result is sorted by the descending started crawling date
056   * (i.e. the last crawl comes first).
057   */
058  PagingResponse<DatasetProcessStatus> listDatasetProcessStatus(@NotNull UUID datasetKey, @Nullable Pageable page);
059
060  /**
061   * Retrieves a pageable result of all dataset processing statuses that have been aborted in their latest crawl
062   */
063  PagingResponse<DatasetProcessStatus> listAbortedDatasetProcesses(@Nullable Pageable page);
064}