diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2019-09-25 16:06:48 +0300 |
---|---|---|
committer | Einat Vinouze <einat.vinouze@intl.att.com> | 2019-10-03 14:52:55 +0300 |
commit | 9131e3944d1cf571b6a6d57f402a30d8468237a3 (patch) | |
tree | fb3e0a848fbaf321837660bb88cce78a94407d18 /vid-app-common/src/main/java/org | |
parent | 579e5fa551a9563c5747c6e73a479f81ab947f53 (diff) |
sort base resource according it's position field
Issue-ID: VID-646
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Change-Id: I35705cd4a239e30bc6d86da7cde05495648d2a04
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt | 9 |
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)} + } } |