Search in sources :

Example 11 with IdentitySchemaNode

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

the class SchemaContextTest method findIdentityByQName.

IdentitySchemaNode findIdentityByQName(final Module module, final QName qName) {
    Map<QName, IdentitySchemaNode> mapIdentitiesByQNames = mapIdentitiesByQNames(module);
    IdentitySchemaNode found = mapIdentitiesByQNames.get(qName);
    assertNotNull(found);
    return found;
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) IdentitySchemaNode(org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)

Example 12 with IdentitySchemaNode

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

the class ModuleMXBeanEntryBuilder method build.

public Map<String, ModuleMXBeanEntry> build() {
    LOG.debug("Generating ModuleMXBeans of {} to package {}", currentModule.getNamespace(), packageName);
    String configModulePrefix;
    try {
        configModulePrefix = getConfigModulePrefixFromImport(currentModule);
    } catch (IllegalArgumentException e) {
        // this currentModule does not import config currentModule
        return Collections.emptyMap();
    }
    // get identities of base config:currentModule-type
    Map<String, IdentitySchemaNode> moduleIdentities = getIdentityMap();
    Map<String, QName> uniqueGeneratedClassesNames = new HashMap<>();
    // each currentModule name should have an augmentation defined
    Map<String, IdentitySchemaNode> unaugmentedModuleIdentities = new HashMap<>(moduleIdentities);
    Map<String, ModuleMXBeanEntry> result = new HashMap<>();
    for (AugmentationSchemaNode augmentation : currentModule.getAugmentations()) {
        Collection<DataSchemaNode> childNodes = augmentation.getChildNodes();
        if (areAllChildrenCaseSchemaNodes(childNodes)) {
            for (CaseSchemaNode childCase : castChildNodesToChoiceCases(childNodes)) {
                // TODO refactor, extract to standalone builder class
                processCaseSchemaNode(result, uniqueGeneratedClassesNames, configModulePrefix, moduleIdentities, unaugmentedModuleIdentities, augmentation, childCase);
            }
        }
    // skip if child nodes are not all cases
    }
    // clean up nulls
    cleanUpNulls(result);
    // check attributes name uniqueness
    checkAttributeNamesUniqueness(uniqueGeneratedClassesNames, result);
    checkUnaugumentedIdentities(unaugmentedModuleIdentities);
    LOG.debug("Number of ModuleMXBeans to be generated: {}", result.size());
    return result;
}
Also used : AugmentationSchemaNode(org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode) HashMap(java.util.HashMap) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) ConfigConstants.createConfigQName(org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName) IdentitySchemaNode(org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode) CaseSchemaNode(org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)

Aggregations

IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)12 QName (org.opendaylight.yangtools.yang.common.QName)9 HashMap (java.util.HashMap)8 Optional (com.google.common.base.Optional)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)2 AttributeIfc (org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc)2 TypeProviderImpl (org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl)2 CaseSchemaNode (org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)2 Module (org.opendaylight.yangtools.yang.model.api.Module)2 UnknownSchemaNode (org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)2 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1 SimpleType (javax.management.openmbean.SimpleType)1 IdentityMapping (org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping)1 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)1