-
Notifications
You must be signed in to change notification settings - Fork 612
NMS-19261: Implement REST endpoint to upload and import vendor XML files into database #8239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: features/snmp-datacollection-db
Are you sure you want to change the base?
NMS-19261: Implement REST endpoint to upload and import vendor XML files into database #8239
Conversation
…g unique names and ids list
* new changes * new changes * changes * changes * file reverted * changes * revert changes * new changes
…d searching (#8245) * Integrate source rest endpoint with pagination, sorting and searching * Overwrite and rename file changes
There was a problem hiding this 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.
| import { EventConfigFilesUploadResponse } from '@/types/eventConfig' | ||
| import { FeatherButton } from '@featherds/button' | ||
| import { FeatherDialog } from '@featherds/dialog' | ||
| const props = defineProps<{ | ||
| report: EventConfigFilesUploadResponse, |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| 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, |
| label="New File Name" | ||
| :error="error" | ||
| :error-message="error || ''" | ||
| placeholder="Enter new file name (must end with .events.xml)" |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| placeholder="Enter new file name (must end with .events.xml)" | |
| placeholder="Enter new file name (must end with .xml)" |
| <div class="info-section"> | ||
| <h3>Instructions:</h3> | ||
| <ul> | ||
| <li>Event configuration files must be in XML format with a .xml extension.</li> |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.'
| <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> |
| @Operation( | ||
| summary = "Upload datacollectionconf files", | ||
| description = "Upload one or more data collection config files.", | ||
| operationId = "uploadEventConfFiles" |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| operationId = "uploadEventConfFiles" | |
| operationId = "uploadSnmpDataCollectionConfFiles" |
| @Operation( | ||
| summary = "Get SnmpCollectionSource by ID", | ||
| description = "Retrieve an SnmpCollectionSource by its unique identifier.", | ||
| operationId = "getEventConfSourceById" |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| operationId = "getEventConfSourceById" | |
| operationId = "getSnmpCollectionSourceById" |
| @Operation( | ||
| summary = "Get SnmpCollection Source Names", | ||
| description = "Retrieve the names and Ids of all SnmpCollection sources stored in the database.", | ||
| operationId = "getEventConfSourcesNames" |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| operationId = "getEventConfSourcesNames" | |
| operationId = "getSnmpCollectionSourceNamesAndIds" |
| } | ||
|
|
||
| if (name != null && !name.trim().isEmpty()) { | ||
| queryBuilder.append(" and lower(t.collectionSource.name) like ? escape '\\' "); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this 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> |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| <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> |
|
|
||
| <script setup lang="ts"> | ||
| import SnmpDataCollectionSourceImport from '@/components/SnmpDataCollectionSourceImport/SnmpDataCollectionSourceImport.vue' | ||
| import FeatherBackButton from '@featherds/back-button/src/components/FeatherBackButton/FeatherBackButton.vue' |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| 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' |
| return result.trim(); | ||
| } | ||
|
|
||
| private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup datCollectionConfig) { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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'.
| private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup datCollectionConfig) { | |
| private Map<String, Object> buildSuccessResponse(String filename, DatacollectionGroup dataCollectionConfig) { |
|
|
||
| void deleteBySourceId(Integer sourceId); | ||
|
|
||
| List<SnmpCollectionMibGroup> filterEventConf(String name,String ifType, String vendor, String collectionSourceName, int offset, int limit); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
External References