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"));
}
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;
}
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());
}
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("}");
}
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;
}
Aggregations