public class DbSanitizer extends Object implements Preprocessor
A Preprocessor tailored to sanitize values within rows. The preprocessor can be added to the target database, causing inserts of any value covered in the sanitizer configuration to be obfuscated or replaced
Via the configuration, the DBSanitizer applies a series of defined @see ch.brickwork.bsetl.sanitize.ValueSanitizer to do the job
Some ValueSanitizers have a row context allowing for various properties (e.g. name, email) to be populated with different but connected values (e.g. marcel - marcel@camporelli.ch instead of marcel - foo@foo.com; to this end, a mapping function must be provided returning the value of a unique id for the row, like so:
this.obTarget.addPreprocessor(new DbSanitizer(sanitizerConfig, map ->
Objects.toString(map.get("Id")).replaceAll("null", "")
.concat(Objects.toString(map.get("id")).replaceAll("null", ""))));
The id map is per Db, not per table. However, if different tables have different ids, concatenation of any available/required id property will usually work (all "unused" id properties will deliver null).
| Constructor and Description |
|---|
DbSanitizer(SanitizerConfiguration sanitizerConfiguration)
If rows can't be identified; means you will
not be able to use contextual value sanitizers; if each row in your table has a unique
key (may be composed), it is preferrable to use DbSanitizer(config, function)
|
DbSanitizer(SanitizerConfiguration sanitizerConfiguration,
Function<Map<String,Object>,String> getIdFromMap)
If each of your rows can be identified with a unique identifier (may be composed), this
is the best constructor to use; if not, use the simple constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getUntouchedColumns() |
Map<String,Object> |
preprocessRow(String tableName,
Map<String,Object> inputRow) |
public DbSanitizer(SanitizerConfiguration sanitizerConfiguration)
sanitizerConfiguration - public DbSanitizer(SanitizerConfiguration sanitizerConfiguration, Function<Map<String,Object>,String> getIdFromMap)
map -> map.get("id")sanitizerConfiguration - getIdFromMap - function mapping a row (Map of properties) to a String which is unique across all rowsCopyright © 2021. All rights reserved.