summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons')
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt6
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt84
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt101
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt (renamed from ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ModelContentRepository.kt)23
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt (renamed from ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ModelRepository.kt)18
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt (renamed from ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt21
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt20
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt21
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt20
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintCatalogServiceImpl.kt (renamed from ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintCatalogServiceImpl.kt)2
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt (renamed from ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt)22
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt121
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt2
15 files changed, 169 insertions, 306 deletions
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 7bc88d8c2..17ffd5bac 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
@@ -26,7 +26,7 @@ import java.util.*
import javax.persistence.*
/**
- * Provide Configuration Generator BlueprintModel Entity
+ * Provide BlueprintModel Entity
*
* @author Brinda Santh
* @version 1.0
@@ -76,7 +76,7 @@ class BlueprintModel : Serializable {
@Column(name = "artifact_version", nullable = false)
@ApiModelProperty(required = true)
- var artifactVersion: String? = null
+ lateinit var artifactVersion: String
@Lob
@Column(name = "artifact_description")
@@ -93,20 +93,20 @@ class BlueprintModel : Serializable {
@Column(name = "artifact_name", nullable = false)
@ApiModelProperty(required = true)
- var artifactName: String? = null
+ lateinit var artifactName: String
@Column(name = "published", nullable = false)
@ApiModelProperty(required = true)
- var published: String? = null
+ lateinit var published: String
@Column(name = "updated_by", nullable = false)
@ApiModelProperty(required = true)
- var updatedBy: String? = null
+ lateinit var updatedBy: String
@Lob
@Column(name = "tags", nullable = false)
@ApiModelProperty(required = true)
- var tags: String? = null
+ lateinit var tags: String
@OneToOne(mappedBy = "blueprintModel", fetch = FetchType.EAGER, orphanRemoval = true, cascade = [CascadeType.ALL])
var blueprintModelContent: BlueprintModelContent? = null
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 a3a42ff3d..e0d26a7ae 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
@@ -41,11 +41,11 @@ class BlueprintModelContent : Serializable {
@Column(name = "name", nullable = false)
@ApiModelProperty(required = true)
- var name: String? = null
+ lateinit var name: String
@Column(name = "content_type", nullable = false)
@ApiModelProperty(required = true)
- var contentType: String? = null
+ lateinit var contentType: String
@OneToOne
@JoinColumn(name = "config_model_id")
@@ -58,7 +58,7 @@ class BlueprintModelContent : Serializable {
@Lob
@Column(name = "content", nullable = false)
@ApiModelProperty(required = true)
- var content: ByteArray? = null
+ lateinit var content: ByteArray
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
@LastModifiedDate
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModel.kt
deleted file mode 100755
index c565262db..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/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.cds.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/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintProcessorModelContent.kt
deleted file mode 100644
index dc02d2fd0..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/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.cds.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/cds/blueprintsprocessor/db/primary/repository/ModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt
index 59f2a20f5..7bbfbce79 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ModelContentRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelContentRepository.kt
@@ -18,16 +18,18 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
import org.jetbrains.annotations.NotNull
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
import org.springframework.data.jpa.repository.JpaRepository
-import org.springframework.data.repository.NoRepositoryBean
+import org.springframework.stereotype.Repository
import java.util.*
/**
* @param <T> Model
* @param <B> ModelContent
*/
-@NoRepositoryBean
-interface ModelContentRepository<T, B> : JpaRepository<B, String> {
+@Repository
+interface BlueprintModelContentRepository : JpaRepository<BlueprintModelContent, String> {
/**
* This is a findById method
@@ -36,7 +38,7 @@ interface ModelContentRepository<T, B> : JpaRepository<B, String> {
* @return Optional<T>
*/
@NotNull
- override fun findById(@NotNull id: String): Optional<B>
+ override fun findById(@NotNull id: String): Optional<BlueprintModelContent>
/**
* This is a findTopByBlueprintModelAndContentType method
@@ -45,7 +47,8 @@ interface ModelContentRepository<T, B> : JpaRepository<B, String> {
* @param contentType contentType
* @return B?
*/
- fun findTopByBlueprintModelAndContentType(blueprintModel: T, contentType: String): B?
+ fun findTopByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String)
+ : BlueprintModelContent?
/**
* This is a findByBlueprintModelAndContentType method
@@ -54,7 +57,8 @@ interface ModelContentRepository<T, B> : JpaRepository<B, String> {
* @param contentType contentType
* @return List<B>
*/
- fun findByBlueprintModelAndContentType(blueprintModel: T, contentType: String): List<B>
+ fun findByBlueprintModelAndContentType(blueprintModel: BlueprintModel, contentType: String)
+ : List<BlueprintModelContent>
/**
* This is a findByBlueprintModel method
@@ -62,7 +66,7 @@ interface ModelContentRepository<T, B> : JpaRepository<B, String> {
* @param blueprintModel T
* @return List<B>
*/
- fun findByBlueprintModel(blueprintModel: T): List<B>
+ fun findByBlueprintModel(blueprintModel: BlueprintModel): List<BlueprintModelContent>
/**
* This is a findByBlueprintModelAndContentTypeAndName method
@@ -72,14 +76,15 @@ interface ModelContentRepository<T, B> : JpaRepository<B, String> {
* @param name name
* @return B?
*/
- fun findByBlueprintModelAndContentTypeAndName(blueprintModel: T, contentType: String, name: String): B?
+ fun findByBlueprintModelAndContentTypeAndName(blueprintModel: BlueprintModel,
+ contentType: String, name: String): BlueprintModelContent?
/**
* This is a deleteByMdeleteByBlueprintModelodelName method
*
* @param blueprintModel T
*/
- fun deleteByBlueprintModel(blueprintModel: T)
+ fun deleteByBlueprintModel(blueprintModel: BlueprintModel)
/**
* This is a deleteById method
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt
index 4ad14758c..8ef352852 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ModelRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelRepository.kt
@@ -18,16 +18,17 @@
package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
import org.jetbrains.annotations.NotNull
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
import org.springframework.data.jpa.repository.JpaRepository
-import org.springframework.data.repository.NoRepositoryBean
+import org.springframework.stereotype.Repository
import java.util.*
import javax.transaction.Transactional
/**
* @param <T> Model
*/
-@NoRepositoryBean
-interface ModelRepository<T> : JpaRepository<T, String> {
+@Repository
+interface BlueprintModelRepository : JpaRepository<BlueprintModel, String> {
/**
* This is a findById method
@@ -35,8 +36,7 @@ interface ModelRepository<T> : JpaRepository<T, String> {
* @param id id
* @return Optional<T>
*/
- @NotNull
- override fun findById(@NotNull id: String): Optional<T>
+ override fun findById(id: String): Optional<BlueprintModel>
/**
* This is a findByArtifactNameAndArtifactVersion method
@@ -45,7 +45,7 @@ interface ModelRepository<T> : JpaRepository<T, String> {
* @param artifactVersion artifactVersion
* @return T?
*/
- fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): T?
+ fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): BlueprintModel?
/**
* This is a findTopByArtifactNameOrderByArtifactIdDesc method
@@ -53,7 +53,7 @@ interface ModelRepository<T> : JpaRepository<T, String> {
* @param artifactName artifactName
* @return T?
*/
- fun findTopByArtifactNameOrderByArtifactVersionDesc(artifactName: String): T?
+ fun findTopByArtifactNameOrderByArtifactVersionDesc(artifactName: String): BlueprintModel?
/**
* This is a findTopByArtifactName method
@@ -61,7 +61,7 @@ interface ModelRepository<T> : JpaRepository<T, String> {
* @param artifactName artifactName
* @return List<T>
*/
- fun findTopByArtifactName(artifactName: String): List<T>
+ fun findTopByArtifactName(artifactName: String): List<BlueprintModel>
/**
* This is a findByTagsContainingIgnoreCase method
@@ -69,7 +69,7 @@ interface ModelRepository<T> : JpaRepository<T, String> {
* @param tags tags
* @return List<T>
*/
- fun findByTagsContainingIgnoreCase(tags: String): List<T>
+ fun findByTagsContainingIgnoreCase(tags: String): List<BlueprintModel>
/**
* This is a deleteByArtifactNameAndArtifactVersion method
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
index 0e0c5435b..f5ef0740e 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelSearchRepository.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Repository
* @version 1.0
*/
@Repository
-interface ControllerBlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, Long> {
+interface BlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, Long> {
/**
* This is a findById method
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.kt
deleted file mode 100644
index e8cdee397..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelContentRepository.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.cds.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModelContent
-
-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/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt
deleted file mode 100644
index e200184d6..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintProcessorModelRepository.kt
+++ /dev/null
@@ -1,20 +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.cds.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-
-interface BlueprintProcessorModelRepository : ModelRepository<BlueprintProcessorModel>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.kt
deleted file mode 100644
index 3dbaf7b58..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelContentRepository.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.cds.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
-
-interface ControllerBlueprintModelContentRepository : ModelContentRepository<BlueprintModel, BlueprintModelContent>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt
deleted file mode 100644
index 4e765cd28..000000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/ControllerBlueprintModelRepository.kt
+++ /dev/null
@@ -1,20 +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.cds.blueprintsprocessor.db.primary.repository
-
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
-
-interface ControllerBlueprintModelRepository : ModelRepository<BlueprintModel>
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintCatalogServiceImpl.kt
index 4a1e8f194..aef7c18a2 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintCatalogServiceImpl.kt
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.db
+package org.onap.ccsdk.cds.blueprintsprocessor.db.service
import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt
index 1509e11f1..63c44d209 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.db
+package org.onap.ccsdk.cds.blueprintsprocessor.db.service
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModelContent
-import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintProcessorModelRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository
import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
@@ -34,14 +34,14 @@ import org.springframework.stereotype.Service
import java.io.File
import java.nio.file.Path
import java.util.*
-
+// TODO("Duplicate : Merge BlueprintProcessorCatalogServiceImpl and ControllerBlueprintCatalogServiceImpl")
/**
* Similar/Duplicate implementation in [org.onap.ccsdk.cds.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
*/
@Service("blueprintsProcessorCatalogService")
class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val blueprintModelRepository: BlueprintProcessorModelRepository)
+ private val blueprintModelRepository: BlueprintModelRepository)
: BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintRuntimeValidatorService) {
private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
@@ -123,16 +123,18 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
}
}
- val blueprintModel = BlueprintProcessorModel()
+ val blueprintModel = BlueprintModel()
blueprintModel.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
+ blueprintModel.published = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID]
+ ?: BluePrintConstants.FLAG_Y
blueprintModel.artifactName = artifactName
blueprintModel.artifactVersion = artifactVersion
- blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]
- blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]
+ blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!!
+ blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]!!
blueprintModel.artifactDescription = "Controller Blueprint for $artifactName:$artifactVersion"
- val blueprintModelContent = BlueprintProcessorModelContent()
+ val blueprintModelContent = BlueprintModelContent()
blueprintModelContent.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
blueprintModelContent.contentType = "CBA_ZIP"
blueprintModelContent.name = "$artifactName:$artifactVersion"
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt
new file mode 100755
index 000000000..66b5d00c4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.db.service
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPath
+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.util.*
+//TODO("Duplicate : Merge BlueprintProcessorCatalogServiceImpl and ControllerBlueprintCatalogServiceImpl")
+/**
+ * Similar implementation in [org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl]
+ */
+@Service("controllerBlueprintsCatalogService")
+class ControllerBlueprintCatalogServiceImpl(bluePrintDesignTimeValidatorService: BluePrintValidatorService,
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintModelRepository: BlueprintModelRepository)
+ : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintDesignTimeValidatorService) {
+
+
+ private val log = LoggerFactory.getLogger(ControllerBlueprintCatalogServiceImpl::class.toString())
+
+ init {
+ log.info("BlueprintProcessorCatalogServiceImpl initialized")
+ }
+
+ override suspend fun delete(name: String, version: String) {
+ // Cleaning Deployed Blueprint
+ deleteDir(bluePrintLoadConfiguration.blueprintDeployPath, name, version)
+ // Cleaning Data Base
+ blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version)
+ }
+
+ override suspend fun get(name: String, version: String, extract: Boolean): Path? {
+ val path = if (extract) {
+ normalizedPath(bluePrintLoadConfiguration.blueprintDeployPath, name, version)
+ } else {
+ normalizedPath(bluePrintLoadConfiguration.blueprintArchivePath, UUID.randomUUID().toString(), "cba.zip")
+ }
+ blueprintModelRepository.findByArtifactNameAndArtifactVersion(name, version)?.also {
+ it.blueprintModelContent.run {
+ path.toFile().writeBytes(this!!.content!!).let {
+ return path
+ }
+ }
+ }
+ return null
+ }
+
+ override suspend fun save(metadata: MutableMap<String, String>, archiveFile: File) {
+
+ val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
+ val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+
+ check(archiveFile.isFile && !archiveFile.isDirectory) {
+ throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})")
+ }
+
+ blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let {
+ log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
+ blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion)
+ }
+
+ val blueprintModel = BlueprintModel()
+ blueprintModel.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID]
+ blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL
+ blueprintModel.published = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID]
+ ?: BluePrintConstants.FLAG_N
+ 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 = BlueprintModelContent()
+ 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
+ // Set the Blueprint Model Content into 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/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 11cd90e7d..8058dc26e 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
@@ -22,6 +22,8 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.db.mock.MockBlueprintProcessorCatalogServiceImpl
+import org.onap.ccsdk.cds.blueprintsprocessor.db.service.BlueprintCatalogServiceImpl
+import org.onap.ccsdk.cds.blueprintsprocessor.db.service.BlueprintProcessorCatalogServiceImpl
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile