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;
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.eclipse.jdt.annotation.NonNull;
23 import org.eclipse.jdt.annotation.Nullable;
24 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
25 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentInstance;
26 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentType;
27 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturedThing;
28 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturerProperties;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
31 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
34 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
42 public class Onf14ToInternalDataModel {
44 private static final Logger log = LoggerFactory.getLogger(Onf14ToInternalDataModel.class);
46 public Inventory getInternalEquipment(NodeId nodeId, Equipment currentEq, Equipment parentEq, long treeLevel) {
48 InventoryBuilder inventoryBuilder = new InventoryBuilder();
51 ActualEquipment component = currentEq.getActualEquipment();
52 if (component != null) {
55 inventoryBuilder.setNodeId(nodeId.getValue());
57 inventoryBuilder.setTreeLevel(treeLevel);
58 inventoryBuilder.setUuid(currentEq.getUuid().getValue());
60 if (parentEq != null) {
61 inventoryBuilder.setParentUuid(parentEq.getUuid().getValue());
63 inventoryBuilder.setParentUuid("None");
66 List<String> containedHolderKeyList = new ArrayList<String>();
68 List<ContainedHolder> containedHolderList = currentEq.nonnullContainedHolder();
69 for (ContainedHolder holder : containedHolderList) {
71 UniversalId occupyingFru = holder.getOccupyingFru();
73 if (occupyingFru != null) {
74 containedHolderKeyList.add(occupyingFru.getValue());
77 inventoryBuilder.setContainedHolder(containedHolderKeyList);
80 ManufacturedThing manThing = component.getManufacturedThing();
81 if (manThing != null) {
82 // Manufacturer properties
84 ManufacturerProperties manProp = manThing.getManufacturerProperties();
85 if (manProp != null) {
86 inventoryBuilder.setManufacturerName(manProp.getManufacturerName());
87 inventoryBuilder.setManufacturerIdentifier(manProp.getManufacturerIdentifier());
89 log.debug("manufacturer-properties is not present in Equipment with uuid={}",
90 currentEq.getUuid().getValue());
95 EquipmentInstance eqInstance = manThing.getEquipmentInstance();
96 if (eqInstance != null) {
97 inventoryBuilder.setSerial(eqInstance.getSerialNumber());
98 inventoryBuilder.setDate(eqInstance.getManufactureDate().getValue());
100 log.debug("equipment-instance is not present in Equipment with uuid={}",
101 currentEq.getUuid().getValue());
106 EquipmentType eqType = manThing.getEquipmentType();
107 if (eqType != null) {
108 inventoryBuilder.setVersion(eqType.getVersion());
109 inventoryBuilder.setDescription(eqType.getDescription());
110 inventoryBuilder.setPartTypeId(eqType.getPartTypeIdentifier());
111 inventoryBuilder.setModelIdentifier(eqType.getModelIdentifier());
112 inventoryBuilder.setTypeName(eqType.getTypeName());
114 log.debug("equipment-type is not present in Equipment with uuid={}",
115 currentEq.getUuid().getValue());
118 log.debug("manufactured-thing is not present in Equipment with uuid={}",
119 currentEq.getUuid().getValue());
122 log.debug("actual-equipment is not present in Equipment with uuid={}", currentEq.getUuid().getValue());
125 return inventoryBuilder.build();