import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
-import org.springframework.beans.factory.annotation.Autowired\r
import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
-import org.springframework.context.ApplicationContext\r
import org.springframework.context.annotation.Scope\r
import org.springframework.stereotype.Component\r
\r
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {\r
\r
- @Autowired\r
- private lateinit var applicationContext: ApplicationContext\r
-\r
override fun process(executionRequest: ExecutionServiceInput) {\r
\r
val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)\r
\r
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
\r
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
--- /dev/null
+/*
+ * 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.functions.resource.resolution
+
+open class ResourceSourceProperties {
+
+}
+
+open class InputResourceSource : ResourceSourceProperties() {
+ lateinit var key: String
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class DefaultResourceSource : ResourceSourceProperties() {
+ lateinit var key: String
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class DatabaseResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var query: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class RestResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var urlPath: String
+ lateinit var path: String
+ lateinit var expressionType: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class CapabilityResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var instanceName: String
+ lateinit var path: String
+ lateinit var expressionType: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service("resource-assignment-processor-capability")
+open class CapabilityResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ companion object {
+ const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
+ const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
+ }
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
+
+ override fun getName(): String {
+ return "resource-assignment-processor-capability"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+
+ val resourceDefinition = resourceDictionaries[executionRequest.dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ${executionRequest.dictionaryName}")
+
+ val resourceSource = resourceDefinition.sources[executionRequest.dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition ${executionRequest.dictionaryName} source(${executionRequest.dictionarySource})")
+
+ checkNotNull(resourceSource.properties) { "failed to get ${executionRequest.dictionarySource} properties" }
+
+ val capabilityResourceSourceProperty = ResourceResolutionUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java)
+
+ val instanceType = capabilityResourceSourceProperty.type
+ val instanceName = capabilityResourceSourceProperty.instanceName
+
+
+ var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
+
+ when (instanceType) {
+ CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ // Initialize Capability Resource Assignment Processor
+ componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ }
+ CAPABILITY_TYPE_JYTHON_COMPONENT -> {
+ TODO(" No implementation")
+ }
+ }
+
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+
+ // Assign Current Blueprint runtime and ResourceDictionaries
+ componentResourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentResourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+
+ // Invoke componentResourceAssignmentProcessor
+ componentResourceAssignmentProcessor.apply(executionRequest)
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+
+ TODO("To Implement")
+ }
+}
\ No newline at end of file
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.springframework.stereotype.Service\r
-\r
-/**\r
- * DefaultResourceAssignmentProcessor\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Service("resource-assignment-processor-default")\r
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
-\r
- override fun getName(): String {\r
- return "resource-assignment-processor-default"\r
- }\r
-\r
- override fun process(executionRequest: ResourceAssignment) {\r
- }\r
-\r
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {\r
- }\r
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * 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.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+/**
+ * DefaultResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-default")
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ override fun getName(): String {
+ return "resource-assignment-processor-default"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ }
}
\ No newline at end of file
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
-\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.springframework.stereotype.Service\r
-\r
-/**\r
- * InputResourceAssignmentProcessor\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Service("resource-assignment-processor-input")\r
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
-\r
- override fun getName(): String {\r
- return "resource-assignment-processor-input"\r
- }\r
-\r
- override fun process(executionRequest: ResourceAssignment) {\r
- }\r
-\r
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {\r
- }\r
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * 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.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+/**
+ * InputResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-input")
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ override fun getName(): String {
+ return "resource-assignment-processor-input"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ }
}
\ No newline at end of file
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
- var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
+ lateinit var resourceDictionaries: Map<String, ResourceDefinition>
open fun resourceDefinition(name: String): ResourceDefinition {
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
--- /dev/null
+/*
+ * 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.functions.resource.resolution.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+
+class ResourceResolutionUtils {
+ companion object {
+
+ fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
+ val content = JacksonUtils.getJson(properties)
+ return JacksonUtils.readValue(content, classType)
+ ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
+ }
+ }
+}
\ No newline at end of file
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class,
InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
+ CapabilityResourceAssignmentProcessor::class])
class ResourceResolutionComponentTest {
@Autowired
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionService::class,
InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
+ CapabilityResourceAssignmentProcessor::class])
class ResourceResolutionServiceTest {
private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)