aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfProperties.java
blob: 4d9316a8e21b72e7449bc913d8bfa69463d0cc7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*-
 * ============LICENSE_START=======================================================
 * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.controlloop.actor.cds.properties;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.onap.policy.controlloop.actor.cds.GrpcOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.Util;

/**
 * GRPC Operation with PNF properties.
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class GrpcOperationPnfProperties extends GrpcOperationProperties {

    // @formatter:off
    protected static final List<String> PNF_PROPERTY_NAMES = List.of(
                            OperationProperties.AAI_PNF,
                            OperationProperties.EVENT_ADDITIONAL_PARAMS,
                            OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES);
    // @formatter:on

    @Override
    public List<String> getPropertyNames() {
        return PNF_PROPERTY_NAMES;
    }

    @Override
    public Map<String, String> convertToAaiProperties(GrpcOperation operation) {
        Map<String, String> result = operation.getProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES);
        if (result != null) {
            return result;
        }

        Object pnfData = operation.getRequiredProperty(OperationProperties.AAI_PNF, "PNF");
        Map<String, Object> source = Util.translateToMap(operation.getFullName(), pnfData);

        result = new LinkedHashMap<>();

        for (Map.Entry<String, Object> ent : source.entrySet()) {
            result.put(AAI_PNF_PREFIX + ent.getKey(), ent.getValue().toString());
        }

        return result;
    }
}