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.Collection; 017import org.gbif.api.model.collections.request.CollectionSearchRequest; 018import org.gbif.api.model.collections.view.CollectionView; 019import org.gbif.api.model.common.paging.Pageable; 020import org.gbif.api.model.common.paging.PagingResponse; 021import org.gbif.api.model.registry.search.collections.KeyCodeNameResult; 022 023import java.util.List; 024import java.util.UUID; 025 026import javax.annotation.Nullable; 027import javax.validation.constraints.NotNull; 028 029/** API Service to work with collections. */ 030public interface CollectionService extends CollectionEntityService<Collection> { 031 032 /** 033 * Pages {@link Collection} entities based on the parameters received. 034 * 035 * <p>To iterate over <em>all</em> entities you can use code like this: {@code PagingRequest req = 036 * new PagingRequest(); PagingResponse<T> response; do { response = service.list(req); for (T obj 037 * : response.getResults()) { doStuff(); } req.nextPage(); } while (!response.isEndOfRecords()); } 038 * 039 * @param searchRequest {@link CollectionSearchRequest} with all the parameters 040 * @return a list of entities ordered by their creation date, newest coming first 041 */ 042 PagingResponse<CollectionView> list(CollectionSearchRequest searchRequest); 043 044 /** Provides access to deleted collections. */ 045 PagingResponse<CollectionView> listDeleted(CollectionSearchRequest searchRequest); 046 047 /** Retrieves a {@link CollectionView} by the collection key. */ 048 CollectionView getCollectionView(@NotNull UUID key); 049 050 /** Provides a simple suggest service. */ 051 List<KeyCodeNameResult> suggest(@Nullable String q); 052 053 /** 054 * Creates a {@link Collection} from a {@link org.gbif.api.model.registry.Dataset}. 055 * 056 * @param datasetKey key of the dataset to create the collection from 057 * @param collectionCode the code to assign to the collection since it can't be inferred from the 058 * dataset 059 * @return UUID of the created collection 060 */ 061 UUID createFromDataset(UUID datasetKey, String collectionCode); 062}