5c70ad9721e48e492eeae804ed3d2d6beeb73a71
[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.impl.database.types.equipment;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
23 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
24 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder;
25 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing;
26 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstance;
27 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType;
28 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties;
29
30 public class EsEquipment extends EsObject {
31
32     public static final String ESDATATYPENAME = "inventoryequipment";
33
34     int treeLevel;
35     String parentUuid;
36     String mountpoint;
37     String uuid;
38     List<String> containedHolder;
39     String manufacturerName;
40     String manufacturerIdentifier;
41     String serial;
42     String date;
43     String version;
44     String description;
45     String partTypeId;
46     String modelIdentifier;
47     String typeName;
48
49
50     public EsEquipment set( String mountpoint, ExtendedEquipment extendedEquipment ) {
51
52         Equipment equipment = extendedEquipment.getEquipment();
53
54         this.parentUuid = extendedEquipment.getParentUuid();
55         this.treeLevel = extendedEquipment.getTreeLevel();
56         this.mountpoint = mountpoint;
57         this.uuid = equipment.getUuid().getValue();
58         this.setEsId(this.mountpoint+"/"+this.uuid);
59
60         this.containedHolder = new ArrayList<>();
61         List<ContainedHolder> containedHolderList = equipment.getContainedHolder();
62         if (containedHolderList != null && !containedHolderList.isEmpty()) {
63             for (ContainedHolder containedHolderElement: containedHolderList) {
64                 this.containedHolder.add(containedHolderElement.key().getUuid().getValue());
65             }
66         }
67         ManufacturedThing manufacturedThing = equipment.getManufacturedThing();
68         if (manufacturedThing != null) {
69             ManufacturerProperties manufacturedProperties = manufacturedThing.getManufacturerProperties();
70             if (manufacturedProperties != null) {
71                 this.manufacturerName = manufacturedProperties.getManufacturerName();
72                 this.manufacturerIdentifier = manufacturedProperties.getManufacturerIdentifier();
73             }
74             EquipmentInstance equipmentInstance = manufacturedThing.getEquipmentInstance();
75             if (equipmentInstance != null) {
76                 this.serial = equipmentInstance.getSerialNumber();
77                 this.date = equipmentInstance.getManufactureDate();
78             }
79             EquipmentType equipmentType = manufacturedThing.getEquipmentType();
80             if (equipmentType != null) {
81                 this.version = equipmentType.getVersion();
82                 this.description = equipmentType.getDescription();
83                 this.partTypeId = equipmentType.getPartTypeIdentifier();
84                 this.modelIdentifier = equipmentType.getModelIdentifier();
85                 this.typeName = equipmentType.getTypeName();
86             }
87         }
88
89         return this;
90     }
91
92 }