Search in sources :

Example 1 with StageArtifactCleanupProhibited

use of com.thoughtworks.go.domain.StageArtifactCleanupProhibited in project gocd by gocd.

the class ConfigDbStateRepository method flushArtifactCleanupProhibitions.

private Object flushArtifactCleanupProhibitions() {
    List<StageArtifactCleanupProhibited> existingEntries = getHibernateTemplate().find("from StageArtifactCleanupProhibited");
    HashMap<Map.Entry<String, String>, StageArtifactCleanupProhibited> persistentStateMap = new HashMap<>();
    for (StageArtifactCleanupProhibited persistentState : existingEntries) {
        persistentState.setProhibited(false);
        persistentStateMap.put(new AbstractMap.SimpleEntry<>(persistentState.getPipelineName(), persistentState.getStageName()), persistentState);
    }
    List<PipelineConfig> pipelineConfigs = goConfigService.currentCruiseConfig().allPipelines();
    for (PipelineConfig pipelineConfig : pipelineConfigs) {
        for (StageConfig stageConfig : pipelineConfig) {
            StageArtifactCleanupProhibited stageArtifactCleanupProhibited = persistentStateMap.get(new AbstractMap.SimpleEntry<>(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stageConfig.name())));
            if (stageArtifactCleanupProhibited == null) {
                stageArtifactCleanupProhibited = new StageArtifactCleanupProhibited(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(stageConfig.name()));
            }
            stageArtifactCleanupProhibited.setProhibited(stageConfig.isArtifactCleanupProhibited());
            getHibernateTemplate().saveOrUpdate(stageArtifactCleanupProhibited);
        }
    }
    return null;
}
Also used : AbstractMap(java.util.AbstractMap) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HashMap(java.util.HashMap) StageArtifactCleanupProhibited(com.thoughtworks.go.domain.StageArtifactCleanupProhibited) StageConfig(com.thoughtworks.go.config.StageConfig)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 StageArtifactCleanupProhibited (com.thoughtworks.go.domain.StageArtifactCleanupProhibited)1 AbstractMap (java.util.AbstractMap)1 HashMap (java.util.HashMap)1