@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { this.value.put(child.getIdentifier(), child); return this; }
final NormalizedNodeStreamWriter writer = getWriter(); if(writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); final Set<QName> qnames = node.getIdentifier().getKeyValues().keySet(); final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname)); if (child.isPresent()) { write(child.get()); boolean result = writeChildren(Iterables.filter(node.getValue(), new Predicate<NormalizedNode<?, ?>>() { @Override public boolean apply(final NormalizedNode<?, ?> input) {
@Override public Collection<NormalizedNodeUpdate> normalizedUpdates(@Nonnull final YangInstanceIdentifier topLevelIdentifier, @Nonnull final Map.Entry<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> entry) { // identifier has different format : parent_node/list_node/list_node_with_key LOG.debug("Processing {} as list", topLevelIdentifier); return ((MapNode) entry.getValue()).getValue().stream() .map(mapEntryNode -> new NormalizedNodeUpdate(YangInstanceIdentifier.builder(topLevelIdentifier) .node(mapEntryNode.getNodeType()) .node(mapEntryNode.getIdentifier()).build(), mapEntryNode, null)) .collect(Collectors.toList()); } }
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } return writeChildren(node.getValue()); }
protected boolean writeMapEntryChildren(final MapEntryNode mapEntryNode) throws IOException { if (currentDepth < maxDepth) { writeChildren(mapEntryNode.getValue()); } else if (currentDepth == maxDepth) { writeOnlyKeys(mapEntryNode.getIdentifier().getKeyValues()); } return true; }
private Collection<String> getCandidateNames(MapEntryNode entity) { Collection<MapEntryNode> candidates = ((MapNode)entity.getChild(CANDIDATE_NODE_ID).get()).getValue(); Collection<String> candidateNames = new ArrayList<>(candidates.size()); for(MapEntryNode candidate: candidates) { candidateNames.add(candidate.getChild(CANDIDATE_NAME_NODE_ID).get().getValue().toString()); } return candidateNames; }
private static NormalizedNode<?, ?> translateRootShardIdentifierToListenerPath( final YangInstanceIdentifier listenerPath, final NormalizedNode<?, ?> node) { if (listenerPath.isEmpty()) { return node; } final NormalizedNodeBuilder nodeBuilder; if (node instanceof ContainerNode) { nodeBuilder = ImmutableContainerNodeBuilder.create().withValue(((ContainerNode) node).getValue()); } else if (node instanceof MapEntryNode) { nodeBuilder = ImmutableMapEntryNodeBuilder.create().withValue(((MapEntryNode) node).getValue()); } else { throw new IllegalArgumentException("Expected ContainerNode or MapEntryNode, but was " + node.getClass()); } nodeBuilder.withNodeIdentifier(listenerPath.getLastPathArgument()); return nodeBuilder.build(); }
static Optional<RemoteYangSchema> createFromNormalizedNode(final RemoteDeviceId id, final MapEntryNode schemaNode) { Preconditions.checkArgument(schemaNode.getNodeType().equals(Schema.QNAME), "Wrong QName %s", schemaNode.getNodeType()); QName childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_FORMAT; String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get(); if(formatAsString.equals(Yang.QNAME.toString()) == false) { LOG.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString); return Optional.absent(); } childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_LOCATION; final Set<String> locationsAsString = getAllChildNodeValues(schemaNode, childNode); if(locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString()) == false) { LOG.debug("{}: Ignoring schema due to unsupported location: {}", id, locationsAsString); return Optional.absent(); } childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_NAMESPACE; final String namespaceAsString = getSingleChildNodeValue(schemaNode, childNode).get(); childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_VERSION; // Revision does not have to be filled final Optional<String> revisionAsString = getSingleChildNodeValue(schemaNode, childNode); childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_IDENTIFIER; final String moduleNameAsString = getSingleChildNodeValue(schemaNode, childNode).get(); final QName moduleQName = revisionAsString.isPresent() ? QName.create(namespaceAsString, revisionAsString.get(), moduleNameAsString) : QName.create(URI.create(namespaceAsString), null, moduleNameAsString); return Optional.of(new RemoteYangSchema(moduleQName)); }
private boolean writeMapEntryNode(final MapEntryNode node, final SchemaNode dataSchemaNode) throws IOException { if(writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), OrderedNormalizedNodeWriter.childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), OrderedNormalizedNodeWriter.childSizeHint(node.getValue())); } return writeChildren(node.getValue(), dataSchemaNode, true); }
private void validateMapNodeData(final MapNode node, final LeafRefContext referencedByCtx, final LeafRefContext referencingCtx, final ModificationType modificationType, final YangInstanceIdentifier current) { for (final MapEntryNode mapEntry : node.getValue()) { final YangInstanceIdentifier mapEntryIdentifier = current.node(mapEntry.getIdentifier()); for (final DataContainerChild<?, ?> child : mapEntry.getValue()) { if (child instanceof AugmentationNode) { validateNodeData(child, referencedByCtx, referencingCtx, modificationType, current.node( child.getIdentifier())); return; } validateChildNodeData(child, referencedByCtx, referencingCtx, modificationType, mapEntryIdentifier); } } }
private List<Ipv4Prefix> extractPrefixes(final Collection<MapEntryNode> routes) { final List<Ipv4Prefix> prefs = new ArrayList<>(routes.size()); for (final MapEntryNode ipv4Route : routes) { final String prefix = (String) ipv4Route.getChild(this.routeKeyLeaf).get().getValue(); prefs.add(new Ipv4Prefix(prefix)); } return prefs; }
@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { this.value.put(child.getIdentifier(), child); return this; }
final NormalizedNodeStreamWriter nnWriter = getWriter(); if (nnWriter instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) nnWriter).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { nnWriter.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); final Set<QName> qnames = node.getIdentifier().getKeyValues().keySet(); final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname)); if (child.isPresent()) { write(child.get()); return writeChildren(Iterables.filter(node.getValue(), input -> { if (input instanceof AugmentationNode) { return true;
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if (writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } return writeChildren(node.getValue()); }
private void validateMapNodeData(final MapNode node, final LeafRefContext referencedByCtx, final LeafRefContext referencingCtx, final ModificationType modificationType, final YangInstanceIdentifier current) { for (final MapEntryNode mapEntry : node.getValue()) { final YangInstanceIdentifier mapEntryIdentifier = current.node(mapEntry.getIdentifier()); for (final DataContainerChild<?, ?> child : mapEntry.getValue()) { if (child instanceof AugmentationNode) { validateNodeData(child, referencedByCtx, referencingCtx, modificationType, current.node( child.getIdentifier())); return; } validateChildNodeData(child, referencedByCtx, referencingCtx, modificationType, mapEntryIdentifier); } } }
@Override public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) { DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Collections.singleton(schema.getQName())); return super.withChild(child); }
private void searchForEntitiesOwnedBy(final String owner, final EntityWalker walker) { LOG.debug("{}: Searching for entities owned by {}", persistenceId(), owner); searchForEntities((entityTypeNode, entityNode) -> { Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID); if(possibleOwner.isPresent() && owner.equals(possibleOwner.get().getValue().toString())) { walker.onEntity(entityTypeNode, entityNode); } }); }
@Override public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) { checkDirty(); this.value.put(child.getIdentifier(), child); return this; }
final NormalizedNodeStreamWriter nnWriter = getWriter(); if (nnWriter instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) nnWriter).startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { nnWriter.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); final Set<QName> qnames = node.getIdentifier().getKeyValues().keySet(); final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname)); if (child.isPresent()) { write(child.get()); return writeChildren(Iterables.filter(node.getValue(), input -> { if (input instanceof AugmentationNode) { return true;
protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException { if(writer instanceof NormalizedNodeStreamAttributeWriter) { ((NormalizedNodeStreamAttributeWriter) writer) .startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()), node.getAttributes()); } else { writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue())); } currentDepth++; writeMapEntryChildren(node); currentDepth--; return true; }