001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.api.service.collections;
015
016import org.gbif.api.model.collections.Institution;
017import org.gbif.api.model.collections.request.InstitutionSearchRequest;
018import org.gbif.api.model.common.paging.PagingResponse;
019import org.gbif.api.model.registry.search.collections.KeyCodeNameResult;
020
021import java.util.List;
022import java.util.UUID;
023
024import javax.annotation.Nullable;
025
026import org.geojson.FeatureCollection;
027
028/** Service for institutions in the collections context. */
029public interface InstitutionService extends CollectionEntityService<Institution> {
030
031  /**
032   * Pages {@link Institution} entities based on the parameters received.
033   *
034   * <p>To iterate over <em>all</em> entities you can use code like this: {@code PagingRequest req =
035   * new PagingRequest(); PagingResponse<T> response; do { response = service.list(req); for (T obj
036   * : response.getResults()) { doStuff(); } req.nextPage(); } while (!response.isEndOfRecords()); }
037   *
038   * @param searchRequest {@link InstitutionSearchRequest} with all the parameters
039   * @return a list of entities ordered by their creation date, newest coming first
040   */
041  PagingResponse<Institution> list(InstitutionSearchRequest searchRequest);
042
043  /** Provides access to deleted institutions. */
044  PagingResponse<Institution> listDeleted(InstitutionSearchRequest searchRequest);
045
046  /** Provides a simple suggest service. */
047  List<KeyCodeNameResult> suggest(@Nullable String q);
048
049  /** Converts an institution into a collection. The institution converted is deleted. */
050  void convertToCollection(UUID targetEntityKey, UUID collectionKey);
051
052  /**
053   * Creates a {@link Institution} from a {@link org.gbif.api.model.registry.Organization}.
054   *
055   * @param organizationKey key of the dataset to create the institution from
056   * @param institutionCode the code to assign to the institution since it can't be inferred from
057   *     the organization
058   * @return UUID of the created institution
059   */
060  UUID createFromOrganization(UUID organizationKey, String institutionCode);
061
062  /**
063   * Lists the institutions in GeoJson format.
064   *
065   * @param searchRequest parameters to filter the request
066   * @return a {@link FeatureCollection} object that conforms with GeoJson
067   */
068  FeatureCollection listGeojson(InstitutionSearchRequest searchRequest);
069}