2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.compatibility;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemovedBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdatedBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class NodeDataChangeListener extends AbstractDataChangeListener<Node> {
24 private static final Logger LOG = LoggerFactory.getLogger(NodeDataChangeListener.class);
27 public NodeDataChangeListener (final InventoryAndReadAdapter adapter, final DataBroker db) {
28 super(adapter,db,Node.class);
31 protected void add(InstanceIdentifier<Node> createKeyIdent, Node node) {
32 FlowCapableNode fcn = node.getAugmentation(FlowCapableNode.class);
34 FlowCapableNodeUpdatedBuilder fcbnu = new FlowCapableNodeUpdatedBuilder(fcn);
35 NodeUpdatedBuilder builder = new NodeUpdatedBuilder();
36 builder.setId(node.getId());
37 builder.setNodeRef(new NodeRef(createKeyIdent));
38 builder.setNodeConnector(node.getNodeConnector());
39 builder.addAugmentation(FlowCapableNodeUpdated.class, fcbnu.build());
40 adapter.onNodeUpdatedInternal(builder.build());
44 protected void update(InstanceIdentifier<Node> updateKeyIdent, Node original,
46 this.add(updateKeyIdent, update);
49 protected void remove(InstanceIdentifier<Node> ident, Node removeValue) {
50 NodeRemovedBuilder builder = new NodeRemovedBuilder();
51 builder.setNodeRef(new NodeRef(ident));
52 adapter.onNodeRemovedInternal(builder.build());
55 protected InstanceIdentifier<Node> getWildCardPath() {
56 return InstanceIdentifier.create(Nodes.class).child(Node.class);