| Version | Date | Notes | By |
|---|---|---|---|
| 0.3 | 2018-03-20 | Baum Node Transformer | ROB |
| 0.2 | 2018-01-29 | More Transformers | ROB |
| 0.1 | 2018-01-23 | Initial release | ROB |
Transformers change the list of extracted items in some way, they can be chained multiple times to obtain the needed result.
This transformer allows the renaming of columns (source column to new name column for the destination)
| Name | Type | Description |
|---|---|---|
| columns | Array - String => String | allows the columns to be renamed. must be array of old_name => new_name |
$job->transform('App\Etl\Transformers\ColumnRenameTransformer', [
'columns' => [
'C1262' => 'id',
'C1263' => 'name',
'C1274' => 'username',
'C1269' => 'email',
'C1752' => 'acronym',
'C1276' => 'locale',
'C1267' => 'company_phone_number',
'C1267' => 'national_id_number',
'C21174' => 'number'
]
]);
This transformer excludes all columns not in the provided list
| Name | Type | Description |
|---|---|---|
| columns | Array - String | array of columns to include (all others will be excluded) |
$job->transform('App\Etl\Transformers\IncludeOnlyColumnsTransformer', [
'columns' => [
'id',
'name',
'username',
'email',
'acronym',
'locale',
'company_phone_number',
'national_id_number',
'number'
]
]);
This transformer encrypts the value of the column (Using laravel's Crypt::encrypt() function)
| Name | Type | Description |
|---|---|---|
| columns | Array - String | columns to encrypt |
| key | String | application key of the client |
$job->transform('App\Etl\Transformers\EncryptColumnsTransformer', [
'columns' => [
'national_id_number'
],
'key' => base64_decode('base64:DuJBVxAMTPzC5YWNpAniTTL8gxOe04CxSxvrfgcx0qw=')
]);
This transformer adds a new column with a static value (value will be repeated for all rows)
| Name | Type | Description |
|---|---|---|
| new_columns | Array - String => mixed | columns to create with a set value. |
$job->transform('App\Etl\Transformers\AddColumnsStaticValueTransformer', [
'new_columns' => [
'password' => \Hash::make('wemake'),
'system_reserved_user' => 0,
'status_id' => 1,
'sync_status_with_external_auth_provider' => 0,
'created_at' => $now,
'updated_at' => $now
]
]);
This transformer adds a new column with a value returned by a given callback
| Name | Type | Description |
|---|---|---|
| new_columns | Array - String => Callback($row, $index) | columns to create with the value returned by the callback. |
$job->transform('App\Etl\Transformers\AddColumnsCallbackValueTransformer', [
'new_columns' => [
'email' => function($row) {
return $row['username'] . '@wemake.pt';
},
'acronym' => function($row) {
return (!empty($row['acronym'])) ? $row['acronym'] : $row['username'];
},
'locale' => function($row) {
$locale = strtolower($row['locale']);
return (in_array($locale, ['pt', 'en'])) ? $locale : 'pt';
}
]
]);
This transformer will update the values of any given column to use the diff stored in the sequencer.
| Name | Type | Description |
|---|---|---|
| columns | Array - String => String | columns to update the values of using the table (in the destination database) named (column => table), for example user_id => t00_users. |
$job
->transform('App\Etl\Transformers\DropRowsIfCallbackFailTransformer', [
'columns' => [
'user_id' => 't00_users'
]
])
This transformer drops rows if the callback returns false
| Name | Type | Description |
|---|---|---|
| columns | Array - String => Callback($row) | if this callback returns false, then the row evaluated will be dropped from the data list. |
$job
->transform('App\Etl\Transformers\DropRowsIfCallbackFailTransformer', [
'callback' => function($item) {
return $item['user_id'] > 0;
}
])
This transformer uses a callback to completelly transform the items list into a new items list (only what the callback returns will be passed on, the old items will be discarded). The callback must return an array of items, so there is the potential for one old row to become many new ones.
| Name | Type | Description |
|---|---|---|
| callback | Callback($row) : Array of $row | the callback that will operate the per row transformation. |
$job->transform('App\Etl\Transformers\RemakeItemsViaCallbackTransformer', [
'callback' => function($item) use ($document_actions) {
$new_items = collect([]);
if($item['v9_permissions__alter_constitution']) {
$new_items->push([
'family_id' => $item['family_id'],
'action_id' => $document_actions['change-constitution']
]);
}
if($item['v9_permissions__alter_accesses']) {
$new_items->push([
'family_id' => $item['family_id'],
'action_id' => $document_actions['change-access']
]);
}
if($item['v9_permissions__alter_workflow']) {
$new_items->push([
'family_id' => $item['family_id'],
'action_id' => $document_actions['change-workflow']
]);
}
if($item['v9_permissions__alter_notification_definitions']) {
$new_items->push([
'family_id' => $item['family_id'],
'action_id' => $document_actions['change-definition-notifications']
]);
}
return $new_items->values()->toArray();
}
]);
These two transformers work together to "collapse" and "uncollapse" the items list by grouping it by a selected column, you also have the opurtunity to isolate a group of columns in the group by.
| Name | Type | Description |
|---|---|---|
| group_by | String | Column to group by. |
| grouped_columns | Array or null | If set, this will also move the selected columns into a group by list (This can be undone by MergeByTransformer) |
| group_name | String or null | If set, this names the group that the grouped columns will be stored in, if not, the name of the group will be group_by . '_group' |
| Name | Type | Description |
|---|---|---|
| group_name | String | Name of the group to merge back to. |
This transformer will copy files referenced by items (this is important) from a source folder to a destination folder. You may also use a renaming callback to rename the files being copied.
| Name | Type | Description |
|---|---|---|
| column | String | Column containing the name of the source file. |
| source_file_structure | String | file structure from source root (set in the .env) to the actual folder containing the file. |
| destination_file_structure | String | file structure from destination root (set in the .env) to the actual folder that will contain the copy of the file. |
| renaming_callback | Callback($row) : String | Callback used to determine the name the file will have at the destination. |
This transformer receives items with parent_id and id (these columns must exist) and calculates the values for lft, rgt and depth, used in v10 by Baum/Node for preserving a tree structure in database.
| Name | Type | Description |
|---|