Modified scm section.
[unimgr.git] / impl / src / main / java / org / opendaylight / vcpe / command / EvcDeleteCommand.java
1 /*
2  * Copyright (c) 2015 CableLabs 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.vcpe.command;
9
10 import java.util.Map;
11 import java.util.Map.Entry;
12 import java.util.Set;
13
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.vcpe.impl.VcpeUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vcpe.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;
22
23 public class EvcDeleteCommand extends AbstractDeleteCommand {
24
25     private static final Logger LOG = LoggerFactory.getLogger(EvcDeleteCommand.class);
26
27     public EvcDeleteCommand(DataBroker dataBroker,
28             AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
29         super.changes = changes;
30         super.dataBroker = dataBroker;
31     }
32
33     @Override
34     public void execute() {
35         Map<InstanceIdentifier<Evc>, Evc> originalEvcs = VcpeUtils.extractOriginal(changes, Evc.class);
36         Set<InstanceIdentifier<Evc>> removedEvcs = VcpeUtils.extractRemoved(changes, Evc.class);
37
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());
49                         }
50                     }
51                 }
52             }
53         }
54     }
55 }