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()));
}
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;
}
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);
}
Aggregations