summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java
diff options
context:
space:
mode:
authorAmichai Hemli <amichai.hemli@intl.att.com>2019-10-03 14:42:23 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-03 14:42:23 +0000
commit31237ff2baa728d41cba4d2f8fb4ddeb01deeb63 (patch)
tree5fab9a0d705e5b5d4c3b256b524b7cacf1a4aa4e /vid-app-common/src/main/java
parent2c8747b7d258b96b362227cb383aeb350eea5bd6 (diff)
parent9131e3944d1cf571b6a6d57f402a30d8468237a3 (diff)
Merge "sort base resource according it's position field"
Diffstat (limited to 'vid-app-common/src/main/java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
index ac5c2751c..df97f89f8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
@@ -427,14 +427,17 @@ abstract class ResourceCommand(
protected fun pushChildrenJobsToBroker(children:Collection<BaseResource>,
dataForChild: Map<String, Any>,
jobType: JobType?=null): List<String> {
- var counter = 0;
- return children
- .map {Pair(it, counter++)}
+ return setPositionWhereIsMissing(children)
.map { jobAdapter.createChildJob(jobType ?: it.first.jobType, it.first, sharedData, dataForChild, it.second) }
.map { jobsBrokerService.add(it) }
.map { it.toString() }
}
+ protected fun setPositionWhereIsMissing(children: Collection<BaseResource>): List<Pair<BaseResource, Int>> {
+ var orderingPosition = children.map{ defaultIfNull(it.position, 0) }.max() ?: 0
+ return children
+ .map {Pair(it, it.position ?: ++orderingPosition)}
+ }
}