+ private void searchForEntitiesOwnedBy(final Set<String> ownedBy, final EntityWalker walker) {
+ LOG.debug("{}: Searching for entities owned by {}", persistenceId(), ownedBy);
+
+ searchForEntities((entityTypeNode, entityNode) -> {
+ Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner =
+ entityNode.getChild(ENTITY_OWNER_NODE_ID);
+ String currentOwner = possibleOwner.isPresent() ? possibleOwner.get().getValue().toString() : "";
+ if (ownedBy.contains(currentOwner)) {
+ walker.onEntity(entityTypeNode, entityNode);
+ }
+ });
+ }
+
+ private void removeCandidateFromEntities(final MemberName member) {
+ final List<Modification> modifications = new ArrayList<>();
+ searchForEntities((entityTypeNode, entityNode) -> {
+ if (hasCandidate(entityNode, member)) {
+ YangInstanceIdentifier entityId =
+ (YangInstanceIdentifier) entityNode.getIdentifier().getKeyValues().get(ENTITY_ID_QNAME);
+ YangInstanceIdentifier candidatePath = candidatePath(
+ entityTypeNode.getIdentifier().getKeyValues().get(ENTITY_TYPE_QNAME).toString(),
+ entityId, member.getName());
+
+ LOG.info("{}: Found entity {}, removing candidate {}, path {}", persistenceId(), entityId,
+ member, candidatePath);
+
+ modifications.add(new DeleteModification(candidatePath));