Search in sources :

Example 16 with GroupingDefinition

use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project netconf by opendaylight.

the class RestconfImpl method getLibraryVersion.

@Override
public NormalizedNodePayload getLibraryVersion() {
    final EffectiveModelContext context = schemaContextHandler.get();
    // FIXME: why are we going through a grouping here?!
    final GroupingDefinition grouping = context.findModule(Restconf.QNAME.getModule()).orElseThrow(() -> new IllegalStateException("Failed to find restcibf module")).getGroupings().stream().filter(grp -> Restconf.QNAME.equals(grp.getQName())).findFirst().orElseThrow(() -> new IllegalStateException("Failed to find restconf grouping"));
    final LeafSchemaNode schemaNode = (LeafSchemaNode) ((ContainerSchemaNode) grouping.getDataChildByName(Restconf.QNAME)).getDataChildByName(YANG_LIBRARY_VERSION);
    return NormalizedNodePayload.of(new InstanceIdentifierContext<>(YangInstanceIdentifier.of(YANG_LIBRARY_VERSION), schemaNode, null, context), ImmutableNodes.leafNode(YANG_LIBRARY_VERSION, IetfYangLibrary.REVISION.toString()));
}
Also used : LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) GroupingDefinition(org.opendaylight.yangtools.yang.model.api.GroupingDefinition) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Example 17 with GroupingDefinition

use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project netconf by opendaylight.

the class ControllerContext method getRestconfModuleRestConfSchemaNode.

public DataSchemaNode getRestconfModuleRestConfSchemaNode(final Module inRestconfModule, final String schemaNodeName) {
    Module restconfModule = inRestconfModule;
    if (restconfModule == null) {
        restconfModule = getRestconfModule();
    }
    if (restconfModule == null) {
        return null;
    }
    final Collection<? extends GroupingDefinition> groupings = restconfModule.getGroupings();
    final Iterable<? extends GroupingDefinition> filteredGroups = Iterables.filter(groupings, g -> RestConfModule.RESTCONF_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()));
    final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null);
    final List<DataSchemaNode> instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, RestConfModule.RESTCONF_CONTAINER_SCHEMA_NODE);
    final DataSchemaNode restconfContainer = Iterables.getFirst(instanceDataChildrenByName, null);
    if (RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
        final List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.OPERATIONS_CONTAINER_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    } else if (RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
        final List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    } else if (RestConfModule.STREAM_LIST_SCHEMA_NODE.equals(schemaNodeName)) {
        List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
        final DataSchemaNode modules = Iterables.getFirst(instances, null);
        instances = findInstanceDataChildrenByName((DataNodeContainer) modules, RestConfModule.STREAM_LIST_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    } else if (RestConfModule.MODULES_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
        final List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    } else if (RestConfModule.MODULE_LIST_SCHEMA_NODE.equals(schemaNodeName)) {
        List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.MODULES_CONTAINER_SCHEMA_NODE);
        final DataSchemaNode modules = Iterables.getFirst(instances, null);
        instances = findInstanceDataChildrenByName((DataNodeContainer) modules, RestConfModule.MODULE_LIST_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    } else if (RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE.equals(schemaNodeName)) {
        final List<DataSchemaNode> instances = findInstanceDataChildrenByName((DataNodeContainer) restconfContainer, RestConfModule.STREAMS_CONTAINER_SCHEMA_NODE);
        return Iterables.getFirst(instances, null);
    }
    return null;
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) List(java.util.List) ArrayList(java.util.ArrayList) DataNodeContainer(org.opendaylight.yangtools.yang.model.api.DataNodeContainer) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) GroupingDefinition(org.opendaylight.yangtools.yang.model.api.GroupingDefinition)

Example 18 with GroupingDefinition

use of org.opendaylight.yangtools.yang.model.api.GroupingDefinition in project netconf by opendaylight.

the class ControllerContext method getRestconfModuleErrorsSchemaNode.

public DataSchemaNode getRestconfModuleErrorsSchemaNode() {
    final Module restconfModule = getRestconfModule();
    if (restconfModule == null) {
        return null;
    }
    final Collection<? extends GroupingDefinition> groupings = restconfModule.getGroupings();
    final Iterable<? extends GroupingDefinition> filteredGroups = Iterables.filter(groupings, g -> RestConfModule.ERRORS_GROUPING_SCHEMA_NODE.equals(g.getQName().getLocalName()));
    final GroupingDefinition restconfGrouping = Iterables.getFirst(filteredGroups, null);
    final List<DataSchemaNode> instanceDataChildrenByName = findInstanceDataChildrenByName(restconfGrouping, RestConfModule.ERRORS_CONTAINER_SCHEMA_NODE);
    return Iterables.getFirst(instanceDataChildrenByName, null);
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) RestConfModule(org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule) GroupingDefinition(org.opendaylight.yangtools.yang.model.api.GroupingDefinition)

Aggregations

GroupingDefinition (org.opendaylight.yangtools.yang.model.api.GroupingDefinition)18 Test (org.junit.Test)13 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)8 Module (org.opendaylight.yangtools.yang.model.api.Module)8 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)7 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)6 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)6 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)5 QName (org.opendaylight.yangtools.yang.common.QName)4 AnyxmlSchemaNode (org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode)4 ChoiceSchemaNode (org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode)4 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)3 RestConfModule (org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 UsesNode (org.opendaylight.yangtools.yang.model.api.UsesNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Before (org.junit.Before)1 AugmentationSchemaNode (org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode)1 CaseSchemaNode (org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)1