|
18 | 18 | import java.util.Collections; |
19 | 19 | import java.util.List; |
20 | 20 | import java.util.Map; |
| 21 | +import java.util.TreeMap; |
21 | 22 | import java.util.concurrent.ConcurrentHashMap; |
22 | 23 |
|
23 | 24 | import org.eclipse.jdt.annotation.NonNullByDefault; |
@@ -81,7 +82,26 @@ public void initializeDevice() { |
81 | 82 | memberReachability.clear(); |
82 | 83 | memberDeviceIds.forEach(id -> memberReachability.put(id, false)); |
83 | 84 |
|
84 | | - updateProperties(); |
| 85 | + // special handling for device set properties - add for each device in set their individual canReceive and |
| 86 | + // canSend properties |
| 87 | + receiveCapabilities.clear(); |
| 88 | + sendCapabilities.clear(); |
| 89 | + memberDeviceIds.forEach(id -> { |
| 90 | + Map<String, Object> modelProperties = gateway().model().getPropertiesFor(id); |
| 91 | + Object customName = gateway().model().getCustonNameFor(id); |
| 92 | + |
| 93 | + TreeMap<String, String> handlerProperties = new TreeMap<>(editProperties()); |
| 94 | + Object receiveCapabilities = modelProperties.get(CAPABILITIES_KEY_CAN_RECEIVE); |
| 95 | + handlerProperties.put(customName + " " + CAPABILITIES_KEY_CAN_RECEIVE, |
| 96 | + receiveCapabilities != null ? receiveCapabilities.toString() : "[]"); |
| 97 | + Object sendCapabilities = modelProperties.get(CAPABILITIES_KEY_CAN_SEND); |
| 98 | + handlerProperties.put(customName + " " + CAPABILITIES_KEY_CAN_SEND, |
| 99 | + sendCapabilities != null ? sendCapabilities.toString() : "[]"); |
| 100 | + updateProperties(handlerProperties); |
| 101 | + // properties updated and user is able to check all devices in the set and their capabilities, now add the |
| 102 | + // capabilities to the set itself |
| 103 | + addCapabilities(id); |
| 104 | + }); |
85 | 105 |
|
86 | 106 | // 2) Initialize the set's own customName from the model so that subsequent member |
87 | 107 | // updates (which carry the member's own customName) cannot overwrite it. |
|
0 commit comments