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