X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FNodeDataChangeListener.java;fp=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FNodeDataChangeListener.java;h=cdb26162c0a776b3f934fdb699752c7a11ad9bf2;hp=0000000000000000000000000000000000000000;hb=e062c06cd7ca669e3fc2200a43c11c5ed3b20f04;hpb=726c13c574c0154d21434692ba22a1d2310ecec8 diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java new file mode 100644 index 0000000000..cdb26162c0 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeDataChangeListener.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NodeDataChangeListener extends AbstractDataChangeListener { + private static final Logger LOG = LoggerFactory.getLogger(NodeDataChangeListener.class); + + + public NodeDataChangeListener (final InventoryAndReadAdapter adapter, final DataBroker db) { + super(adapter,db,Node.class); + } + + protected void add(InstanceIdentifier createKeyIdent, Node node) { + FlowCapableNode fcn = node.getAugmentation(FlowCapableNode.class); + if(fcn != null) { + FlowCapableNodeUpdatedBuilder fcbnu = new FlowCapableNodeUpdatedBuilder(fcn); + NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); + builder.setId(node.getId()); + builder.setNodeRef(new NodeRef(createKeyIdent)); + builder.setNodeConnector(node.getNodeConnector()); + builder.addAugmentation(FlowCapableNodeUpdated.class, fcbnu.build()); + adapter.onNodeUpdatedInternal(builder.build()); + } + } + + protected void update(InstanceIdentifier updateKeyIdent, Node original, + Node update) { + this.add(updateKeyIdent, update); + } + + protected void remove(InstanceIdentifier ident, Node removeValue) { + NodeRemovedBuilder builder = new NodeRemovedBuilder(); + builder.setNodeRef(new NodeRef(ident)); + adapter.onNodeRemovedInternal(builder.build()); + } + + protected InstanceIdentifier getWildCardPath() { + return InstanceIdentifier.create(Nodes.class).child(Node.class); + } + +}