2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2020 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==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.Objects;
24 import org.eclipse.jdt.annotation.NonNull;
25 import org.eclipse.jdt.annotation.Nullable;
26 import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
27 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
28 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentInstance;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentType;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturedThing;
31 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturerProperties;
32 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
33 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
34 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder;
37 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
38 import org.opendaylight.yangtools.yang.common.Uint32;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
46 public class Onf14ToInternalDataModel {
48 private static final Logger LOG = LoggerFactory.getLogger(Onf14ToInternalDataModel.class);
50 public Inventory getInternalEquipment(NodeId nodeId, Equipment currentEq, Equipment parentEq, long treeLevel) {
52 Objects.requireNonNull(nodeId);
53 Objects.requireNonNull(currentEq);
55 InventoryBuilder inventoryBuilder = new InventoryBuilder();
56 String parentUuid = parentEq != null ? parentEq.getUuid().getValue() : "None";
59 ActualEquipment component = currentEq.getActualEquipment();
60 if (component != null) {
62 inventoryBuilder.setNodeId(nodeId.getValue());
63 inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel));
64 inventoryBuilder.setUuid(currentEq.getUuid().getValue());
65 inventoryBuilder.setParentUuid(parentUuid);
67 List<String> containedHolderKeyList = new ArrayList<String>();
69 Collection<ContainedHolder> containedHolderList =
70 YangHelper.getCollection(currentEq.nonnullContainedHolder());
71 for (ContainedHolder holder : containedHolderList) {
73 UniversalId occupyingFru = holder.getOccupyingFru();
75 if (occupyingFru != null) {
76 containedHolderKeyList.add(occupyingFru.getValue());
79 inventoryBuilder.setContainedHolder(containedHolderKeyList);
82 ManufacturedThing manThing = component.getManufacturedThing();
83 if (manThing != null) {
84 // Manufacturer properties
86 ManufacturerProperties manProp = manThing.getManufacturerProperties();
87 if (manProp != null) {
88 inventoryBuilder.setManufacturerName(manProp.getManufacturerName());
89 inventoryBuilder.setManufacturerIdentifier(manProp.getManufacturerIdentifier());
91 LOG.debug("manufacturer-properties is not present in Equipment with uuid={}",
92 currentEq.getUuid().getValue());
97 EquipmentInstance eqInstance = manThing.getEquipmentInstance();
98 if (eqInstance != null) {
99 inventoryBuilder.setSerial(eqInstance.getSerialNumber());
100 inventoryBuilder.setDate(eqInstance.getManufactureDate().getValue());
102 LOG.debug("equipment-instance is not present in Equipment with uuid={}",
103 currentEq.getUuid().getValue());
108 EquipmentType eqType = manThing.getEquipmentType();
109 if (eqType != null) {
110 inventoryBuilder.setVersion(eqType.getVersion());
111 inventoryBuilder.setDescription(eqType.getDescription());
112 inventoryBuilder.setPartTypeId(eqType.getPartTypeIdentifier());
113 inventoryBuilder.setModelIdentifier(eqType.getModelIdentifier());
114 inventoryBuilder.setTypeName(eqType.getTypeName());
116 LOG.debug("equipment-type is not present in Equipment with uuid={}",
117 currentEq.getUuid().getValue());
120 LOG.debug("manufactured-thing is not present in Equipment with uuid={}",
121 currentEq.getUuid().getValue());
124 LOG.debug("actual-equipment is not present in Equipment with uuid={}", currentEq.getUuid().getValue());
127 return inventoryBuilder.build();