use of org.opendaylight.yangtools.yang.model.api.ActionNodeContainer in project yangtools by opendaylight.
the class ActionStatementTest method assertContainsActions.
private static void assertContainsActions(final SchemaContext schemaContext, final String dataContainerName, final String... actionNames) {
final DataSchemaNode dataChildByName = schemaContext.getDataChildByName(QName.create(FOO_NS, FOO_REV, dataContainerName));
assertTrue(dataChildByName instanceof ActionNodeContainer);
assertContainsActions((ActionNodeContainer) dataChildByName, actionNames);
}
use of org.opendaylight.yangtools.yang.model.api.ActionNodeContainer in project netconf by opendaylight.
the class ParserIdentifier method getPathSchema.
private static SchemaNode getPathSchema(final EffectiveModelContext schemaContext, final YangInstanceIdentifier urlPath) {
// First things first: an empty path means data invocation on SchemaContext
if (urlPath.isEmpty()) {
return schemaContext;
}
// Peel the last component and locate the parent data node, empty path resolves to SchemaContext
final DataSchemaContextNode<?> parent = DataSchemaContextTree.from(schemaContext).findChild(verifyNotNull(urlPath.getParent())).orElseThrow(// Parent data node is not present, this is not a valid location.
() -> new RestconfDocumentedException("Parent of " + urlPath + " not found", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE));
// Now try to resolve the last component as a data item...
final DataSchemaContextNode<?> data = parent.getChild(urlPath.getLastPathArgument());
if (data != null) {
return data.getDataSchemaNode();
}
// ... otherwise this has to be an operation invocation. RPCs cannot be defined anywhere but schema root,
// actions can reside everywhere else (and SchemaContext reports them empty)
final QName qname = urlPath.getLastPathArgument().getNodeType();
final DataSchemaNode parentSchema = parent.getDataSchemaNode();
if (parentSchema instanceof SchemaContext) {
for (final RpcDefinition rpc : ((SchemaContext) parentSchema).getOperations()) {
if (qname.equals(rpc.getQName())) {
return rpc;
}
}
}
if (parentSchema instanceof ActionNodeContainer) {
for (final ActionDefinition action : ((ActionNodeContainer) parentSchema).getActions()) {
if (qname.equals(action.getQName())) {
return action;
}
}
}
// is deemed invalid
throw new RestconfDocumentedException("Context for " + urlPath + " not found", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
}
use of org.opendaylight.yangtools.yang.model.api.ActionNodeContainer in project lighty-netconf-simulator by PANTHEONtech.
the class ActionServiceDeviceProcessor method getAction.
private Collection<ActionDefinition> getAction() {
final Builder<ActionDefinition> builder = ImmutableSet.builder();
Collection<? extends DataSchemaNode> childNodes = this.adapterContext.currentSerializer().getRuntimeContext().getEffectiveModelContext().getChildNodes();
for (final DataSchemaNode dataSchemaNode : childNodes) {
if (dataSchemaNode instanceof ActionNodeContainer) {
findAction(dataSchemaNode, builder);
}
}
return builder.build();
}
Aggregations