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