summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-02-06 12:05:32 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-06 12:05:32 +0000
commitd109233f1a626d5bbb299209ff94dcee3aac4693 (patch)
treeaed6027fafb2541e832f7606a09f8adad9d88dde /bpmn/so-bpmn-tasks/src/main
parentd76c6f0f6da7bbce853c96c3d3472a446b2f3c1f (diff)
parent2a123ff7a50f3147a41135b559452563bca4727b (diff)
Merge "logic to handle null values for vf module index"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java45
1 files changed, 35 insertions, 10 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 55e74339a4..4dd0147163 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.Arrays;
-import java.util.Set;
import java.util.TreeSet;
import org.camunda.bpm.engine.delegate.BpmnError;
@@ -54,6 +53,8 @@ import org.onap.so.client.orchestration.AAIVolumeGroupResources;
import org.onap.so.client.orchestration.AAIVpnBindingResources;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -62,6 +63,8 @@ import org.springframework.stereotype.Component;
public class AAICreateTasks {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAICreateTasks.class);
+ private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class.getName());
+
private static final String networkTypeProvider = "PROVIDER";
private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
@Autowired
@@ -452,23 +455,45 @@ public class AAICreateTasks {
if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) {
- Set<Integer> moduleIndices = new TreeSet<>();
+ TreeSet<Integer> moduleIndices = new TreeSet<>();
+ int nullIndexFound = 0;
for (VfModule vfModule : genericVnf.getVfModules()) {
if (vfModule.getModelInfoVfModule() != null) {
if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) {
- moduleIndices.add(vfModule.getModuleIndex());
+ if (vfModule.getModuleIndex() != null) {
+ moduleIndices.add(vfModule.getModuleIndex());
+ } else {
+ nullIndexFound++;
+ logger.warn("Found null index for vf-module-id {} and model-invariant-uuid {}", vfModule.getVfModuleId(), vfModule.getModelInfoVfModule().getModelInvariantUUID());
+ }
}
}
}
- Object[] array = moduleIndices.toArray();
- for (int i=0; i < array.length; i++) {
- if ((int) array[i] != i) {
- return i;
- }
- }
- return array.length;
+
+ return calculateUnusedIndex(moduleIndices, nullIndexFound);
} else {
return 0;
}
}
+
+ protected int calculateUnusedIndex(TreeSet<Integer> moduleIndices, int nullIndexFound) {
+ //pad array with nulls
+ Integer[] temp = new Integer[moduleIndices.size() + nullIndexFound];
+ Integer[] array = moduleIndices.toArray(temp);
+ int result = 0;
+ //when a null is found skip that potential value
+ //effectively creates something like, [0,1,3,null,null] -> [0,1,null(2),3,null(4)]
+ for (int i=0; i < array.length; i++, result++) {
+ if (Integer.valueOf(result) != array[i]) {
+ if (nullIndexFound > 0) {
+ nullIndexFound--;
+ i--;
+ } else {
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
}
.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#stencil {
    position: relative;
    border: 1px solid gray;
    display: inline-block;
    background: transparent;
    overflow: hidden;
}
#stencil svg {
    background: transparent;
}
#stencil svg .link {
    z-index: 2;
}
.html-element {
    position: absolute;
    background: #3498DB;
    /* Make sure events are propagated to the JointJS element so, e.g. dragging works.*/
    pointer-events: none;
    -webkit-user-select: none;
    border-radius: 4px;
    border: 2px solid #2980B9;
    box-shadow: inset 0 0 5px black, 2px 2px 1px gray;
    padding: 5px;
    box-sizing: border-box;
    z-index: 2;
}
.html-element select,
.html-element input,
.html-element button {
    /* Enable interacting with inputs only. */
    pointer-events: auto;
}
.html-element button.delete {
    color: white;
    border: none;
    background-color: #C0392B;
    border-radius: 20px;
    width: 15px;
    height: 15px;
    line-height: 15px;
    text-align: middle;
    position: absolute;
    top: -15px;
    left: -15px;
    padding: 0;
    margin: 0;
    font-weight: bold;
    cursor: pointer;
}
.html-element button.delete:hover {
    width: 20px;
    height: 20px;
    line-height: 20px;
}
.html-element select {
    position: absolute;
    right: 2px;
    bottom: 28px;
}
.html-element input {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border: none;
    color: #333;
    padding: 5px;
    height: 16px;
}
.html-element label {
    color: #333;
    text-shadow: 1px 0 0 lightgray;
    font-weight: bold;
}
.html-element span {
    position: absolute;
    top: 2px;
    right: 9px;
    color: white;
    font-size: 10px;
}