3d2e04e87c0b42b931af27b7f657877d71a97b4d
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl;
19
20 import java.util.Optional;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
32 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35
36 /**
37  * Create a Network Element representation according to the capability
38  * information. The capabilities are more than an ODL-QName. After the ? other
39  * terms than "revision" are provided.
40  *
41  */
42 public class ONFCoreNetworkElementFactory implements NetworkElementFactory {
43
44     private static final Logger log = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
45
46     private final @NonNull DeviceManagerOnfConfiguration configuration;
47
48     public ONFCoreNetworkElementFactory(@NonNull DeviceManagerOnfConfiguration configuration) {
49         this.configuration = configuration;
50     }
51
52
53     @Override
54     public Optional<org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement> create(
55             @NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
56
57         log.info("Enter factory {}", ONFCoreNetworkElementFactory.class.getName(), acessor.getNodeId());
58
59         Capabilities capabilities = acessor.getCapabilites();
60
61         if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) {
62             OnfMicrowaveModel onfMicrowaveModel = null;
63
64             if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) {
65                 onfMicrowaveModel = new WrapperMicrowaveModelRev170324(acessor, serviceProvider);
66             } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) {
67                 onfMicrowaveModel = new WrapperMicrowaveModelRev180907(acessor, serviceProvider);
68             } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) {
69                 onfMicrowaveModel = new WrapperMicrowaveModelRev181010(acessor, serviceProvider);
70             }
71
72             if (onfMicrowaveModel != null) {
73                 return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, serviceProvider, configuration, onfMicrowaveModel));
74             } else {
75                 return Optional.of(new ONFCoreNetworkElement12Basic(acessor, serviceProvider, configuration));
76             }
77         }
78
79         return Optional.empty();
80     }
81
82 }