Search in sources :

Example 1 with DetailedGroupInfo

use of org.openhab.binding.digitalstrom.internal.client.entity.DetailedGroupInfo 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;
        }
    }
}
Also used : HashMap(java.util.HashMap) Device(org.openhab.binding.digitalstrom.internal.client.entity.Device) Zone(org.openhab.binding.digitalstrom.internal.client.entity.Zone) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList) Map(java.util.Map) HashMap(java.util.HashMap) DetailedGroupInfo(org.openhab.binding.digitalstrom.internal.client.entity.DetailedGroupInfo)

Aggregations

HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 DetailedGroupInfo (org.openhab.binding.digitalstrom.internal.client.entity.DetailedGroupInfo)1 Device (org.openhab.binding.digitalstrom.internal.client.entity.Device)1 Zone (org.openhab.binding.digitalstrom.internal.client.entity.Zone)1