Search in sources :

Example 11 with PipelineInstanceModel

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

the class PipelineDependencyGraphOldTest method shouldProvideMaterialRevisionForAGivenDownStreamPipeline.

@Test
public void shouldProvideMaterialRevisionForAGivenDownStreamPipeline() throws Exception {
    StageInstanceModels stages = new StageInstanceModels();
    stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
    stages.add(new StageInstanceModel("stage-1", "2", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-1", "2")));
    PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
    PipelineInstanceModel down1 = pim("blahDown1");
    down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
    PipelineInstanceModel down2 = pim("blahDown2");
    down2.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
    PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1, down2));
    assertThat(graph.dependencyRevisionFor(down1), is("blahUpStream/23/stage-0/21"));
    assertThat(graph.dependencyRevisionFor(down2), is("blahUpStream/23/stage-1/2"));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel) PipelineDependencyGraphOld(com.thoughtworks.go.domain.PipelineDependencyGraphOld) Test(org.junit.Test)

Example 12 with PipelineInstanceModel

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

the class FanInGraph method createFinalRevisionsForScmChildren.

private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
    Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
    List<MaterialRevision> finalRevisions = new ArrayList<>();
    for (RootFanInNode child : scmChildren) {
        child.setScmRevision(scmMaterialsFromDepChildren);
        MaterialConfig materialConfig = child.materialConfig;
        Material material = materialConfigConverter.toMaterial(materialConfig);
        MaterialRevision revision = new MaterialRevision(material);
        if (latestRootNodeInstance != null) {
            PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
            for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
                if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
                    List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
                    revision.addModifications(modificationsSince);
                    break;
                }
            }
        }
        if (revision.getModifications().isEmpty() && child.scmRevision == null) {
            MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
            finalRevisions.addAll(latestRevisions.getRevisions());
            continue;
        }
        if (revision.getModifications().isEmpty()) {
            revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
        }
        finalRevisions.add(revision);
    }
    return finalRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 13 with PipelineInstanceModel

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

the class ViewCacheKey method keyForPipelineModelFragment.

private String keyForPipelineModelFragment(PipelineModel model, String name) {
    StringBuilder s = new StringBuilder();
    s.append(name);
    //FIXME: use the delimiter, the two values appended at this point can combine to get something completely different (ALWAYS USE DELIMITER.)!!! - Sara & JJ
    s.append(model.getName());
    appendLockStatus(model, s);
    for (PipelineInstanceModel pim : model.getActivePipelineInstances()) {
        s.append("[");
        s.append(pim.getId()).append(DELIMITER);
        for (StageInstanceModel stageInstanceModel : pim.getStageHistory()) {
            s.append(stageInstanceModel.getName()).append(DELIMITER);
            s.append(stageInstanceModel.getId()).append(DELIMITER);
            s.append(stageInstanceModel.getState()).append(DELIMITER);
        }
        s.append("]");
    }
    s.append(model.canOperate()).append(DELIMITER);
    s.append(model.canForce()).append(DELIMITER);
    PipelinePauseInfo pauseInfo = model.getPausedInfo();
    s.append(pauseInfo.isPaused()).append(DELIMITER).append(pauseInfo.getPauseCause().replaceAll("\\W", "")).append(DELIMITER).append(pauseInfo.getPauseBy());
    s.append(DELIMITER).append(model.canAdminister());
    return key(s.toString());
}
Also used : PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 14 with PipelineInstanceModel

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

the class ViewCacheKey method appendLockStatus.

private void appendLockStatus(PipelineModel model, StringBuilder s) {
    PipelineInstanceModel latestPIM = model.getLatestPipelineInstance();
    s.append("{");
    s.append(latestPIM.isLockable()).append(DELIMITER);
    s.append(latestPIM.isCurrentlyLocked()).append(DELIMITER);
    s.append(latestPIM.canUnlock());
    s.append("}");
}
Also used : PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)

Example 15 with PipelineInstanceModel

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

the class PipelineHistoryMother method singlePipeline.

public static PipelineInstanceModel singlePipeline(String pipelineName, StageInstanceModels stages, Date modifiedDate) {
    BuildCause manualForced = BuildCause.createManualForced(new MaterialRevisions(new MaterialRevision(MaterialsMother.hgMaterial(), new Modification(modifiedDate, "abc", "MOCK_LABEL-12", null))), Username.ANONYMOUS);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline(pipelineName, -1, "1", manualForced, stages);
    model.setCounter(1);
    return model;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause)

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