com.capitalone.dashboard.model.HudsonCollector Maven / Gradle / Ivy
package com.capitalone.dashboard.model;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Extension of Collector that stores current build server configuration.
*/
public class HudsonCollector extends Collector {
private List buildServers = new ArrayList<>();
private List niceNames = new ArrayList<>();
private List environments = new ArrayList<>();
private static final String NICE_NAME = "niceName";
private static final String JOB_NAME = "options.jobName";
public List getBuildServers() {
return buildServers;
}
public List getNiceNames() {
return niceNames;
}
public void setNiceNames(List niceNames) {
this.niceNames = niceNames;
}
public List getEnvironments() {
return environments;
}
public void setEnvironments(List environments) {
this.environments = environments;
}
public void setBuildServers(List buildServers) {
this.buildServers = buildServers;
}
public static HudsonCollector prototype(List buildServers, List niceNames,
List environments) {
HudsonCollector protoType = new HudsonCollector();
protoType.setName("Hudson");
protoType.setCollectorType(CollectorType.Build);
protoType.setOnline(true);
protoType.setEnabled(true);
protoType.getBuildServers().addAll(buildServers);
if (!CollectionUtils.isEmpty(niceNames)) {
protoType.getNiceNames().addAll(niceNames);
}
if (!CollectionUtils.isEmpty(environments)) {
protoType.getEnvironments().addAll(environments);
}
Map options = new HashMap<>();
options.put(HudsonJob.INSTANCE_URL,"");
options.put(HudsonJob.JOB_URL,"");
options.put(HudsonJob.JOB_NAME,"");
Map uniqueOptions = new HashMap<>();
uniqueOptions.put(HudsonJob.JOB_URL,"");
uniqueOptions.put(HudsonJob.JOB_NAME,"");
protoType.setAllFields(options);
protoType.setUniqueFields(uniqueOptions);
protoType.setSearchFields(Arrays.asList(JOB_NAME,NICE_NAME));
return protoType;
}
}