Search in sources :

Example 1 with OutputWriter

use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.

the class MessageJson method toString.

public String toString() {
    StringWriter buffer = new StringWriter(1024);
    new JsonOutputWriter(buffer, null).forTopLevelObject((OutputWriter writer) -> {
        writer.add("message", message);
        if (data != null) {
            writer.add("data", data);
        }
    });
    return buffer.toString();
}
Also used : StringWriter(java.io.StringWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonOutputWriter(com.thoughtworks.go.api.base.JsonOutputWriter)

Example 2 with OutputWriter

use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.

the class TriggerWithOptionsViewRepresenter method toJSON.

public static void toJSON(OutputWriter writer, TriggerOptions triggerOptions) {
    PipelineInstanceModel pipelineInstanceModel = triggerOptions.getPipelineInstanceModel();
    writer.addLinks(outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Pipeline.DOC_TRIGGER_OPTIONS).addLink("self", Routes.Pipeline.triggerOptions(pipelineInstanceModel.getName())).addLink("schedule", Routes.Pipeline.schedule(pipelineInstanceModel.getName()))).addChildList("variables", outputListWriter -> triggerOptions.getVariables().forEach(env -> outputListWriter.addChild(envWriter -> {
        envWriter.add("name", env.getName()).add("secure", env.isSecure());
        if (!env.isSecure()) {
            envWriter.add("value", env.getValue());
        }
    }))).addChildList("materials", outputListWriter -> pipelineInstanceModel.getMaterials().forEach(material -> outputListWriter.addChild(material(material, pipelineInstanceModel.findCurrentMaterialRevisionForUI(material)))));
}
Also used : Consumer(java.util.function.Consumer) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Routes(com.thoughtworks.go.spark.Routes) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)

Example 3 with OutputWriter

use of com.thoughtworks.go.api.base.OutputWriter in project gocd by gocd.

the class PipelineRepresenter method toJSON.

public static void toJSON(OutputWriter jsonOutputWriter, GoDashboardPipeline model, Username username) {
    String usernameString = username.getUsername().toString();
    jsonOutputWriter.addLinks(linksWriter -> addLinks(linksWriter, model)).add("name", model.name().toString()).add("last_updated_timestamp", model.getLastUpdatedTimeStamp()).add("locked", model.model().getLatestPipelineInstance().isCurrentlyLocked()).addChild("pause_info", getPauseInfoNEW(model)).add("can_operate", model.isPipelineOperator(usernameString)).add("can_administer", model.canBeAdministeredBy(usernameString)).add("can_unlock", model.canBeOperatedBy(usernameString)).add("can_pause", model.canBeOperatedBy(usernameString)).add("from_config_repo", !model.isLocal());
    if (model.getTrackingTool().isPresent()) {
        TrackingTool trackingTool = model.getTrackingTool().get();
        jsonOutputWriter.addChild("tracking_tool", childWriter -> {
            childWriter.add("regex", trackingTool.getRegex()).add("link", trackingTool.getLink());
        });
    }
    jsonOutputWriter.addChild("_embedded", childWriter -> {
        childWriter.addChildList("instances", writeInstances(model));
    });
}
Also used : OutputListWriter(com.thoughtworks.go.api.base.OutputListWriter) Consumer(java.util.function.Consumer) TrackingTool(com.thoughtworks.go.config.TrackingTool) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) StringUtils(org.apache.commons.lang.StringUtils) GoDashboardPipeline(com.thoughtworks.go.server.dashboard.GoDashboardPipeline) Username(com.thoughtworks.go.server.domain.Username) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) OutputLinkWriter(com.thoughtworks.go.api.base.OutputLinkWriter) Routes(com.thoughtworks.go.spark.Routes) EmptyPipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel) TrackingTool(com.thoughtworks.go.config.TrackingTool)

Aggregations

OutputWriter (com.thoughtworks.go.api.base.OutputWriter)3 Routes (com.thoughtworks.go.spark.Routes)2 Consumer (java.util.function.Consumer)2 JsonOutputWriter (com.thoughtworks.go.api.base.JsonOutputWriter)1 OutputLinkWriter (com.thoughtworks.go.api.base.OutputLinkWriter)1 OutputListWriter (com.thoughtworks.go.api.base.OutputListWriter)1 TrackingTool (com.thoughtworks.go.config.TrackingTool)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 EmptyPipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.EmptyPipelineInstanceModel)1 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)1 GoDashboardPipeline (com.thoughtworks.go.server.dashboard.GoDashboardPipeline)1 Username (com.thoughtworks.go.server.domain.Username)1 StringWriter (java.io.StringWriter)1 StringUtils (org.apache.commons.lang.StringUtils)1