use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method getAllActivePipelineNamesVsTheirInstanceIDs.
private Map<String, TreeSet<Long>> getAllActivePipelineNamesVsTheirInstanceIDs() {
String cacheKey = activePipelinesCacheKey();
Map<String, TreeSet<Long>> result = (Map<String, TreeSet<Long>>) goCache.get(cacheKey);
if (result == null) {
synchronized (cacheKey) {
result = (Map<String, TreeSet<Long>>) goCache.get(cacheKey);
if (result == null) {
List<PipelineInstanceModel> pipelines = getAllPIMs();
result = groupPipelineInstanceIdsByPipelineName(pipelines);
goCache.put(cacheKey, result);
}
}
}
return result;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method cacheMaterialRevisions.
private void cacheMaterialRevisions(List<PipelineInstanceModel> models) {
List<CaseInsensitiveString> pipelinesInConfig = getPipelineNamesInConfig();
if (pipelinesInConfig.isEmpty()) {
LOGGER.warn("No pipelines found in Config, Skipping material revision caching.");
return;
}
Set<Long> ids = new HashSet<Long>();
for (PipelineInstanceModel model : models) {
if (pipelinesInConfig.contains(new CaseInsensitiveString(model.getName()))) {
ids.add(model.getId());
}
}
if (ids.isEmpty()) {
LOGGER.warn("No PIMs found in Config, Skipping material revision caching.");
return;
}
materialRepository.cacheMaterialRevisionsForPipelines(ids);
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method loadPipelineInstanceModelByNameAndCounter.
private PipelineInstanceModel loadPipelineInstanceModelByNameAndCounter(String pipelineName, int pipelineCounter) {
String cacheKey = cacheKeyForPipelineHistoryByNameAndCounter(pipelineName, pipelineCounter);
PipelineInstanceModel instanceModel = (PipelineInstanceModel) goCache.get(cacheKey);
if (instanceModel == null) {
synchronized (cacheKey) {
instanceModel = (PipelineInstanceModel) goCache.get(cacheKey);
if (instanceModel == null) {
instanceModel = (PipelineInstanceModel) getSqlMapClientTemplate().queryForObject("getPipelineHistoryByNameAndCounter", arguments("pipelineName", pipelineName).and("pipelineCounter", pipelineCounter).asMap());
goCache.put(cacheKey, instanceModel);
}
}
}
return instanceModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method convertToPipelineInstanceModels.
private PipelineInstanceModels convertToPipelineInstanceModels(Map<String, TreeSet<Long>> result) {
List<PipelineInstanceModel> models = new ArrayList<PipelineInstanceModel>();
List<CaseInsensitiveString> pipelinesInConfig = getPipelineNamesInConfig();
if (pipelinesInConfig.isEmpty()) {
LOGGER.warn("No pipelines found in Config, Skipping PIM loading.");
return PipelineInstanceModels.createPipelineInstanceModels(models);
}
List<Long> pipelineIds = loadIdsFromHistory(result);
int collectionCount = pipelineIds.size();
for (int i = 0; i < collectionCount; i++) {
Long id = pipelineIds.get(i);
PipelineInstanceModel model = loadHistory(id);
if (model == null) {
continue;
}
if (!pipelinesInConfig.contains(new CaseInsensitiveString(model.getName()))) {
LOGGER.debug("Skipping PIM for pipeline {} ,since its not found in current config", model.getName());
continue;
}
models.add(model);
loadPipelineHistoryBuildCause(model);
}
return PipelineInstanceModels.createPipelineInstanceModels(models);
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineOperationsControllerV1Delegate method triggerOptions.
public String triggerOptions(Request request, Response response) throws IOException {
String pipelineName = request.params("pipeline_name");
EnvironmentVariablesConfig variables = goConfigService.variablesFor(pipelineName);
PipelineInstanceModel pipelineInstanceModel = pipelineHistoryService.latest(pipelineName, currentUsername());
TriggerOptions triggerOptions = new TriggerOptions(variables, pipelineInstanceModel);
return writerForTopLevelObject(request, response, writer -> TriggerWithOptionsViewRepresenter.toJSON(writer, triggerOptions));
}
Aggregations