Search in sources :

Example 1 with DocumentBuilder

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();
}
Also used : DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder)

Example 2 with DocumentBuilder

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();
}
Also used : Document(org.dom4j.Document) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder) XmlRepresentable(com.thoughtworks.go.domain.XmlRepresentable) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder)

Example 3 with DocumentBuilder

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();
}
Also used : Document(org.dom4j.Document) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) ElementBuilder(com.thoughtworks.go.server.domain.xml.builder.ElementBuilder) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) XmlRepresentable(com.thoughtworks.go.domain.XmlRepresentable) MaterialXmlRepresenter(com.thoughtworks.go.server.domain.xml.materials.MaterialXmlRepresenter) NullStageHistoryItem(com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry)

Example 4 with DocumentBuilder

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();
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Document(org.dom4j.Document) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) ElementBuilder(com.thoughtworks.go.server.domain.xml.builder.ElementBuilder) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder) StringUtils.lowerCase(org.apache.commons.lang3.StringUtils.lowerCase) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry) XmlRepresentable(com.thoughtworks.go.domain.XmlRepresentable) FeedEntries(com.thoughtworks.go.domain.feed.FeedEntries) DocumentBuilder(com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder) StageFeedEntry(com.thoughtworks.go.domain.feed.stage.StageFeedEntry)

Aggregations

DocumentBuilder (com.thoughtworks.go.server.domain.xml.builder.DocumentBuilder)4 XmlRepresentable (com.thoughtworks.go.domain.XmlRepresentable)3 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)3 Document (org.dom4j.Document)3 ElementBuilder (com.thoughtworks.go.server.domain.xml.builder.ElementBuilder)2 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 FeedEntries (com.thoughtworks.go.domain.feed.FeedEntries)1 StageFeedEntry (com.thoughtworks.go.domain.feed.stage.StageFeedEntry)1 NullStageHistoryItem (com.thoughtworks.go.presentation.pipelinehistory.NullStageHistoryItem)1 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 MaterialXmlRepresenter (com.thoughtworks.go.server.domain.xml.materials.MaterialXmlRepresenter)1 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)1 StringUtils.lowerCase (org.apache.commons.lang3.StringUtils.lowerCase)1