Skip to content

Add multiple devices assign to multiple groups functionality#69

Open
sulaiman2909 wants to merge 2 commits into
entgra:masterfrom
sulaiman2909:improvement-12707
Open

Add multiple devices assign to multiple groups functionality#69
sulaiman2909 wants to merge 2 commits into
entgra:masterfrom
sulaiman2909:improvement-12707

Conversation

@sulaiman2909

@sulaiman2909 sulaiman2909 commented Apr 22, 2025

Copy link
Copy Markdown
Contributor

Previously, separate endpoints were used for different assignment scenarios — such as assigning a single device to multiple groups, or multiple devices to a single group. This update replaces all those with a single generalized endpoint capable of handling assignments of multiple devices to multiple groups.
Ticket: https://roadmap.entgra.net/issues/12707

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Update year of the license header.

policyManagerService.getEffectivePolicy(deviceIdentifier);
}
}
pap.publishChanges();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Publish changes only group assignments are exist.

for(DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
Device device = dms.getDevice(deviceIdentifier, false);
if(!device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) {
GroupManagementProviderService groupManagementProviderService = DeviceMgtAPIUtils.getGroupManagementProviderService();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assignment of these services can move after validation check.

for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
List<DeviceGroup> existingGroups = groupManagementProviderService.getGroups(deviceIdentifier, false);
List<Integer> existingGroupIds = new ArrayList<>();
for (DeviceGroup group : existingGroups) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can move existingGroupIds variable declaration and assignment outside the loop and then you can use existingGroupIds.clear().

List l = new ArrayList();
for (condition) {
    l.clear();
    l.add();
}

This approach will ensure followings,

  • Low GC pressure hence one object reused throughout.
  • Memory reuse is efficient hence avoids unnecessary heap allocation.

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