Blueprints Processor Service 55/65955/1
authorBrinda Santh <brindasanth@in.ibm.com>
Wed, 12 Sep 2018 00:55:46 +0000 (20:55 -0400)
committerBrinda Santh <brindasanth@in.ibm.com>
Wed, 12 Sep 2018 00:55:46 +0000 (20:55 -0400)
Add Input, default, mdsal and sdnc db resource processor prototype.

Change-Id: I1ad8c4ea5d7cdf5793af23ac52b7152d1a58b762
Issue-ID: CCSDK-548
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
12 files changed:
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java
ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json

index 4836cd2..6fed53e 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
@@ -21,22 +22,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode
 import io.swagger.annotations.ApiModelProperty\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 \r
-/*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\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
 /**\r
  * BlueprintProcessorData\r
  * @author Brinda Santh\r
@@ -49,7 +34,7 @@ open class ResourceResolutionInput {
     @get:ApiModelProperty(required=true)\r
     lateinit var actionIdentifiers: ActionIdentifiers\r
     @get:ApiModelProperty(required=true)\r
-    lateinit var resourceAssignments: List<ResourceAssignment>\r
+    lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
     @get:ApiModelProperty(required=true )\r
     lateinit var payload: ObjectNode\r
 }\r
@@ -62,7 +47,7 @@ open class ResourceResolutionOutput {
     @get:ApiModelProperty(required=true)\r
     lateinit var status: Status\r
     @get:ApiModelProperty(required=true)\r
-    lateinit var resourceAssignments: List<ResourceAssignment>\r
+    lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
 }\r
 \r
 open class ExecutionServiceInput {\r
index f42613c..feacbca 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
@@ -18,12 +19,15 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory
 \r
 import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
-import org.slf4j.Logger\r
-import org.slf4j.LoggerFactory\r
 import org.springframework.context.ApplicationContext\r
 import org.springframework.context.ApplicationContextAware\r
 import org.springframework.stereotype.Service\r
 \r
+/**\r
+ * ComponentNode\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
 interface ComponentNode {\r
 \r
     @Throws(BluePrintProcessorException::class)\r
@@ -39,8 +43,13 @@ interface ComponentNode {
     fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)\r
 }\r
 \r
+/**\r
+ * ComponentNodeFactory\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
 @Service\r
-class ComponentNodeFactory : ApplicationContextAware {\r
+open class ComponentNodeFactory : ApplicationContextAware {\r
     private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)\r
 \r
     var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()\r
index 8104c10..01a110d 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
@@ -18,14 +19,17 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory
 \r
 import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
-import org.slf4j.Logger\r
-import org.slf4j.LoggerFactory\r
 import org.springframework.context.ApplicationContext\r
 import org.springframework.context.ApplicationContextAware\r
 import org.springframework.stereotype.Service\r
 \r
+/**\r
+ * ResourceAssignmentProcessorFactory\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
 @Service\r
-class ResourceAssignmentProcessorFactory : ApplicationContextAware {\r
+open class ResourceAssignmentProcessorFactory : ApplicationContextAware {\r
 \r
     private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)\r
 \r
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt
new file mode 100644 (file)
index 0000000..427dc87
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  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.services.execution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+/**
+ * JavaScriptExecuteComponent
+ *
+ * @author Brinda Santh
+ */
+@Component("component-javascript-executor")
+class JavaScriptExecuteComponent : ComponentNode {
+
+    override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt
new file mode 100644 (file)
index 0000000..59be1f5
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  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.services.execution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+/**
+ * PythonExecuteComponent
+ *
+ * @author Brinda Santh
+ */
+@Component("component-python-executor")
+class PythonExecuteComponent : ComponentNode {
+    override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+}
\ No newline at end of file
index 14ab784..d442c96 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
 \r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
+import org.onap.ccsdk.apps.controllerblueprints.core.format\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
 import org.springframework.stereotype.Service\r
 \r
 /**\r
@@ -28,7 +34,7 @@ import org.springframework.stereotype.Service
  */\r
 \r
 @Service\r
-class ResourceResolutionService {\r
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {\r
 \r
     fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {\r
         val resourceResolutionOutput = ResourceResolutionOutput()\r
@@ -36,6 +42,10 @@ class ResourceResolutionService {
         resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader\r
         resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments\r
 \r
+        val context = hashMapOf<String, Any>()\r
+\r
+        process(resourceResolutionOutput.resourceAssignments, context)\r
+\r
         val status = Status()\r
         status.code = 200\r
         status.message = "Success"\r
@@ -43,4 +53,28 @@ class ResourceResolutionService {
 \r
         return resourceResolutionOutput\r
     }\r
+\r
+    fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {\r
+\r
+        val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
+\r
+        bulkSequenced.map { batchResourceAssignments ->\r
+            batchResourceAssignments.filter { it.name != "*" && it.name != "start"}\r
+            .map { resourceAssignment ->\r
+                val dictionarySource = resourceAssignment.dictionarySource\r
+                val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)\r
+                val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)\r
+                        ?: throw BlueprintProcessorException(format("failed to get resource processor for instance name({}) " +\r
+                                "for resource assignment({})", processorInstanceName, resourceAssignment.name))\r
+                try {\r
+                    resourceAssignmentProcessor.validate(resourceAssignment, context)\r
+                    resourceAssignmentProcessor.process(resourceAssignment, context)\r
+                } catch (e: Exception) {\r
+                    resourceAssignmentProcessor.errorHandle(resourceAssignment, context)\r
+                    throw BlueprintProcessorException(e)\r
+                }\r
+\r
+            }\r
+        }\r
+    }\r
 }\r
index 396ca1d..9580ca4 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
 \r
+import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\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
-    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)\r
+\r
+    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("Validation Resource Assignments")\r
     }\r
 \r
     override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+        log.info("Processing Resource Assignments")\r
     }\r
 \r
-    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("ErrorHandle Resource Assignments")\r
     }\r
 \r
-    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("Re Trigger Resource Assignments")\r
     }\r
 }
\ No newline at end of file
index 9d0734e..05f7d5c 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\r
 \r
+import com.att.eelf.configuration.EELFManager\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\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
-    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)\r
+\r
+    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("Validation Resource Assignments")\r
     }\r
 \r
     override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+        log.info("Processing Resource Assignments")\r
     }\r
 \r
-    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("ErrorHandle Resource Assignments")\r
     }\r
 \r
-    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {\r
+        log.info("Re Trigger Resource Assignments")\r
     }\r
 }
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
new file mode 100644 (file)
index 0000000..9d54cd4
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  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.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * MDSALResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-mdsal")
+open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor {
+    private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java)
+
+    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Validation Resource Assignments")
+    }
+
+    override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Processing Resource Assignments")
+    }
+
+    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("ErrorHandle Resource Assignments")
+    }
+
+    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Re Trigger Resource Assignments")
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
new file mode 100644 (file)
index 0000000..4b11f58
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  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.services.resolution.processor
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+import org.springframework.stereotype.Service
+
+/**
+ * SdncResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-db")
+open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor {
+
+    private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java)
+
+    override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Validation Resource Assignments")
+    }
+
+    override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Processing Resource Assignments")
+    }
+
+    override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("ErrorHandle Resource Assignments")
+    }
+
+    override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+        log.info("Re Trigger Resource Assignments")
+    }
+
+}
\ No newline at end of file
index 6335990..0768c60 100644 (file)
@@ -1,5 +1,6 @@
 /*\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
@@ -24,6 +25,11 @@ import org.junit.Test;
 import org.junit.runner.RunWith;\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;\r
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;\r
+import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
 import org.slf4j.Logger;\r
@@ -42,7 +48,9 @@ import java.util.List;
  * @author Brinda Santh DATE : 8/15/2018\r
  */\r
 @RunWith(SpringRunner.class)\r
-@ContextConfiguration(classes = ResourceResolutionService.class)\r
+@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,\r
+        InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,\r
+        SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})\r
 public class ResourceResolutionServiceTest {\r
     private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);\r
 \r
@@ -57,8 +65,8 @@ public class ResourceResolutionServiceTest {
         String resourceResolutionInputContent = FileUtils.readFileToString(\r
                 new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());\r
 \r
-        ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class );\r
-        Assert.assertNotNull("failed to populate resourceResolutionInput request ",resourceResolutionInput);\r
+        ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);\r
+        Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);\r
 \r
         String resourceAssignmentContent = FileUtils.readFileToString(\r
                 new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());\r
@@ -68,13 +76,13 @@ public class ResourceResolutionServiceTest {
         Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));\r
         resourceResolutionInput.setResourceAssignments(batchResourceAssignment);\r
 \r
-        ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");\r
-        Assert.assertNotNull("failed to populate input payload ",inputContent);\r
+        ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");\r
+        Assert.assertNotNull("failed to populate input payload ", inputContent);\r
         resourceResolutionInput.setPayload(inputContent);\r
         log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));\r
 \r
         ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);\r
-        Assert.assertNotNull("failed to populate output",resourceResolutionOutput);\r
+        Assert.assertNotNull("failed to populate output", resourceResolutionOutput);\r
 \r
     }\r
 }\r
index 02ce68b..ddcf32e 100644 (file)
@@ -1,12 +1,22 @@
 [\r
-       {\r
-               "name": "country",\r
-               "input-param": true,\r
-               "property": {\r
-                       "type": "string"\r
-               },\r
-               "dictionary-name": "country",\r
-               "dictionary-source": "db",\r
-               "dependencies": []\r
-       }\r
+  {\r
+    "name": "country",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "country",\r
+    "dictionary-source": "db",\r
+    "dependencies": ["state"]\r
+  },\r
+  {\r
+    "name": "state",\r
+    "input-param": true,\r
+    "property": {\r
+      "type": "string"\r
+    },\r
+    "dictionary-name": "state",\r
+    "dictionary-source": "input",\r
+    "dependencies": []\r
+  }\r
 ]\r