Merge "Bug 1029: Remove dead code: sal-schema-repository-api"
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / topology / TopologyAdapter.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.compatibility.topology;
9
10 import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader;
11 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
12 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
13 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
16 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19
20 import com.google.common.base.Preconditions;
21
22 public class TopologyAdapter implements IPluginInTopologyService {
23     private final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder(NetworkTopology.class)
24             .child(Topology.class, new TopologyKey(new TopologyId("flow:1"))).toInstance();
25
26     // FIXME: seems to be unused
27     private IPluginOutTopologyService topologyPublisher;
28     private DataProviderService dataService;
29
30     public void setDataService(final DataProviderService dataService) {
31         this.dataService = Preconditions.checkNotNull(dataService);
32     }
33
34     @Override
35     public void sollicitRefresh() {
36         final TypeSafeDataReader reader = TypeSafeDataReader.forReader(dataService);
37         final Topology t = reader.readOperationalData(topology);
38         topologyPublisher.edgeUpdate(TopologyMapping.toADEdgeUpdates(t, reader));
39     }
40 }