@Override protected DataNormalizationOperation<?> fromLocalSchemaAndQName(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); if (!potential.isPresent()) { return null; } final DataSchemaNode result = potential.get(); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
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(); }
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); checkArgument(potential.isPresent(), "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes()); final DataSchemaNode result = potential.get(); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); checkArgument(potential.isPresent(), "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes()); final DataSchemaNode result = potential.get(); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
private static DataNormalizationOperation<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) throws DataNormalizationException { final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child); if (!potential.isPresent()) { throw new DataNormalizationException(String.format( "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema,schema.getChildNodes())); } final DataSchemaNode result = potential.get(); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
@Override protected DataSchemaContextNode<?> fromLocalSchemaAndQName(final DataNodeContainer schema, final QName child) { final DataSchemaNode result = findChildSchemaNode(schema, child); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
static DataSchemaContextNode<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final DataSchemaNode result = findChildSchemaNode(schema, child); // We try to look up if this node was added by augmentation if (result != null && schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
/** * Adds the methods to <code>typeBuilder</code> what represents subnodes of node for which <code>typeBuilder</code> * was created. * * @param module current module * @param typeBuilder generated type builder which represents any node. The subnodes of this node are added * to the <code>typeBuilder</code> as methods. The subnode can be of type leaf, leaf-list, list, * container, choice. * @param childOf parent type * @param schemaNodes set of data schema nodes which are the children of the node for which <code>typeBuilder</code> * was created * @return generated type builder which is the same object as the input parameter <code>typeBuilder</code>. * The getter method could be added to it. */ private GeneratedTypeBuilder augSchemaNodeToMethods(final ModuleContext context, final GeneratedTypeBuilder typeBuilder, final Iterable<DataSchemaNode> schemaNodes) { if (schemaNodes != null && typeBuilder != null) { final Type baseInterface = childOf(typeBuilder); for (final DataSchemaNode schemaNode : schemaNodes) { if (!schemaNode.isAugmenting()) { addSchemaNodeToBuilderAsMethod(context, schemaNode, typeBuilder, baseInterface); } } } return typeBuilder; }
@Override protected DataSchemaContextNode<?> fromLocalSchemaAndQName(final DataNodeContainer schema, final QName child) { final DataSchemaNode result = findChildSchemaNode(schema, child); // We try to look up if this node was added by augmentation if (schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
static DataSchemaContextNode<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) { final DataSchemaNode result = findChildSchemaNode(schema, child); // We try to look up if this node was added by augmentation if (result != null && schema instanceof DataSchemaNode && result.isAugmenting()) { return fromAugmentation(schema, (AugmentationTarget) schema, result); } return fromDataSchemaNode(result); }
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 boolean emitCheck(final DataSchemaNode schemaChild) { if (schemaChild.isAugmenting()) { QName root = schemaChild.getPath().getPathFromRoot().iterator().next(); return root.getModule().equals(schemaChild.getQName().getModule()); } return true; }
private AbstractNodeDataWithSchema addSimpleChild(final DataSchemaNode schema) { SimpleNodeDataWithSchema newChild = null; if (schema instanceof LeafSchemaNode) { newChild = new LeafNodeDataWithSchema(schema); } else if (schema instanceof AnyXmlSchemaNode) { // YangModeledAnyXmlSchemaNode is handled by addCompositeChild method. if (schema instanceof YangModeledAnyXmlSchemaNode) { return null; } newChild = new AnyXmlNodeDataWithSchema(schema); } else { return null; } AugmentationSchemaNode augSchema = null; if (schema.isAugmenting()) { augSchema = findCorrespondingAugment(getSchema(), schema); } if (augSchema != null) { augmentationsToChild.put(augSchema, newChild); } else { addChild(newChild); } return newChild; }
private AbstractNodeDataWithSchema addSimpleChild(final DataSchemaNode schema) { SimpleNodeDataWithSchema newChild = null; if (schema instanceof LeafSchemaNode) { newChild = new LeafNodeDataWithSchema(schema); } else if (schema instanceof AnyXmlSchemaNode) { // YangModeledAnyXmlSchemaNode is handled by addCompositeChild method. if (schema instanceof YangModeledAnyXmlSchemaNode) { return null; } newChild = new AnyXmlNodeDataWithSchema(schema); } else { return null; } AugmentationSchemaNode augSchema = null; if (schema.isAugmenting()) { augSchema = findCorrespondingAugment(getSchema(), schema); } if (augSchema != null) { augmentationsToChild.put(augSchema, newChild); } else { addChild(newChild); } return newChild; }
@Override public PropertiesNode addChild(String name, Namespace namespace, NodeType type, String value, Namespace valueNs, Object appInfo) throws SvcLogicException { LeafNode node = ((LeafNode) children.get(name)); if (node != null) { return node; } AugmentationSchemaNode augSchema = null; if (((DataSchemaNode) appInfo).isAugmenting()) { augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), ((DataSchemaNode) appInfo)); } String uri = getUri(this, name, namespace); node = new LeafNode(name, namespace, uri, this, appInfo, type, value); node.valueNs(valueNs); if (augSchema != null && !isNamespaceAsParent(this, node)) { addToAugmentations(augSchema, this, node); } else { children.put(name, ((T) node)); } return node; }
@Override public PropertiesNode addChild(String name, Namespace namespace, NodeType type, Object appInfo) throws SvcLogicException { PropertiesNode node = ((PropertiesNode) children.get(name)); if (node != null) { return node; } // get augment schema, if it is augmented node AugmentationSchemaNode augSchema = null; if (((DataSchemaNode) appInfo).isAugmenting()) { augSchema = findCorrespondingAugment(((DataSchemaNode) this.appInfo()), ((DataSchemaNode) appInfo)); node = getAugmentationNode(augSchema, this, name); } // create node based on type, this api will be invoked only for these three types if (node == null) { String uri = getUri(this, name, namespace); node = createNode(name, namespace, uri, this, appInfo, type); } // If namespace is not same as parent then it is augmented node if (augSchema != null && !isNamespaceAsParent(this, node)) { addToAugmentations(augSchema, this, node); } else { children.put(name, ((T) node)); } return node; }
private void emitDataSchemaNode(final DataSchemaNode child) { if (!super.emitInstantiated && (child.isAddedByUses() || child.isAugmenting())) { // We skip instantiated nodes. return; } if (child instanceof ContainerSchemaNode) { emitContainer((ContainerSchemaNode) child); } else if (child instanceof LeafSchemaNode) { emitLeaf((LeafSchemaNode) child); } else if (child instanceof LeafListSchemaNode) { emitLeafList((LeafListSchemaNode) child); } else if (child instanceof ListSchemaNode) { emitList((ListSchemaNode) child); } else if (child instanceof ChoiceSchemaNode) { emitChoice((ChoiceSchemaNode) child); } else if (child instanceof AnyXmlSchemaNode) { emitAnyxml((AnyXmlSchemaNode) child); } else if (child instanceof AnyDataSchemaNode) { emitAnydata((AnyDataSchemaNode) child); } else { throw new UnsupportedOperationException("Not supported DataSchemaNode type " + child.getClass()); } }
private RestconfNormalizedNodeWriter createNormalizedNodeWriter(final InstanceIdentifierContext<SchemaNode> context, final SchemaPath path, final JsonWriter jsonWriter, Optional<Integer> depth) { final SchemaNode schema = context.getSchemaNode(); final JSONCodecFactory codecs = getCodecFactory(context); final URI initialNs; if ((schema instanceof DataSchemaNode) && !((DataSchemaNode)schema).isAugmenting() && !(schema instanceof SchemaContext)) { initialNs = schema.getQName().getNamespace(); } else if (schema instanceof RpcDefinition) { initialNs = schema.getQName().getNamespace(); } else { initialNs = null; } final NormalizedNodeStreamWriter streamWriter = JSONNormalizedNodeStreamWriter.createNestedWriter(codecs,path,initialNs,jsonWriter); if (depth.isPresent()) { return DepthAwareNormalizedNodeWriter.forStreamWriter(streamWriter, depth.get()); } else { return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(streamWriter); } }
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 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; }