Skip to content

Conversation

@aurang-zeb313
Copy link
Member

External References

…rces | Expose services to delete list of mibgroups,resourcetypes and systemdefs
@aurang-zeb313 aurang-zeb313 changed the base branch from develop to features/snmp-datacollection-db February 6, 2026 14:36
@aurang-zeb313 aurang-zeb313 marked this pull request as draft February 6, 2026 14:37
@aurang-zeb313 aurang-zeb313 requested a review from Copilot February 6, 2026 14:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds REST v2 delete endpoints and DAO support for bulk deletion of SNMP data collection sources and related entities (MIB groups, resource types, system defs).

Changes:

  • Introduces new REST payload models for bulk delete requests.
  • Adds REST API interface methods + REST service implementations for delete operations.
  • Extends DAOs with bulk-delete methods (HQL delete ... where id in (...)) for sources and child entities.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/SnmpDataCollectionSystemDefDeletePayload.java Adds request payload for deleting system defs by ID list
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/SnmpDataCollectionSourceDeletePayload.java Adds request payload for deleting collection sources by ID list
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/SnmpDataCollectionResourceTypeDeletePayload.java Adds request payload for deleting resource types by ID list
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/SnmpDataCollectionMibGroupDeletePayload.java Adds request payload for deleting MIB groups by ID list
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/api/DataCollectionConfRestApi.java Exposes new DELETE endpoints for the above bulk deletions
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/DataCollectionConfRestService.java Implements REST endpoints and delegates deletions to DAO/service layer
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/DataCollectionConfPersistenceService.java Adds transactional delete operations with validation against DB state
opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/SnmpCollectionSystemDefDaoHibernate.java Adds bulk delete by source + systemDef IDs
opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/SnmpCollectionSourceDaoHibernate.java Adds bulk delete by source IDs
opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/SnmpCollectionResourceTypeDaoHibernate.java Adds bulk delete by source + resourceType IDs
opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/SnmpCollectionMibGroupDaoHibernate.java Adds bulk delete by source + mibGroup IDs
opennms-dao-api/src/main/java/org/opennms/netmgt/dao/api/SnmpCollectionSystemDefDao.java Adds DAO API for bulk systemDef deletion
opennms-dao-api/src/main/java/org/opennms/netmgt/dao/api/SnmpCollectionSourceDao.java Adds DAO API for bulk source deletion
opennms-dao-api/src/main/java/org/opennms/netmgt/dao/api/SnmpCollectionResourceTypeDao.java Adds DAO API for bulk resourceType deletion
opennms-dao-api/src/main/java/org/opennms/netmgt/dao/api/SnmpCollectionMibGroupDao.java Adds DAO API for bulk mibGroup deletion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aurang-zeb313 aurang-zeb313 marked this pull request as ready for review February 9, 2026 16:53
@cgorantla cgorantla changed the title NMS-19486: Expose rest end points to delete list of snmpCollectionSources | Expose services to delete list of mibgroups,resourcetypes and systemdefs NMS-19486: Support deletion of mibgroups,resourcetypes and systemdefs Feb 10, 2026

@Transactional
public void deleteSnmpDataCollectionSources(final SnmpDataCollectionSourceDeletePayload request) throws Exception {
snmpCollectionSourceDao.deleteByIds(request.getSnmpCollectionSourceIds());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use Service and what happens to it's child entities ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we delete source its child entities will also be deleted

Comment on lines 230 to 240
final var mibGroupsIds = snmpCollectionMibGroupDao.findAllBySource(snmpDataCollectionSourceId);

final Set<Integer> databaseMibGroupIds = mibGroupsIds
.stream()
.map(SnmpCollectionMibGroup::getId)
.collect(Collectors.toSet());

final var requestMibGroupIds = payload.getMibGroupsIds();
final var existingMibGroupIds = requestMibGroupIds.stream()
.filter(databaseMibGroupIds::contains)
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to load all mibgroups to delete ?

Copy link
Contributor

@cgorantla cgorantla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants