2 * Copyright © 2017-2018 AT&T 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.apps.blueprintsprocessor.services.workflow
19 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
20 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
21 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
22 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
23 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
24 import org.slf4j.LoggerFactory
25 import org.springframework.stereotype.Service
29 interface BlueprintDGExecutionService {
31 fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
32 executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput
37 class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService {
39 private val log = LoggerFactory.getLogger(DefaultBlueprintDGExecutionService::class.java)
41 override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
42 executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
44 val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
46 val workflowName = executionServiceInput.actionIdentifiers.actionName
48 // Get the DG Node Template
49 val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
51 log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)")
53 // Get the DG file info
54 val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
55 WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
57 // Populate the DG Path
58 val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
59 .plus(File.separator).plus(artifactDefinition.file)
61 log.info("Executing directed graph ($dgFilePath)")
64 val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
67 return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput