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.DBLibConstants.Companion.PROCESSOR_DB
import org.onap.ccsdk.cds.blueprintsprocessor.db.MariaDataSourceProperties
import org.onap.ccsdk.cds.blueprintsprocessor.db.MySqlDataSourceProperties
-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 =
MYSQL_DB -> JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java)
MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java)
else -> {
- throw BluePrintProcessorException(
+ throw BlueprintProcessorException(
"DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB"
)
}
MARIA_DB, PROCESSOR_DB -> mariaDBConnectionProperties(prefix)
MYSQL_DB -> mySqlDBConnectionProperties(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)
- else -> throw BluePrintProcessorException(
+ else -> throw BlueprintProcessorException(
"Failed to create db configuration for ${dBConnetionProperties.url}"
)
}