Search in sources :

Example 6 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class NormalizedNodeXmlTranslationTest method withAttributes.

private static ContainerNode withAttributes() {
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> b = containerBuilder();
    b.withNodeIdentifier(getNodeIdentifier("container"));
    final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listBuilder = Builders.mapBuilder().withNodeIdentifier(getNodeIdentifier("list"));
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> list1Builder = Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(getNodeIdentifier("list").getNodeType(), getNodeIdentifier("uint32InList").getNodeType(), Uint32.valueOf(3)));
    final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> uint32InListBuilder = Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"));
    list1Builder.withChild(uint32InListBuilder.withValue(Uint32.valueOf(3)).build());
    listBuilder.withChild(list1Builder.build());
    b.withChild(listBuilder.build());
    final NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> booleanBuilder = Builders.leafBuilder().withNodeIdentifier(getNodeIdentifier("boolean"));
    booleanBuilder.withValue(Boolean.FALSE);
    b.withChild(booleanBuilder.build());
    final ListNodeBuilder<Object, SystemLeafSetNode<Object>> leafListBuilder = Builders.leafSetBuilder().withNodeIdentifier(getNodeIdentifier("leafList"));
    final NormalizedNodeBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> leafList1Builder = Builders.leafSetEntryBuilder().withNodeIdentifier(new NodeWithValue(getNodeIdentifier("leafList").getNodeType(), "a"));
    leafList1Builder.withValue("a");
    leafListBuilder.withChild(leafList1Builder.build());
    b.withChild(leafListBuilder.build());
    return b.build();
}
Also used : SystemLeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode) LeafSetEntryNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) LeafNode(org.opendaylight.yangtools.yang.data.api.schema.LeafNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)

Example 7 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class NormalizedNodeWriter method wasProcessedAsCompositeNode.

protected boolean wasProcessedAsCompositeNode(final NormalizedNode node) throws IOException {
    if (node instanceof ContainerNode) {
        final ContainerNode n = (ContainerNode) node;
        writer.startContainerNode(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof MapEntryNode) {
        return writeMapEntryNode((MapEntryNode) node);
    }
    if (node instanceof UnkeyedListEntryNode) {
        final UnkeyedListEntryNode n = (UnkeyedListEntryNode) node;
        writer.startUnkeyedListItem(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof ChoiceNode) {
        final ChoiceNode n = (ChoiceNode) node;
        writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof AugmentationNode) {
        final AugmentationNode n = (AugmentationNode) node;
        writer.startAugmentationNode(n.getIdentifier());
        return writeChildren(n.body());
    }
    if (node instanceof UnkeyedListNode) {
        final UnkeyedListNode n = (UnkeyedListNode) node;
        writer.startUnkeyedList(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof UserMapNode) {
        final UserMapNode n = (UserMapNode) node;
        writer.startOrderedMapNode(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof SystemMapNode) {
        final SystemMapNode n = (SystemMapNode) node;
        writer.startMapNode(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof UserLeafSetNode) {
        final UserLeafSetNode<?> n = (UserLeafSetNode<?>) node;
        writer.startOrderedLeafSet(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    if (node instanceof SystemLeafSetNode) {
        final SystemLeafSetNode<?> n = (SystemLeafSetNode<?>) node;
        writer.startLeafSet(n.getIdentifier(), childSizeHint(n.body()));
        return writeChildren(n.body());
    }
    return false;
}
Also used : SystemLeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) UserMapNode(org.opendaylight.yangtools.yang.data.api.schema.UserMapNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) UserLeafSetNode(org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode)

Example 8 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug4454Test method minMaxListNoMinMaxDeleteTest.

@Test
public void minMaxListNoMinMaxDeleteTest() throws DataValidationFailedException {
    final MapEntryNode fooEntryNoMinMaxNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME, "foo");
    final SystemMapNode mapNode1 = ImmutableNodes.mapNodeBuilder().withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX)).withChild(fooEntryNoMinMaxNode).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    Map<QName, Object> key = new HashMap<>();
    key.put(MIN_MAX_KEY_LEAF_QNAME, "foo");
    NodeIdentifierWithPredicates mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME_NO_MINMAX, key);
    final YangInstanceIdentifier minMaxLeafFoo = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2);
    key.clear();
    key.put(MIN_MAX_KEY_LEAF_QNAME, "non-existing-leaf");
    mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME_NO_MINMAX, key);
    YangInstanceIdentifier minMaxLeafNel = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node(MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2).build();
    modificationTree.write(MIN_MAX_LIST_NO_MINMAX_PATH, mapNode1);
    modificationTree.delete(minMaxLeafFoo);
    modificationTree.delete(minMaxLeafNel);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
    final DataTreeSnapshot snapshotAfterCommit = inMemoryDataTree.takeSnapshot();
    final Optional<NormalizedNode> minMaxListRead = snapshotAfterCommit.readNode(MIN_MAX_LIST_NO_MINMAX_PATH);
    // Empty list should have disappeared
    assertFalse(minMaxListRead.isPresent());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) HashMap(java.util.HashMap) QName(org.opendaylight.yangtools.yang.common.QName) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 9 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug4295Test method secondModification.

private void secondModification(final int testScenarioNumber) throws DataValidationFailedException {
    /*  MERGE */
    SystemMapNode outerListNode = ImmutableNodes.mapNodeBuilder().withNodeIdentifier(NodeIdentifier.create(outerList)).withChild(createOuterListEntry("3", "o-3")).withChild(createOuterListEntry("4", "o-4")).withChild(createOuterListEntry("5", "o-5")).build();
    ContainerNode rootContainerNode = createRootContainerBuilder().withChild(createSubRootContainerBuilder().withChild(outerListNode).build()).build();
    YangInstanceIdentifier path = YangInstanceIdentifier.of(root);
    DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
    modification.merge(path, rootContainerNode);
    if (testScenarioNumber == 1) {
        /* WRITE EMPTY INNER LIST */
        writeEmptyInnerList(modification, "2");
    } else if (testScenarioNumber == 2) {
        /* WRITE INNER LIST ENTRY */
        MapEntryNode innerListEntryA = createInnerListEntry("a", "i-a-2");
        path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2")).node(innerList).node(createInnerListEntryPath("a"));
        modification.write(path, innerListEntryA);
    } else if (testScenarioNumber == 3) {
        /* WRITE INNER LIST WITH ENTRIES */
        SystemMapNode innerListNode = createInnerListBuilder().withChild(createInnerListEntry("a", "i-a-3")).withChild(createInnerListEntry("c", "i-c")).build();
        path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2")).node(innerList);
        modification.write(path, innerListNode);
    }
    /*  COMMIT */
    modification.ready();
    inMemoryDataTree.validate(modification);
    inMemoryDataTree.commit(inMemoryDataTree.prepare(modification));
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 10 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project netconf by opendaylight.

the class RestconfImpl method getAvailableStreams.

@Override
@Deprecated
public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
    final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema();
    final Set<String> availableStreams = Notificator.getStreamNames();
    final Module restconfModule = getRestconfModule();
    final DataSchemaNode streamSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.STREAM_LIST_SCHEMA_NODE);
    checkState(streamSchemaNode instanceof ListSchemaNode);
    final CollectionNodeBuilder<MapEntryNode, SystemMapNode> listStreamsBuilder = SchemaAwareBuilders.mapBuilder((ListSchemaNode) streamSchemaNode);
    for (final String streamName : availableStreams) {
        listStreamsBuilder.withChild(toStreamEntryNode(streamName, streamSchemaNode));
    }
    final DataSchemaNode streamsContainerSchemaNode = controllerContext.getRestconfModuleRestConfSchemaNode(restconfModule, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
    checkState(streamsContainerSchemaNode instanceof ContainerSchemaNode);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> streamsContainerBuilder = SchemaAwareBuilders.containerBuilder((ContainerSchemaNode) streamsContainerSchemaNode);
    streamsContainerBuilder.withChild(listStreamsBuilder.build());
    return new NormalizedNodeContext(new InstanceIdentifierContext<>(STREAMS, streamsContainerSchemaNode, null, schemaContext), streamsContainerBuilder.build(), QueryParametersParser.parseWriterParameters(uriInfo));
}
Also used : SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NormalizedNodeContext(org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Aggregations

SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)34 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)23 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)21 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)21 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)12 Test (org.junit.Test)11 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)9 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)8 UserMapNode (org.opendaylight.yangtools.yang.data.api.schema.UserMapNode)8 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)8 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)7 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)7 LeafNode (org.opendaylight.yangtools.yang.data.api.schema.LeafNode)6 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)6 CollectionNodeBuilder (org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder)5 DataTree (org.opendaylight.yangtools.yang.data.tree.api.DataTree)5 QName (org.opendaylight.yangtools.yang.common.QName)4 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)4 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)4 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)4