use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialsRepresenter method fromJSON.
static MaterialConfig fromJSON(JsonReader jsonReader) {
String type = jsonReader.getString("type");
JsonReader attributes = jsonReader.readJsonObject("attributes");
return stream(Materials.values()).filter(material -> equalsIgnoreCase(type, material.name())).findFirst().map(material -> material.representer.fromJSON(attributes)).orElseThrow(unprocessableMaterialType(type));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigReposControllerV4 method inProgress.
String inProgress(Request req, Response res) {
MaterialConfig materialConfig = repoFromRequest(req).getRepo();
final boolean state = materialUpdateService.isInProgress(converter.toMaterial(materialConfig));
return String.format("{\"in_progress\":%b}", state);
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method getUniqueMaterialConfigs.
private Set<MaterialConfig> getUniqueMaterialConfigs(boolean ignoreManualPipelines) {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<Map> uniqueMaterials = new HashSet<>();
for (PipelineConfig pipelineConfig : pipelinesFromAllGroups()) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
if (ignoreManualPipelines && !materialConfig.isAutoUpdate() && materialConfig instanceof ScmMaterialConfig) {
continue;
}
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method getUniqueMaterials.
private Set<MaterialConfig> getUniqueMaterials(boolean ignoreManualPipelines, boolean ignoreConfigRepos) {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<Map> uniqueMaterials = new HashSet<>();
for (PipelineConfig pipelineConfig : pipelinesFromAllGroups()) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
boolean shouldSkipPolling = !materialConfig.isAutoUpdate();
boolean scmOrPackageMaterial = !(materialConfig instanceof DependencyMaterialConfig);
if (ignoreManualPipelines && scmOrPackageMaterial && shouldSkipPolling) {
continue;
}
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
if (!ignoreConfigRepos) {
for (ConfigRepoConfig configRepo : this.configRepos) {
MaterialConfig materialConfig = configRepo.getRepo();
if (materialConfig.isAutoUpdate() && !uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method getStagesUsedAsMaterials.
@Override
public Set<StageConfig> getStagesUsedAsMaterials(PipelineConfig pipelineConfig) {
Set<String> stagesUsedAsMaterials = new HashSet<>();
for (MaterialConfig materialConfig : getAllUniqueMaterials()) {
if (materialConfig instanceof DependencyMaterialConfig) {
DependencyMaterialConfig dep = (DependencyMaterialConfig) materialConfig;
stagesUsedAsMaterials.add(dep.getPipelineName() + "|" + dep.getStageName());
}
}
Set<StageConfig> stages = new HashSet<>();
for (StageConfig stage : pipelineConfig) {
if (stagesUsedAsMaterials.contains(pipelineConfig.name() + "|" + stage.name())) {
stages.add(stage);
}
}
return stages;
}
Aggregations