001/*
002 * Copyright 2014 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.checklistbank;
017
018import org.gbif.api.vocabulary.Rank;
019import org.gbif.api.vocabulary.TypeDesignationType;
020import org.gbif.api.vocabulary.TypeStatus;
021
022import javax.annotation.Nullable;
023
024import com.google.common.base.Objects;
025
026
027/**
028 * TypeSpecimen Model originally designed for both specimens and types, including type specimens, type species and type genera and simple
029 * specimens unrelated to types.
030 *
031 * Since the initial release of the GBIF API version 1.0 ChecklistBank has been modified to only store type species or type genera.
032 * All specimens including types are stored in the Occurrence store, hence the majority of properties in this class are now deprecated!
033 *
034 * @see <a href="http://rs.gbif.org/extension/gbif/1.0/typesandspecimen.xml">Types And Specimen Definition</a>
035 */
036public class TypeSpecimen implements NameUsageExtension {
037
038  private Integer taxonKey;
039  private String source;
040  private Integer sourceTaxonKey;
041  private TypeDesignationType typeDesignationType;
042  private String typeDesignatedBy;
043  private String scientificName;
044  private Rank taxonRank;
045
046  @Deprecated
047  private TypeStatus typeStatus;
048  @Deprecated
049  private String citation;
050  @Deprecated
051  private String verbatimLabel;
052  @Deprecated
053  private String locality;
054  @Deprecated
055  private String recordedBy;
056  @Deprecated
057  private String verbatimEventDate;
058  @Deprecated
059  private String verbatimLongitude;
060  @Deprecated
061  private String verbatimLatitude;
062  @Deprecated
063  private String occurrenceId;
064  @Deprecated
065  private String institutionCode;
066  @Deprecated
067  private String collectionCode;
068  @Deprecated
069  private String catalogNumber;
070
071  /**
072   * The name usage "taxon" key this description belongs to.
073   */
074  @Override
075  public Integer getTaxonKey() {
076    return taxonKey;
077  }
078
079  @Override
080  public void setTaxonKey(Integer taxonKey) {
081    this.taxonKey = taxonKey;
082  }
083
084  /**
085   * An identifier (preferably unique) for the record within the data set or collection.
086   * <blockquote>
087   * <p>
088   * <i>Examples:</i> "2008.1334", "145732a", "145732".
089   * </p>
090   * </blockquote>
091   *
092   * @return the catalogNumber
093   */
094  @Nullable
095  @Deprecated
096  public String getCatalogNumber() {
097    return catalogNumber;
098  }
099
100  /**
101   * @param catalogNumber the catalogNumber to set.
102   */
103  @Deprecated
104  public void setCatalogNumber(String catalogNumber) {
105    this.catalogNumber = catalogNumber;
106  }
107
108  /**
109   * A text string citating the described specimen. Often found in taxonomic treatments and frequently based on
110   * institution code and catalog number.
111   * <blockquote>
112   * <p>
113   * <i>Examples:</i> Iraq: Mosul: Jabal Khantur prope Sharanish N. Zakho, in fissures rupium calc., 1200 m, Rech.
114   * 12083. (W!).
115   * </p>
116   * </blockquote>
117   *
118   * @return the citation
119   */
120  @Nullable
121  @Deprecated
122  public String getCitation() {
123    return citation;
124  }
125
126  /**
127   * @param citation the citation to set
128   */
129  @Deprecated
130  public void setCitation(String citation) {
131    this.citation = citation;
132  }
133
134  /**
135   * The name, acronym, coden, or initialism identifying the collection or data set from which the record was derived.
136   * <blockquote>
137   * <p>
138   * <i>Examples:</i> "Mammals", "Hildebrandt", "eBird".
139   * </p>
140   * </blockquote>
141   *
142   * @return the collectionCode
143   */
144  @Nullable
145  @Deprecated
146  public String getCollectionCode() {
147    return collectionCode;
148  }
149
150  /**
151   * @param collectionCode the collectionCode to set
152   */
153  @Deprecated
154  public void setCollectionCode(String collectionCode) {
155    this.collectionCode = collectionCode;
156  }
157
158  /**
159   * The name (or acronym) in use by the institution having custody of the object(s) or information referred to in the
160   * record.
161   * <blockquote>
162   * <p>
163   * <i>Examples:</i> "MVZ", "FMNH", "AKN-CLO", "University of California Museum of Paleontology (UCMP)".
164   * </p>
165   * </blockquote>
166   *
167   * @return the institutionCode
168   */
169  @Nullable
170  @Deprecated
171  public String getInstitutionCode() {
172    return institutionCode;
173  }
174
175  /**
176   * @param institutionCode the institutionCode to set
177   */
178  @Deprecated
179  public void setInstitutionCode(String institutionCode) {
180    this.institutionCode = institutionCode;
181  }
182
183  /**
184   * The location where the the specimen was collected. In case of type specimens the type locality.
185   * <blockquote>
186   * <p>
187   * <i>Examples:</i> Iraq: Mosul: Jabal Khantur prope Sharanish N. Zakho, in fissures rupium calc., 1200 m.
188   * </p>
189   * </blockquote>
190   *
191   * @return the locality
192   */
193  @Nullable
194  @Deprecated
195  public String getLocality() {
196    return locality;
197  }
198
199  /**
200   * @param locality the locality to set
201   */
202  @Deprecated
203  public void setLocality(String locality) {
204    this.locality = locality;
205  }
206
207  /**
208   * An identifier for the specimen, preferably a resolvable globally unique identifier.
209   *
210   * @return the occurrenceId
211   */
212  @Nullable
213  @Deprecated
214  public String getOccurrenceId() {
215    return occurrenceId;
216  }
217
218  /**
219   * @param occurrenceId the occurrenceId to set
220   */
221  @Deprecated
222  public void setOccurrenceId(String occurrenceId) {
223    this.occurrenceId = occurrenceId;
224  }
225
226  /**
227   * The primary collector or observer, especially one who applies a personal identifier (recordNumber), should be
228   * listed first.
229   * <blockquote>
230   * <p>
231   * <i>Examples:</i> KH Rechinger.
232   * </p>
233   * </blockquote>
234   *
235   * @return the recordedBy
236   */
237  @Nullable
238  @Deprecated
239  public String getRecordedBy() {
240    return recordedBy;
241  }
242
243  /**
244   * @param recordedBy the recordedBy to set
245   */
246  @Deprecated
247  public void setRecordedBy(String recordedBy) {
248    this.recordedBy = recordedBy;
249  }
250
251  /**
252   * The scientific name originally used for the specimen, species or genus. Not necessarily the same as the currently
253   * recognized name. For type species this is the species name.
254   * <blockquote>
255   * <p>
256   * <i>Examples:</i> "Ctenomys sociabilis" - "Roptrocerus typographi (Györfi, 1952)".
257   * </p>
258   * </blockquote>
259   *
260   * @return the scientificName
261   */
262  @Nullable
263  public String getScientificName() {
264    return scientificName;
265  }
266
267  /**
268   * @param scientificName the scientificName to set
269   */
270  public void setScientificName(String scientificName) {
271    this.scientificName = scientificName;
272  }
273
274  /**
275   * The source.
276   *
277   * @return the source
278   */
279  @Nullable
280  @Override
281  public String getSource() {
282    return source;
283  }
284
285  /**
286   * @param source the source to set
287   */
288  @Override
289  public void setSource(String source) {
290    this.source = source;
291  }
292
293  @Nullable
294  @Override
295  public Integer getSourceTaxonKey() {
296    return sourceTaxonKey;
297  }
298
299  @Override
300  public void setSourceTaxonKey(Integer sourceTaxonKey) {
301    this.sourceTaxonKey = sourceTaxonKey;
302  }
303
304  /**
305   * The rank of the taxon bearing the scientific name.
306   *
307   * @return the taxonRank
308   */
309  public Rank getTaxonRank() {
310    return taxonRank;
311  }
312
313  /**
314   * @param taxonRank the taxonRank to set
315   */
316  public void setTaxonRank(Rank taxonRank) {
317    this.taxonRank = taxonRank;
318  }
319
320  /**
321   * The citation of the publication where the type designation is found.
322   * <blockquote>
323   * <p>
324   * <i>Examples:</i> Vachal, J. (1897) Éclaircissements sur de genre Scrapter et description d’une espéce nouvelle de
325   * Dufourea. Bulletin de la Société Entomologique de France, 1897, 61–64.
326   * </p>
327   * </blockquote>
328   *
329   * @return the typeDesignatedBy
330   */
331  @Nullable
332  public String getTypeDesignatedBy() {
333    return typeDesignatedBy;
334  }
335
336  /**
337   * @param typeDesignatedBy the typeDesignatedBy to set
338   */
339  public void setTypeDesignatedBy(String typeDesignatedBy) {
340    this.typeDesignatedBy = typeDesignatedBy;
341  }
342
343  /**
344   * The reason why this specimen or name is designated as a type.
345   * <blockquote>
346   * <p>
347   * <i>Examples:</i> monotypy, original designation, tautonomy.
348   * </p>
349   * </blockquote>
350   *
351   * @return the typeDesignationType
352   */
353  @Nullable
354  public TypeDesignationType getTypeDesignationType() {
355    return typeDesignationType;
356  }
357
358  /**
359   * @param typeDesignationType the typeDesignationType to set
360   */
361  public void setTypeDesignationType(TypeDesignationType typeDesignationType) {
362    this.typeDesignationType = typeDesignationType;
363  }
364
365  /**
366   * The type status of the specimen, not used for type species or type genus.
367   * <blockquote>
368   * <p>
369   * <i>Examples:</i> holotype, syntype, lectotype, type species.
370   * </p>
371   * </blockquote>
372   *
373   * @return the typeStatus
374   */
375  @Nullable
376  @Deprecated
377  public TypeStatus getTypeStatus() {
378    return typeStatus;
379  }
380
381  /**
382   * @param typeStatus the typeStatus to set
383   */
384  @Deprecated
385  public void setTypeStatus(TypeStatus typeStatus) {
386    this.typeStatus = typeStatus;
387  }
388
389  /**
390   * The date when the specimen was collected.
391   * <blockquote>
392   * <p>
393   * <i>Examples:</i> "spring 1910", "Marzo 2002", "1999-03-XX", "17IV1934".
394   * </p>
395   * </blockquote>
396   *
397   * @return the verbatimEventDate
398   */
399  @Nullable
400  @Deprecated
401  public String getVerbatimEventDate() {
402    return verbatimEventDate;
403  }
404
405  /**
406   * @param verbatimEventDate the verbatimEventDate to set
407   */
408  @Deprecated
409  public void setVerbatimEventDate(String verbatimEventDate) {
410    this.verbatimEventDate = verbatimEventDate;
411  }
412
413  /**
414   * The full, verbatim text from the specimen label.
415   *
416   * @return the verbatimLabel
417   */
418  @Nullable
419  @Deprecated
420  public String getVerbatimLabel() {
421    return verbatimLabel;
422  }
423
424  /**
425   * @param verbatimLabel the verbatimLabel to set
426   */
427  @Deprecated
428  public void setVerbatimLabel(String verbatimLabel) {
429    this.verbatimLabel = verbatimLabel;
430  }
431
432  /**
433   * The geographic latitude.
434   * <blockquote>
435   * <p>
436   * <i>Examples:</i> 41 05 54.03 S.
437   * </p>
438   * </blockquote>
439   *
440   * @return the verbatimLatitude
441   */
442  @Nullable
443  @Deprecated
444  public String getVerbatimLatitude() {
445    return verbatimLatitude;
446  }
447
448  /**
449   * @param verbatimLatitude the verbatimLatitude to set
450   */
451  @Deprecated
452  public void setVerbatimLatitude(String verbatimLatitude) {
453    this.verbatimLatitude = verbatimLatitude;
454  }
455
456  /**
457   * The geographic longitude.
458   * <blockquote>
459   * <p>
460   * <i>Examples:</i> 121d 10' 34 W.
461   * </p>
462   * </blockquote>
463   *
464   * @return the verbatimLongitude
465   */
466  @Nullable
467  @Deprecated
468  public String getVerbatimLongitude() {
469    return verbatimLongitude;
470  }
471
472  /**
473   * @param verbatimLongitude the verbatimLongitude to set
474   */
475  @Deprecated
476  public void setVerbatimLongitude(String verbatimLongitude) {
477    this.verbatimLongitude = verbatimLongitude;
478  }
479
480  @Override
481  public boolean equals(Object object) {
482    if (this == object) {
483      return true;
484    }
485    if (!(object instanceof TypeSpecimen)) {
486      return false;
487    }
488
489    TypeSpecimen that = (TypeSpecimen) object;
490    return Objects.equal(this.source, that.source)
491           && Objects.equal(this.sourceTaxonKey, that.sourceTaxonKey)
492           && Objects.equal(this.typeDesignationType, that.typeDesignationType)
493           && Objects.equal(this.typeDesignatedBy, that.typeDesignatedBy)
494           && Objects.equal(this.scientificName, that.scientificName)
495           && Objects.equal(this.taxonRank, that.taxonRank)
496           && Objects.equal(this.citation, that.citation)
497           && Objects.equal(this.typeStatus, that.typeStatus)
498           && Objects.equal(this.verbatimLabel, that.verbatimLabel)
499           && Objects.equal(this.locality, that.locality)
500           && Objects.equal(this.recordedBy, that.recordedBy)
501           && Objects.equal(this.verbatimEventDate, that.verbatimEventDate)
502           && Objects.equal(this.verbatimLongitude, that.verbatimLongitude)
503           && Objects.equal(this.verbatimLatitude, that.verbatimLatitude)
504           && Objects.equal(this.occurrenceId, that.occurrenceId)
505           && Objects.equal(this.institutionCode, that.institutionCode)
506           && Objects.equal(this.collectionCode, that.collectionCode)
507           && Objects.equal(this.catalogNumber, that.catalogNumber);
508  }
509
510  @Override
511  public int hashCode() {
512    return Objects.hashCode(source,
513                            sourceTaxonKey,
514                            typeDesignationType,
515                            typeDesignatedBy,
516                            scientificName,
517                            taxonRank,
518                            citation,
519                            typeStatus,
520                            verbatimLabel,
521                            locality,
522                            recordedBy,
523                            verbatimEventDate,
524                            verbatimLongitude,
525                            verbatimLatitude,
526                            occurrenceId,
527                            institutionCode,
528                            collectionCode,
529                            catalogNumber);
530  }
531
532  @Override
533  public String toString() {
534    return Objects.toStringHelper(this)
535      .add("source", source)
536      .add("sourceTaxonKey", sourceTaxonKey)
537      .add("typeDesignationType", typeDesignationType)
538      .add("typeDesignatedBy", typeDesignatedBy)
539      .add("scientificName", scientificName)
540      .add("taxonRank", taxonRank)
541      .toString();
542  }
543
544}