Search in sources :

Example 11 with SchemaPath

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

the class BindingToNormalizedNodeCodec method getRpcMethodToSchemaPath.

// FIXME: This should be probably part of Binding Runtime context
public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
    final Module module = getModuleBlocking(key);
    final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
    try {
        for (final RpcDefinition rpcDef : module.getRpcs()) {
            final Method method = findRpcMethod(key, rpcDef);
            ret.put(method, rpcDef.getPath());
        }
    } catch (final NoSuchMethodException e) {
        throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
    }
    return ret.build();
}
Also used : ImmutableBiMap(com.google.common.collect.ImmutableBiMap) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) Method(java.lang.reflect.Method) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module)

Example 12 with SchemaPath

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

the class DOMRpcRoutingTable method add.

DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcsToAdd) {
    if (rpcsToAdd.isEmpty()) {
        return this;
    }
    // First decompose the identifiers to a multimap
    final ListMultimap<SchemaPath, YangInstanceIdentifier> toAdd = decomposeIdentifiers(rpcsToAdd);
    // Now iterate over existing entries, modifying them as appropriate...
    final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> mb = ImmutableMap.builder();
    for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> re : this.rpcs.entrySet()) {
        List<YangInstanceIdentifier> newRpcs = new ArrayList<>(toAdd.removeAll(re.getKey()));
        if (!newRpcs.isEmpty()) {
            final AbstractDOMRpcRoutingTableEntry ne = re.getValue().add(implementation, newRpcs);
            mb.put(re.getKey(), ne);
        } else {
            mb.put(re);
        }
    }
    // Finally add whatever is left in the decomposed multimap
    for (Entry<SchemaPath, Collection<YangInstanceIdentifier>> e : toAdd.asMap().entrySet()) {
        final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
        final List<DOMRpcImplementation> v = Collections.singletonList(implementation);
        for (YangInstanceIdentifier i : e.getValue()) {
            vb.put(i, v);
        }
        mb.put(e.getKey(), createRpcEntry(schemaContext, e.getKey(), vb.build()));
    }
    return new DOMRpcRoutingTable(mb.build(), schemaContext);
}
Also used : ArrayList(java.util.ArrayList) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) DOMRpcImplementation(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with SchemaPath

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

the class TopicDOMNotificationTest method getTypeTest.

@Test
public void getTypeTest() {
    SchemaPath topicNotificationId = SchemaPath.create(true, TopicNotification.QNAME);
    assertEquals("Type has not been created correctly.", topicNotificationId, topicDOMNotification.getType());
}
Also used : SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) Test(org.junit.Test)

Example 14 with SchemaPath

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

the class UtilTest method createSchemaPathList.

private static List<SchemaPath> createSchemaPathList() {
    final QName qname1 = QName.create("urn:odl:xxx", "2015-01-01", "localName");
    final QName qname2 = QName.create("urn:odl:yyy", "2015-01-01", "localName");
    final SchemaPath path1 = SchemaPath.create(true, qname1);
    final SchemaPath path2 = SchemaPath.create(true, qname2);
    return Arrays.asList(path1, path2);
}
Also used : SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) QName(org.opendaylight.yangtools.yang.common.QName)

Example 15 with SchemaPath

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

the class ConfigLoaderImplTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    final SchemaPath schemaPath = SchemaPath.create(true, NetworkInstances.QNAME, NetworkInstance.QNAME, Protocols.QNAME);
    doReturn(schemaPath).when(this.processor).getSchemaPath();
    doReturn("processor").when(this.processor).toString();
}
Also used : SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) Before(org.junit.Before)

Aggregations

SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)15 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)4 Method (java.lang.reflect.Method)3 Test (org.junit.Test)3 QName (org.opendaylight.yangtools.yang.common.QName)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 DOMNotificationListener (org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener)2 DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)2 DOMRpcService (org.opendaylight.controller.md.sal.dom.api.DOMRpcService)2 RpcRoutingStrategy (org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy)2 AbstractListenerRegistration (org.opendaylight.yangtools.concepts.AbstractListenerRegistration)2 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)2 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)2 ActorRef (akka.actor.ActorRef)1 Preconditions (com.google.common.base.Preconditions)1