Rest endpoint for message Prioritization
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / message-prioritizaion / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / message / prioritization / service / SampleMessagePrioritizationService.kt
1 /*
2  * Copyright © 2018-2019 AT&T Intellectual Property.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.service
18
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.MessagePrioritizationStateService
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db.MessagePrioritization
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.kafka.DefaultMessagePrioritizeProcessor
22 import org.onap.ccsdk.cds.controllerblueprints.core.logger
23
24 open class SampleMessagePrioritizationService(messagePrioritizationStateService: MessagePrioritizationStateService) :
25     AbstractMessagePrioritizationService(messagePrioritizationStateService) {
26
27     private val log = logger(DefaultMessagePrioritizeProcessor::class)
28
29     /** Child overriding this implementation , if necessary */
30     override suspend fun handleAggregation(messageIds: List<String>) {
31         log.info("messages($messageIds) aggregated")
32         messageIds.forEach { id ->
33             output(id)
34         }
35     }
36
37     /** If consumer wants specific correlation with respect to group and types, then populate the specific types,
38      * otherwise correlation happens with group and correlationId */
39     override fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
40         return when (messagePrioritization.group) {
41             /** Dummy Implementation, This can also be read from file and stored as cached map **/
42             "group-typed" -> arrayListOf("type-0", "type-1", "type-2")
43             else -> null
44         }
45     }
46 }