Search in sources :

Example 1 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineSqlMapDao method loadHistory.

public PipelineInstanceModel loadHistory(long id) {
    String cacheKey = pipelineHistoryCacheKey(id);
    PipelineInstanceModel result = (PipelineInstanceModel) goCache.get(cacheKey);
    if (result == null) {
        synchronized (cacheKey) {
            result = (PipelineInstanceModel) goCache.get(cacheKey);
            if (result == null) {
                result = (PipelineInstanceModel) getSqlMapClientTemplate().queryForObject("getPipelineHistoryById", arguments("id", id).asMap());
                if (result == null) {
                    return null;
                }
                goCache.put(cacheKey, result);
            }
        }
    }
    return cloner.deepClone(result);
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 2 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineSqlMapDao method pipelineGraphByNameAndCounter.

public PipelineDependencyGraphOld pipelineGraphByNameAndCounter(String pipelineName, int pipelineCounter) {
    PipelineInstanceModels instanceModels = null;
    try {
        instanceModels = PipelineInstanceModels.createPipelineInstanceModels((List<PipelineInstanceModel>) getSqlMapClientTemplate().queryForList("pipelineAndItsDepedenciesByNameAndCounter", arguments("pipelineName", pipelineName).and("pipelineCounter", pipelineCounter).and("stageLocator", pipelineName + "/" + pipelineCounter + "/%/%").asMap()));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    if (instanceModels.isEmpty()) {
        return null;
    }
    PipelineInstanceModel upstreamPipeline = instanceModels.find(pipelineName);
    loadPipelineHistoryBuildCause(upstreamPipeline);
    return new PipelineDependencyGraphOld(upstreamPipeline, dependentPipelines(upstreamPipeline, instanceModels));
}
Also used : PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException)

Example 3 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineSqlMapDao method findPipelineHistoryByNameAndCounter.

public PipelineInstanceModel findPipelineHistoryByNameAndCounter(String pipelineName, int pipelineCounter) {
    PipelineInstanceModel instanceModel = loadPipelineInstanceModelByNameAndCounter(pipelineName, pipelineCounter);
    loadPipelineHistoryBuildCause(instanceModel);
    return instanceModel;
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)

Example 4 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineSqlMapDao method loadActivePipelineAndHistoryToCache.

private Thread[] loadActivePipelineAndHistoryToCache(final List<PipelineInstanceModel> pipelines) {
    final Thread activePipelinesCacheLoader = new Thread() {

        @Override
        public void run() {
            LOGGER.info("Loading Active Pipelines to cache...Started");
            Map<String, TreeSet<Long>> result = groupPipelineInstanceIdsByPipelineName(pipelines);
            goCache.put(activePipelinesCacheKey(), result);
            LOGGER.info("Loading Active Pipelines to cache...Done");
        }
    };
    final Thread historyCacheLoader = new Thread() {

        @Override
        public void run() {
            LOGGER.info("Loading pipeline history to cache...Started");
            for (PipelineInstanceModel pipeline : pipelines) {
                goCache.put(pipelineHistoryCacheKey(pipeline.getId()), pipeline);
            }
            LOGGER.info("Loading pipeline history to cache...Done");
        }
    };
    historyCacheLoader.start();
    activePipelinesCacheLoader.start();
    return new Thread[] { activePipelinesCacheLoader, historyCacheLoader };
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 5 with PipelineInstanceModel

use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.

the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineInstanceWithMultipleRevisions.

@Test
public void shouldLoadPipelineInstanceWithMultipleRevisions() {
    Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled(ModificationsMother.multipleModifications(pipelineOne.pipelineConfig()));
    configHelper.setViewPermissionForGroup("group1", "foo");
    PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
    assertThat(pipelineInstance, is(not(nullValue())));
    assertThat(pipelineInstance.hasNewRevisions(), is(false));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) Test(org.junit.Test)

Aggregations

PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)69 Test (org.junit.Test)46 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)20 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)15 Username (com.thoughtworks.go.server.domain.Username)15 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)14 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)10 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)8 Modification (com.thoughtworks.go.domain.materials.Modification)7 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)7 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)6 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)4 Material (com.thoughtworks.go.domain.materials.Material)4 PipelineHistoryGroups (com.thoughtworks.go.server.presentation.models.PipelineHistoryGroups)4 Date (java.util.Date)4 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3