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
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.impl.xml;
20 import com.fasterxml.jackson.annotation.JsonIgnore;
21 import java.util.List;
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.ToggleAlarmFilterable;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultcurrent;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultlog;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
34 import org.slf4j.Logger;
36 @XmlRootElement(name = "ProblemNotification")
37 public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType, ToggleAlarmFilterable {
39 private static String EVENTTYPE = "ProblemNotification";
41 @XmlElement(name = "problem")
42 private String problem;
44 @XmlElement(name = "severity")
45 private InternalSeverity severity;
47 public ProblemNotificationXml() {
52 * Generic Problem. All the parameters are of type Strings according to YANG specification.
54 * @param nodeName Name of mountpoint
55 * @param uuId Name of Interface Pac
56 * @param problemNameString Name of the problem
57 * @param problemSeverityString Severitycode of the problem
58 * @param counter Counter from device
59 * @param internaltimeStampString Timestamp according to internal format.
61 public ProblemNotificationXml(String nodeName, String uuId, String problemNameString,
62 InternalSeverity problemSeverityString, Integer counter, InternalDateAndTime internaltimeStampString) {
63 super(nodeName, counter, internaltimeStampString, uuId);
64 this.problem = problemNameString;
65 this.severity = problemSeverityString;
68 public ProblemNotificationXml(FaultlogEntity input) {
69 this(input.getNodeId(), input.getObjectId(), input.getProblem(), InternalSeverity.valueOf(input.getSeverity()),
70 input.getCounter(), InternalDateAndTime.valueOf(input.getTimestamp()));
73 public String getProblem() {
77 public InternalSeverity getSeverity() {
81 public boolean isNotManagedAsCurrentProblem() {
82 return !FaultEntityManager.isManagedAsCurrentProblem(getProblem());
85 public boolean isNoAlarmIndication() {
86 return severity.isNoAlarmIndication();
90 public String getUuidForMountpoint() {
91 return genSpecificEsId();
95 public boolean isCleared() {
96 return !isNotManagedAsCurrentProblem() && isNoAlarmIndication();
101 * Create a specific ES id for the current log.
103 * @return a string with the generated ES Id
106 public String genSpecificEsId() {
107 return FaultEntityManager.genSpecificEsId(getNodeName(), getObjectId(), getProblem());
111 public Faultlog getFaultlog(SourceType sourceType) {
112 return new FaultlogBuilder().setNodeId(getNodeName()).setCounter(Integer.parseInt(getCounter()))
113 .setObjectId(getObjectId()).setProblem(getProblem()).setSourceType(sourceType)
114 .setSeverity(getSeverity().toDataProviderSeverityType()).setTimestamp(new DateAndTime(getTimeStamp()))
119 public Faultcurrent getFaultcurrent() {
120 return new FaultcurrentBuilder().setNodeId(getNodeName()).setCounter(Integer.parseInt(getCounter()))
121 .setObjectId(genSpecificEsId()).setProblem(getProblem())
122 .setSeverity(getSeverity().toDataProviderSeverityType()).setTimestamp(new DateAndTime(getTimeStamp()))
127 public String toString() {
128 return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()="
129 + super.toString() + "]";
134 public String getEventType() {
139 * LOG the newly added problems of the interface pac
141 * @param log of logger
142 * @param uuid as log info
143 * @param resultList with all problems
144 * @param idxStart start of listing till end
146 public static void debugResultList(Logger log, String uuid, List<ProblemNotificationXml> resultList, int idxStart) {
147 if (log.isDebugEnabled()) {
148 StringBuffer sb = new StringBuffer();
150 for (int t = idxStart; t < resultList.size(); t++) {
153 sb.append(resultList.get(t));
156 log.debug("Found problems {} {}", uuid, sb.toString());