Clean up ietf-netconf-monitoring-extension
[netconf.git] / restconf / restconf-common / src / main / java / org / opendaylight / restconf / common / util / OperationsResourceUtils.java
index 03e289d19e0534a7c274f0968250807dd6182c07..ada0442bc0710855c67a438ed8c72411935895f8 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 
 
 // FIXME: remove this class
@@ -33,7 +34,7 @@ public final class OperationsResourceUtils {
         // Hidden on purpose
     }
 
-    public static @NonNull Entry<InstanceIdentifierContext<OperationsContainerSchemaNode>, ContainerNode>
+    public static @NonNull Entry<InstanceIdentifierContext, ContainerNode>
                 contextForModelContext(final @NonNull SchemaContext context, final @Nullable DOMMountPoint mountPoint) {
         // Determine which modules we need and construct leaf schemas to correspond to all RPC definitions
         final Collection<Module> modules = new ArrayList<>();
@@ -57,10 +58,13 @@ public final class OperationsResourceUtils {
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> operationsBuilder = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(OperationsContainerSchemaNode.QNAME));
         for (final OperationsLeafSchemaNode leaf : rpcLeafSchemas) {
-            operationsBuilder.withChild(ImmutableNodes.leafNode(leaf.getQName(), Empty.getInstance()));
+            operationsBuilder.withChild(ImmutableNodes.leafNode(leaf.getQName(), Empty.value()));
         }
 
-        return Map.entry(new InstanceIdentifierContext<>(null, operatationsSchema, mountPoint,
-            new OperationsEffectiveModuleContext(ImmutableSet.copyOf(modules))), operationsBuilder.build());
+        final var opContext = new OperationsEffectiveModuleContext(ImmutableSet.copyOf(modules));
+        final var stack = SchemaInferenceStack.of(opContext);
+        stack.enterSchemaTree(operatationsSchema.getQName());
+
+        return Map.entry(InstanceIdentifierContext.ofStack(stack, mountPoint), operationsBuilder.build());
     }
 }