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;
}
Aggregations