2 * Copyright © 2018-2019 Bell Canada Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.resolutionresults.api
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionResult
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionResultService
22 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
23 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
24 import org.springframework.stereotype.Service
28 * Process Resolution Results API request to store and retrieve resource resolution results using database acess layer
29 * ResourceResolutionResultService and corresponding entities
31 * @author Serge Simard
35 class ResolutionResultsServiceHandler(private val bluePrintCatalogService: BluePrintCatalogService,
36 private var resolutionResultService: ResourceResolutionResultService) {
38 suspend fun loadStoredResultById(resolutionResultId: String): String {
40 return resolutionResultService.readByKey(resolutionResultId)
43 suspend fun loadStoredResult(blueprintName : String, blueprintVersion : String, artifactTemplate: String,
44 resolutionKey: String): String {
46 val basePath = bluePrintCatalogService.getFromDatabase(blueprintName, blueprintVersion)
47 val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(),
50 return resolutionResultService.read(blueprintRuntimeService, artifactTemplate, resolutionKey)
53 suspend fun saveNewStoredResult(blueprintName : String, blueprintVersion : String, artifactTemplate: String,
54 resolutionKey: String, result: String): ResourceResolutionResult {
56 val basePath = bluePrintCatalogService.getFromDatabase(blueprintName, blueprintVersion)
57 val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(),
60 val properties = mapOf(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY to resolutionKey)
62 val resultStored = resolutionResultService.write(properties, result, blueprintRuntimeService, artifactTemplate)
67 suspend fun removeStoredResultById(resolutionResultId: String): Unit {
69 return resolutionResultService.deleteByKey(resolutionResultId)