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.base.onfcore;
20 import java.util.Optional;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.DeviceManagerServiceProvider;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.NetworkElementFactory;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.UnkownDevicemanagerServiceException;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.wrapperc.OnfMicrowaveModel;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.wrapperc.WrapperMicrowaveModelRev170324;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.wrapperc.WrapperMicrowaveModelRev180907;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.wrapperc.WrapperMicrowaveModelRev181010;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DevicemanagerNotificationDelayService;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.INetconfAcessor;
35 import org.opendaylight.mdsal.binding.api.DataBroker;
36 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
41 * Create a Network Element representation according to the capability
42 * information. The capabilities are more than an ODL-QName. After the ? other
43 * terms than "revision" are provided.
46 public class ONFCoreNetworkElementFactory implements NetworkElementFactory {
48 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
50 private static final ONFCoreNetworkElementRepresentation ONFCORE_NETWORKELEMENT_LOCK = new ONFCoreNetworkElementEmpty("NE-LOCK");
53 * Used as Lock by devicemanager
54 * @return ONFCoreNetworkElementRepresentation for lock purpose
56 public @NonNull ONFCoreNetworkElementRepresentation getLock() {
57 return ONFCORE_NETWORKELEMENT_LOCK;
61 public Optional<org.onap.ccsdk.features.sdnr.wt.devicemanager.NetworkElement> create(INetconfAcessor acessor,
62 DeviceManagerServiceProvider serviceProvider) {
64 DataProvider dataProvider = serviceProvider.getDataProvider();
65 WebSocketServiceClientInternal webSocketService = serviceProvider.getService(WebSocketServiceClientInternal.class);
66 DcaeForwarderInternal aotsDcaeForwarder = serviceProvider.getService(DcaeForwarderInternal.class);
67 DevicemanagerNotificationDelayService notificationDelayService = serviceProvider
68 .getService(DevicemanagerNotificationDelayService.class);
70 Capabilities capabilities = acessor.getCapabilites();
72 if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) {
73 OnfMicrowaveModel onfMicrowaveModel = null;
75 if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) {
76 onfMicrowaveModel = new WrapperMicrowaveModelRev170324(acessor);
77 } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) {
78 onfMicrowaveModel = new WrapperMicrowaveModelRev180907(acessor);
79 } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) {
80 onfMicrowaveModel = new WrapperMicrowaveModelRev181010(acessor);
83 String mountPointNodeName = acessor.getNodeId().getValue();
84 DataBroker netconfNodeDataBroker = acessor.getDataBroker();
86 if (onfMicrowaveModel != null) {
87 return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, mountPointNodeName, capabilities, netconfNodeDataBroker,
88 webSocketService, dataProvider, aotsDcaeForwarder,
89 notificationDelayService, onfMicrowaveModel));
91 return Optional.of(new ONFCoreNetworkElement12Basic(acessor, mountPointNodeName, capabilities, netconfNodeDataBroker,
92 webSocketService, dataProvider, aotsDcaeForwarder,
93 notificationDelayService));
97 } catch (UnkownDevicemanagerServiceException e) {
98 LOG.warn("Service missing", e);
100 return Optional.empty();