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.model.registry.search;
015
016import org.gbif.api.model.common.paging.Pageable;
017import org.gbif.api.model.common.paging.PageableBase;
018import org.gbif.api.model.common.paging.PagingRequest;
019import org.gbif.api.util.Range;
020import org.gbif.api.vocabulary.IdentifierType;
021
022import java.time.LocalDate;
023
024import lombok.Getter;
025import lombok.Setter;
026
027/** Base class for registry requests to list the entities. */
028@Getter
029@Setter
030public class RequestSearchParams extends PageableBase {
031
032  public static final String IDENTIFIER_TYPE_PARAM = "identifierType";
033  public static final String IDENTIFIER_PARAM = "identifier";
034  public static final String MACHINE_TAG_NAMESPACE_PARAM = "machineTagNamespace";
035  public static final String MACHINE_TAG_NAME_PARAM = "machineTagName";
036  public static final String MACHINE_TAG_VALUE_PARAM = "machineTagValue";
037  public static final String Q_PARAM = "q";
038  public static final String MODIFIED_PARAM = "modified";
039
040  private IdentifierType identifierType;
041  private String identifier;
042  private String machineTagNamespace; // namespace
043  private String machineTagName; // name
044  private String machineTagValue; // value
045  private String q; // query
046  private Range<LocalDate> modified;
047
048  public Pageable getPage() {
049    return new PagingRequest(this.getOffset(), this.getLimit());
050  }
051
052  public void setPage(Pageable page) {
053    if (page != null) {
054      this.offset = page.getOffset();
055      this.limit = page.getLimit();
056    }
057  }
058}