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.collections.request;
015
016import org.gbif.api.model.common.paging.Pageable;
017import org.gbif.api.vocabulary.CollectionsSortField;
018import org.gbif.api.vocabulary.Country;
019import org.gbif.api.vocabulary.GbifRegion;
020import org.gbif.api.vocabulary.IdentifierType;
021import org.gbif.api.vocabulary.SortOrder;
022import org.gbif.api.vocabulary.collections.AccessionStatus;
023import org.gbif.api.vocabulary.collections.CollectionContentType;
024import org.gbif.api.vocabulary.collections.MasterSourceType;
025import org.gbif.api.vocabulary.collections.PreservationType;
026
027import java.util.List;
028import java.util.UUID;
029
030import javax.annotation.Nullable;
031
032public class CollectionSearchRequest extends SearchRequest {
033
034  @Deprecated @Nullable private UUID institution;
035  @Nullable private List<CollectionContentType> contentTypes;
036  @Nullable private List<PreservationType> preservationTypes;
037  @Nullable private AccessionStatus accessionStatus;
038  @Nullable private Boolean personalCollection;
039
040  @Nullable
041  public UUID getInstitution() {
042    return institution;
043  }
044
045  public void setInstitution(@Nullable UUID institution) {
046    this.institution = institution;
047  }
048
049  @Nullable
050  public List<CollectionContentType> getContentTypes() {
051    return contentTypes;
052  }
053
054  public void setContentTypes(@Nullable List<CollectionContentType> contentTypes) {
055    this.contentTypes = contentTypes;
056  }
057
058  @Nullable
059  public List<PreservationType> getPreservationTypes() {
060    return preservationTypes;
061  }
062
063  public void setPreservationTypes(@Nullable List<PreservationType> preservationTypes) {
064    this.preservationTypes = preservationTypes;
065  }
066
067  @Nullable
068  public AccessionStatus getAccessionStatus() {
069    return accessionStatus;
070  }
071
072  public void setAccessionStatus(@Nullable AccessionStatus accessionStatus) {
073    this.accessionStatus = accessionStatus;
074  }
075
076  @Nullable
077  public Boolean getPersonalCollection() {
078    return personalCollection;
079  }
080
081  public void setPersonalCollection(@Nullable Boolean personalCollection) {
082    this.personalCollection = personalCollection;
083  }
084
085  public static Builder builder() {
086    return new Builder();
087  }
088
089  public static class Builder {
090
091    UUID institution;
092    String q;
093    String code;
094    String name;
095    String alternativeCode;
096    String machineTagNamespace;
097    String machineTagName;
098    String machineTagValue;
099    IdentifierType identifierType;
100    String identifier;
101    List<Country> country;
102    List<GbifRegion> gbifRegion;
103    String city;
104    String fuzzyName;
105    Boolean active;
106    List<CollectionContentType> contentTypes;
107    List<PreservationType> preservationTypes;
108    AccessionStatus accessionStatus;
109    Boolean personalCollection;
110    MasterSourceType masterSourceType;
111    String numberSpecimens;
112    Boolean displayOnNHCPortal;
113    UUID replacedBy;
114    String occurrenceCount;
115    String typeSpecimenCount;
116    List<UUID> institutionKeys;
117    CollectionsSortField sortBy;
118    SortOrder sortOrder;
119    Pageable page;
120
121    public Builder institution(UUID institution) {
122      this.institution = institution;
123      return this;
124    }
125
126    public Builder query(String q) {
127      this.q = q;
128      return this;
129    }
130
131    public Builder code(String code) {
132      this.code = code;
133      return this;
134    }
135
136    public Builder name(String name) {
137      this.name = name;
138      return this;
139    }
140
141    public Builder alternativeCode(String alternativeCode) {
142      this.alternativeCode = alternativeCode;
143      return this;
144    }
145
146    public Builder machineTagNamespace(String machineTagNamespace) {
147      this.machineTagNamespace = machineTagNamespace;
148      return this;
149    }
150
151    public Builder machineTagName(String machineTagName) {
152      this.machineTagName = machineTagName;
153      return this;
154    }
155
156    public Builder machineTagValue(String machineTagValue) {
157      this.machineTagValue = machineTagValue;
158      return this;
159    }
160
161    public Builder identifierType(IdentifierType identifierType) {
162      this.identifierType = identifierType;
163      return this;
164    }
165
166    public Builder identifier(String identifier) {
167      this.identifier = identifier;
168      return this;
169    }
170
171    public Builder country(List<Country> country) {
172      this.country = country;
173      return this;
174    }
175
176    public Builder gbifRegion(List<GbifRegion> gbifRegion) {
177      this.gbifRegion = gbifRegion;
178      return this;
179    }
180
181    public Builder city(String city) {
182      this.city = city;
183      return this;
184    }
185
186    public Builder fuzzyName(String fuzzyName) {
187      this.fuzzyName = fuzzyName;
188      return this;
189    }
190
191    public Builder active(boolean active) {
192      this.active = active;
193      return this;
194    }
195
196    public Builder contentTypes(List<CollectionContentType> contentTypes) {
197      this.contentTypes = contentTypes;
198      return this;
199    }
200
201    public Builder preservationTypes(List<PreservationType> preservationTypes) {
202      this.preservationTypes = preservationTypes;
203      return this;
204    }
205
206    public Builder accessionStatus(AccessionStatus accessionStatus) {
207      this.accessionStatus = accessionStatus;
208      return this;
209    }
210
211    public Builder personalCollection(boolean personalCollection) {
212      this.personalCollection = personalCollection;
213      return this;
214    }
215
216    public Builder masterSourceType(MasterSourceType masterSourceType) {
217      this.masterSourceType = masterSourceType;
218      return this;
219    }
220
221    public Builder numberSpecimens(String numberSpecimens) {
222      this.numberSpecimens = numberSpecimens;
223      return this;
224    }
225
226    public Builder displayOnNHCPortal(boolean displayOnNHCPortal) {
227      this.displayOnNHCPortal = displayOnNHCPortal;
228      return this;
229    }
230
231    public Builder replacedBy(UUID replacedBy) {
232      this.replacedBy = replacedBy;
233      return this;
234    }
235
236    public Builder occurrenceCount(String occurrenceCount) {
237      this.occurrenceCount = occurrenceCount;
238      return this;
239    }
240
241    public Builder typeSpecimenCount(String typeSpecimenCount) {
242      this.typeSpecimenCount = typeSpecimenCount;
243      return this;
244    }
245
246    public Builder institutionKeys(List<UUID> institutionKeys) {
247      this.institutionKeys = institutionKeys;
248      return this;
249    }
250
251    public Builder sortBy(CollectionsSortField sortBy) {
252      this.sortBy = sortBy;
253      return this;
254    }
255
256    public Builder sortOrder(SortOrder sortOrder) {
257      this.sortOrder = sortOrder;
258      return this;
259    }
260
261    public Builder page(Pageable page) {
262      this.page = page;
263      return this;
264    }
265
266    public CollectionSearchRequest build() {
267      CollectionSearchRequest req = new CollectionSearchRequest();
268      req.setInstitution(institution);
269      req.setQ(q);
270      req.setCode(code);
271      req.setName(name);
272      req.setAlternativeCode(alternativeCode);
273      req.setMachineTagNamespace(machineTagNamespace);
274      req.setMachineTagName(machineTagName);
275      req.setMachineTagValue(machineTagValue);
276      req.setIdentifierType(identifierType);
277      req.setIdentifier(identifier);
278      req.setCountry(country);
279      req.setGbifRegion(gbifRegion);
280      req.setCity(city);
281      req.setFuzzyName(fuzzyName);
282      req.setActive(active);
283      req.setContentTypes(contentTypes);
284      req.setPreservationTypes(preservationTypes);
285      req.setAccessionStatus(accessionStatus);
286      req.setPersonalCollection(personalCollection);
287      req.setMasterSourceType(masterSourceType);
288      req.setNumberSpecimens(numberSpecimens);
289      req.setDisplayOnNHCPortal(displayOnNHCPortal);
290      req.setReplacedBy(replacedBy);
291      req.setOccurrenceCount(occurrenceCount);
292      req.setTypeSpecimenCount(typeSpecimenCount);
293      req.setInstitutionKeys(institutionKeys);
294      req.setSortBy(sortBy);
295      req.setSortOrder(sortOrder);
296      if (page != null) {
297        req.setLimit(page.getLimit());
298        req.setOffset(page.getOffset());
299      }
300      return req;
301    }
302  }
303}