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