aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2018-03-14 08:36:25 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2018-03-14 10:32:39 -0500
commita0ee4b360d59a98b2f82ad21b07e60ac166ca4e2 (patch)
tree218c30dab809bf5d676b52ca7b826127b538ff9f /controlloop/common/actors
parente3087ccf305aedb968005bd1d91e8b624a10346e (diff)
Changed SO request to iterate extra props
Modified SoActorServiceProvider.constructRequest() method so that it iterates over extra properties instead of hard coding array values. Issue-ID: POLICY-443 Change-Id: I37d6be9dc595bd8d5e9f9f3f63d6890ef1b2f8b3 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'controlloop/common/actors')
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
index 4385ce272..69a266e6b 100644
--- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
@@ -28,6 +28,8 @@ import java.util.UUID;
import org.drools.core.WorkingMemory;
import org.onap.policy.aai.AAIManager;
+import org.onap.policy.aai.AAINQExtraProperties;
+import org.onap.policy.aai.AAINQExtraProperty;
import org.onap.policy.aai.AAINQInstanceFilters;
import org.onap.policy.aai.AAINQInventoryResponseItem;
import org.onap.policy.aai.AAINQNamedQuery;
@@ -115,6 +117,11 @@ public class SOActorServiceProvider implements Actor {
* @return a SO request conforming to the lcm API using the DMAAP wrapper
*/
public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
+ String modelNamePropertyKey = "model-ver.model-name";
+ String modelVersionPropertyKey = "model-ver.model-version";
+ String modelVersionIdPropertyKey = "model-ver.model-version-id";
+
+
if (!SO_ACTOR.equals(policy.getActor()) || !RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) {
// for future extension
return null;
@@ -165,6 +172,7 @@ public class SOActorServiceProvider implements Actor {
logger.error("Either base or non-base vf module is not found from AAI response.");
return null;
}
+
// Construct SO Request
SORequest request = new SORequest();
@@ -190,9 +198,16 @@ public class SOActorServiceProvider implements Actor {
request.getRequestDetails().getModelInfo().setModelType("vfModule");
request.getRequestDetails().getModelInfo().setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId());
request.getRequestDetails().getModelInfo().setModelVersionId(vfModuleItem.getVfModule().getModelVersionId());
- request.getRequestDetails().getModelInfo().setModelName(vfModuleItem.getExtraProperties().getExtraProperty().get(1).getPropertyValue());
- request.getRequestDetails().getModelInfo().setModelVersion(vfModuleItem.getExtraProperties().getExtraProperty().get(4).getPropertyValue());
+ for (AAINQExtraProperty prop : vfModuleItem.getExtraProperties().getExtraProperty()) {
+ if (prop.getPropertyName().equals(modelNamePropertyKey)) {
+ request.getRequestDetails().getModelInfo().setModelName(prop.getPropertyValue());
+ }
+ else if (prop.getPropertyName().equals(modelVersionPropertyKey)) {
+ request.getRequestDetails().getModelInfo().setModelVersion(prop.getPropertyValue());
+ }
+ }
+
//
// requestInfo
//
@@ -230,17 +245,31 @@ public class SOActorServiceProvider implements Actor {
relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId());
relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId(vnfServiceItem.getServiceInstance().getModelVersionId());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(vnfServiceItem.getExtraProperties().getExtraProperty().get(1).getPropertyValue());
- relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion(vnfServiceItem.getExtraProperties().getExtraProperty().get(4).getPropertyValue());
+ for (AAINQExtraProperty prop : vnfServiceItem.getExtraProperties().getExtraProperty()) {
+ if (prop.getPropertyName().equals(modelNamePropertyKey)) {
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
+ }
+ else if (prop.getPropertyName().equals(modelVersionPropertyKey)) {
+ relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion(prop.getPropertyValue());
+ }
+ }
// VNF Item
relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getGenericVNF().getVnfID());
relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo());
relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId(vnfItem.getGenericVNF().getModelInvariantId());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId(vnfItem.getExtraProperties().getExtraProperty().get(0).getPropertyValue());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(vnfItem.getExtraProperties().getExtraProperty().get(1).getPropertyValue());
- relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion(vnfItem.getExtraProperties().getExtraProperty().get(4).getPropertyValue());
+ for (AAINQExtraProperty prop : vnfItem.getExtraProperties().getExtraProperty()) {
+ if (prop.getPropertyName().equals(modelNamePropertyKey)) {
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
+ }
+ else if (prop.getPropertyName().equals(modelVersionPropertyKey)) {
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion(prop.getPropertyValue());
+ }
+ else if (prop.getPropertyName().equals(modelVersionIdPropertyKey)) {
+ relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId(prop.getPropertyValue());
+ }
+ }
relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(vnfItem.getGenericVNF().getVnfType().substring(vnfItem.getGenericVNF().getVnfType().lastIndexOf('/') + 1));
// Insert the Service Item and VNF Item