Search in sources :

Example 6 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule 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 7 with RestConfModule

use of org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule 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

RestConfModule (org.opendaylight.netconf.sal.rest.api.Draft02.RestConfModule)7 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)7 Module (org.opendaylight.yangtools.yang.model.api.Module)7 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)5 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)5 NormalizedNodeContext (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)4 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)3 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)3 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)3 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)3 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)3 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)2 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)2 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)2 GroupingDefinition (org.opendaylight.yangtools.yang.model.api.GroupingDefinition)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Revision (org.opendaylight.yangtools.yang.common.Revision)1