Delete a group with childAssets that are also used in another group using "cascade=true"

Hi,

in the following scenario we’re having “device2” assigned to multiple groups:

  • Group1
    – childAssets
    — device1
    — device2

  • Group2
    – childAssets
    — device2

The childAssets of the groups and the assetParents of the devices show the correct relationship between them.

Now when deleting Group1 with cascade=true, the group itself and also the device1 are deleted. I’d expect the device2 to be NOT deleted because it is still used in Group2. But that is not true, all devices assigned to the group are deleted - no matter if they are used somewhere else or not.

Is that an expected behaviour? Is there a way to avoid the removal of devices that are still used in other groups?

Thanks,
Michael

Yes, neither cascade nor forceCascade evaluate whether objects in the child hierarchy are associated to other objects outside this tree. They remove the entire hierarchy starting form the parent specified in the request.

There is a way, but it is more complex than a query param. You will have to traverse the hierarchy tree yourself and only remove the objects that are no longer needed based on your definition of what exactly that means.