001package org.gbif.api.model.registry;
002
003import org.gbif.api.model.common.DOI;
004import org.gbif.api.model.occurrence.Download;
005
006import java.util.UUID;
007
008import javax.validation.constraints.NotNull;
009
010import com.google.common.base.Objects;
011
012/**
013 * Represents the information about the usage of one dataset in an occurrence download.
014 * Provides information about the number of records that the dataset provided to the download; additionally, provide the
015 * references to the download and dataset entities.
016 */
017public class DatasetOccurrenceDownloadUsage {
018
019  private String downloadKey;
020  private UUID datasetKey;
021  private String datasetTitle;
022  private DOI datasetDOI;
023  private String datasetCitation;
024  private long numberRecords;
025  private Download download;
026
027  /**
028   * Dataset key.
029   */
030  @NotNull
031  public UUID getDatasetKey() {
032    return datasetKey;
033  }
034
035  /**
036   * @return the download
037   */
038  public Download getDownload() {
039    return download;
040  }
041
042  /**
043   * Occurrence download key.
044   */
045  @NotNull
046  public String getDownloadKey() {
047    return downloadKey;
048  }
049
050  /**
051   * Number of records that the dataset has provided to the occurrence download.
052   */
053  @NotNull
054  public long getNumberRecords() {
055    return numberRecords;
056  }
057
058  /**
059   * Dataset title at the moment when the download was created.
060   */
061  public String getDatasetTitle() {
062    return datasetTitle;
063  }
064
065  /**
066   * Dataset DOI at the moment when the download was created.
067   */
068  public DOI getDatasetDOI() {
069    return datasetDOI;
070  }
071
072  /**
073   * Dataset citation at the moment when the download was created.
074   */
075  public String getDatasetCitation() {
076    return datasetCitation;
077  }
078
079  public void setDatasetKey(UUID datasetKey) {
080    this.datasetKey = datasetKey;
081  }
082
083  public void setDownload(Download download) {
084    this.download = download;
085  }
086
087  public void setDownloadKey(String downloadKey) {
088    this.downloadKey = downloadKey;
089  }
090
091  public void setNumberRecords(long numberOfRecords) {
092    this.numberRecords = numberOfRecords;
093  }
094
095  public void setDatasetTitle(String datasetTitle) {
096    this.datasetTitle = datasetTitle;
097  }
098
099  public void setDatasetDOI(DOI datasetDOI) {
100    this.datasetDOI = datasetDOI;
101  }
102
103  public void setDatasetCitation(String datasetCitation) {
104    this.datasetCitation = datasetCitation;
105  }
106
107  @Override
108  public String toString() {
109    return Objects.toStringHelper(this).add("downloadKey", downloadKey).add("datasetKey", datasetKey)
110      .add("datasetTitle", datasetTitle).add("datasetDOI", datasetDOI).add("datasetCitation",datasetCitation)
111      .add("numberRecords", numberRecords).add("download", download).toString();
112  }
113
114  @Override
115  public int hashCode() {
116    return Objects
117      .hashCode(downloadKey, datasetKey, datasetTitle, datasetDOI, datasetDOI, numberRecords, download);
118  }
119
120  @Override
121  public boolean equals(Object object) {
122    if (object instanceof DatasetOccurrenceDownloadUsage) {
123      DatasetOccurrenceDownloadUsage that = (DatasetOccurrenceDownloadUsage) object;
124      return Objects.equal(this.downloadKey, that.downloadKey)
125        && Objects.equal(this.datasetKey, that.datasetKey)
126        && Objects.equal(this.datasetTitle, that.datasetTitle)
127        && Objects.equal(this.datasetDOI, that.datasetDOI)
128        && Objects.equal(this.datasetCitation, that.datasetCitation)
129        && Objects.equal(this.numberRecords, that.numberRecords)
130        && Objects.equal(this.download, that.download);
131    }
132    return false;
133  }
134
135
136}