Search in sources :

Example 6 with UnknownSchemaNode

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

the class ModuleMXBeanEntryBuilder method findProvidedServices.

private static Map<String, QName> findProvidedServices(final IdentitySchemaNode moduleIdentity, final Module currentModule, final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {
    Map<String, QName> result = new HashMap<>();
    for (UnknownSchemaNode unknownNode : moduleIdentity.getUnknownSchemaNodes()) {
        if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME.equals(unknownNode.getNodeType())) {
            String prefixAndIdentityLocalName = unknownNode.getNodeParameter();
            ServiceInterfaceEntry sie = findSIE(prefixAndIdentityLocalName, currentModule, qNamesToSIEs, schemaContext);
            result.put(sie.getFullyQualifiedName(), sie.getQName());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) QName(org.opendaylight.yangtools.yang.common.QName) ConfigConstants.createConfigQName(org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)

Example 7 with UnknownSchemaNode

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

the class ModuleMXBeanEntryBuilder method extractDependency.

private static Optional<? extends AbstractDependencyAttribute> extractDependency(final DataNodeContainer dataNodeContainer, final DataSchemaNode attrNode, final Module currentModule, final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {
    if (isDependencyContainer(dataNodeContainer)) {
        // reference
        UsesNode usesNode = dataNodeContainer.getUses().iterator().next();
        for (SchemaNode refineNode : usesNode.getRefines().values()) {
            // this will ignore name nodes, since they are not needed here
            if (TYPE.equals(refineNode.getQName().getLocalName())) {
                checkState(refineNode.getUnknownSchemaNodes().size() == 1, "Unexpected unknown schema node size of " + refineNode);
                UnknownSchemaNode requiredIdentity = refineNode.getUnknownSchemaNodes().iterator().next();
                checkState(ConfigConstants.REQUIRED_IDENTITY_EXTENSION_QNAME.equals(requiredIdentity.getNodeType()), "Unexpected language extension " + requiredIdentity);
                String prefixAndIdentityLocalName = requiredIdentity.getNodeParameter();
                // import should point to a module
                ServiceInterfaceEntry serviceInterfaceEntry = findSIE(prefixAndIdentityLocalName, currentModule, qNamesToSIEs, schemaContext);
                LeafSchemaNode refine = (LeafSchemaNode) usesNode.getRefines().values().iterator().next();
                boolean mandatory = refine.isMandatory();
                AbstractDependencyAttribute reference;
                if (dataNodeContainer instanceof ContainerSchemaNode) {
                    reference = new DependencyAttribute(attrNode, serviceInterfaceEntry, mandatory, attrNode.getDescription().orElse(null));
                } else {
                    reference = new ListDependenciesAttribute(attrNode, serviceInterfaceEntry, mandatory, attrNode.getDescription().orElse(null));
                }
                return Optional.of(reference);
            }
        }
    }
    return Optional.absent();
}
Also used : CaseSchemaNode(org.opendaylight.yangtools.yang.model.api.CaseSchemaNode) AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) IdentitySchemaNode(org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) DependencyAttribute(org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute) AbstractDependencyAttribute(org.opendaylight.controller.config.yangjmxgenerator.attribute.AbstractDependencyAttribute) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) AbstractDependencyAttribute(org.opendaylight.controller.config.yangjmxgenerator.attribute.AbstractDependencyAttribute) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) ListDependenciesAttribute(org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) UsesNode(org.opendaylight.yangtools.yang.model.api.UsesNode)

Example 8 with UnknownSchemaNode

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

the class RuntimeBeanEntry method findQNameFromGrouping.

/**
 * Find "proper" qname of unknown node in case it comes from a grouping
 */
private static QName findQNameFromGrouping(final DataNodeContainer subtree, final SchemaContext ctx, final UnknownSchemaNode unknownSchemaNode, final String localIdentityName) {
    QName identityQName = null;
    for (UsesNode usesNode : subtree.getUses()) {
        SchemaNode dataChildByName = SchemaContextUtil.findDataSchemaNode(ctx, usesNode.getGroupingPath());
        Module m = SchemaContextUtil.findParentModule(ctx, dataChildByName);
        List<UnknownSchemaNode> unknownSchemaNodes = dataChildByName.getUnknownSchemaNodes();
        if (Collections2.transform(unknownSchemaNodes, UNKNOWN_NODE_TO_STRING).contains(UNKNOWN_NODE_TO_STRING.apply(unknownSchemaNode))) {
            identityQName = QName.create(dataChildByName.getQName(), localIdentityName);
        }
    }
    return identityQName;
}
Also used : LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) Module(org.opendaylight.yangtools.yang.model.api.Module) UnknownSchemaNode(org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode) UsesNode(org.opendaylight.yangtools.yang.model.api.UsesNode)

Aggregations

UnknownSchemaNode (org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)8 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)5 QName (org.opendaylight.yangtools.yang.common.QName)4 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)4 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)4 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)4 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)4 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)4 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)3 UsesNode (org.opendaylight.yangtools.yang.model.api.UsesNode)3 Test (org.junit.Test)2 CaseSchemaNode (org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)2 Module (org.opendaylight.yangtools.yang.model.api.Module)2 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)2 Optional (com.google.common.base.Optional)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)1 AbstractDependencyAttribute (org.opendaylight.controller.config.yangjmxgenerator.attribute.AbstractDependencyAttribute)1