Using Table Parameters
The Parameters tab of the Process Definition editing pop-up window lets you create parameters that use the Table parameter type.
Table parameters contain data in rows and columns, much like a spreadsheet. Table parameters come in four types:
TableParameterType.Inline
: Table parameters of typeInline
hold a String value with anInline:
prefix, followed by XML data. Processing instructions are optional, but if present, must be followed by newline characters before the<table>
tag if specified.TableParameterType.JobFile
: Table parameters of typeJobFile
hold a String value with aJobFile:
prefix, followed by reference to a process file in the format<ID>:<file_name>
. For example,JobFile:1234:stdout.rtx
evaluates to the filestdout.rtx
on process with ID1234
.TableParameterType.RelativeFile
: Table parameters of typeRelativeFile
hold a String value with aRelativeFile:
prefix, followed by a file specification of a relative process such asRelative:<step_name>, Job <process_ID>:<file_name>
. For example:RelativeFile:Initialization, Job 3:output.rtx
.TableParameterType.Table
: Table parameters of typeTable
contain the business key of a table in the formatTable:<partition>.<table>
. For example:Table:MyPartition.MyTable
.
Prerequisites
Table parameters are supported by the RedwoodScript Process Definition and certain Redwood Finance Automation-specific Definition Types
API
The TableParameterRuntime interface (Table parameters at Runtime) has getRTXReader()
and getRTXWriter()
methods that allow you to read and write Tables, respectively. Each column has a data type (for example, String
, DateTimeZone
, BigDecimal
). The value of each row in a column must be convertible to the data type or the table will be considered invalid. See the com.redwood.scheduler.api.rtx
package for classes and how to use them.
Sample RTX File
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://schema.redwood.com/report/rtx.xsd">
<metadata>
<columns>
<column>
<name>symbol</name>
<string></string>
</column>
<column>
<name>value</name>
<number></number>
</column>
<column>
<name>date</name>
<date></date>
</column>
</columns>
</metadata>
<data>
<r><k></k><v>APPL</v><v>156.41</v><v>2023/07/27</v></r>
<r><k></k><v>SDY</v><v>93.14</v><v>2023/07/27</v></r>
<r><k></k><v>INTC</v><v>40.80</v><v>2023/07/27</v></r>
<r><k></k><v>BRKB</v><v>189.71</v><v>2023/07/27</v></r>
<r><k></k><v>FB</v><v>170.60</v><v>2023/07/27</v></r>
<r><k></k><v>GOOG</v><v>973.33</v><v>2023/07/27</v></r>
</data>
</table>
Writing an RTX File
This technique uses a Table parameter named outParameter
on the definition that is an Out parameter. The out value of the parameter will be set to a file reference (for example, JobFile:1234:stdout.rtx
). Use getRTXWriterInline()
if you want to have the table data inline.
import java.math.BigDecimal;
import com.redwood.scheduler.api.date.DateTimeZone;
import com.redwood.scheduler.api.rtx.*;
{
try (RTXWriter writer = outParameter.getRTXWriterToStandardOutput())
{
writer.addColumn(new RTXColumn("symbol", RTXType.String));
writer.addColumn(new RTXColumn("value", RTXType.Number));
writer.addColumn(new RTXColumn("date", RTXType.Date));
writer.addColumn(new RTXColumn("date2", RTXType.String));
DateTimeZone dtz = DateTimeZone.valueOf("2023/07/27 00:00:00,000 America/New_York");
String date2 = dtz.toFormattedString("dd-MM-yyyy");
writer.addRow(new Object [] { "AAPL", "156.41", dtz, date2, });
writer.addRow(new Object [] { "SDY", "93.14" , dtz, date2, });
writer.addRow(new Object [] { "INTC", "40.80" , dtz, date2, });
writer.addRow(new Object [] { "BRKB", "189.71", dtz, date2, });
writer.addRow(new Object [] { "FB", "170.60", dtz, date2, });
writer.addRow(new Object [] { "GOOG", "973.33", dtz, date2, });
}
}