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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl;
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;
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.
42 public class ONFCoreNetworkElementFactory implements NetworkElementFactory {
44 private static final Logger log = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
47 public Optional<org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement> create(
48 @NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
50 log.info("Enter factory {}", ONFCoreNetworkElementFactory.class.getName(), acessor.getNodeId());
52 Capabilities capabilities = acessor.getCapabilites();
54 if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) {
55 OnfMicrowaveModel onfMicrowaveModel = null;
57 if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) {
58 onfMicrowaveModel = new WrapperMicrowaveModelRev170324(acessor, serviceProvider);
59 } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) {
60 onfMicrowaveModel = new WrapperMicrowaveModelRev180907(acessor, serviceProvider);
61 } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) {
62 onfMicrowaveModel = new WrapperMicrowaveModelRev181010(acessor, serviceProvider);
65 if (onfMicrowaveModel != null) {
66 return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, serviceProvider, onfMicrowaveModel));
68 return Optional.of(new ONFCoreNetworkElement12Basic(acessor, serviceProvider));
72 return Optional.empty();