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.pipelines.ws;
017
018import org.gbif.api.jackson.LocalDateTimeSerDe;
019
020import java.io.Serializable;
021import java.time.LocalDateTime;
022import java.util.Objects;
023import java.util.UUID;
024
025import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
026import com.fasterxml.jackson.databind.annotation.JsonSerialize;
027
028/** Models a flat response of a pipeline process search. */
029public class SearchResult implements Serializable {
030
031  private UUID datasetKey;
032  private int attempt;
033  private int executionKey;
034  private String rerunReason;
035  private String stepType;
036  private String stepState;
037  private String pipelinesVersion;
038
039  @JsonSerialize(using = LocalDateTimeSerDe.LocalDateTimeSerializer.class)
040  @JsonDeserialize(using = LocalDateTimeSerDe.LocalDateTimeDeserializer.class)
041  private LocalDateTime stepStarted;
042
043  @JsonSerialize(using = LocalDateTimeSerDe.LocalDateTimeSerializer.class)
044  @JsonDeserialize(using = LocalDateTimeSerDe.LocalDateTimeDeserializer.class)
045  private LocalDateTime stepFinished;
046
047  public UUID getDatasetKey() {
048    return datasetKey;
049  }
050
051  public void setDatasetKey(UUID datasetKey) {
052    this.datasetKey = datasetKey;
053  }
054
055  public int getAttempt() {
056    return attempt;
057  }
058
059  public void setAttempt(int attempt) {
060    this.attempt = attempt;
061  }
062
063  public int getExecutionKey() {
064    return executionKey;
065  }
066
067  public void setExecutionKey(int executionKey) {
068    this.executionKey = executionKey;
069  }
070
071  public String getRerunReason() {
072    return rerunReason;
073  }
074
075  public void setRerunReason(String rerunReason) {
076    this.rerunReason = rerunReason;
077  }
078
079  public String getStepType() {
080    return stepType;
081  }
082
083  public void setStepType(String stepType) {
084    this.stepType = stepType;
085  }
086
087  public String getStepState() {
088    return stepState;
089  }
090
091  public void setStepState(String stepState) {
092    this.stepState = stepState;
093  }
094
095  public String getPipelinesVersion() {
096    return pipelinesVersion;
097  }
098
099  public void setPipelinesVersion(String pipelinesVersion) {
100    this.pipelinesVersion = pipelinesVersion;
101  }
102
103  public LocalDateTime getStepStarted() {
104    return stepStarted;
105  }
106
107  public void setStepStarted(LocalDateTime stepStarted) {
108    this.stepStarted = stepStarted;
109  }
110
111  public LocalDateTime getStepFinished() {
112    return stepFinished;
113  }
114
115  public void setStepFinished(LocalDateTime stepFinished) {
116    this.stepFinished = stepFinished;
117  }
118
119  @Override
120  public boolean equals(Object o) {
121    if (this == o) {
122      return true;
123    }
124    if (o == null || getClass() != o.getClass()) {
125      return false;
126    }
127    SearchResult that = (SearchResult) o;
128    return attempt == that.attempt
129        && executionKey == that.executionKey
130        && Objects.equals(datasetKey, that.datasetKey)
131        && Objects.equals(rerunReason, that.rerunReason)
132        && Objects.equals(stepType, that.stepType)
133        && Objects.equals(stepState, that.stepState)
134        && Objects.equals(pipelinesVersion, that.pipelinesVersion)
135        && Objects.equals(stepStarted, that.stepStarted)
136        && Objects.equals(stepFinished, that.stepFinished);
137  }
138
139  @Override
140  public int hashCode() {
141    return Objects.hash(
142        datasetKey,
143        attempt,
144        executionKey,
145        rerunReason,
146        stepType,
147        stepState,
148        pipelinesVersion,
149        stepStarted,
150        stepFinished);
151  }
152}