use of com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder in project gocd by gocd.
the class JobPlanXmlRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
DocumentBuilder builder = DocumentBuilder.withRoot("scheduledJobs");
jobPlans.forEach(waitingJobPlan -> {
builder.node("job", jb -> populateJob(jb, ctx, waitingJobPlan));
});
return builder.build();
}
use of com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder in project gocd by gocd.
the class PipelinesXmlRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
DocumentBuilder builder = DocumentBuilder.withRoot("pipelines").encoding("UTF-8").link(ctx.relative(SELF), "self");
pipelineInstanceModels.forEach(pipeline -> builder.node("pipeline", nodeBuilder -> {
nodeBuilder.attr("href", ctx.stagesXmlLink(pipeline.getName()));
}));
return builder.build();
}
use of com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder in project gocd by gocd.
the class PipelineXmlRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
String self = ctx.pipelineXmlLink(instance.getName(), instance.getCounter());
DocumentBuilder builder = DocumentBuilder.withRoot("pipeline").attr("name", instance.getName()).attr("counter", instance.getCounter()).link(self, "self").cdataNode("id", instance.getPipelineIdentifier().asURN()).textNode("scheduleTime", instance.getScheduledDate());
PipelineTimelineEntry pipelineAfter = instance.getPipelineAfter();
if (pipelineAfter != null) {
builder.link(ctx.pipelineXmlLink(pipelineAfter.getPipelineName(), pipelineAfter.getId()), "insertedBefore");
}
PipelineTimelineEntry pipelineBefore = instance.getPipelineBefore();
if (pipelineBefore != null) {
builder.link(ctx.pipelineXmlLink(pipelineBefore.getPipelineName(), pipelineBefore.getId()), "insertedAfter");
}
builder.node("materials", materialBuilder -> {
instance.getLatestRevisions().forEach(revision -> {
this.populateMaterials(materialBuilder, revision, ctx);
});
});
builder.node("stages", stagesBuilder -> {
instance.getStageHistory().stream().filter(stage -> !(stage instanceof NullStageHistoryItem)).forEach(stage -> stagesBuilder.node("stage", stageBuilder -> stageBuilder.attr("href", ctx.stageXmlLink(stage.getIdentifier()))));
});
builder.cdataNode("approvedBy", instance.getApprovedBy());
return builder.build();
}
use of com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder in project gocd by gocd.
the class FeedEntriesRepresenter method toXml.
@Override
public Document toXml(XmlWriterContext ctx) {
String selfUrl = ctx.stagesXmlLink(pipelineName);
DocumentBuilder documentBuilder = DocumentBuilder.withRoot("feed", "http://www.w3.org/2005/Atom").encoding("UTF-8").additionalNamespace("go", "http://www.thoughtworks-studios.com/ns/go").cdataNode("title", pipelineName).textNode("id", selfUrl).node("author", builder -> builder.textNode("name", "Go")).textNode("updated", feedEntries.lastUpdatedDate()).link(selfUrl, "self");
if (feedEntries.last() != null) {
StageFeedEntry last = (StageFeedEntry) feedEntries.last();
documentBuilder.link(ctx.stagesXmlLink(pipelineName, last.getStageIdentifier().getPipelineCounter()), "next");
}
feedEntries.forEach(feed -> documentBuilder.node("entry", builder -> {
this.addEntry((StageFeedEntry) feed, builder, ctx);
}));
return documentBuilder.build();
}
Aggregations