From 1072867dfac0df993cbd3e44bcc11a5cac7465fd Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Tue, 22 Sep 2020 12:16:46 -0400 Subject: Enabling Code Formatter Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8 --- .../db/BluePrintDBLibConfiguration.kt | 1 + .../blueprintsprocessor/db/BluePrintDBLibData.kt | 4 ++ .../db/primary/BluePrintDBLibPropertyService.kt | 55 ++++++++++++---------- .../db/primary/MySqlDatabaseConfiguration.kt | 1 + .../db/primary/domain/BlueprintModel.kt | 1 + .../db/primary/domain/BlueprintModelContent.kt | 12 +++-- .../db/primary/domain/BlueprintModelSearch.kt | 1 + .../repository/BlueprintModelContentRepository.kt | 4 +- .../repository/BlueprintModelSearchRepository.kt | 10 ++-- .../BlueprintProcessorCatalogServiceImpl.kt | 11 +++-- .../db/BlueprintProcessorCatalogServiceImplTest.kt | 9 ++-- 11 files changed, 64 insertions(+), 45 deletions(-) (limited to 'ms/blueprintsprocessor/modules/commons/db-lib') diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt index 637031972..d4b3f807b 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt @@ -62,6 +62,7 @@ fun BluePrintDependencyService.primaryDBLibGenericService(): BluePrintDBLibGener class DBLibConstants { companion object { + const val PREFIX_DB: String = "blueprintsprocessor.db" // list of database diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt index f78334fcd..7023106eb 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BluePrintDBLibData.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db open class DBDataSourceProperties { + var type: String = DBLibConstants.MARIA_DB lateinit var url: String lateinit var username: String @@ -25,6 +26,7 @@ open class DBDataSourceProperties { } open class PrimaryDataSourceProperties : DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String lateinit var hibernateDDLAuto: String lateinit var hibernateNamingStrategy: String @@ -32,6 +34,7 @@ open class PrimaryDataSourceProperties : DBDataSourceProperties() { } open class MariaDataSourceProperties : DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String lateinit var hibernateDDLAuto: String lateinit var hibernateNamingStrategy: String @@ -40,6 +43,7 @@ open class MariaDataSourceProperties : DBDataSourceProperties() { } open class MySqlDataSourceProperties : DBDataSourceProperties() { + lateinit var hibernateHbm2ddlAuto: String lateinit var hibernateDDLAuto: String lateinit var hibernateNamingStrategy: String diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt index e686e8396..79f5c09bc 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/BluePrintDBLibPropertyService.kt @@ -33,44 +33,47 @@ import org.springframework.stereotype.Service class BluePrintDBLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) { fun JdbcTemplate(jsonNode: JsonNode): BluePrintDBLibGenericService = - blueprintDBDataSourceService(dBDataSourceProperties(jsonNode)) + blueprintDBDataSourceService(dBDataSourceProperties(jsonNode)) fun JdbcTemplate(selector: String): BluePrintDBLibGenericService = - blueprintDBDataSourceService(dBDataSourceProperties("blueprintsprocessor.db.$selector")) + blueprintDBDataSourceService(dBDataSourceProperties("blueprintsprocessor.db.$selector")) private fun dBDataSourceProperties(jsonNode: JsonNode): DBDataSourceProperties = - when (val type = jsonNode.get("type").textValue()) { - MYSQL_DB -> JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java) - MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java) - else -> { - throw BluePrintProcessorException( - "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB") - } - }!! + when (val type = jsonNode.get("type").textValue()) { + MYSQL_DB -> JacksonUtils.readValue(jsonNode, MySqlDataSourceProperties::class.java) + MARIA_DB -> JacksonUtils.readValue(jsonNode, MariaDataSourceProperties::class.java) + else -> { + throw BluePrintProcessorException( + "DB type ($type) is not supported. Valid types: $MARIA_DB, $MYSQL_DB" + ) + } + }!! private fun dBDataSourceProperties(prefix: String): DBDataSourceProperties = - bluePrintPropertiesService.propertyBeanType("$prefix.type", String::class.java).let { - return when (it) { - MARIA_DB, PROCESSOR_DB -> mariaDBConnectionProperties(prefix) - MYSQL_DB -> mySqlDBConnectionProperties(prefix) - else -> { - throw BluePrintProcessorException( - "DB type ($it) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $PROCESSOR_DB") - } + bluePrintPropertiesService.propertyBeanType("$prefix.type", String::class.java).let { + return when (it) { + MARIA_DB, PROCESSOR_DB -> mariaDBConnectionProperties(prefix) + MYSQL_DB -> mySqlDBConnectionProperties(prefix) + else -> { + throw BluePrintProcessorException( + "DB type ($it) is not supported. Valid types: $MARIA_DB, $MYSQL_DB, $PROCESSOR_DB" + ) } } + } private fun blueprintDBDataSourceService(dBConnetionProperties: DBDataSourceProperties): BluePrintDBLibGenericService = - when (dBConnetionProperties) { - is MariaDataSourceProperties -> MariaDatabaseConfiguration(dBConnetionProperties) - is MySqlDataSourceProperties -> MySqlDatabaseConfiguration(dBConnetionProperties) - else -> throw BluePrintProcessorException( - "Failed to create db configuration for ${dBConnetionProperties.url}") - } + when (dBConnetionProperties) { + is MariaDataSourceProperties -> MariaDatabaseConfiguration(dBConnetionProperties) + is MySqlDataSourceProperties -> MySqlDatabaseConfiguration(dBConnetionProperties) + else -> throw BluePrintProcessorException( + "Failed to create db configuration for ${dBConnetionProperties.url}" + ) + } private fun mySqlDBConnectionProperties(prefix: String): MySqlDataSourceProperties = - bluePrintPropertiesService.propertyBeanType(prefix, MySqlDataSourceProperties::class.java) + bluePrintPropertiesService.propertyBeanType(prefix, MySqlDataSourceProperties::class.java) private fun mariaDBConnectionProperties(prefix: String): MariaDataSourceProperties = - bluePrintPropertiesService.propertyBeanType(prefix, MariaDataSourceProperties::class.java) + bluePrintPropertiesService.propertyBeanType(prefix, MariaDataSourceProperties::class.java) } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt index 49b7ec9eb..0761b72d2 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/MySqlDatabaseConfiguration.kt @@ -24,6 +24,7 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource import javax.sql.DataSource class MySqlDatabaseConfiguration(private val mySqlDataSourceProperties: MySqlDataSourceProperties) : BluePrintDBLibGenericService { + override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate { return mySqlNamedParameterJdbcTemplate(mySqlDataSource()) } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt index 43bcb6741..9f4d32e7a 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt @@ -124,6 +124,7 @@ class BlueprintModel : Serializable { var blueprintModelContent: BlueprintModelContent? = null companion object { + private const val serialVersionUID = 1L } } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt index a18ae8b1d..08977f6aa 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt @@ -78,9 +78,9 @@ class BlueprintModelContent : Serializable { override fun toString(): String { return "[" + "id = " + id + - ", name = " + name + - ", contentType = " + contentType + - "]" + ", name = " + name + + ", contentType = " + contentType + + "]" } override fun equals(o: Any?): Boolean { @@ -92,8 +92,10 @@ class BlueprintModelContent : Serializable { return false } val blueprintModelContent = o as BlueprintModelContent? - return (id == blueprintModelContent!!.id && name == blueprintModelContent.name && - contentType == blueprintModelContent.contentType) + return ( + id == blueprintModelContent!!.id && name == blueprintModelContent.name && + contentType == blueprintModelContent.contentType + ) } override fun hashCode(): Int { diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt index b1c006793..e6373d9b8 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt @@ -83,6 +83,7 @@ class BlueprintModelSearch : Serializable { var tags: String? = null companion object { + const val serialversionuid = 1L } } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt index 59ace723a..4bfc07845 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt @@ -48,7 +48,7 @@ interface BlueprintModelContentRepository : JpaRepository */ fun findByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String): - List + List /** * This is a findByBlueprintModel method diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt index 5986603ca..7ba9dd710 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt @@ -37,13 +37,13 @@ interface BlueprintModelSearchRepository : JpaRepository - */ + */ fun findById(id: String): BlueprintModelSearch? /** * This is a findAll method * @return List - */ + */ override fun findAll(): List /** @@ -52,7 +52,7 @@ interface BlueprintModelSearchRepository : JpaRepository - */ + */ fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): BlueprintModelSearch? /** @@ -60,7 +60,7 @@ interface BlueprintModelSearchRepository : JpaRepository - */ + */ fun findByTagsContainingIgnoreCase(tags: String): List /** @@ -74,7 +74,7 @@ interface BlueprintModelSearchRepository : JpaRepository - + */ fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType( updatedBy: String, diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt index d10ec17b0..1b58bc082 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt @@ -103,7 +103,7 @@ class BlueprintProcessorCatalogServiceImpl( deleteNBDir(deployFile.absolutePath) throw BluePrintProcessorException( "failed to get get cba file name($name), version($version) from db" + - " : ${e.message}" + " : ${e.message}" ) } finally { deleteNBDir(cbaFile.parentFile.absolutePath) @@ -149,7 +149,8 @@ class BlueprintProcessorCatalogServiceImpl( blueprintModel.artifactVersion = artifactVersion blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!! blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]!! - val description = if (null != metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION]) metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION] else "" + val description = + if (null != metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION]) metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION] else "" blueprintModel.artifactDescription = description val blueprintModelContent = BlueprintModelContent() @@ -166,8 +167,10 @@ class BlueprintProcessorCatalogServiceImpl( blueprintModelRepository.saveAndFlush(blueprintModel) } catch (ex: DataIntegrityViolationException) { throw BluePrintException( - ErrorCode.CONFLICT_ADDING_RESOURCE.value, "The blueprint entry " + - "is already exist in database: ${ex.message}", ex + ErrorCode.CONFLICT_ADDING_RESOURCE.value, + "The blueprint entry " + + "is already exist in database: ${ex.message}", + ex ) } } diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt index 5d546c2ef..b7b1f78cf 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt @@ -45,8 +45,10 @@ import kotlin.test.assertTrue @EnableAutoConfiguration @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor"]) @ContextConfiguration( - classes = [BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class, - MockBlueprintProcessorCatalogServiceImpl::class] + classes = [ + BlueprintProcessorCatalogServiceImpl::class, BluePrintCoreConfiguration::class, + MockBlueprintProcessorCatalogServiceImpl::class + ] ) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BlueprintProcessorCatalogServiceImplTest { @@ -123,7 +125,8 @@ class BlueprintProcessorCatalogServiceImplTest { File( blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath + "/baseconfiguration" - ).deleteRecursively(), "Couldn't get blueprint archive " + + ).deleteRecursively(), + "Couldn't get blueprint archive " + "${blueprintCoreConfiguration.bluePrintLoadConfiguration().blueprintArchivePath}/baseconfiguration " + "from data base." ) -- cgit 1.2.3-korg