package org.onap.ccsdk.cds.blueprintsprocessor.db.primary
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService
-import org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintDBLibGenericService
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibGenericService
import org.onap.ccsdk.cds.blueprintsprocessor.db.DBDataSourceProperties
import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MARIA_DB
import org.onap.ccsdk.cds.blueprintsprocessor.db.DBLibConstants.Companion.MYSQL_DB
import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties
import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties
import org.onap.ccsdk.cds.blueprintsprocessor.db.MSSqlDataSourceProperties
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service
-class BlueprintDBLibPropertyService(private var bluePrintPropertiesService: BlueprintPropertiesService) {
+class BluePrintDBLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) {
- fun JdbcTemplate(jsonNode: JsonNode): BlueprintDBLibGenericService =
+ fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService =
blueprintDBDataSourceService(dBDataSourceProperties(jsonNode))
- fun JdbcTemplate(selector: String): BlueprintDBLibGenericService =
+ fun JdbcTemplate(selector: String): BluePrintDBLibGenericService =
blueprintDBDataSourceService(dBDataSourceProperties("blueprintsprocessor.db.$selector"))
private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties =
MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java)
MSSQL_DB -> JacksonUtils.readValue(jsonNode, MSSqlDataSourceProperties::class.java)
else -> {
- throw BlueprintProcessorException(
+ throw BluePrintProcessorException(
"DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $MSSQL_DB"
)
}
MYSQL_DB -> mySqlDBConnectionProperties(prefix)
MSSQL_DB -> mssqlDBConnectionProperties(prefix)
else -> {
- throw BlueprintProcessorException(
+ throw BluePrintProcessorException(
"DB type ($it) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $PROCESSOR_DB"
)
}
}
}
- private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BlueprintDBLibGenericService =
+ private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BluePrintDBLibGenericService =
when (dBConnetionProperties) {
is MariaDataSourceProperties -> MariaDatabaseConfiguration(dBConnetionProperties)
is MySqlDataSourceProperties -> MySqlDatabaseConfiguration(dBConnetionProperties)
is MSSqlDataSourceProperties -> MSSqlDatabaseConfiguration(dBConnetionProperties)
- else -> throw BlueprintProcessorException(
+ else -> throw BluePrintProcessorException(
"Failed to create db configuration for ${dBConnetionProperties.url}"
)
}