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 org.eclipse.jdt.annotation.NonNull;
24 import org.eclipse.jdt.annotation.Nullable;
25 import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
26 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
27 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentInstance;
28 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentType;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturedThing;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturerProperties;
31 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
32 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
33 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
37 import org.opendaylight.yangtools.yang.common.Uint32;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
45 public class Onf14ToInternalDataModel {
47 private static final Logger LOG = LoggerFactory.getLogger(Onf14ToInternalDataModel.class);
49 public Inventory getInternalEquipment(NodeId nodeId, Equipment currentEq, Equipment parentEq, long treeLevel) {
51 InventoryBuilder inventoryBuilder = new InventoryBuilder();
54 ActualEquipment component = currentEq.getActualEquipment();
55 if (component != null) {
58 inventoryBuilder.setNodeId(nodeId.getValue());
60 inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel));
61 inventoryBuilder.setUuid(currentEq.getUuid().getValue());
63 if (parentEq != null) {
64 inventoryBuilder.setParentUuid(parentEq.getUuid().getValue());
66 inventoryBuilder.setParentUuid("None");
69 List<String> containedHolderKeyList = new ArrayList<String>();
71 Collection<ContainedHolder> containedHolderList = YangHelper.getCollection(currentEq.nonnullContainedHolder());
72 for (ContainedHolder holder : containedHolderList) {
74 UniversalId occupyingFru = holder.getOccupyingFru();
76 if (occupyingFru != null) {
77 containedHolderKeyList.add(occupyingFru.getValue());
80 inventoryBuilder.setContainedHolder(containedHolderKeyList);
83 ManufacturedThing manThing = component.getManufacturedThing();
84 if (manThing != null) {
85 // Manufacturer properties
87 ManufacturerProperties manProp = manThing.getManufacturerProperties();
88 if (manProp != null) {
89 inventoryBuilder.setManufacturerName(manProp.getManufacturerName());
90 inventoryBuilder.setManufacturerIdentifier(manProp.getManufacturerIdentifier());
92 LOG.debug("manufacturer-properties is not present in Equipment with uuid={}",
93 currentEq.getUuid().getValue());
98 EquipmentInstance eqInstance = manThing.getEquipmentInstance();
99 if (eqInstance != null) {
100 inventoryBuilder.setSerial(eqInstance.getSerialNumber());
101 inventoryBuilder.setDate(eqInstance.getManufactureDate().getValue());
103 LOG.debug("equipment-instance is not present in Equipment with uuid={}",
104 currentEq.getUuid().getValue());
109 EquipmentType eqType = manThing.getEquipmentType();
110 if (eqType != null) {
111 inventoryBuilder.setVersion(eqType.getVersion());
112 inventoryBuilder.setDescription(eqType.getDescription());
113 inventoryBuilder.setPartTypeId(eqType.getPartTypeIdentifier());
114 inventoryBuilder.setModelIdentifier(eqType.getModelIdentifier());
115 inventoryBuilder.setTypeName(eqType.getTypeName());
117 LOG.debug("equipment-type is not present in Equipment with uuid={}",
118 currentEq.getUuid().getValue());
121 LOG.debug("manufactured-thing is not present in Equipment with uuid={}",
122 currentEq.getUuid().getValue());
125 LOG.debug("actual-equipment is not present in Equipment with uuid={}", currentEq.getUuid().getValue());
128 return inventoryBuilder.build();