Project

The project steps allows you to select columns to display (rearrange them) and also to create new columns.

Input data

For all the examples, the following input data will be used:

ID FIRSTNAME LASTNAME SEX BIRTHDATE DEPARTMENT SALARY FEES LEVEL PARENT ACTIVE
01 Peter Bosshard M 05.02.1958 DIR 5800.00 340.05 1 true
02 Maria Skinov F 25.06.1964 DIR 5700.00 480.15 2 01 true
03 Casey Cole M 28.08.1955 DIR 5700.00 210.50 2 01 true
04 Roger Binner M 13.01.1959 DIR 5700.00 230.55 2 01 true
05 Olive Saltin F 31.03.1961 DIR 5700.00 727.12 2 01 false
06 Bill Amacker M 27.10.1968 HEA 5300.00 0.00 3 02 true
07 Aby Thornson F 26.11.1967 HEA 5300.00 140.00 3 02 true
08 Anne Pevler F 14.09.1967 HEA 5300.00 150.00 3 03 true
09 Annita Smith F 17.12.1967 HEA 5300.00 60.00 3 04 true
10 Robert Smith M 13.12.1970 DEV 5000.00 0.00 4 06 true
11 Maggie Frill F 29.02.1972 DEV 5000.00 0.00 4 06 true
12 Daniel Metzler M 01.01.1973 DEV 4900.00 0.00 4 07 true
13 Frank Witz M 05.01.1973 DEV 4900.00 10.00 4 07 true
14 Franky Bilen M 12.12.1972 DEV 4900.00 0.00 4 07 true
15 Ed Krack M 08.04.1969 DEV 5100.00 0.00 4 07 true
16 Sean Huskynd M 04.09.1971 DEV 4900.00 0.00 4 07 false
17 Alice Muller F 09.10.1976 STG 4500.00 0.00 4 07 true

Select and rearrange columns

This first examples shows a simple BlueIron descriptor that will simple select some columns to display and the newcolumn projector reference an existing input column, only the IDs in the input step can be referenced.

<blueiron output="final">
  <input id="employees">
    <column id="ID" type="String" />
    <column id="FIRSTNAME" type="String" />
    <column id="LASTNAME" type="String" />
    <column id="SEX" type="String" />
    <column id="BIRTHDATE" type="Date" />
    <column id="DEPARTMENT" type="String" />
    <column id="SALARY" type="BigDecimal" />
    <column id="FEES" type="BigDecimal" />
    <column id="LEVEL" type="Integer" />
    <column id="PARENT" type="String" />
    <column id="ACTIVE" type="Boolean" />
  </input>

  <step id="final" source="employees">
     <project> <!-- only the five columns below will be outputted -->
       <column id="ID" />
       <column id="LASTNAME" />
       <column id="FIRSTNAME" />
       <column id="BIRTHDATE" />
       <column id="SEX" />
     </project>
  </step>
</blueiron>
ID LASTNAME FIRSTNAME BIRTHDATE SEX
01 Bosshard Peter 05.02.1958 M
02 Skinov Maria 25.06.1964 F
03 Cole Casey 28.08.1955 M
04 Binner Roger 13.01.1959 M
05 Saltin Olive 31.03.1961 F
06 Amacker Bill 27.10.1968 M
07 Thornson Aby 26.11.1967 F
08 Pevler Anne 14.09.1967 F
09 Smith Annita 17.12.1967 F
10 Smith Robert 13.12.1970 M
11 Frill Maggie 29.02.1972 F
12 Metzler Daniel 01.01.1973 M
13 Witz Frank 05.01.1973 M
14 Bilen Franky 12.12.1972 M
15 Krack Ed 08.04.1969 M
16 Huskynd Sean 04.09.1971 M
17 Muller Alice 09.10.1976 F

Create new columns

It is possible to create new columns and also keep the exising columns. The project step supports the attribute insert which can contains either the value ‘before’ or ‘after’.

In this example, the columns FULLNAME and FULLSALARY will be created. Since these columns are insrted after the input columns, their name must not clash with an existing input column.

<blueiron output="final">
  <input id="employees">
    <column id="ID" type="String" />
    <column id="FIRSTNAME" type="String" />
    <column id="LASTNAME" type="String" />
    <column id="SEX" type="String" />
    <column id="BIRTHDATE" type="Date" />
    <column id="DEPARTMENT" type="String" />
    <column id="SALARY" type="BigDecimal" />
    <column id="FEES" type="BigDecimal" />
    <column id="LEVEL" type="Integer" />
    <column id="PARENT" type="String" />
    <column id="ACTIVE" type="Boolean" />
  </input>

  <step id="final" source="employees">
     <project insert="after">
       <value id="FULLNAME">${FIRSTNAME} ${LASTNAME}</value>
       <expr id="FULLSALARY">SALARY + FEES</expr>
     </project>
  </step>
</blueiron>
ID FIRSTNAME LASTNAME SEX BIRTHDATE DEPARTMENT SALARY FEES LEVEL PARENT ACTIVE FULLNAME FULLSALARY
01 Peter Bosshard M 05.02.1958 DIR 5800.00 340.05 1 true Peter Bosshard 6140.05
02 Maria Skinov F 25.06.1964 DIR 5700.00 480.15 2 01 true Maria Skinov 6180.15
03 Casey Cole M 28.08.1955 DIR 5700.00 210.50 2 01 true Casey Cole 5910.50
04 Roger Binner M 13.01.1959 DIR 5700.00 230.55 2 01 true Roger Binner 5930.55
05 Olive Saltin F 31.03.1961 DIR 5700.00 727.12 2 01 false Olive Saltin 6427.12
06 Bill Amacker M 27.10.1968 HEA 5300.00 0.00 3 02 true Bill Amacker 5300.00
07 Aby Thornson F 26.11.1967 HEA 5300.00 140.00 3 02 true Aby Thornson 5440.00
08 Anne Pevler F 14.09.1967 HEA 5300.00 150.00 3 03 true Anne Pevler 5450.00
09 Annita Smith F 17.12.1967 HEA 5300.00 60.00 3 04 true Annita Smith 5360.00
10 Robert Smith M 13.12.1970 DEV 5000.00 0.00 4 06 true Robert Smith 5000.00
11 Maggie Frill F 29.02.1972 DEV 5000.00 0.00 4 06 true Maggie Frill 5000.00
12 Daniel Metzler M 01.01.1973 DEV 4900.00 0.00 4 07 true Daniel Metzler 4900.00
13 Frank Witz M 05.01.1973 DEV 4900.00 10.00 4 07 true Frank Witz 4910.00
14 Franky Bilen M 12.12.1972 DEV 4900.00 0.00 4 07 true Franky Bilen 4900.00
15 Ed Krack M 08.04.1969 DEV 5100.00 0.00 4 07 true Ed Krack 5100.00
16 Sean Huskynd M 04.09.1971 DEV 4900.00 0.00 4 07 false Sean Huskynd 4900.00
17 Alice Muller F 09.10.1976 STG 4500.00 0.00 4 07 true Alice Muller 4500.00

Projection with new columns

It is possible to select some columns and to create new ones within the same project step. Moreover, it is also possible to completely override an existing input column.

<blueiron output="final">
  <input id="employees">
    <column id="ID" type="String" />
    <column id="FIRSTNAME" type="String" />
    <column id="LASTNAME" type="String" />
    <column id="SEX" type="String" />
    <column id="BIRTHDATE" type="Date" />
    <column id="DEPARTMENT" type="String" />
    <column id="SALARY" type="BigDecimal" />
    <column id="FEES" type="BigDecimal" />
    <column id="LEVEL" type="Integer" />
    <column id="PARENT" type="String" />
    <column id="ACTIVE" type="Boolean" />
  </input>

  <step id="final" source="employees">
     <project>
       <column id="ID" />
       <value id="FULLNAME">${FIRSTNAME} ${LASTNAME}</value>
       <expr id="SALARY">SALARY + FEES</expr>
       <column id="BIRTHDATE" />
     </project>
  </step>
</blueiron>
ID FULLNAME SALARY BIRTHDATE
01 Peter Bosshard 6140.05 05.02.1958
02 Maria Skinov 6180.15 25.06.1964
03 Casey Cole 5910.50 28.08.1955
04 Roger Binner 5930.55 13.01.1959
05 Olive Saltin 6427.12 31.03.1961
06 Bill Amacker 5300.00 27.10.1968
07 Aby Thornson 5440.00 26.11.1967
08 Anne Pevler 5450.00 14.09.1967
09 Annita Smith 5360.00 17.12.1967
10 Robert Smith 5000.00 13.12.1970
11 Maggie Frill 5000.00 29.02.1972
12 Daniel Metzler 4900.00 01.01.1973
13 Frank Witz 4910.00 05.01.1973
14 Franky Bilen 4900.00 12.12.1972
15 Ed Krack 5100.00 08.04.1969
16 Sean Huskynd 4900.00 04.09.1971
17 Alice Muller 4500.00 09.10.1976

Go further