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.registry.search;
017
018import org.gbif.api.model.common.DOI;
019import org.gbif.api.vocabulary.Continent;
020import org.gbif.api.vocabulary.Country;
021import org.gbif.api.vocabulary.DatasetSubtype;
022import org.gbif.api.vocabulary.DatasetType;
023import org.gbif.api.vocabulary.License;
024
025import java.util.Date;
026import java.util.List;
027import java.util.Objects;
028import java.util.Set;
029import java.util.StringJoiner;
030import java.util.UUID;
031
032/**
033 * The dataset search model object for faceted and full text search.
034 */
035public class DatasetSearchResult {
036
037  private UUID key;
038  private String title;
039  private DOI doi;
040  private String description;
041  private DatasetType type;
042  private DatasetSubtype subtype;
043  private String fullText;
044  private UUID hostingOrganizationKey;
045  private String hostingOrganizationTitle;
046  private Country hostingCountry;
047  private String publisherTitle;
048  private Set<Country> countryCoverage;
049  private Set<Continent> continent;
050  private Country publishingCountry;
051  private UUID publishingOrganizationKey;
052  private String publishingOrganizationTitle;
053  private Date publicationDate;
054  private Date modified;
055  private UUID endorsingNodeKey;
056  private List<UUID> networkKeys;
057  private License license;
058  private List<Integer> decades;
059  private List<String> keywords;
060  private String projectIdentifier;
061  private Integer recordCount;
062  private Integer nameUsagesCount;
063  private Integer eventCount;
064  private Set<String> category;
065
066  public UUID getKey() {
067    return key;
068  }
069
070  public void setKey(UUID key) {
071    this.key = key;
072  }
073
074  public String getTitle() {
075    return title;
076  }
077
078  public void setTitle(String title) {
079    this.title = title;
080  }
081
082  public DOI getDoi() {
083    return doi;
084  }
085
086  public void setDoi(DOI doi) {
087    this.doi = doi;
088  }
089
090  public String getDescription() {
091    return description;
092  }
093
094  public void setDescription(String description) {
095    this.description = description;
096  }
097
098  public DatasetType getType() {
099    return type;
100  }
101
102  public void setType(DatasetType type) {
103    this.type = type;
104  }
105
106  public DatasetSubtype getSubtype() {
107    return subtype;
108  }
109
110  public void setSubtype(DatasetSubtype subtype) {
111    this.subtype = subtype;
112  }
113
114  public String getFullText() {
115    return fullText;
116  }
117
118  public void setFullText(String fullText) {
119    this.fullText = fullText;
120  }
121
122  public UUID getHostingOrganizationKey() {
123    return hostingOrganizationKey;
124  }
125
126  public void setHostingOrganizationKey(UUID hostingOrganizationKey) {
127    this.hostingOrganizationKey = hostingOrganizationKey;
128  }
129
130  public String getHostingOrganizationTitle() {
131    return hostingOrganizationTitle;
132  }
133
134  public void setHostingOrganizationTitle(String hostingOrganizationTitle) {
135    this.hostingOrganizationTitle = hostingOrganizationTitle;
136  }
137
138  public Country getHostingCountry() {
139    return hostingCountry;
140  }
141
142  public void setHostingCountry(Country hostingCountry) {
143    this.hostingCountry = hostingCountry;
144  }
145
146  public String getPublisherTitle() {
147    return publisherTitle;
148  }
149
150  public void setPublisherTitle(String publisherTitle) {
151    this.publisherTitle = publisherTitle;
152  }
153
154  public UUID getEndorsingNodeKey() {
155    return endorsingNodeKey;
156  }
157
158  public void setEndorsingNodeKey(UUID endorsingNodeKey) {
159    this.endorsingNodeKey = endorsingNodeKey;
160  }
161
162  /**
163   * Currently not populated.
164   * TODO: http://dev.gbif.org/issues/browse/REG-393
165   */
166  public Set<Country> getCountryCoverage() {
167    return countryCoverage;
168  }
169
170  public void setCountryCoverage(Set<Country> countryCoverage) {
171    this.countryCoverage = countryCoverage;
172  }
173
174  /**
175   * Currently not populated.
176   * TODO: http://dev.gbif.org/issues/browse/REG-393
177   */
178  public Set<Continent> getContinent() {
179    return continent;
180  }
181
182  public void setContinent(Set<Continent> continent) {
183    this.continent = continent;
184  }
185
186  public Country getPublishingCountry() {
187    return publishingCountry;
188  }
189
190  public void setPublishingCountry(Country publishingCountry) {
191    this.publishingCountry = publishingCountry;
192  }
193
194  public UUID getPublishingOrganizationKey() {
195    return publishingOrganizationKey;
196  }
197
198  public void setPublishingOrganizationKey(UUID publishingOrganizationKey) {
199    this.publishingOrganizationKey = publishingOrganizationKey;
200  }
201
202  public String getPublishingOrganizationTitle() {
203    return publishingOrganizationTitle;
204  }
205
206  public void setPublishingOrganizationTitle(String publishingOrganizationTitle) {
207    this.publishingOrganizationTitle = publishingOrganizationTitle;
208  }
209
210  public Date getPublicationDate() {
211    return publicationDate;
212  }
213
214  public void setPublicationDate(Date publicationDate) {
215    this.publicationDate = publicationDate;
216  }
217
218  public Date getModified() {
219    return modified;
220  }
221
222  public void setModified(Date modified) {
223    this.modified = modified;
224  }
225
226  public List<UUID> getNetworkKeys() {
227    return networkKeys;
228  }
229
230  public void setNetworkKeys(List<UUID> networkKeys) {
231    this.networkKeys = networkKeys;
232  }
233
234  public License getLicense() {
235    return license;
236  }
237
238  public void setLicense(License license) {
239    this.license = license;
240  }
241
242  public List<Integer> getDecades() {
243    return decades;
244  }
245
246  public void setDecades(List<Integer> decades) {
247    this.decades = decades;
248  }
249
250  public List<String> getKeywords() {
251    return keywords;
252  }
253
254  public void setKeywords(List<String> keywords) {
255    this.keywords = keywords;
256  }
257
258  public String getProjectIdentifier() {
259    return projectIdentifier;
260  }
261
262  public void setProjectIdentifier(String projectIdentifier) {
263    this.projectIdentifier = projectIdentifier;
264  }
265
266  public Integer getRecordCount() {
267    return recordCount;
268  }
269
270  public void setRecordCount(Integer recordCount) {
271    this.recordCount = recordCount;
272  }
273
274  public Integer getNameUsagesCount() {
275    return nameUsagesCount;
276  }
277
278  public void setNameUsagesCount(Integer nameUsagesCount) {
279    this.nameUsagesCount = nameUsagesCount;
280  }
281
282  public Integer getEventCount() {
283    return eventCount;
284  }
285
286  public void setEventCount(Integer eventCount) {
287    this.eventCount = eventCount;
288  }
289
290  public Set<String> getCategory() {
291    return category;
292  }
293
294  public void setCategory(Set<String> category) {
295    this.category = category;
296  }
297
298
299  @Override
300  public boolean equals(Object o) {
301    if (this == o) {
302      return true;
303    }
304    if (o == null || getClass() != o.getClass()) {
305      return false;
306    }
307    DatasetSearchResult that = (DatasetSearchResult) o;
308    return Objects.equals(key, that.key) &&
309      Objects.equals(title, that.title) &&
310      Objects.equals(doi, that.doi) &&
311      Objects.equals(description, that.description) &&
312      type == that.type &&
313      subtype == that.subtype &&
314      Objects.equals(fullText, that.fullText) &&
315      Objects.equals(hostingOrganizationKey, that.hostingOrganizationKey) &&
316      Objects.equals(hostingOrganizationTitle, that.hostingOrganizationTitle) &&
317      Objects.equals(publisherTitle, that.publisherTitle) &&
318      Objects.equals(countryCoverage, that.countryCoverage) &&
319      Objects.equals(continent, that.continent) &&
320      publishingCountry == that.publishingCountry &&
321      Objects.equals(publishingOrganizationKey, that.publishingOrganizationKey) &&
322      Objects.equals(publishingOrganizationTitle, that.publishingOrganizationTitle) &&
323      publicationDate == that.publicationDate &&
324      modified == that.modified &&
325      license == that.license &&
326      Objects.equals(decades, that.decades) &&
327      Objects.equals(keywords, that.keywords) &&
328      Objects.equals(projectIdentifier, that.projectIdentifier) &&
329      Objects.equals(recordCount, that.recordCount) &&
330      Objects.equals(networkKeys, that.networkKeys) &&
331      Objects.equals(nameUsagesCount, that.nameUsagesCount) &&
332      Objects.equals(eventCount, that.eventCount) &&
333      Objects.equals(category, that.category);
334  }
335
336  @Override
337  public int hashCode() {
338    return Objects.hash(key, title, doi, description, type, subtype, fullText, hostingOrganizationKey,
339      hostingOrganizationTitle, publisherTitle, countryCoverage, continent, publishingCountry,
340      publishingOrganizationKey, publishingOrganizationTitle, publicationDate, modified, license, decades, keywords,
341      projectIdentifier, recordCount, networkKeys, nameUsagesCount, eventCount, category);
342  }
343
344  @Override
345  public String toString() {
346    return new StringJoiner(", ", DatasetSearchResult.class.getSimpleName() + "[", "]")
347      .add("key=" + key)
348      .add("title='" + title + "'")
349      .add("doi='" + doi + "'")
350      .add("description='" + description + "'")
351      .add("type=" + type)
352      .add("subtype=" + subtype)
353      .add("fullText='" + fullText + "'")
354      .add("hostingOrganizationKey=" + hostingOrganizationKey)
355      .add("hostingOrganizationTitle='" + hostingOrganizationTitle + "'")
356      .add("publisherTitle='" + publisherTitle + "'")
357      .add("countryCoverage=" + countryCoverage)
358      .add("continent=" + continent)
359      .add("publishingCountry=" + publishingCountry)
360      .add("publishingOrganizationKey=" + publishingOrganizationKey)
361      .add("publishingOrganizationTitle='" + publishingOrganizationTitle + "'")
362      .add("publicationDate=" + publicationDate)
363      .add("modified+" + modified)
364      .add("license=" + license)
365      .add("decades=" + decades)
366      .add("keywords=" + keywords)
367      .add("projectIdentifier='" + projectIdentifier + "'")
368      .add("recordCount=" + recordCount)
369      .add("networkKeys=" + networkKeys)
370      .add("nameUsagesCount=" + nameUsagesCount)
371      .add("eventCount=" + eventCount)
372      .add("category=" + category)
373      .toString();
374  }
375}