@Override protected final TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) { throw new UnsupportedOperationException("Node " + schema.getPath() + " is leaf type node. Subtree change is not allowed."); }
@Override public final Optional<ModificationApplyOperation> getChild(final PathArgument child) { throw new UnsupportedOperationException("Node " + schema.getPath() + " is leaf type node. Child nodes not allowed"); }
@Override protected final TreeNode applyTouch(final ModifiedNode modification, final TreeNode currentMeta, final Version version) { throw new UnsupportedOperationException("Node " + schema.getPath() + " is leaf type node. Subtree change is not allowed."); }
@Override public final Optional<ModificationApplyOperation> getChild(final PathArgument child) { throw new UnsupportedOperationException("Node " + schema.getPath() + " is leaf type node. Child nodes not allowed"); }
private List<LeafRefContext> getLeafRefsFor(final DataSchemaNode node, final Module module) { final LeafRefPath nodeXPath = LeafRefUtils.schemaPathToLeafRefPath(node.getPath(), module); final List<LeafRefContext> foundLeafRefs = new LinkedList<>(); for (final LeafRefContext leafref : leafRefs) { final LeafRefPath leafRefTargetPath = leafref.getAbsoluteLeafRefTargetPath(); if (leafRefTargetPath.equals(nodeXPath)) { foundLeafRefs.add(leafref); } } return foundLeafRefs; } }
private List<LeafRefContext> getLeafRefsFor(final DataSchemaNode node, final Module module) { final LeafRefPath nodeXPath = LeafRefUtils.schemaPathToLeafRefPath(node.getPath(), module); final List<LeafRefContext> foundLeafRefs = new LinkedList<>(); for (final LeafRefContext leafref : leafRefs) { final LeafRefPath leafRefTargetPath = leafref.getAbsoluteLeafRefTargetPath(); if (leafRefTargetPath.equals(nodeXPath)) { foundLeafRefs.add(leafref); } } return foundLeafRefs; } }
public ImplicitCaseSchemaNode(final DataSchemaNode caseShorthandNode) { this.caseShorthandNode = requireNonNull(caseShorthandNode); this.path = requireNonNull(caseShorthandNode.getPath().getParent()); this.original = getOriginalIfPresent(caseShorthandNode); // We need to cache this, as it will be reset this.augmenting = caseShorthandNode.isAugmenting(); }
private void emitBody(final StringBuilder sb) { final Map<String, Type> getterToType = collectAllProperties(dtoType, new HashMap<String, Type>()); for (final DataSchemaNode schemaChild : schemaNode.getChildNodes()) { if (!schemaChild.isAugmenting()) { final String getter = BindingSchemaMapping.getGetterMethodName(schemaChild); final Type childType = getterToType.get(getter); if (childType == null) { // FIXME AnyXml nodes are ignored, since their type cannot be found in generated bindnig // Bug-706 https://bugs.opendaylight.org/show_bug.cgi?id=706 if (schemaChild instanceof AnyXmlSchemaNode) { LOG.warn("Node {} will be ignored. AnyXml is not yet supported from binding aware code." + "Binding Independent code can be used to serialize anyXml nodes.", schemaChild.getPath()); continue; } throw new IllegalStateException( String.format("Unable to find type for child node %s. Expected child nodes: %s", schemaChild.getPath(), getterToType)); } emitChild(sb, getter, childType, schemaChild); } } }
private void emitBody(final StringBuilder builder) { final Map<String, Type> getterToType = collectAllProperties(dtoType, new HashMap<String, Type>()); for (final DataSchemaNode schemaChild : getChildNodes()) { /** * As before, it only emitted data nodes which were not added by uses or augment, now * according to binding v2 specification, augment of the same module is same as inlining, * all data node children should be processed as-if they were directly defined inside * target node. */ if (emitCheck(schemaChild)) { final String getter = getGetterName(schemaChild); final Type childType = getterToType.get(getter); if (childType == null) { // FIXME AnyXml nodes are ignored, since their type cannot be found in generated bindnig // Bug-706 https://bugs.opendaylight.org/show_bug.cgi?id=706 if (schemaChild instanceof AnyXmlSchemaNode) { LOG.warn("Node {} will be ignored. AnyXml is not yet supported from binding aware code." + "Binding Independent code can be used to serialize anyXml nodes.", schemaChild.getPath()); continue; } throw new IllegalStateException( String.format("Unable to find type for child node %s. Expected child nodes: %s", schemaChild.getPath(), getterToType)); } emitChild(builder, getter, childType, schemaChild); } } }
@Override public Object apply(final ClientResponse clientResponse) { if (clientResponse.getStatus() != 200) { throw new IllegalStateException("Can't get data from restconf. "+clientResponse.getClientResponseStatus()); } List<RpcError> errors = new ArrayList<>(); try { ContainerNode output = null; DataContainer rpcOutputDataObject = mappingService.fromNormalizedNodeRpcData(rpcOutputSchema.getPath(), output); return new RestRpcResult(true,rpcOutputDataObject); } catch (Exception e) { logger.trace("Error while extracting rpc output in proxy method {}",e); RestRpcError error = new RestRpcError(RpcError.ErrorSeverity.ERROR, RpcError.ErrorType.APPLICATION,"Error while extracting rpc output in proxy method.",e); errors.add(error); } return new RestRpcResult(false,errors); } });
private boolean emitCheck(final DataSchemaNode schemaChild) { if (schemaChild.isAugmenting()) { QName root = schemaChild.getPath().getPathFromRoot().iterator().next(); return root.getModule().equals(schemaChild.getQName().getModule()); } return true; }
public static ModificationApplyOperation from(final DataSchemaNode schemaNode, final DataTreeConfiguration treeConfig) { if (treeConfig.getTreeType() == TreeType.CONFIGURATION) { checkArgument(schemaNode.isConfiguration(), "Supplied %s does not belongs to configuration tree.", schemaNode.getPath()); } if (schemaNode instanceof ContainerSchemaNode) { return ContainerModificationStrategy.of((ContainerSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof ListSchemaNode) { return fromListSchemaNode((ListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof ChoiceSchemaNode) { return new ChoiceModificationStrategy((ChoiceSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafListSchemaNode) { return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafSchemaNode) { return new LeafModificationStrategy((LeafSchemaNode) schemaNode); } throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass()); }
public static ModificationApplyOperation from(final DataSchemaNode schemaNode, final DataTreeConfiguration treeConfig) { if (treeConfig.getTreeType() == TreeType.CONFIGURATION) { checkArgument(schemaNode.isConfiguration(), "Supplied %s does not belongs to configuration tree.", schemaNode.getPath()); } if (schemaNode instanceof ContainerSchemaNode) { final ContainerSchemaNode containerSchema = (ContainerSchemaNode) schemaNode; return containerSchema.isPresenceContainer() ? new PresenceContainerModificationStrategy(containerSchema, treeConfig) : new StructuralContainerModificationStrategy(containerSchema, treeConfig); } else if (schemaNode instanceof ListSchemaNode) { return fromListSchemaNode((ListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof ChoiceSchemaNode) { return new ChoiceModificationStrategy((ChoiceSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafListSchemaNode) { return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode, treeConfig); } else if (schemaNode instanceof LeafSchemaNode) { return new LeafModificationStrategy((LeafSchemaNode) schemaNode); } throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass()); }
private static String getGetterName(final DataSchemaNode node) { final TypeDefinition<?> type; if (node instanceof TypedDataSchemaNode) { type = ((TypedDataSchemaNode) node).getType(); } else { type = null; } final String prefix; // Bug 8903: If it is a derived type of boolean, not a built-in type, then the return type // of method would be the generated type and the prefix should be 'get'. if (type instanceof BooleanTypeDefinition && (type.getPath().equals(node.getPath()) || type.getBaseType() == null)) { prefix = "is"; } else { prefix = "get"; } return prefix + JavaIdentifierNormalizer.normalizeSpecificIdentifier(node.getQName().getLocalName(), JavaIdentifier.CLASS); }
private GeneratedTypeBuilder processDataSchemaNode(final Module module, final String basePackageName, final GeneratedTypeBuilder childOf, final DataSchemaNode node) { if (node.isAugmenting() || node.isAddedByUses()) { return null; } final String packageName = packageNameForGeneratedType(basePackageName, node.getPath()); final GeneratedTypeBuilder genType = addDefaultInterfaceDefinition(packageName, node, childOf, module); genType.addComment(node.getDescription()); genType.setDescription(createDescription(node, genType.getFullyQualifiedName())); genType.setModuleName(module.getName()); genType.setReference(node.getReference()); genType.setSchemaPath(node.getPath().getPathFromRoot()); if (node instanceof DataNodeContainer) { genCtx.get(module).addChildNodeType(node, genType); groupingsToGenTypes(module, ((DataNodeContainer) node).getGroupings()); processUsesAugments((DataNodeContainer) node, module); } return genType; }
private LeafRefContext buildLeafRefContextReferencedByTree(final DataSchemaNode node, final Module currentModule) throws LeafRefYangSyntaxErrorException { final LeafRefContextBuilder currentLeafRefContextBuilder = new LeafRefContextBuilder(node.getQName(), node.getPath(), schemaContext); if (node instanceof DataNodeContainer) { for (final DataSchemaNode childNode : ((DataNodeContainer) node).getChildNodes()) {
private LeafRefContext buildLeafRefContextReferencedByTree(final DataSchemaNode node, final Module currentModule) throws LeafRefYangSyntaxErrorException { final LeafRefContextBuilder currentLeafRefContextBuilder = new LeafRefContextBuilder(node.getQName(), node.getPath(), schemaContext); if (node instanceof DataNodeContainer) { for (final DataSchemaNode childNode : ((DataNodeContainer) node).getChildNodes()) {
private GeneratedTypeBuilder processDataSchemaNode(final ModuleContext context, final Type baseInterface, final DataSchemaNode node) { if (node.isAugmenting() || node.isAddedByUses()) { return null; } final GeneratedTypeBuilder genType = addDefaultInterfaceDefinition(context, node, baseInterface); annotateDeprecatedIfNecessary(node.getStatus(), genType); final Module module = context.module(); genType.setModuleName(module.getName()); addCodegenInformation(genType, module, node); genType.setSchemaPath(node.getPath()); if (node instanceof DataNodeContainer) { context.addChildNodeType(node, genType); groupingsToGenTypes(context, ((DataNodeContainer) node).getGroupings()); processUsesAugments((DataNodeContainer) node, context); } return genType; }
private LeafRefContext buildLeafRefContextReferencingTree(final DataSchemaNode node, final Module currentModule) throws LeafRefYangSyntaxErrorException { final LeafRefContextBuilder currentLeafRefContextBuilder = new LeafRefContextBuilder(node.getQName(), node.getPath(), schemaContext);