Search in sources :

Example 51 with PipelineInstanceModel

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;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 52 with PipelineInstanceModel

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);
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 53 with PipelineInstanceModel

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;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 54 with PipelineInstanceModel

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);
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 55 with PipelineInstanceModel

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));
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) TriggerOptions(com.thoughtworks.go.apiv1.pipelineoperations.representers.TriggerOptions) EnvironmentVariablesConfig(com.thoughtworks.go.config.EnvironmentVariablesConfig)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)60 Test (org.junit.Test)31 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)15 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)12 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)7 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)5 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)4 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Modification (com.thoughtworks.go.domain.materials.Modification)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Matchers.anyString (org.mockito.Matchers.anyString)4 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)3 TimeProvider (com.thoughtworks.go.util.TimeProvider)3 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 TrackingTool (com.thoughtworks.go.config.TrackingTool)2