389a550b16bb7217a477e6e27a6be0a2d409980c
[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.types;
19
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultlog;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
28 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
29 import org.slf4j.Logger;
30
31 /**
32  * Fault information
33  */
34 public class FaultData {
35
36     private final List<Faultlog> problemList = new ArrayList<>();
37
38     /**
39      * @return
40      */
41     public int size() {
42         return problemList.size();
43     }
44
45     /**
46      * @param log
47      * @param value
48      * @param resultList
49      * @param idxStart
50      */
51     public static void debugResultList(Logger log, String value, FaultData resultList, int idxStart) {
52         // TODO Auto-generated method stub
53
54     }
55
56     /**
57      * @param nodeId of device
58      * @param sequenceNumber given by device
59      * @param timeStamp of occurence
60      * @param objectReference uuid in ONF model
61      * @param problemName of object
62      * @param severity of problem
63      */
64     public void add(NodeId nodeId, @Nullable Integer sequenceNumber, @Nullable DateAndTime timeStamp,
65             @Nullable String objectReference, @Nullable String problemName, @Nullable SeverityType severity) {
66         FaultlogBuilder bFaullog = new FaultlogBuilder().setNodeId(nodeId.getValue()).setCounter(sequenceNumber)
67                 .setTimestamp(timeStamp).setObjectId(objectReference).setProblem(problemName).setSeverity(severity);
68         bFaullog.setSourceType(SourceType.Netconf);
69         problemList.add(bFaullog.build());
70     }
71
72     /**
73      * @param globalProblemList to add
74      */
75     public void addAll(FaultData globalProblemList) {
76         problemList.addAll(globalProblemList.problemList);
77     }
78
79     /**
80      *
81      */
82     public void clear() {
83     }
84
85     /**
86      * @param idx of element to get
87      * @return Faultlog the element
88      */
89     public Faultlog get(int idx) {
90         return problemList.get(idx);
91     }
92
93     /**
94      * Provide list with all problems of node
95      * @return list
96      */
97     public List<Faultlog> getProblemList() {
98         return problemList;
99     }
100
101 }