com.datawizards.dqm.configuration.loader.FileMultipleTablesConfigurationLoader.scala Maven / Gradle / Ivy
package com.datawizards.dqm.configuration.loader
import java.io.File
import com.datawizards.dqm.configuration.DataQualityMonitoringConfiguration
import com.typesafe.config.{Config, ConfigFactory}
/**
* Loads multiple tables configuration from file.
*
* Expected format:
*
*tablesConfiguration = [
{
location = {type = Hive, table = clients},
rules = {
rowRules = [
{
field = client_id,
rules = [
{type = NotNull},
{type = min, value = 0}
]
},
{
field = client_name,
rules = [
{type = NotNull}
]
}
]
}
},
{
location = {type = Hive, table = companies},
rules = {
rowRules = [
{
field = company_id,
rules = [
{type = NotNull},
{type = max, value = 100}
]
},
{
field = company_name,
rules = [
{type = NotNull}
]
}
]
}
}
]
*
*
* @param path configuration file
*/
class FileMultipleTablesConfigurationLoader(path: String) extends ConfigurationLoader {
override def loadConfiguration(): DataQualityMonitoringConfiguration = {
val config = ConfigFactory.parseFile(new File(path))
parseConfig(config)
}
private def parseConfig(config: Config): DataQualityMonitoringConfiguration = {
val tablesConfiguration = config.getList("tablesConfiguration")
DataQualityMonitoringConfiguration(parseTablesConfiguration(tablesConfiguration))
}
}