Skip to content

Commit

Permalink
Merge pull request #79 from OpenNMS/jira/NMS-15439-ticketing-improvem…
Browse files Browse the repository at this point in the history
…ents

NMS-15439 alarm ticketing improvements
  • Loading branch information
Benjamin Reed authored May 30, 2023
2 parents ade44c8 + bca7eec commit b7da1ed
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api</artifactId>
Expand Down
86 changes: 83 additions & 3 deletions api/src/main/java/org/opennms/integration/api/v1/dao/AlarmDao.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
* Copyright (C) 2018-2023 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand Down Expand Up @@ -34,6 +34,8 @@
import org.opennms.integration.api.v1.annotations.Consumable;
import org.opennms.integration.api.v1.graph.NodeRef;
import org.opennms.integration.api.v1.model.Alarm;
import org.opennms.integration.api.v1.model.Severity;
import org.opennms.integration.api.v1.ticketing.Ticket.State;

/**
* Lookup alarms.
Expand All @@ -42,10 +44,88 @@
*/
@Consumable
public interface AlarmDao {

/**
* Get the number of alarms.
*
* @return the number of alarms
*/
Long getAlarmCount();

/**
* Get all alarms.
*
* @return the list of alarms
*/
List<Alarm> getAlarms();

/**
* Retrieve the highest-severity alarm associated with a node.
*
* @param nodeRef a node reference of foreignSource:foreignId
* @return the alarm, if any
*/
Optional<Alarm> getAlarmWithHighestSeverity(NodeRef nodeRef);

/**
* Get the alarm associated with the given trouble ticket ID.
*
* @since 1.5.0
* @param ticketId the ticket ID to search for
* @return the associated alarm
*/
Optional<Alarm> getAlarmForTicket(final String ticketId);

/**
* Updates the ticket state for the given alarm(s).
*
* @since 1.5.0
* @param state the ticket state to set
* @param alarmIds the alarm(s) to set the state on
*/
void setTicketState(final State state, final int... alarmIds);

/**
* Acknowledge the specified alarm(s).
*
* @since 1.5.0
* @param user the user acknowledging the alarm(s)
* @param alarmIds the alarm(s) to acknowledge
*/
void acknowledge(final String user, final int... alarmIds);

/**
* Unacknowledge the specified alarm(s).
*
* @since 1.5.0
* @param alarmIds the alarm(s) to unacknowledge
*/
void unacknowledge(final int... alarmIds);

/**
* Escalate the specified alarm(s).
*
* @since 1.5.0
* @param user the user escalating the alarm(s)
* @param alarmIds the alarm(s) to escalate
*/
void escalate(final String user, final int... alarmIds);

/**
* Clear the specified alarm(s).
*
* @since 1.5.0
* @param alarmIds the alarm(s) to clear
*/
void clear(final int... alarmIds);

/**
* Set the severity of the specified alarm(s).
*
* @since 1.5.0
* @param severity the severity to set
* @param alarmIds the alarm(s) to update
*/
void setSeverity(final Severity severity, final int... alarmIds);


}
17 changes: 15 additions & 2 deletions api/src/main/java/org/opennms/integration/api/v1/model/Alarm.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
* Copyright (C) 2018-2023 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand Down Expand Up @@ -34,6 +34,7 @@

import org.opennms.integration.api.v1.annotations.Model;
import org.opennms.integration.api.v1.config.events.AlarmType;
import org.opennms.integration.api.v1.ticketing.Ticket.State;

/**
* An alarm.
Expand Down Expand Up @@ -77,4 +78,16 @@ public interface Alarm {

boolean isAcknowledged();

/**
* @since 1.5.0
* @return the ticket ID associated with this alarm
*/
String getTicketId();

/**
* @since 1.5.0
* @return the state of the ticket associated with this alarm
*/
State getTicketState();

}
2 changes: 1 addition & 1 deletion archetypes/example-kar-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>archetypes</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<artifactId>example-kar-plugin</artifactId>
<packaging>maven-archetype</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archetypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>archetypes</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2019 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc.
* Copyright (C) 2019-2023 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand Down Expand Up @@ -40,6 +40,7 @@
import org.opennms.integration.api.v1.model.DatabaseEvent;
import org.opennms.integration.api.v1.model.Node;
import org.opennms.integration.api.v1.model.Severity;
import org.opennms.integration.api.v1.ticketing.Ticket.State;
import org.opennms.integration.api.v1.util.ImmutableCollections;
import org.opennms.integration.api.v1.util.MutableCollections;

Expand All @@ -62,6 +63,8 @@ public final class ImmutableAlarm implements Alarm {
private final Date firstEventTime;
private final DatabaseEvent lastEvent;
private final boolean acknowledged;
private final String ticketId;
private final State ticketState;

private ImmutableAlarm(Builder builder) {
reductionKey = builder.reductionKey;
Expand All @@ -79,6 +82,8 @@ private ImmutableAlarm(Builder builder) {
firstEventTime = builder.firstEventTime;
lastEvent = builder.lastEvent;
acknowledged = builder.acknowledged;
ticketId = builder.ticketId;
ticketState = builder.ticketState;
}

public static Builder newBuilder() {
Expand Down Expand Up @@ -112,6 +117,8 @@ public static final class Builder {
private Date firstEventTime;
private DatabaseEvent lastEvent;
private boolean acknowledged;
private String ticketId;
private State ticketState;

private Builder() {
}
Expand All @@ -132,6 +139,8 @@ private Builder(Alarm alarm) {
firstEventTime = alarm.getFirstEventTime();
lastEvent = alarm.getLastEvent();
acknowledged = alarm.isAcknowledged();
ticketId = alarm.getTicketId();
ticketState = alarm.getTicketState();
}

public Builder setReductionKey(String reductionKey) {
Expand Down Expand Up @@ -225,6 +234,16 @@ public Builder setAcknowledged(boolean acknowledged) {
return this;
}

public Builder setTicketId(final String id) {
this.ticketId = id;
return this;
}

public Builder setTicketState(final State state) {
this.ticketState = state;
return this;
}

public ImmutableAlarm build() {
return new ImmutableAlarm(this);
}
Expand Down Expand Up @@ -310,6 +329,16 @@ public boolean isAcknowledged() {
return acknowledged;
}

@Override
public String getTicketId() {
return ticketId;
}

@Override
public State getTicketState() {
return ticketState;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -329,14 +358,16 @@ public boolean equals(Object o) {
Objects.equals(lastEventTime, that.lastEventTime) &&
Objects.equals(firstEventTime, that.firstEventTime) &&
Objects.equals(lastEvent, that.lastEvent) &&
Objects.equals(acknowledged, that.acknowledged);
Objects.equals(acknowledged, that.acknowledged) &&
Objects.equals(ticketId, that.ticketId) &&
Objects.equals(ticketState, that.ticketState);
}

@Override
public int hashCode() {
return Objects.hash(reductionKey, id, node, managedObjectInstance, managedObjectType, type, severity,
attributes, relatedAlarms, logMessage, description, lastEventTime, firstEventTime,
lastEvent, acknowledged);
lastEvent, acknowledged, ticketId, ticketState);
}

@Override
Expand All @@ -357,6 +388,9 @@ public String toString() {
", firstEventTime=" + firstEventTime +
", lastEvent=" + lastEvent +
", acknowledged=" + acknowledged +
", ticketId=" + ticketId +
", ticketState=" + ticketState +
'}';
}

}
2 changes: 1 addition & 1 deletion config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>config</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion karaf-features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>karaf-features</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<packaging>pom</packaging>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<name>OpenNMS Integration API :: Parent</name>
<url>https://github.com/OpenNMS/opennms-integration-api</url>
<description>Integration and extension API for OpenNMS</description>
Expand Down
2 changes: 1 addition & 1 deletion sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opennms.integration.api.sample</groupId>
Expand Down
2 changes: 1 addition & 1 deletion test-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion test-suites/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>api-project</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-suites</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion test-suites/tss-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.opennms.integration.api</groupId>
<artifactId>test-suites</artifactId>
<version>v1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tss-tests</artifactId>
Expand Down

0 comments on commit b7da1ed

Please sign in to comment.