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.registry.Dataset;
021import org.gbif.api.model.registry.Network;
022import org.gbif.api.model.registry.Organization;
023import org.gbif.api.model.registry.search.KeyTitleResult;
024import org.gbif.api.model.registry.search.NetworkRequestSearchParams;
025
026import java.util.List;
027import java.util.UUID;
028
029import javax.annotation.Nullable;
030import javax.validation.constraints.NotNull;
031
032@SuppressWarnings("unused")
033public interface NetworkService extends NetworkEntityService<Network> {
034
035  /**
036   * Pages through dataset constituents of a network, i.e. returns datasets which have an entry in
037   * the dataset_network table.
038   *
039   * @param networkKey the network identifier
040   */
041  PagingResponse<Dataset> listConstituents(@NotNull UUID networkKey, @Nullable Pageable page);
042
043  /**
044   * Pages through publishing organizations of a network.
045   *
046   * @param networkKey the network identifier
047   */
048  PagingResponse<Organization> publishingOrganizations(
049      @NotNull UUID networkKey, @Nullable Pageable page);
050
051  /**
052   * Adds an existing dataset to the list of constituents of a network.
053   *
054   * @param networkKey the network to add the dataset to
055   * @param datasetKey the dataset to be added
056   */
057  void addConstituent(@NotNull UUID networkKey, @NotNull UUID datasetKey);
058
059  /**
060   * Removes an existing constituent dataset from a network.
061   *
062   * @param networkKey the network to remove the dataset from
063   * @param datasetKey the dataset to be removed
064   */
065  void removeConstituent(@NotNull UUID networkKey, @NotNull UUID datasetKey);
066
067  /** Provides a simple suggest service. */
068  List<KeyTitleResult> suggest(@Nullable String q);
069
070  /**
071   * Provides paging service to list networks that can be filtered by multiple parameters.
072   *
073   * @param searchParams {@link NetworkRequestSearchParams}
074   * @return list of networks ordered by creation date with the latest coming first
075   */
076  PagingResponse<Network> list(NetworkRequestSearchParams searchParams);
077}