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.metrics;
017
018import org.gbif.api.vocabulary.ProcessingErrorType;
019
020import java.io.Serializable;
021
022import com.google.common.base.Objects;
023
024
025/**
026 * Error reports for a single Record (occurrence, species).
027 */
028@Deprecated
029public class RecordError implements Serializable {
030
031  private static final long serialVersionUID = 4942485228689322658L;
032
033  /**
034   * type of error.
035   */
036  private ProcessingErrorType processingErrorType;
037
038  /**
039   * ID of the problematic record (occurrence, species).
040   */
041  private long recordId;
042
043  /**
044   * catalog number.
045   */
046  private String catalogNumber;
047
048  /**
049   * collection code.
050   */
051  private String collectionCode;
052
053  /**
054   * institution code.
055   */
056  private String institutionCode;
057
058  public static Builder builder() {
059    return new Builder();
060  }
061
062  public RecordError() {
063  }
064
065  public RecordError(Builder builder) {
066    processingErrorType = builder.processingErrorType;
067    recordId = builder.recordId;
068    catalogNumber = builder.catalogNumber;
069    collectionCode = builder.collectionCode;
070    institutionCode = builder.institutionCode;
071  }
072
073  /**
074   * @return the catalogNumber
075   */
076  public String getCatalogNumber() {
077    return catalogNumber;
078  }
079
080  /**
081   * @param catalogNumber the catalogNumber to set
082   */
083  public void setCatalogNumber(String catalogNumber) {
084    this.catalogNumber = catalogNumber;
085  }
086
087  /**
088   * @return the collectionCode
089   */
090  public String getCollectionCode() {
091    return collectionCode;
092  }
093
094  /**
095   * @param collectionCode the collectionCode to set
096   */
097  public void setCollectionCode(String collectionCode) {
098    this.collectionCode = collectionCode;
099  }
100
101  /**
102   * @return the processingErrorType
103   */
104  public ProcessingErrorType getProcessingErrorType() {
105    return processingErrorType;
106  }
107
108  /**
109   * @param processingErrorType the processingErrorType to set
110   */
111  public void setProcessingErrorType(ProcessingErrorType processingErrorType) {
112    this.processingErrorType = processingErrorType;
113  }
114
115  /**
116   * @return the institutionCode
117   */
118  public String getInstitutionCode() {
119    return institutionCode;
120  }
121
122  /**
123   * @param institutionCode the institutionCode to set
124   */
125  public void setInstitutionCode(String institutionCode) {
126    this.institutionCode = institutionCode;
127  }
128
129  /**
130   * @return the recordId
131   */
132  public long getRecordId() {
133    return recordId;
134  }
135
136  /**
137   * @param recordId the recordId to set
138   */
139  public void setRecordId(long recordId) {
140    this.recordId = recordId;
141  }
142
143  @Override
144  public boolean equals(Object obj) {
145    if (this == obj) {
146      return true;
147    }
148    if (!(obj instanceof RecordError)) {
149      return false;
150    }
151
152    RecordError that = (RecordError) obj;
153    return Objects.equal(this.processingErrorType, that.processingErrorType)
154           && Objects.equal(this.recordId, that.recordId)
155           && Objects.equal(this.catalogNumber, that.catalogNumber)
156           && Objects.equal(this.collectionCode, that.collectionCode)
157           && Objects.equal(this.institutionCode, that.institutionCode);
158  }
159
160  @Override
161  public int hashCode() {
162    return Objects.hashCode(processingErrorType, recordId, catalogNumber, collectionCode, institutionCode);
163  }
164
165  @Override
166  public String toString() {
167    return Objects.toStringHelper(this)
168      .add("processingErrorType", processingErrorType)
169      .add("recordId", recordId)
170      .add("catalogNumber", catalogNumber)
171      .add("collectionCode", collectionCode)
172      .add("institutionCode", institutionCode)
173      .toString();
174  }
175
176  public static class Builder {
177
178    private ProcessingErrorType processingErrorType;
179    private long recordId;
180    private String catalogNumber;
181    private String collectionCode;
182    private String institutionCode;
183
184    public RecordError build() {
185      return new RecordError(this);
186    }
187
188    public Builder catalogNumber(String catalogNumber) {
189      this.catalogNumber = catalogNumber;
190      return this;
191    }
192
193    public Builder collectionCode(String collectionCode) {
194      this.collectionCode = collectionCode;
195      return this;
196    }
197
198    public Builder errorType(ProcessingErrorType processingErrorType) {
199      this.processingErrorType = processingErrorType;
200      return this;
201    }
202
203    public Builder institutionCode(String institutionCode) {
204      this.institutionCode = institutionCode;
205      return this;
206    }
207
208    public Builder recordId(long recordId) {
209      this.recordId = recordId;
210      return this;
211    }
212
213  }
214
215}