summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2019-05-22 11:35:46 +0530
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2019-05-22 12:28:47 +0000
commitb65770718b8b65f9bdeec0cc0f6276e6985228b1 (patch)
tree995286f317a4ddd4e88596f6c724bb56943070ab
parentbebced5988018f7c3792e87796be62dbf94bb428 (diff)
Fix instance resource list
Fix instance resource list if group is not list type. Change-Id: I99d37d5407c925dbb3355de73105de755b30bc04 Issue-ID: SO-1393 Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java
index e32a03dfa2..cc628657db 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java
@@ -42,12 +42,14 @@ public class InstanceResourceList {
List<Resource> seqResourceList) {
Map<String, List<List<GroupResource>>> normalizedRequest = new HashMap<>();
+ Resource lastVfProcessed = null;
for (Resource r : seqResourceList) {
if (r.getResourceType() == ResourceType.VNF) {
String pk = getPrimaryKey(r);
JsonElement vfNode = reqInputJsonObj.get(pk);
+ lastVfProcessed = r;
// if the service property is type of array then it
// means it is a VF resource
@@ -67,27 +69,36 @@ public class InstanceResourceList {
} else if (r.getResourceType() == ResourceType.GROUP) {
String sk = getPrimaryKey(r);
- for (String pk : normalizedRequest.keySet()) {
- JsonArray vfs = reqInputJsonObj.getAsJsonArray(pk);
+ // if sk is empty that means it is not list type
+ if (sk.isEmpty()) {
+ List<List<GroupResource>> vfList = normalizedRequest.get(getPrimaryKey(lastVfProcessed));
+ for (List<GroupResource> grpList : vfList) {
+ grpList.add((GroupResource) r);
+ }
+ continue;
+ }
- for (int i = 0; i < vfs.size(); i++) {
+ String pk = getPrimaryKey(lastVfProcessed);
+ JsonArray vfs = reqInputJsonObj.getAsJsonArray(pk);
- JsonElement vfcsNode = vfs.get(i).getAsJsonObject().get(sk);
- if (vfcsNode instanceof JsonArray) {
+ for (int i = 0; i < vfs.size(); i++) {
- List<GroupResource> groupResources = normalizedRequest.get(pk).get(i);
+ JsonElement vfcsNode = vfs.get(i).getAsJsonObject().get(sk);
+ if (vfcsNode instanceof JsonArray) {
- if (groupResources == null) {
- groupResources = new ArrayList<>();
- normalizedRequest.get(pk).add(i, groupResources);
- }
+ List<GroupResource> groupResources = normalizedRequest.get(pk).get(i);
- for (int j = 0; j < ((JsonArray) vfcsNode).size(); j++) {
- groupResources.add((GroupResource) r);
- }
+ if (groupResources == null) {
+ groupResources = new ArrayList<>();
+ normalizedRequest.get(pk).add(i, groupResources);
+ }
+
+ for (int j = 0; j < ((JsonArray) vfcsNode).size(); j++) {
+ groupResources.add((GroupResource) r);
}
}
}
+
}
}
return normalizedRequest;