Skip to content

Conversation

@aurang-zeb313
Copy link
Member

External References

@aurang-zeb313 aurang-zeb313 marked this pull request as draft January 15, 2026 16:55
@Shahbaz-dataq Shahbaz-dataq changed the base branch from develop to features/snmp-datacollection-db January 18, 2026 10:41
@aurang-zeb313 aurang-zeb313 marked this pull request as ready for review January 23, 2026 15:59
Copy link

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

This PR implements a REST endpoint for uploading and importing vendor XML files into the database for SNMP data collection configuration. The implementation includes frontend components for file upload, validation, and display, along with backend services for parsing XML files, persisting data to the database, and retrieving collection sources with filtering and pagination.

Changes:

  • Added REST API endpoints for uploading SNMP data collection XML files and retrieving collection sources
  • Implemented frontend UI components for file upload with drag-and-drop, validation, and duplicate detection
  • Created database persistence layer with DAO methods for filtering and pagination

Reviewed changes

Copilot reviewed 38 out of 42 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ui/src/stores/snmpDataCollectionStore.ts Added API integration for fetching and filtering SNMP collection sources
ui/src/stores/snmpDataCollectionDetailStore.ts Replaced mock data with actual API calls for fetching collection source details
ui/src/services/snmpDataCollectionService.ts New service layer for SNMP data collection API calls
ui/src/mappers/snmpDataCollection.mapper.ts Added mappers to transform server responses to client data structures
ui/src/main/router/index.ts Added route for SNMP data collection import page
ui/src/containers/SnmpDataCollectionSourceImport.vue New container component for the import page
ui/src/containers/SnmpDataCollectionDetail.vue Reorganized imports
ui/src/containers/SnmpDataCollection.vue Added navigation handlers for create and import actions
ui/src/components/SnmpDataCollectionSourceImport/snmpDataCollectionSourceXmlValidator.ts Client-side XML validation logic for SNMP collection files
ui/src/components/SnmpDataCollectionSourceImport/SnmpDataCollectionSourceImport.vue Main component for file upload, validation, and submission
ui/src/components/SnmpDataCollectionSourceImport/Dialog/UploadedFileRenameDialog.vue Dialog for handling duplicate file names
ui/src/components/SnmpDataCollectionSourceImport/Dialog/DataCollectionFilesUploadReportDialog.vue Dialog showing upload results
ui/src/components/SnmpDataCollection/data.ts Removed mock data file
ui/src/components/SnmpDataCollection/SnmpDataCollectionSourcesTable.vue Added pagination support
opennms-webapp-rest/src/test/resources/applicationContext-rest-test.xml Registered new REST service beans
opennms-webapp-rest/src/test/resources/DATACOLLECTION/dell.xml Test XML file for data collection configuration
opennms-webapp-rest/src/test/java/org/opennms/web/rest/v2/DataCollectionConfRestServiceIT.java Integration tests for REST endpoints
opennms-webapp-rest/src/test/java/org/opennms/web/rest/v2/DataCollectionConfPersistenceServiceIT.java Integration tests for persistence service
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/SnmpCollectionSourceNamesAndIdsResponse.java DTO for collection source names and IDs
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/api/DataCollectionConfRestApi.java REST API interface definition
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/DataCollectionConfRestService.java REST API implementation
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/DataCollectionConfPersistenceService.java Service for persisting data collection configurations
opennms-model/src/main/java/org/opennms/netmgt/model/SnmpCollectionSystemDefDto.java DTO for system definitions
opennms-model/src/main/java/org/opennms/netmgt/model/SnmpCollectionSourceDto.java DTO for collection sources
opennms-model/src/main/java/org/opennms/netmgt/model/SnmpCollectionResourceTypeDto.java DTO for resource types
opennms-model/src/main/java/org/opennms/netmgt/model/SnmpCollectionMibGroupDto.java DTO for MIB groups
opennms-dao/src/test/java/org/opennms/netmgt/dao/*.java DAO integration tests for filtering and pagination
opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/*.java DAO implementations with filtering, sorting, and pagination
opennms-dao-api/src/main/java/org/opennms/netmgt/dao/api/*.java DAO interface definitions

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

Comment on lines +43 to +48
import { EventConfigFilesUploadResponse } from '@/types/eventConfig'
import { FeatherButton } from '@featherds/button'
import { FeatherDialog } from '@featherds/dialog'
const props = defineProps<{
report: EventConfigFilesUploadResponse,
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The import uses EventConfigFilesUploadResponse type but this is for SNMP data collection, not event configuration. This appears to be a copy-paste error from similar event config functionality. The type should be SnmpDataCollectionSourceUploadResponse which is already defined in the snmpDataCollection types.

Suggested change
import { EventConfigFilesUploadResponse } from '@/types/eventConfig'
import { FeatherButton } from '@featherds/button'
import { FeatherDialog } from '@featherds/dialog'
const props = defineProps<{
report: EventConfigFilesUploadResponse,
import { SnmpDataCollectionSourceUploadResponse } from '@/types/snmpDataCollection'
import { FeatherButton } from '@featherds/button'
import { FeatherDialog } from '@featherds/dialog'
const props = defineProps<{
report: SnmpDataCollectionSourceUploadResponse,

Copilot uses AI. Check for mistakes.
label="New File Name"
:error="error"
:error-message="error || ''"
placeholder="Enter new file name (must end with .events.xml)"
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The placeholder text incorrectly states files must end with '.events.xml' but this is for SNMP data collection files which should end with '.xml'. The validation at line 97 correctly checks for '.xml' extension.

Suggested change
placeholder="Enter new file name (must end with .events.xml)"
placeholder="Enter new file name (must end with .xml)"

Copilot uses AI. Check for mistakes.
<div class="info-section">
<h3>Instructions:</h3>
<ul>
<li>Event configuration files must be in XML format with a .xml extension.</li>
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The instruction refers to 'Event configuration files' but this component is for SNMP data collection source files. The text should say 'SNMP data collection configuration files must be in XML format with a .xml extension.'

Suggested change
<li>Event configuration files must be in XML format with a .xml extension.</li>
<li>SNMP data collection configuration files must be in XML format with a .xml extension.</li>

Copilot uses AI. Check for mistakes.
@Operation(
summary = "Upload datacollectionconf files",
description = "Upload one or more data collection config files.",
operationId = "uploadEventConfFiles"
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The operationId is 'uploadEventConfFiles' but this endpoint uploads SNMP data collection configuration files, not event configuration files. It should be 'uploadSnmpDataCollectionConfFiles' or similar to match the actual functionality.

Suggested change
operationId = "uploadEventConfFiles"
operationId = "uploadSnmpDataCollectionConfFiles"

Copilot uses AI. Check for mistakes.
@Operation(
summary = "Get SnmpCollectionSource by ID",
description = "Retrieve an SnmpCollectionSource by its unique identifier.",
operationId = "getEventConfSourceById"
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The operationId is 'getEventConfSourceById' but this endpoint retrieves SNMP collection sources, not event configuration sources. It should be 'getSnmpCollectionSourceById' to accurately reflect its purpose.

Suggested change
operationId = "getEventConfSourceById"
operationId = "getSnmpCollectionSourceById"

Copilot uses AI. Check for mistakes.
@Operation(
summary = "Get SnmpCollection Source Names",
description = "Retrieve the names and Ids of all SnmpCollection sources stored in the database.",
operationId = "getEventConfSourcesNames"
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The operationId is 'getEventConfSourcesNames' but this endpoint retrieves SNMP collection source names and IDs. It should be 'getSnmpCollectionSourceNamesAndIds' to match the method name and functionality.

Suggested change
operationId = "getEventConfSourcesNames"
operationId = "getSnmpCollectionSourceNamesAndIds"

Copilot uses AI. Check for mistakes.
}

if (name != null && !name.trim().isEmpty()) {
queryBuilder.append(" and lower(t.collectionSource.name) like ? escape '\\' ");
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The variable name 'name' in the method signature for filterEventConf is misleading - it actually filters by collection source name, not resource type name. The parameter should be renamed to 'collectionSourceName' for clarity.

Copilot uses AI. Check for mistakes.
@aurang-zeb313 aurang-zeb313 requested a review from Copilot January 23, 2026 17:52
Copy link

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

Copilot reviewed 38 out of 42 changed files in this pull request and generated 3 comments.


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

<div class="info-section">
<h3>Instructions:</h3>
<ul>
<li>Event configuration files must be in XML format with a .xml extension.</li>
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected instruction text from "Event configuration files" to "SNMP data collection files" to accurately reflect the file type being uploaded.

Suggested change
<li>Event configuration files must be in XML format with a .xml extension.</li>
<li>SNMP data collection files must be in XML format with a .xml extension.</li>

Copilot uses AI. Check for mistakes.

<script setup lang="ts">
import SnmpDataCollectionSourceImport from '@/components/SnmpDataCollectionSourceImport/SnmpDataCollectionSourceImport.vue'
import FeatherBackButton from '@featherds/back-button/src/components/FeatherBackButton/FeatherBackButton.vue'
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Missing import statement for useRouter. Add "import { useRouter } from 'vue-router'" to the imports section.

Suggested change
import FeatherBackButton from '@featherds/back-button/src/components/FeatherBackButton/FeatherBackButton.vue'
import FeatherBackButton from '@featherds/back-button/src/components/FeatherBackButton/FeatherBackButton.vue'
import { useRouter } from 'vue-router'

Copilot uses AI. Check for mistakes.
return result.trim();
}

private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup datCollectionConfig) {
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of parameter name from 'datCollectionConfig' to 'dataCollectionConfig'.

Suggested change
private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup datCollectionConfig) {
private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup dataCollectionConfig) {

Copilot uses AI. Check for mistakes.

void deleteBySourceId(Integer sourceId);

List<SnmpCollectionMibGroup> filterEventConf(String name,String ifType, String vendor, String collectionSourceName, int offset, int limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

filterEventConf ?


void deleteBySourceId(Integer sourceId);

List<SnmpCollectionMibGroup> filterEventConf(String name,String ifType, String vendor, String collectionSourceName, int offset, int limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

please format


void deleteBySourceId(Integer sourceId);

List<SnmpCollectionResourceType> filterEventConf(String name,String label, String vendor, String collectionSourceName, int offset, int limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

filterEventConf seems to be wrong here

* @param input the input string
* @return the escaped string
*/
private String escapeLike(String input) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be common util method


List<SnmpCollectionSystemDef> filterSystemDefsConf(String name,String vendor, String collectionSourceName, int offset, int limit);

Map<String, Object> findByDataCollectionGroupId(Integer dataCollectionGroupId, String systemDefsFilter, String sortBy, String order, Integer totalRecords, Integer offset, Integer limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

may be it's better to rename datacollection_group_id to snmpcollection_source_id


Map<Integer, String> getIdToNameMap();

Map<String, Object> filterDataCollectionSource(final String filter, final String sortBy, final String order, Integer totalRecords,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to avoid using Object. You can wrap these into another object and use actual Class with generics

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.

3 participants