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.model.collections.request;
017
018import java.io.Serializable;
019import java.util.List;
020import java.util.UUID;
021import javax.annotation.Nullable;
022import lombok.Data;
023import lombok.experimental.SuperBuilder;
024import org.gbif.api.model.common.paging.Pageable;
025import org.gbif.api.model.common.paging.PagingConstants;
026import org.gbif.api.model.common.paging.PagingRequest;
027import org.gbif.api.vocabulary.Country;
028import org.gbif.api.vocabulary.GbifRegion;
029import org.gbif.api.vocabulary.IdentifierType;
030import org.gbif.api.vocabulary.SortOrder;
031import org.gbif.api.vocabulary.collections.CollectionsSortField;
032import org.gbif.api.vocabulary.collections.MasterSourceType;
033import org.gbif.api.vocabulary.collections.Source;
034
035@SuperBuilder
036@Data
037public abstract class SearchRequest implements Serializable {
038
039  @Nullable private Boolean hl;
040  @Nullable private String q;
041  @Nullable private List<String> code;
042  @Nullable private List<String> name;
043  @Nullable private List<String> alternativeCode;
044  @Nullable private List<UUID> contact;
045  @Nullable private List<String> machineTagNamespace;
046  @Nullable private List<String> machineTagName;
047  @Nullable private List<String> machineTagValue;
048  @Nullable private List<IdentifierType> identifierType;
049  @Nullable private List<String> identifier;
050  @Nullable private List<Country> country;
051  @Nullable private List<GbifRegion> gbifRegion;
052  @Nullable private List<String> city;
053  @Nullable private List<String> fuzzyName;
054  @Nullable private List<Boolean> active;
055  @Nullable private List<MasterSourceType> masterSourceType;
056  @Nullable private List<String> numberSpecimens;
057  @Nullable private List<Boolean> displayOnNHCPortal;
058  @Nullable private List<UUID> replacedBy;
059  @Nullable private List<String> occurrenceCount;
060  @Nullable private List<String> typeSpecimenCount;
061  @Nullable private CollectionsSortField sortBy;
062  @Nullable private SortOrder sortOrder;
063  @Nullable private List<UUID> institutionKeys;
064  @Nullable private List<Source> source;
065  @Nullable private List<String> sourceId;
066  @Nullable private Long offset;
067  @Nullable private Integer limit;
068
069  public Pageable getPage() {
070    return new PagingRequest(
071        offset != null ? offset : PagingConstants.DEFAULT_PARAM_OFFSET,
072        limit != null ? limit : PagingConstants.DEFAULT_PARAM_LIMIT);
073  }
074}