aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/db-lib/src/main
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-26 09:49:13 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-26 09:49:13 -0400
commit72d22a4339db09824d46746dacbba1e141763dc0 (patch)
tree7fbfea4b81afca0bc0c95e5d4b810f236f4dea29 /ms/blueprintsprocessor/modules/commons/db-lib/src/main
parentef6983b670796becfa66c69075c1829e8f9aef4b (diff)
Migrate ccdsk/apps to ccsdk/cds
Change-Id: I020a2ccec4e691717f888e8bd2afec91a7c4e987 Issue-ID: CCSDK-1178 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/db-lib/src/main')
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt56
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt52
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt44
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt114
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt105
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt59
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt55
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt27
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt82
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt84
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt101
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt22
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt21
13 files changed, 0 insertions, 822 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
deleted file mode 100644
index 3e9ec0ce..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.springframework.boot.context.properties.EnableConfigurationProperties
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.ComponentScan
-import org.springframework.context.annotation.Configuration
-
-@Configuration
-@ComponentScan
-@EnableConfigurationProperties
-open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrintProperties) {
-
- @Bean("primary-database-properties")
- open fun getPrimaryProperties(): PrimaryDataSourceProperties {
- return bluePrintProperties.propertyBeanType(DBLibConstants.PREFIX_DB_PRIMARY,
- PrimaryDataSourceProperties::class.java)
- }
-}
-
-class DBLibConstants {
- companion object {
- const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
-
- //list of database
- const val MARIA_DB: String = "maria-db"
- const val PRIMARY_DB: String = "primary-db"
- const val MYSQL_DB: String = "mysql-db"
- const val ORACLE_DB: String = "oracle-db"
- const val POSTGRES_DB: String = "postgres-db"
-
- //List of database drivers
- const val DRIVER_MARIA_DB = "org.mariadb.jdbc.Driver"
- const val DRIVER_MYSQL_DB = "com.mysql.jdbc.Driver"
- const val DRIVER_ORACLE_DB = "oracle.jdbc.driver.OracleDriver"
- const val DRIVER_POSTGRES_DB = "org.postgresql.Driver"
-
-
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt
deleted file mode 100644
index ab2c19a4..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db
-
-
-open class DBDataSourceProperties {
- lateinit var url: String
- lateinit var username: String
- lateinit var password: String
- open lateinit var driverClassName: String
-
-}
-
-open class PrimaryDataSourceProperties: DBDataSourceProperties() {
- lateinit var hibernateHbm2ddlAuto: String
- lateinit var hibernateDDLAuto: String
- lateinit var hibernateNamingStrategy: String
- lateinit var hibernateDialect: String
-}
-
-open class MariaDataSourceProperties: DBDataSourceProperties() {
- lateinit var hibernateHbm2ddlAuto: String
- lateinit var hibernateDDLAuto: String
- lateinit var hibernateNamingStrategy: String
- lateinit var type: String
- lateinit var hibernateDialect: String
- override var driverClassName = DBLibConstants.DRIVER_MARIA_DB
-}
-
-open class MySqlDataSourceProperties: DBDataSourceProperties() {
- lateinit var hibernateHbm2ddlAuto: String
- lateinit var hibernateDDLAuto: String
- lateinit var hibernateNamingStrategy: String
- lateinit var type: String
- lateinit var hibernateDialect: String
- override var driverClassName = DBLibConstants.DRIVER_MYSQL_DB
-}
-
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
deleted file mode 100644
index aee74d3f..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db
-
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-
-interface BluePrintDBLibGenericService {
-
- fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate
-
- fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>>
-
- fun update(sql: String, params: Map<String, Any>): Int
-}
-
-abstract class AbstractDBLibGenericService(private val namedParameterJdbcTemplate: NamedParameterJdbcTemplate)
- : BluePrintDBLibGenericService {
-
- override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
- return namedParameterJdbcTemplate
- }
-
- override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
- return namedParameterJdbcTemplate.queryForList(sql, params)
- }
-
- override fun update(sql: String, params: Map<String, Any>): Int {
- return namedParameterJdbcTemplate.update(sql, params)
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
deleted file mode 100755
index e94bcff5..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 Bell Canada.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProcessorModelContent
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.repository.BlueprintProcessorModelRepository
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.common.ApplicationConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ErrorCode
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils
-import org.onap.ccsdk.apps.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
-import org.slf4j.LoggerFactory
-import org.springframework.dao.DataIntegrityViolationException
-import org.springframework.stereotype.Service
-import java.io.File
-import java.nio.file.Files
-import java.nio.file.Path
-import java.nio.file.Paths
-
-/**
- * Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
- */
-@Service
-class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
- private val blueprintConfig: BluePrintCoreConfiguration,
- private val blueprintModelRepository: BlueprintProcessorModelRepository)
- : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) {
-
- private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
-
- init {
-
- log.info("BlueprintProcessorCatalogServiceImpl initialized")
- }
-
- override fun delete(name: String, version: String) = blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version)
-
-
- override fun get(name: String, version: String, extract: Boolean): Path? {
- var path = "${blueprintConfig.archivePath}/$name/$version.zip"
-
- blueprintModelRepository.findByArtifactNameAndArtifactVersion(name, version)?.also {
- it.blueprintModelContent.run {
- val file = File(path)
- file.parentFile.mkdirs()
- file.createNewFile()
- file.writeBytes(this!!.content!!).let {
- if (extract) {
- path = "${blueprintConfig.archivePath}/$name/$version"
- BluePrintArchiveUtils.deCompress(file, path)
- }
- return Paths.get(path)
- }
- }
- }
- return null
- }
-
- override fun save(metadata: MutableMap<String, String>, archiveFile: File) {
- val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
- val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
-
- blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let {
- log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
- blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion)
- }
-
- val blueprintModel = BlueprintProcessorModel()
- blueprintModel.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
- blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
- blueprintModel.artifactName = artifactName
- blueprintModel.artifactVersion = artifactVersion
- blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]
- blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]
- blueprintModel.artifactDescription = "Controller Blueprint for $artifactName:$artifactVersion"
-
- val blueprintModelContent = BlueprintProcessorModelContent()
- blueprintModelContent.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
- blueprintModelContent.contentType = "CBA_ZIP"
- blueprintModelContent.name = "$artifactName:$artifactVersion"
- blueprintModelContent.description = "$artifactName:$artifactVersion CBA Zip Content"
- blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath())
- blueprintModelContent.blueprintModel = blueprintModel
-
- blueprintModel.blueprintModelContent = blueprintModelContent
-
- try {
- blueprintModelRepository.saveAndFlush(blueprintModel)
- } catch (ex: DataIntegrityViolationException) {
- throw BluePrintException(ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " +
- "is already exist in database: ${ex.message}", ex)
- }
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt
deleted file mode 100644
index f93c241d..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.db.*
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.springframework.stereotype.Service
-
-@Service
-class BluePrintDBLibPropertySevice(private var bluePrintProperties: BluePrintProperties) {
-
- fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService {
- val dBConnetionProperties = dBDataSourceProperties(jsonNode)
- return blueprintDBDataSourceService(dBConnetionProperties)
- }
-
- fun JdbcTemplate(selector: String): BluePrintDBLibGenericService {
- val prefix = "blueprintsprocessor.database.$selector"
- val dBConnetionProperties = dBDataSourceProperties(prefix)
- return blueprintDBDataSourceService(dBConnetionProperties)
- }
-
- private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties {
- val type = jsonNode.get("type").textValue()
- return when (type) {
- DBLibConstants.MYSQL_DB -> {
- JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java)!!
- }
- DBLibConstants.MARIA_DB -> {
- JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java)!!
- }
- else -> {
- throw BluePrintProcessorException("Rest adaptor($type) is not supported")
- }
- }
- }
-
- private fun dBDataSourceProperties(prefix: String): DBDataSourceProperties {
- val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
- return when (type) {
- DBLibConstants.MARIA_DB -> {
- mariaDBConnectionProperties(prefix)
- }
- DBLibConstants.MYSQL_DB -> {
- mySqlDBConnectionProperties(prefix)
- }
- DBLibConstants.ORACLE_DB -> {
- TODO("not implemented")
- }
- DBLibConstants.POSTGRES_DB -> {
- TODO("not implemented")
- }
- DBLibConstants.PRIMARY_DB -> {
- primaryDBConnectionProperties(prefix)
- }
- else -> {
- throw BluePrintProcessorException("Rest adaptor($type) is not supported")
- }
- }
- }
-
- private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BluePrintDBLibGenericService {
- when (dBConnetionProperties) {
- is MariaDataSourceProperties -> {
- return MariaDatabaseConfiguration(dBConnetionProperties)
- }
- is MySqlDataSourceProperties -> {
- return MySqlDatabaseConfiguration(dBConnetionProperties)
- }
- else -> {
- throw BluePrintProcessorException("couldn't get rest service for")
- }
- }
- }
-
- private fun mySqlDBConnectionProperties(prefix: String): MySqlDataSourceProperties {
- return bluePrintProperties.propertyBeanType(prefix, MySqlDataSourceProperties::class.java)
- }
-
- private fun mariaDBConnectionProperties(prefix: String): MariaDataSourceProperties {
- return bluePrintProperties.propertyBeanType(prefix, MariaDataSourceProperties::class.java)
- }
-
- private fun primaryDBConnectionProperties(prefix: String): PrimaryDataSourceProperties {
- return bluePrintProperties.propertyBeanType(prefix, PrimaryDataSourceProperties::class.java)
- }
-
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt
deleted file mode 100644
index c67fb339..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MariaDatabaseConfiguration.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
-import org.onap.ccsdk.apps.blueprintsprocessor.db.MariaDataSourceProperties
-import org.slf4j.LoggerFactory
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-import org.springframework.jdbc.datasource.DriverManagerDataSource
-import org.springframework.orm.jpa.JpaTransactionManager
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
-import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
-import org.springframework.transaction.PlatformTransactionManager
-import java.util.*
-import javax.sql.DataSource
-
-class MariaDatabaseConfiguration(private val mariaDataSourceProperties: MariaDataSourceProperties) : BluePrintDBLibGenericService {
-
- override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
- return mariaNamedParameterJdbcTemplate(mariaDataSource())
- }
-
- override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
- return mariaNamedParameterJdbcTemplate(mariaDataSource()).queryForList(sql, params)
- }
-
- override fun update(sql: String, params: Map<String, Any>): Int {
- return mariaNamedParameterJdbcTemplate(mariaDataSource()).update(sql, params)
- }
-
- val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
-
- fun mariaDataSource(): DataSource {
- val dataSource = DriverManagerDataSource()
- dataSource.setDriverClassName(mariaDataSourceProperties.driverClassName)
- dataSource.url = mariaDataSourceProperties.url
- dataSource.username = mariaDataSourceProperties.username
- dataSource.password = mariaDataSourceProperties.password
- return dataSource
- }
-
- fun mariaNamedParameterJdbcTemplate(mariaDataSource: DataSource): NamedParameterJdbcTemplate {
- return NamedParameterJdbcTemplate(mariaDataSource)
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt
deleted file mode 100644
index 2a0dec73..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
-import org.onap.ccsdk.apps.blueprintsprocessor.db.MySqlDataSourceProperties
-import org.slf4j.LoggerFactory
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-import org.springframework.jdbc.datasource.DriverManagerDataSource
-import javax.sql.DataSource
-
-class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDataSourceProperties) : BluePrintDBLibGenericService {
- override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
- return mySqlNamedParameterJdbcTemplate(mySqlDataSource())
- }
-
- override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
- return mySqlNamedParameterJdbcTemplate(mySqlDataSource()).queryForList(sql, params)
- }
-
- override fun update(sql: String, params: Map<String, Any>): Int {
- return mySqlNamedParameterJdbcTemplate(mySqlDataSource()).update(sql, params)
- }
-
- val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
-
- fun mySqlDataSource(): DataSource {
- val dataSource = DriverManagerDataSource()
- dataSource.setDriverClassName(mySqlDataSourceProperties.driverClassName)
- dataSource.url = mySqlDataSourceProperties.url
- dataSource.username = mySqlDataSourceProperties.username
- dataSource.password = mySqlDataSourceProperties.password
- return dataSource
- }
-
- fun mySqlNamedParameterJdbcTemplate(mySqlDataSource: DataSource): NamedParameterJdbcTemplate {
- return NamedParameterJdbcTemplate(mySqlDataSource)
- }
-
-
-}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
deleted file mode 100644
index 5a926534..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.AbstractDBLibGenericService
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-import org.springframework.stereotype.Service
-
-@Service
-open class PrimaryDBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
- : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) {
-
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
deleted file mode 100644
index 4039b053..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.PrimaryDataSourceProperties
-import org.slf4j.LoggerFactory
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.context.annotation.Primary
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-import org.springframework.jdbc.datasource.DriverManagerDataSource
-import org.springframework.orm.jpa.JpaTransactionManager
-import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
-import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
-import org.springframework.transaction.PlatformTransactionManager
-import java.util.*
-import javax.sql.DataSource
-
-@Configuration
-@EnableJpaRepositories(
- basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.*"],
- entityManagerFactoryRef = "primaryEntityManager",
- transactionManagerRef = "primaryTransactionManager"
-)
-open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
- val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
-
- @Primary
- @Bean("primaryEntityManager")
- open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
- val em = LocalContainerEntityManagerFactoryBean()
- em.dataSource = primaryDataSource()
- em.setPackagesToScan("org.onap.ccsdk.apps.blueprintsprocessor.*")
- em.jpaVendorAdapter = HibernateJpaVendorAdapter()
- val properties = HashMap<String, Any>()
- properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
- properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect
- em.jpaPropertyMap = properties
- return em
- }
-
- @Primary
- @Bean("primaryDataSource")
- open fun primaryDataSource(): DataSource {
- val dataSource = DriverManagerDataSource()
- dataSource.setDriverClassName(primaryDataSourceProperties.driverClassName)
- dataSource.url = primaryDataSourceProperties.url
- dataSource.username = primaryDataSourceProperties.username
- dataSource.password = primaryDataSourceProperties.password
- return dataSource
- }
-
- @Primary
- @Bean("primaryTransactionManager")
- open fun primaryTransactionManager(): PlatformTransactionManager {
- val transactionManager = JpaTransactionManager()
- transactionManager.entityManagerFactory = primaryEntityManager().getObject()
- log.info("Initialised Primary Transaction Manager for url ${primaryDataSourceProperties.url}")
- return transactionManager
- }
-
- @Bean("primaryNamedParameterJdbcTemplate")
- open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
- return NamedParameterJdbcTemplate(primaryDataSource)
- }
-
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt
deleted file mode 100755
index 0935d038..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain
-
-import com.fasterxml.jackson.annotation.JsonFormat
-import io.swagger.annotations.ApiModelProperty
-import javax.persistence.Entity
-import javax.persistence.EntityListeners
-import javax.persistence.Table
-import org.hibernate.annotations.Proxy
-import org.springframework.data.annotation.LastModifiedDate
-import org.springframework.data.jpa.domain.support.AuditingEntityListener
-import java.io.Serializable
-import java.util.*
-import javax.persistence.CascadeType
-import javax.persistence.Column
-import javax.persistence.FetchType
-import javax.persistence.Id
-import javax.persistence.Lob
-import javax.persistence.OneToOne
-import javax.persistence.Temporal
-import javax.persistence.TemporalType
-
-@EntityListeners(AuditingEntityListener::class)
-@Entity
-@Table(name = "BLUEPRINT_RUNTIME")
-@Proxy(lazy = false)
-class BlueprintProcessorModel : Serializable {
-
- @Id
- @Column(name = "blueprint_runtime_id")
- var id: String? = null
-
- @Column(name = "artifact_type")
- var artifactType: String? = null
-
- @Column(name = "artifact_version", nullable = false)
- @ApiModelProperty(required = true)
- var artifactVersion: String? = null
-
- @Lob
- @Column(name = "artifact_description")
- var artifactDescription: String? = null
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "creation_date")
- var createdDate = Date()
-
- @Column(name = "artifact_name", nullable = false)
- @ApiModelProperty(required = true)
- var artifactName: String? = null
-
- @Column(name = "updated_by", nullable = false)
- @ApiModelProperty(required = true)
- var updatedBy: String? = null
-
- @Lob
- @Column(name = "tags", nullable = false)
- @ApiModelProperty(required = true)
- var tags: String? = null
-
- @OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = [CascadeType.ALL])
- var blueprintModelContent: BlueprintProcessorModelContent? = null
-
- companion object {
- private const val serialVersionUID = 1L
- }
-}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt
deleted file mode 100644
index 58bf8a33..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain
-
-import com.fasterxml.jackson.annotation.JsonFormat
-import io.swagger.annotations.ApiModelProperty
-import java.io.Serializable
-import java.util.Date
-import java.util.Objects
-import javax.persistence.Column
-import javax.persistence.Entity
-import javax.persistence.EntityListeners
-import javax.persistence.Id
-import javax.persistence.JoinColumn
-import javax.persistence.Lob
-import javax.persistence.OneToOne
-import javax.persistence.Table
-import javax.persistence.Temporal
-import javax.persistence.TemporalType
-import org.springframework.data.annotation.LastModifiedDate
-import org.springframework.data.jpa.domain.support.AuditingEntityListener
-
-@EntityListeners(AuditingEntityListener::class)
-@Entity
-@Table(name = "BLUEPRINT_CONTENT_RUNTIME")
-class BlueprintProcessorModelContent : Serializable {
-
- @Id
- @Column(name = "blueprint_content_runtime_id")
- var id: String? = null
-
- @Column(name = "name", nullable = false)
- @ApiModelProperty(required = true)
- var name: String? = null
-
- @Column(name = "content_type", nullable = false)
- @ApiModelProperty(required = true)
- var contentType: String? = null
-
- @OneToOne
- @JoinColumn(name = "blueprint_runtime_id")
- var blueprintModel: BlueprintProcessorModel? = null
-
- @Lob
- @Column(name = "description")
- var description: String? = null
-
- @Lob
- @Column(name = "content", nullable = false)
- @ApiModelProperty(required = true)
- var content: ByteArray? = null
-
- @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- @LastModifiedDate
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "updated_date")
- var creationDate = Date()
-
- override fun toString(): String {
- return "[" + "id = " + id +
- ", name = " + name +
- ", contentType = " + contentType +
- "]"
- }
-
- override fun equals(o: Any?): Boolean {
-
- if (o === this) {
- return true
- }
- if (o !is BlueprintProcessorModelContent) {
- return false
- }
- val blueprintModelContent = o as BlueprintProcessorModelContent?
- return (id == blueprintModelContent!!.id && name == blueprintModelContent.name
- && contentType == blueprintModelContent.contentType)
- }
-
- override fun hashCode(): Int {
- return Objects.hash(id, name, contentType)
- }
-
- companion object {
- private const val serialVersionUID = 1L
- }
-
-}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt
deleted file mode 100644
index e614544e..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProcessorModelContent
-import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelContentRepository
-
-interface BlueprintProcessorModelContentRepository : ModelContentRepository<BlueprintProcessorModel, BlueprintProcessorModelContent> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt
deleted file mode 100644
index 25f3dac9..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelRepository
-
-interface BlueprintProcessorModelRepository : ModelRepository<BlueprintProcessorModel>