Create VES client example for domain 'notification'
[oam.git] / features / devicemanager / x-ran / ru-fh / provider / src / main / java / org / oransc / oam / features / devicemanager / xran / impl / XRanToInternalDataModel.java
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.oransc.oam.features.devicemanager.xran.impl;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.eclipse.jdt.annotation.NonNull;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
28 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
29
30 public class XRanToInternalDataModel {
31
32
33     public Inventory getInternalEquipment(NodeId nodeId, @NonNull Component component) {
34
35         InventoryBuilder inventoryBuilder = new InventoryBuilder();
36
37         // General
38         inventoryBuilder.setNodeId(nodeId.getValue());
39         inventoryBuilder.setParentUuid(component.getParent());
40         inventoryBuilder.setTreeLevel(
41                 Long.valueOf(
42                         NullableHelper.nnGetInteger(
43                                 component.getParentRelPos())));
44
45         inventoryBuilder.setUuid(NullableHelper.nnGetUuid(component.getUuid()).getValue());
46         // -- String list with ids of holders
47         List<String> containerHolderKeyList = new ArrayList<>();
48         List<String> containerHolderList = component.getContainsChild();
49         if (containerHolderList != null) {
50             for (String containerHolder : containerHolderList) {
51                 containerHolderKeyList.add(containerHolder);
52             }
53         }
54         inventoryBuilder.setContainedHolder(containerHolderKeyList);
55         // -- Manufacturer related things
56         inventoryBuilder.setManufacturerName(component.getName());
57
58         // Equipment type
59         inventoryBuilder.setDescription(component.getDescription());
60         inventoryBuilder.setModelIdentifier(component.getModelName());
61
62         Class<? extends HardwareClass> xmlClass = component.getXmlClass();
63         if (xmlClass != null) {
64           inventoryBuilder.setPartTypeId(xmlClass.getName());
65         }
66         inventoryBuilder.setTypeName(component.getName());
67         inventoryBuilder.setVersion(component.getHardwareRev());
68
69         // Equipment instance
70         DateAndTime mfgDate = component.getMfgDate();
71         if (mfgDate != null) {
72           inventoryBuilder.setDate(mfgDate.getValue());
73         }
74         inventoryBuilder.setSerial(component.getSerialNum());
75
76         return inventoryBuilder.build();
77     }
78
79 }