c563cc49164b03a821d3b0927f6c10641905b9b0
[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.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.rev201110.Inventory;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
26 import org.opendaylight.yangtools.yang.common.Uint32;
27
28 /**
29  * @author herbert
30  *
31  */
32 public class ORanToInternalDataModel {
33
34
35     public Inventory getInternalEquipment(NodeId nodeId, Component component) {
36
37         InventoryBuilder inventoryBuilder = new InventoryBuilder();
38
39         // General
40         inventoryBuilder.setNodeId(nodeId.getValue());
41         inventoryBuilder.setParentUuid(component.getParent());
42         inventoryBuilder.setTreeLevel(new Long(component.getParentRelPos()));
43         inventoryBuilder.setTreeLevel(Uint32.valueOf(component.getParentRelPos().intValue()));
44
45         inventoryBuilder.setUuid(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         inventoryBuilder.setPartTypeId(component.getXmlClass().getName());
62         inventoryBuilder.setTypeName(component.getName());
63         inventoryBuilder.setVersion(component.getHardwareRev());
64
65         // Equipment instance
66         inventoryBuilder.setDate(component.getMfgDate().getValue());
67         inventoryBuilder.setSerial(component.getSerialNum());
68
69         return inventoryBuilder.build();
70     }
71
72 }