X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-restconf-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fbroker%2Fevent%2FRemoteDataChangeEvent.java;fp=opendaylight%2Fmd-sal%2Fsal-restconf-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fbroker%2Fevent%2FRemoteDataChangeEvent.java;h=9dfd262da2a99c55f899ea9b615ed9e911f5fa89;hp=5fad76ff0831e089216337321ffaf57ed1d62989;hb=2360c06ec47235dff72d480292cc50abebcea418;hpb=04d9063615080acf6c7ac49221361cea6f502a5e diff --git a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/event/RemoteDataChangeEvent.java b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/event/RemoteDataChangeEvent.java index 5fad76ff08..9dfd262da2 100644 --- a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/event/RemoteDataChangeEvent.java +++ b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/event/RemoteDataChangeEvent.java @@ -7,24 +7,79 @@ */ package org.opendaylight.controller.sal.restconf.broker.event; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; + +import javax.annotation.concurrent.ThreadSafe; + import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.DataChangedNotification; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +@ThreadSafe public class RemoteDataChangeEvent implements DataChangeEvent,DataObject> { - - - private final DataChangedNotification dataChangedNotification; - - - public RemoteDataChangeEvent(DataChangedNotification dataChangedNotification){ - - this.dataChangedNotification = dataChangedNotification; + private final Map, DataObject> createdConfig, createdOper, origConfig, origOper, updatedConfig, updatedOper; + private final Set> removedConfig, removedOper; + + public RemoteDataChangeEvent(DataChangedNotification dataChangedNotification) { + final Map, DataObject> createdConfig = new HashMap<>(); + final Map, DataObject> createdOper = new HashMap<>(); + final Map, DataObject> origConfig = new HashMap<>(); + final Map, DataObject> origOper = new HashMap<>(); + final Map, DataObject> updatedConfig = new HashMap<>(); + final Map, DataObject> updatedOper = new HashMap<>(); + final Set> removedConfig = new HashSet<>(); + final Set> removedOper = new HashSet<>(); + + for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()) { + switch (d.getOperation()) { + case Created: + switch (d.getStore()) { + case Config: + createdConfig.put(d.getPath(), d); + break; + case Operation: + createdOper.put(d.getPath(), d); + break; + } + break; + case Deleted: + switch (d.getStore()) { + case Config: + removedConfig.add(d.getPath()); + break; + case Operation: + removedOper.add(d.getPath()); + break; + } + break; + case Updated: + switch (d.getStore()) { + case Config: + origConfig.put(d.getPath(), d); + updatedConfig.put(d.getPath(), d); + break; + case Operation: + origOper.put(d.getPath(),d); + updatedOper.put(d.getPath(),d); + break; + } + break; + } + } + + this.createdConfig = Collections.unmodifiableMap(createdConfig); + this.createdOper = Collections.unmodifiableMap(createdOper); + this.origConfig = Collections.unmodifiableMap(origConfig); + this.origOper = Collections.unmodifiableMap(origOper); + this.updatedConfig = Collections.unmodifiableMap(updatedConfig); + this.updatedOper = Collections.unmodifiableMap(updatedOper); + this.removedConfig = Collections.unmodifiableSet(removedConfig); + this.removedOper = Collections.unmodifiableSet(removedOper); } @Override @@ -49,89 +104,41 @@ public class RemoteDataChangeEvent implements DataChangeEvent, DataObject> getCreatedOperationalData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 0 && d.getStore().getIntValue() == 1){ - put(d.getPath(),d); - } - } - }}; + return createdOper; } @Override public Map, DataObject> getCreatedConfigurationData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 0 && d.getStore().getIntValue() == 0){ - put(d.getPath(),d); - } - } - }}; + return createdConfig; } @Override public Map, DataObject> getUpdatedOperationalData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 1){ - put(d.getPath(),d); - } - } - }}; + return updatedOper; } @Override public Map, DataObject> getUpdatedConfigurationData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 0){ - put(d.getPath(),d); - } - } - }}; + return updatedConfig; } @Override public Set> getRemovedConfigurationData() { - return new HashSet>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 2 && d.getStore().getIntValue() == 0){ - add(d.getPath()); - } - } - }}; + return removedConfig; } @Override public Set> getRemovedOperationalData() { - return new HashSet>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 2 && d.getStore().getIntValue() == 1){ - add(d.getPath()); - } - } - }}; + return removedOper; } @Override public Map, DataObject> getOriginalConfigurationData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 0){ - put(d.getPath(),d); - } - } - }}; + return origConfig; } @Override public Map, DataObject> getOriginalOperationalData() { - return new HashMap, DataObject>(){{ - for (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.data.changed.notification.DataChangeEvent d :dataChangedNotification.getDataChangeEvent()){ - if (d.getOperation().getIntValue() == 1 && d.getStore().getIntValue() == 1){ - put(d.getPath(),d); - } - } - }}; + return origOper; } }