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.checklistbank;
015
016import java.util.Objects;
017import java.util.StringJoiner;
018
019import javax.annotation.Nullable;
020import javax.validation.constraints.NotNull;
021
022import io.swagger.v3.oas.annotations.media.Schema;
023
024/**
025 * Reference Model Object represents a literature reference stating a bibliography for a taxon.
026 *
027 * Since the initial release of the GBIF API version 1.0 ChecklistBank has been modified to only store the entire citation string of a reference and
028 * none of the atomised fields which are now deprecated.
029 *
030 * @see <a href="http://rs.gbif.org/extension/gbif/1.0/references.xml">Reference Definition</a>
031 */
032@SuppressWarnings("unused")
033public class Reference implements NameUsageExtension {
034
035  private Integer taxonKey;
036  private String citation;
037  private String link;
038  private String doi;
039  private String type;
040  private String remarks;
041  private String source;
042  private Integer sourceTaxonKey;
043
044  @Deprecated
045  private String title;
046  @Deprecated
047  private String author;
048  @Deprecated
049  private String date;
050
051  /**
052   * The name usage "taxon" key this description belongs to.
053   */
054  @Schema(description = "The name usage “taxon“ key to which this species profile belongs.")
055  @Override
056  public Integer getTaxonKey() {
057    return taxonKey;
058  }
059
060  @Override
061  public void setTaxonKey(Integer taxonKey) {
062    this.taxonKey = taxonKey;
063  }
064
065  /**
066   * The author or authors of the referenced work.
067   * <blockquote>
068   * <p>
069   * <i>Example:</i> Patricia Hartge.
070   * </p>
071   * </blockquote>
072   *
073   * @return the author
074   */
075  @Schema(description = "The author or authors of the referenced work.")
076  @Nullable
077  @Deprecated
078  public String getAuthor() {
079    return author;
080  }
081
082  /**
083   * @param author the author to set
084   */
085  @Deprecated
086  public void setAuthor(String author) {
087    this.author = author;
088  }
089
090  /**
091   * A text string referring to an un-parsed bibliographic citation.
092   * The full citation given here should include all the details potentially found in the other atomised fields,
093   * i.e. includes authorship, title, etc.
094   * <p/>
095   * <blockquote>
096   * <p>
097   * <i>Example:</i> Hartge, P., Genetics of reproductive lifespan. Nature Genetics 41, 637 - 638 (2009).
098   * </p>
099   * </blockquote>
100   *
101   * @return the citation
102   */
103  @Schema(description = "A text string referring to an un-parsed bibliographic citation.")
104  @NotNull
105  public String getCitation() {
106    return citation;
107  }
108
109  /**
110   * @param citation the citation to set
111   */
112  public void setCitation(String citation) {
113    this.citation = citation;
114  }
115
116  /**
117   * Date of publication, recommended ISO format YYYY or YYYY-MM-DD.
118   *
119   * @return the publication date
120   */
121  @Schema(description = "Date of publication.")
122  @Nullable
123  @Deprecated
124  public String getDate() {
125    return date;
126  }
127
128  @Deprecated
129  public void setDate(String date) {
130    this.date = date;
131  }
132
133  /**
134   * The pure DOI for the publication without potential http resolver or URI prefix.
135   * For example {@code 10.1038/ng0609-637} instead of {@code doi:10.1038/ng0609-637} or {@code
136   * http://dx.doi.org/10.1038/ng0609-637}. A valid DOI always starts with {@code 10.}.
137   *
138   * @return the doi
139   *
140   * @see <a href="http://www.crossref.org/01company/15doi_info.html">Crossref DOI Info</a>
141   * @see <a href="http://www.doi.org/hb.html">DOI Handbook</a>
142   * @see <a href="http://de.wikipedia.org/wiki/Digital_Object_Identifier">Wikipedia</a>
143   */
144  @Schema(
145    description = "The pure DOI for the publication without potential http resolver or URI prefix.",
146    example = "10.1038/ng0609-637"
147  )
148  @Nullable
149  public String getDoi() {
150    return doi;
151  }
152
153  public void setDoi(String doi) {
154    this.doi = doi;
155  }
156
157  /**
158   * Link.
159   *
160   * @return the link
161   */
162  @Schema(description = "The reference link.")
163  @Nullable
164  public String getLink() {
165    return link;
166  }
167
168  /**
169   * @param link the link to set
170   */
171  public void setLink(String link) {
172    this.link = link;
173  }
174
175  /**
176   * Annotation of taxon-specific information related to the referenced publication.
177   * <p/>
178   * <blockquote>
179   * <p>
180   * <i>Examples:</i> "transferred H. nigritarsus to Acanolonia"; "Type specimen is a skeleton"
181   * </p>
182   * </blockquote>
183   *
184   * @return the taxonomic remarks
185   */
186  @Schema(description = "Annotation of taxon-specific information related to the referenced publication.")
187  @Nullable
188  public String getRemarks() {
189    return remarks;
190  }
191
192  public void setRemarks(String remarks) {
193    this.remarks = remarks;
194  }
195
196  /**
197   * Title of book or article.
198   * <blockquote>
199   * <p>
200   * <i>Example:</i> "Genetics of reproductive lifespan", "Field Guide to Moths of Eastern North America".
201   * </p>
202   * </blockquote>
203   *
204   * @return the title
205   */
206  @Schema(description = "Title of book or article.")
207  @Nullable
208  @Deprecated
209  public String getTitle() {
210    return title;
211  }
212
213  /**
214   * @param title the title to set
215   */
216  @Deprecated
217  public void setTitle(String title) {
218    this.title = title;
219  }
220
221  /**
222   * Used to assign a bibliographic reference to list of taxonomic or nomenclatural categories. Best practice is to use
223   * a controlled vocabulary.
224   * <blockquote>
225   * <p>
226   * <i>Examples:</i> Original publication of new combination (comb nov.)
227   * </p>
228   * </blockquote>
229   *
230   * @return the publication type
231   */
232  @Schema(description = "Used to assign a bibliographic reference to list of taxonomic or nomenclatural categories.")
233  @Nullable
234  public String getType() {
235    return type;
236  }
237
238  public void setType(String type) {
239    this.type = type;
240  }
241
242  @Schema(description = "Bibliographic citation referencing a source for the reference.")
243  @Nullable
244  @Override
245  public String getSource() {
246    return source;
247  }
248
249  @Override
250  public void setSource(String source) {
251    this.source = source;
252  }
253
254  @Schema(description = "The name usage key of the taxon in the checklist including this reference.")
255  @Nullable
256  @Override
257  public Integer getSourceTaxonKey() {
258    return sourceTaxonKey;
259  }
260
261  @Override
262  public void setSourceTaxonKey(Integer sourceTaxonKey) {
263    this.sourceTaxonKey = sourceTaxonKey;
264  }
265
266  @Override
267  public boolean equals(Object o) {
268    if (this == o) {
269      return true;
270    }
271    if (o == null || getClass() != o.getClass()) {
272      return false;
273    }
274    Reference reference = (Reference) o;
275    return Objects.equals(citation, reference.citation) &&
276      Objects.equals(link, reference.link) &&
277      Objects.equals(doi, reference.doi) &&
278      Objects.equals(type, reference.type) &&
279      Objects.equals(remarks, reference.remarks) &&
280      Objects.equals(source, reference.source) &&
281      Objects.equals(sourceTaxonKey, reference.sourceTaxonKey) &&
282      Objects.equals(title, reference.title) &&
283      Objects.equals(author, reference.author) &&
284      Objects.equals(date, reference.date);
285  }
286
287  @Override
288  public int hashCode() {
289    return Objects
290      .hash(citation, link, doi, type, remarks, source, sourceTaxonKey, title, author,
291        date);
292  }
293
294  @Override
295  public String toString() {
296    return new StringJoiner(", ", Reference.class.getSimpleName() + "[", "]")
297      .add("taxonKey=" + taxonKey)
298      .add("citation='" + citation + "'")
299      .add("link='" + link + "'")
300      .add("doi='" + doi + "'")
301      .add("type='" + type + "'")
302      .add("remarks='" + remarks + "'")
303      .add("source='" + source + "'")
304      .add("sourceTaxonKey=" + sourceTaxonKey)
305      .add("title='" + title + "'")
306      .add("author='" + author + "'")
307      .add("date='" + date + "'")
308      .toString();
309  }
310}