mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Update all children groups when updating a group
This commit is contained in:
parent
24e69d5492
commit
ed087e2a0c
@ -177,6 +177,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
GroupManagementDAOFactory.beginTransaction();
|
GroupManagementDAOFactory.beginTransaction();
|
||||||
DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId);
|
DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId);
|
||||||
if (existingGroup != null) {
|
if (existingGroup != null) {
|
||||||
|
List<DeviceGroup> groupsToUpdate = new ArrayList<>();
|
||||||
|
String immediateParentID = StringUtils.substringAfterLast(existingGroup.getParentPath(), "/");
|
||||||
|
String parentPath = "";
|
||||||
if (deviceGroup.getParentGroupId() == 0) {
|
if (deviceGroup.getParentGroupId() == 0) {
|
||||||
deviceGroup.setParentPath("/");
|
deviceGroup.setParentPath("/");
|
||||||
} else {
|
} else {
|
||||||
@ -188,10 +191,20 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new GroupManagementException(msg);
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
String parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup);
|
parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup);
|
||||||
deviceGroup.setParentPath(parentPath);
|
deviceGroup.setParentPath(parentPath);
|
||||||
}
|
}
|
||||||
this.groupDAO.updateGroup(deviceGroup, groupId, tenantId);
|
deviceGroup.setGroupId(groupId);
|
||||||
|
groupsToUpdate.add(deviceGroup);
|
||||||
|
if (StringUtils.isNotBlank(immediateParentID)) {
|
||||||
|
List<DeviceGroup> childrenGroups = groupDAO.getChildrenGroups(DeviceManagerUtil.createParentPath(existingGroup), tenantId);
|
||||||
|
for (DeviceGroup childrenGroup : childrenGroups) {
|
||||||
|
childrenGroup.setParentPath(childrenGroup.getParentPath()
|
||||||
|
.replace(existingGroup.getParentPath(), parentPath));
|
||||||
|
groupsToUpdate.add(childrenGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.groupDAO.updateGroups(groupsToUpdate, tenantId);
|
||||||
if (deviceGroup.getGroupProperties() != null && deviceGroup.getGroupProperties().size() > 0) {
|
if (deviceGroup.getGroupProperties() != null && deviceGroup.getGroupProperties().size() > 0) {
|
||||||
this.groupDAO.updateGroupProperties(deviceGroup, groupId, tenantId);
|
this.groupDAO.updateGroupProperties(deviceGroup, groupId, tenantId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user