Add o-ran devicemanager
[oam.git] / features / devicemanager / o-ran / ru-fh / provider / src / main / java / org / oransc / oam / features / devicemanager / oran / impl / ORanToInternalDataModel.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.oran.impl;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
26
27 /**
28  * @author herbert
29  *
30  */
31 public class ORanToInternalDataModel {
32
33
34     public Inventory getInternalEquipment(NodeId nodeId, Component component) {
35
36         InventoryBuilder inventoryBuilder = new InventoryBuilder();
37
38         // General
39         inventoryBuilder.setNodeId(nodeId.getValue());
40         inventoryBuilder.setParentUuid(component.getParent());
41         inventoryBuilder.setTreeLevel(new Long(component.getParentRelPos()));
42
43         inventoryBuilder.setUuid(component.getUuid().getValue());
44         // -- String list with ids of holders
45         List<String> containerHolderKeyList = new ArrayList<>();
46         List<String> containerHolderList = component.getContainsChild();
47         if (containerHolderList != null) {
48             for (String containerHolder : containerHolderList) {
49                 containerHolderKeyList.add(containerHolder);
50             }
51         }
52         inventoryBuilder.setContainedHolder(containerHolderKeyList);
53         // -- Manufacturer related things
54         inventoryBuilder.setManufacturerName(component.getName());
55
56         // Equipment type
57         inventoryBuilder.setDescription(component.getDescription());
58         inventoryBuilder.setModelIdentifier(component.getModelName());
59         inventoryBuilder.setPartTypeId(component.getXmlClass().getName());
60         inventoryBuilder.setTypeName(component.getName());
61         inventoryBuilder.setVersion(component.getHardwareRev());
62
63         // Equipment instance
64         inventoryBuilder.setDate(component.getMfgDate().getValue());
65         inventoryBuilder.setSerial(component.getSerialNum());
66
67         return inventoryBuilder.build();
68     }
69
70 }