public ContainerSchemaNode getInput() { return delegate.getInput(); }
@Override public Collection<DataSchemaNode> getChildNodes() { final ContainerSchemaNode input = rpcDefinition.getInput(); final ContainerSchemaNode output = rpcDefinition.getOutput(); if (input == null && output == null) { return ImmutableList.of(); } else if (input != null && output != null) { return ImmutableList.of(input,output); } else if (input != null) { return ImmutableList.of(input); } else { return ImmutableList.of(output); } }
@Override public Collection<DataSchemaNode> getChildNodes() { final ContainerSchemaNode input = rpcDefinition.getInput(); final ContainerSchemaNode output = rpcDefinition.getOutput(); if (input == null && output == null) { return ImmutableList.of(); } else if (input != null && output != null) { return ImmutableList.of(input,output); } else if (input != null) { return ImmutableList.of(input); } else { return ImmutableList.of(output); } }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { switch (name.getLocalName()) { case "input": return Optional.of(rpcDefinition.getInput()); case "output": return Optional.of(rpcDefinition.getOutput()); default: return Optional.empty(); } }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { switch (name.getLocalName()) { case "input": return Optional.of(rpcDefinition.getInput()); case "output": return Optional.of(rpcDefinition.getOutput()); default: return Optional.empty(); } }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { final String rpcName = BindingMapping.getClassName(rpc.getQName()); final String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; if (targetType.equals(rpcInputName)) { return Optional.of(rpc.getInput()); } final String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if (targetType.equals(rpcOutputName)) { return Optional.of(rpc.getOutput()); } return Optional.empty(); }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { // FIXME: check QNameModule switch (name.getLocalName()) { case "input": return Optional.of(delegate.getInput()); case "output": return Optional.of(delegate.getOutput()); default: return Optional.empty(); } }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { String rpcName = BindingMapping.getClassName(rpc.getQName()); String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if(targetType.equals(rpcInputName)) { return Optional.<DataNodeContainer>of(rpc.getInput()); } else if (targetType.equals(rpcOutputName)) { return Optional.<DataNodeContainer>of(rpc.getOutput()); } return Optional.absent(); }
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException { final String methodName = BindingMapping.getMethodName(rpcDef.getQName()); if(rpcDef.getInput() != null) { final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput()); return key.getMethod(methodName, inputClz); } return key.getMethod(methodName); }
/** * Returns RPC input or output schema based on supplied QName. * * @param rpc RPC Definition * @param qname input or output QName with namespace same as RPC * @return input or output schema. Returns null if RPC does not have input/output specified. */ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc, final @NonNull QName qname) { requireNonNull(rpc, "Rpc Schema must not be null"); switch (requireNonNull(qname, "QName must not be null").getLocalName()) { case "input": return rpc.getInput(); case "output": return rpc.getOutput(); default: throw new IllegalArgumentException("Supplied qname " + qname + " does not represent rpc input or output."); } } }
/** * Returns RPC input or output schema based on supplied QName. * * @param rpc RPC Definition * @param qname input or output QName with namespace same as RPC * @return input or output schema. Returns null if RPC does not have input/output specified. */ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc, final @NonNull QName qname) { requireNonNull(rpc, "Rpc Schema must not be null"); switch (requireNonNull(qname, "QName must not be null").getLocalName()) { case "input": return rpc.getInput(); case "output": return rpc.getOutput(); default: throw new IllegalArgumentException("Supplied qname " + qname + " does not represent rpc input or output."); } } }
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException { final String methodName = BindingMapping.getMethodName(rpcDef.getQName()); final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput()); return key.getMethod(methodName, inputClz); }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } } return new GlobalRpcStrategy(rpc.getQName()); }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } } return new GlobalRpcStrategy(rpc.getQName()); }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { for (DataSchemaNode schemaNode : rpc.getInput().getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } return new GlobalRpcStrategy(rpc.getQName()); }
static List<TypeDefinition<?>> getAllTypedefs(final Module module) { final List<TypeDefinition<?>> ret = new ArrayList<>(); fillRecursively(ret, module); final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { fillRecursively(ret, notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { ret.addAll(rpcDefinition.getTypeDefinitions()); fillRecursively(ret, rpcDefinition.getInput()); fillRecursively(ret, rpcDefinition.getOutput()); } return ret; }
private void traverseModule(final DataNodeContainer dataNode) { final Module module; if (dataNode instanceof Module) { module = (Module) dataNode; } else { return; } final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { traverse(notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { this.allTypedefs.addAll(rpcDefinition.getTypeDefinitions()); ContainerSchemaNode input = rpcDefinition.getInput(); if (input != null) { traverse(input); } ContainerSchemaNode output = rpcDefinition.getOutput(); if (output != null) { traverse(output); } } }
private void traverseModule(final DataNodeContainer dataNode) { final Module module; if (dataNode instanceof Module) { module = (Module) dataNode; } else { return; } final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { traverse(notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { this.allTypedefs.addAll(rpcDefinition.getTypeDefinitions()); ContainerSchemaNode input = rpcDefinition.getInput(); if (input != null) { traverse(input); } ContainerSchemaNode output = rpcDefinition.getOutput(); if (output != null) { traverse(output); } } }
protected void addRpcs(RpcDefinition rpcDefn, List<Api> apis, String parentPath, SchemaContext schemaContext) { Api rpc = new Api(); String resourcePath = parentPath + resolvePathArgumentsName(rpcDefn, schemaContext); rpc.setPath(resourcePath); Operation operationSpec = new Operation(); operationSpec.setMethod("POST"); operationSpec.setNotes(rpcDefn.getDescription()); operationSpec.setNickname(rpcDefn.getQName().getLocalName()); if (rpcDefn.getOutput() != null) { operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output"); } if (rpcDefn.getInput() != null) { Parameter payload = new Parameter(); payload.setParamType("body"); payload.setType("(" + rpcDefn.getQName().getLocalName() + ")input"); operationSpec.setParameters(Collections.singletonList(payload)); operationSpec.setConsumes(OperationBuilder.CONSUMES_PUT_POST); } rpc.setOperations(Arrays.asList(operationSpec)); apis.add(rpc); }
private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) { final RpcDefinition rpcDef = findRpcDefinition(context, key); if (rpcDef != null) { final ContainerSchemaNode input = rpcDef.getInput(); if (input != null) { for (DataSchemaNode c : input.getChildNodes()) { for (UnknownSchemaNode extension : c.getUnknownSchemaNodes()) { if (CONTEXT_REFERENCE.equals(extension.getNodeType())) { final YangInstanceIdentifier keyId = YangInstanceIdentifier.of(c.getQName()); return new RoutedDOMRpcRoutingTableEntry(rpcDef, keyId, implementations); } } } } return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations); } else { return new UnknownDOMRpcRoutingTableEntry(key, implementations); } }