2 * Copyright (c) 2015 CableLabs 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.unimgr.command;
11 import java.util.Map.Entry;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
16 import org.opendaylight.unimgr.impl.UnimgrUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev150622.Evc;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class EvcDeleteCommand extends AbstractDeleteCommand {
25 private static final Logger LOG = LoggerFactory.getLogger(EvcDeleteCommand.class);
27 public EvcDeleteCommand(DataBroker dataBroker,
28 AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
29 super.changes = changes;
30 super.dataBroker = dataBroker;
34 public void execute() {
35 Map<InstanceIdentifier<Evc>, Evc> originalEvcs = UnimgrUtils.extractOriginal(changes, Evc.class);
36 Set<InstanceIdentifier<Evc>> removedEvcs = UnimgrUtils.extractRemoved(changes, Evc.class);
38 Set<InstanceIdentifier<?>> removedPaths = changes.getRemovedPaths();
39 if (!removedPaths.isEmpty()) {
40 for (InstanceIdentifier<?> removedPath: removedPaths) {
41 Class<?> type = removedPath.getTargetType();
42 LOG.info("Removed paths instance identifier {}", type);
43 if (type.equals(Evc.class)) {
44 LOG.info("Removed paths instance identifier {}", type);
45 for (Entry<InstanceIdentifier<Evc>, Evc> evc: originalEvcs.entrySet()) {
46 if (evc.getKey().equals(type)) {
47 Evc data = evc.getValue();
48 LOG.info("Removed EVC {}", data.getId());