
com.capitalone.dashboard.model.Pipeline Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core package shared by API layer and Microservices
package com.capitalone.dashboard.model;
import com.capitalone.dashboard.util.PipelineUtils;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.*;
/**
* Document containing the details of a Pipeline for a TeamDashboardCollectorItem
*/
@Document(collection="pipelines")
public class Pipeline extends BaseModel{
/**
* {@link CollectorItem} teamdashboard collector item id
* */
private ObjectId collectorItemId;
/**
* Map of environment name and stage object
* */
private Map stages = new HashMap<>();
/**
* not including this in the map above because the enum allows us to
* use ordinals to iterate through pipeline progression
* */
private Set failedBuilds = new HashSet<>();
public ObjectId getCollectorItemId() {
return collectorItemId;
}
public void setCollectorItemId(ObjectId collectorItemId) {
this.collectorItemId = collectorItemId;
}
public Map getStages() {
return stages;
}
public void setStages(Map stages) {
this.stages = stages;
}
/**
* Adds a commit to a given stage. Will create a new stage if it doesn't exist.
* @param stage
* @param commit
*/
public void addCommit(String stage, PipelineCommit commit){
if(!this.getStages().containsKey(stage)){
this.getStages().put(stage, new EnvironmentStage());
}
this.getStages().get(stage).getCommits().add(commit);
}
public Set getFailedBuilds() {
return failedBuilds;
}
public void setFailedBuilds(Set failedBuilds) {
this.failedBuilds = failedBuilds;
}
public void addFailedBuild(Build failedBuild){
this.getFailedBuilds().add(failedBuild);
}
/**
* Gets all pipeline commits as a map of scmrevision number, pipelinecommit for a given stage.
*
* uses a case insensitive map of the pipeline stage names due tot he way the UI currently stores mapped environments
* with lowercase for the stage type and the canonical name
* @param stage
* @return
*/
public Map getCommitsByStage(String stage){
Map caseInsensitiveMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
caseInsensitiveMap.putAll(stages);
EnvironmentStage pipelineStage = caseInsensitiveMap.get(stage);
if(pipelineStage == null) {
return new HashMap<>();
}
Map commitsByStage = PipelineUtils.commitSetToMap(pipelineStage.getCommits());
return commitsByStage;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy