CM Subscription: Link method to publish to DMI in service layer
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / events / cmsubscription / CmNotificationSubscriptionMappersHandler.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.ncmp.api.impl.events.cmsubscription;
22
23 import java.util.List;
24 import java.util.Map;
25 import lombok.RequiredArgsConstructor;
26 import org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper.CmNotificationSubscriptionDmiInEventMapper;
27 import org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper.CmNotificationSubscriptionNcmpOutEventMapper;
28 import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails;
29 import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate;
30 import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.ncmp_to_dmi.CmNotificationSubscriptionDmiInEvent;
31 import org.onap.cps.ncmp.events.cmsubscription_merge1_0_0.ncmp_to_client.CmNotificationSubscriptionNcmpOutEvent;
32 import org.springframework.stereotype.Component;
33
34 @Component
35 @RequiredArgsConstructor
36 public class CmNotificationSubscriptionMappersHandler {
37
38     private final CmNotificationSubscriptionDmiInEventMapper cmNotificationSubscriptionDmiInEventMapper;
39     private final CmNotificationSubscriptionNcmpOutEventMapper cmNotificationSubscriptionNcmpOutEventMapper;
40
41     /**
42      * Mapper to form a request for the DMI Plugin for the Cm Notification Subscription.
43      *
44      * @param dmiCmNotificationSubscriptionPredicates Collection of Cm Notification Subscription predicates
45      * @return cm notification subscription dmi in event
46      */
47     public CmNotificationSubscriptionDmiInEvent toCmNotificationSubscriptionDmiInEvent(
48             final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates) {
49         return cmNotificationSubscriptionDmiInEventMapper.toCmNotificationSubscriptionDmiInEvent(
50                 dmiCmNotificationSubscriptionPredicates);
51     }
52
53     /**
54      * Mapper to form a response for the client for the Cm Notification Subscription.
55      *
56      * @param subscriptionId                          Cm Notification Subscription id
57      * @param dmiCmNotificationSubscriptionDetailsMap contains CmNotificationSubscriptionDetails per dmi plugin
58      * @return CmNotificationSubscriptionNcmpOutEvent to sent back to the client
59      */
60     public CmNotificationSubscriptionNcmpOutEvent toCmNotificationSubscriptionNcmpOutEvent(final String subscriptionId,
61          final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap) {
62         return cmNotificationSubscriptionNcmpOutEventMapper.toCmNotificationSubscriptionNcmpOutEvent(subscriptionId,
63                 dmiCmNotificationSubscriptionDetailsMap);
64     }
65
66     /**
67      * Mapper to form a rejected response for the client for the Cm Notification Subscription Request.
68      *
69      * @param subscriptionId subscription id
70      * @param rejectedTargetFilters list of rejected target filters for the subscription request
71      * @return to sent back to the client
72      */
73     public CmNotificationSubscriptionNcmpOutEvent toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(
74             final String subscriptionId, final List<String> rejectedTargetFilters) {
75         return cmNotificationSubscriptionNcmpOutEventMapper.toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(
76                 subscriptionId, rejectedTargetFilters);
77     }
78 }