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