Search in sources :

Example 61 with MaterialConfig

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));
}
Also used : TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) HashMap(java.util.HashMap) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Supplier(java.util.function.Supplier) String.format(java.lang.String.format) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonReader(com.thoughtworks.go.api.representers.JsonReader) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Map(java.util.Map) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) StringUtils.equalsIgnoreCase(org.apache.commons.lang3.StringUtils.equalsIgnoreCase) Collections(java.util.Collections) Arrays.stream(java.util.Arrays.stream) UnprocessableEntityException(com.thoughtworks.go.config.exceptions.UnprocessableEntityException) JsonReader(com.thoughtworks.go.api.representers.JsonReader)

Example 62 with MaterialConfig

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);
}
Also used : MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig)

Example 63 with MaterialConfig

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;
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Collectors.toMap(java.util.stream.Collectors.toMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig)

Example 64 with MaterialConfig

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;
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Collectors.toMap(java.util.stream.Collectors.toMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Example 65 with MaterialConfig

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;
}
Also used : PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12