Search in sources :

Example 1 with GraphKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.GraphKey in project bgpcep by opendaylight.

the class GraphListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Graph>> changes) {
    for (DataTreeModification<Graph> change : changes) {
        DataObjectModification<Graph> root = change.getRootNode();
        GraphKey key = change.getRootPath().getRootIdentifier().firstKeyOf(Graph.class);
        switch(root.getModificationType()) {
            case DELETE:
                graphProvider.deleteGraph(key);
                break;
            case SUBTREE_MODIFIED:
            /* getModificationType() returns SUBTREE_MODIFIED only when Data Object is already present in the
                     * Data Store, thus, only for deletion. Thus, to insert children, we must used parseSubTree()
                     * method (See above). This method is called only when the graph already exists.
                     */
            case WRITE:
                /* First look if the Graph was not already configured */
                ConnectedGraph cgraph = this.graphProvider.getConnectedGraph(key);
                if (cgraph == null) {
                    graphProvider.addGraph(root.getDataAfter());
                } else {
                    /* Graph exist, process Children */
                    parseSubTree(cgraph, root.getModifiedChildren());
                }
                break;
            default:
                break;
        }
    }
}
Also used : ConnectedGraph(org.opendaylight.graph.ConnectedGraph) Graph(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph) ConnectedGraph(org.opendaylight.graph.ConnectedGraph) GraphKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.GraphKey)

Aggregations

ConnectedGraph (org.opendaylight.graph.ConnectedGraph)1 Graph (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph)1 GraphKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.GraphKey)1