Search in sources :

Example 11 with QName

use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.

the class TestModel method createAugmentedListEntry.

public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
    Set<QName> childAugmentations = new HashSet<>();
    childAugmentations.add(AUG_CONT_QNAME);
    ContainerNode augCont = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)).withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
    final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(augCont).build();
    return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(AUGMENTED_LIST_QNAME, ID_QNAME, id)).withChild(ImmutableNodes.leafNode(ID_QNAME, id)).withChild(augmentationNode).build();
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) QName(org.opendaylight.yangtools.yang.common.QName) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) HashSet(java.util.HashSet)

Example 12 with QName

use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.

the class ServiceRegistryWrapper method getMappedServices.

public Map<String, Map<String, Map<String, String>>> getMappedServices() {
    Map<String, Map<String, Map<String, String>>> retVal = new HashMap<>();
    Map<String, Map<String, ObjectName>> serviceMapping = configServiceRefRegistry.getServiceMapping();
    for (Map.Entry<String, Map<String, ObjectName>> nameToRefEntry : serviceMapping.entrySet()) {
        for (String refName : nameToRefEntry.getValue().keySet()) {
            ObjectName on = nameToRefEntry.getValue().get(refName);
            Services.ServiceInstance si = Services.ServiceInstance.fromObjectName(on);
            QName qname = QName.create(nameToRefEntry.getKey());
            String namespace = qname.getNamespace().toString();
            Map<String, Map<String, String>> serviceToRefs = retVal.computeIfAbsent(namespace, k -> new HashMap<>());
            String localName = qname.getLocalName();
            Map<String, String> refsToSis = serviceToRefs.computeIfAbsent(localName, k -> new HashMap<>());
            Preconditions.checkState(!refsToSis.containsKey(refName), "Duplicate reference name %s for service %s:%s, now for instance %s", refName, namespace, localName, on);
            refsToSis.put(refName, si.toString());
        }
    }
    return retVal;
}
Also used : HashMap(java.util.HashMap) QName(org.opendaylight.yangtools.yang.common.QName) ObjectName(javax.management.ObjectName) Map(java.util.Map) HashMap(java.util.HashMap)

Example 13 with QName

use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.

the class BindingDOMNotificationListenerAdapter method onNotification.

@Override
public void onNotification(@Nonnull final DOMNotification notification) {
    final Notification baNotification = deserialize(notification);
    final QName notificationQName = notification.getType().getLastComponent();
    getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) Notification(org.opendaylight.yangtools.yang.binding.Notification) DOMNotification(org.opendaylight.controller.md.sal.dom.api.DOMNotification)

Example 14 with QName

use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.

the class BindingDOMNotificationListenerAdapter method getNotificationTypes.

private static Set<SchemaPath> getNotificationTypes(final Class<? extends NotificationListener> type) {
    // TODO: Investigate possibility and performance impact if we cache this or expose
    // it from NotificationListenerInvoker
    final Set<SchemaPath> ret = new HashSet<>();
    for (final Method method : type.getMethods()) {
        if (BindingReflections.isNotificationCallback(method)) {
            final Class<?> notification = method.getParameterTypes()[0];
            final QName name = BindingReflections.findQName(notification);
            ret.add(SchemaPath.create(true, name));
        }
    }
    return ret;
}
Also used : SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) QName(org.opendaylight.yangtools.yang.common.QName) Method(java.lang.reflect.Method) HashSet(java.util.HashSet)

Example 15 with QName

use of org.opendaylight.yangtools.yang.common.QName in project controller by opendaylight.

the class CompositeModel method createTestContainer.

public static ContainerNode createTestContainer() {
    final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
    final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
    final LeafSetNode<Object> shoes = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "shoe"))).withChild(nike).withChild(puma).build();
    final LeafSetEntryNode<Object> five = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)).withValue(5).build();
    final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)).withValue(15).build();
    final LeafSetNode<Object> numbers = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "number"))).withChild(five).withChild(fifteen).build();
    Set<QName> childAugmentations = new HashSet<>();
    childAugmentations.add(AUG_QNAME);
    final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")).build();
    return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(augmentationNode).withChild(shoes).withChild(numbers).withChild(mapNodeBuilder(OUTER_LIST_QNAME).withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build()).build();
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) HashSet(java.util.HashSet)

Aggregations

QName (org.opendaylight.yangtools.yang.common.QName)50 HashMap (java.util.HashMap)13 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)12 Test (org.junit.Test)10 IdentitySchemaNode (org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode)9 HashSet (java.util.HashSet)7 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 ConfigConstants.createConfigQName (org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName)6 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)5 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)5 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)5 Module (org.opendaylight.yangtools.yang.model.api.Module)5 ArrayList (java.util.ArrayList)4 AttributeIfc (org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc)4 UnknownSchemaNode (org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)4 Map (java.util.Map)3 JavaAttribute (org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute)3 NameConflictException (org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException)3 TypeProviderImpl (org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl)3 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)3