Skip to content

Pipeline

Purpose

The execution pipeline map is used to pass variables between services. The pipeline allows variables to be passed to scripts and services as well as allowing multiple return values. Values are typically Strings however there are specialisations for XML processing and Platform 6 message item keys.

Methods

Binding name: p6.pipeline


get

Get the value of a named pipeline variable as a String.

Syntax

String p6.pipeline.get(String variableName)

Warning

If the content-type of the variable is not suitable for conversion to a String a P6Exception will be thrown.

Example
println p6.pipeline.get("name")

getBytes

Get the value of a named pipeline variable as a byte array.

Syntax

byte[] p6.pipeline.getBytes(String variableName)
Example
def bytes = p6.pipeline.getBytes("name")

getXml

Get the value of a named pipeline variable as a GPathResult (assumed the variable is an Xml String)

Syntax

GPathResult p6.pipeline.getXml(String variableName)
Example
def xml = p6.pipeline.getXml("name")

getXml (advanced)

Extended variant of the above method allowing greater control over the XmlSlurper

Syntax

GPathResult p6.pipeline.getXml(
    String variableName,
    boolean validating,
    boolean namespaceAware,
    boolean allowDocTypeDeclaration
)

Info

GPath is a path expression language integrated into Groovy which allows parts of nested structured data to be identified. In this sense, it has similar aims and scope as XPath does for XML. The two main places where you use GPath expressions is when dealing with nested POJOs or when dealing with XML.

Example
def xml = p6.pipeline.getXml("name", true, true, true)

getDom

Get the value of a named pipeline variable as a W3C DOM(internal content type is application/p6core.dom)

Syntax

org.w3c.dom.Document p6.pipeline.getDom(String variableName)
Example
def doc = p6.pipeline.getDom("name")

getPk

Get the named BaseItemPK object (internal content type is application/p6core.itempk)

Syntax

BaseItemPK p6.pipeline.getPk(String variableName)
Example
def pk = p6.pipeline.getPk("name")

put

Add or replace the String value of a named pipeline variable. Charset defaults to: text/plain; charset=”utf-8”.

Syntax

TypedContent p6.pipeline.put(String variableName, String value)

Info

Content-type will be default to text/plain and charset to UTF-8

Example
p6.pipeline.put("name", "value")

put (with contentType)

Add or replace the String value of a named pipeline variable using the given content-type.

Syntax

TypedContent p6.pipeline.put(
    String variableName,
    String value,
    String contentType
)

Info

You can define the charset with the contentType (ie. application/xml;charset=UTF-8)

Example
p6.pipeline.put("name", "<xml></xml>", "application/xml")

put (byte array)

Add or replace the byte[] value of a named pipeline variable.

Syntax

TypedContent p6.pipeline.put(String variableName, byte[] bytes)

Info

Content-type will be set to application/octet-stream

Example
p6.pipeline.put("name", [] as byte[])

put (ItemPK)

Add or replace the ItemPK value of a named pipeline variable. Charset defaults to: application/p6core.itempk

Syntax

TypedContent p6.pipeline.put(String variableName, ItemPK itemPk)
Example
p6.pipeline.put("name", pk)

put (with charset)

Add or replace the Object value of a named pipeline variable using the given charset.

Syntax

TypedContent p6.pipeline.put(
    String variableName,
    Object value,
    String charset
)
Example
p6.pipeline.put("name", "value", "application/text")

put (org.w3c.dom.Document)

Add or replace the W3C DOM value of a named pipeline variable. Charset defaults to: application/p6core.dom

Syntax

TypedContent p6.pipeline.put(
    String variableName,
    org.w3c.dom.Document value
)
Example
def doc = p6.pipeline.getDom("name")
p6.pipeline.put("other", doc)

putPk

Add the named BaseItemPK object (internal content type is application/p6core.itempk)

Syntax

TypedContent p6.pipeline.putPk(
    String variableName,
    BaseItemPK baseItemPk
)
Example
def pk = p6.transaction.buildTIPK("123", "456")
p6.pipeline.putPk("name", pk)

remove

Remove the value of a named pipeline variable. The value of the removed variable is returned.

Syntax

String p6.pipeline.remove(String variableName)
Example
def value = p6.pipeline.remove("name")

variables

Returns a collection of all pipeline variable names.

Syntax

String[] p6.pipeline.variables()
Example
p6.pipeline.variables().each() {
    println "${it}"
}

toStringMap

Returns a Map of all pipeline variables expressed as Strings

Syntax

Map<String, String> p6.pipeline.toStringMap()
Example
p6.pipeline.toStringMap().each { key, value ->
    println "${key} = ${value}"
}

Warning

This method only includes pipeline variables with a content-type of text. This does not include json, xml etc.