Search in sources :

Example 1 with AugmentationTarget

use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project yangtools by opendaylight.

the class NormalizedNodeStreamWriterStack method startAugmentationNode.

public AugmentationSchemaNode startAugmentationNode(final AugmentationIdentifier identifier) {
    LOG.debug("Enter augmentation {}", identifier);
    Object parent = getParent();
    checkArgument(parent instanceof AugmentationTarget, "Augmentation not allowed under %s", parent);
    if (parent instanceof ChoiceSchemaNode) {
        final QName name = Iterables.get(identifier.getPossibleChildNames(), 0);
        parent = findCaseByChild((ChoiceSchemaNode) parent, name);
    }
    checkArgument(parent instanceof DataNodeContainer, "Augmentation allowed only in DataNodeContainer", parent);
    final AugmentationSchemaNode schema = findSchemaForAugment((AugmentationTarget) parent, identifier.getPossibleChildNames());
    final AugmentationSchemaNode resolvedSchema = new EffectiveAugmentationSchema(schema, (DataNodeContainer) parent);
    schemaStack.push(resolvedSchema);
    return resolvedSchema;
}
Also used : AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) EffectiveAugmentationSchema(org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema) QName(org.opendaylight.yangtools.yang.common.QName) DataNodeContainer(org.opendaylight.yangtools.yang.model.api.DataNodeContainer) AugmentationTarget(org.opendaylight.yangtools.yang.model.api.AugmentationTarget) ChoiceSchemaNode(org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode)

Example 2 with AugmentationTarget

use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project netconf by opendaylight.

the class StreamingContext method fromSchemaAndQNameChecked.

static StreamingContext<?> 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()) {
        for (final AugmentationSchemaNode aug : ((AugmentationTarget) schema).getAvailableAugmentations()) {
            if (aug.dataChildByName(result.getQName()) != null) {
                return new Augmentation(aug, schema);
            }
        }
    }
    return fromDataSchemaNode(result);
}
Also used : AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) AugmentationTarget(org.opendaylight.yangtools.yang.model.api.AugmentationTarget)

Example 3 with AugmentationTarget

use of org.opendaylight.yangtools.yang.model.api.AugmentationTarget in project yangtools by opendaylight.

the class DataNodeContainerModificationStrategy method resolveChild.

private ModificationApplyOperation resolveChild(final PathArgument identifier) {
    final T schema = getSchema();
    if (identifier instanceof AugmentationIdentifier && schema instanceof AugmentationTarget) {
        return SchemaAwareApplyOperation.from(schema, (AugmentationTarget) schema, (AugmentationIdentifier) identifier, treeConfig);
    }
    final QName qname = identifier.getNodeType();
    final Optional<DataSchemaNode> child = schema.findDataChildByName(qname);
    if (!child.isPresent()) {
        LOG.trace("Child {} not present in container schema {} children {}", identifier, this, schema.getChildNodes());
        return null;
    }
    try {
        return SchemaAwareApplyOperation.from(child.get(), treeConfig);
    } catch (ExcludedDataSchemaNodeException e) {
        LOG.trace("Failed to instantiate child {} in container schema {} children {}", identifier, this, schema.getChildNodes(), e);
        return null;
    }
}
Also used : AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) AugmentationTarget(org.opendaylight.yangtools.yang.model.api.AugmentationTarget)

Aggregations

AugmentationTarget (org.opendaylight.yangtools.yang.model.api.AugmentationTarget)3 QName (org.opendaylight.yangtools.yang.common.QName)2 AugmentationSchemaNode (org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode)2 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)2 AugmentationIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier)1 ChoiceSchemaNode (org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode)1 DataNodeContainer (org.opendaylight.yangtools.yang.model.api.DataNodeContainer)1 EffectiveAugmentationSchema (org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema)1