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; 017 018import java.io.Serializable; 019import java.util.ArrayList; 020import java.util.Comparator; 021import java.util.List; 022import java.util.Objects; 023import java.util.Set; 024import java.util.TreeSet; 025 026/** 027 * Models a step in a Pipeline workflow. 028 * 029 * <p>These steps are identified by the {@link StepType} and are linked to their next steps in the 030 * workflow. 031 */ 032public class WorkflowStep implements Serializable { 033 034 private StepType stepType; 035 036 private PipelineStep lastStep; 037 038 private Set<PipelineStep> allSteps = 039 new TreeSet<>(Comparator.comparing(PipelineStep::getStarted).reversed()); 040 041 private List<WorkflowStep> nextSteps = new ArrayList<>(); 042 043 public StepType getStepType() { 044 return stepType; 045 } 046 047 public void setStepType(StepType stepType) { 048 this.stepType = stepType; 049 } 050 051 public PipelineStep getLastStep() { 052 return lastStep; 053 } 054 055 public void setLastStep(PipelineStep lastStep) { 056 this.lastStep = lastStep; 057 } 058 059 public Set<PipelineStep> getAllSteps() { 060 return allSteps; 061 } 062 063 public void setAllSteps(Set<PipelineStep> allSteps) { 064 this.allSteps = allSteps; 065 } 066 067 public List<WorkflowStep> getNextSteps() { 068 return nextSteps; 069 } 070 071 public void setNextSteps(List<WorkflowStep> nextSteps) { 072 this.nextSteps = nextSteps; 073 } 074 075 @Override 076 public boolean equals(Object o) { 077 if (this == o) return true; 078 if (o == null || getClass() != o.getClass()) return false; 079 WorkflowStep that = (WorkflowStep) o; 080 return stepType == that.stepType; 081 } 082 083 @Override 084 public int hashCode() { 085 return Objects.hash(stepType); 086 } 087}