use of org.openhab.binding.digitalstrom.internal.client.entity.Zone in project openhab1-addons by openhab.
the class DigitalSTROMBinding method handleStructure.
// Here we build up a new hashmap in order to replace it with the old one.
// This hashmap is used to find the affected items after an event from
// digitalSTROM.
private void handleStructure(Apartment apartment) {
if (apartment != null) {
Map<Integer, Map<Short, List<String>>> newZoneGroupMap = Collections.synchronizedMap(new HashMap<Integer, Map<Short, List<String>>>());
Map<String, Device> clonedDsidMap = getDsidToDeviceMap();
for (Zone zone : apartment.getZoneMap().values()) {
Map<Short, List<String>> groupMap = new HashMap<Short, List<String>>();
for (DetailedGroupInfo g : zone.getGroups()) {
List<String> devicesInGroup = new LinkedList<String>();
for (String dsid : g.getDeviceList()) {
if (clonedDsidMap.containsKey(dsid)) {
devicesInGroup.add(dsid);
}
}
groupMap.put(g.getGroupID(), devicesInGroup);
}
newZoneGroupMap.put(zone.getZoneId(), groupMap);
}
synchronized (digitalSTROMZoneGroupMap) {
digitalSTROMZoneGroupMap = newZoneGroupMap;
}
}
}
Aggregations