Committed by
Gerrit Code Review
Enhance the detection of meter table supportability in meter GUI
Change-Id: I9925cf8e4ede51f0c7e627ec93b800e146aefbe7
Showing
1 changed file
with
11 additions
and
7 deletions
| ... | @@ -34,6 +34,7 @@ import org.onosproject.ui.table.cell.HexLongFormatter; | ... | @@ -34,6 +34,7 @@ import org.onosproject.ui.table.cell.HexLongFormatter; |
| 34 | import org.onosproject.ui.table.cell.NumberFormatter; | 34 | import org.onosproject.ui.table.cell.NumberFormatter; |
| 35 | 35 | ||
| 36 | import java.util.Collection; | 36 | import java.util.Collection; |
| 37 | +import java.util.Set; | ||
| 37 | 38 | ||
| 38 | /** | 39 | /** |
| 39 | * Message handler for meter view related messages. | 40 | * Message handler for meter view related messages. |
| ... | @@ -46,6 +47,10 @@ public class MeterViewMessageHandler extends UiMessageHandler { | ... | @@ -46,6 +47,10 @@ public class MeterViewMessageHandler extends UiMessageHandler { |
| 46 | 47 | ||
| 47 | private static final String PROTOCOL = "protocol"; | 48 | private static final String PROTOCOL = "protocol"; |
| 48 | private static final String OF_10 = "OF_10"; | 49 | private static final String OF_10 = "OF_10"; |
| 50 | + private static final String OF_11 = "OF_11"; | ||
| 51 | + private static final String OF_12 = "OF_12"; | ||
| 52 | + private static final Set<String> UNSUPPORTED_PROTOCOLS = | ||
| 53 | + ImmutableSet.of(OF_10, OF_11, OF_12); | ||
| 49 | 54 | ||
| 50 | private static final String ID = "id"; | 55 | private static final String ID = "id"; |
| 51 | private static final String APP_ID = "app_id"; | 56 | private static final String APP_ID = "app_id"; |
| ... | @@ -63,11 +68,6 @@ public class MeterViewMessageHandler extends UiMessageHandler { | ... | @@ -63,11 +68,6 @@ public class MeterViewMessageHandler extends UiMessageHandler { |
| 63 | return ImmutableSet.of(new MeterDataRequest()); | 68 | return ImmutableSet.of(new MeterDataRequest()); |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | - private static String deviceProtocol(Device device) { | ||
| 67 | - String protocol = device.annotations().value(PROTOCOL); | ||
| 68 | - return protocol != null ? protocol : ""; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | // handler for meter table requests | 71 | // handler for meter table requests |
| 72 | private final class MeterDataRequest extends TableRequestHandler { | 72 | private final class MeterDataRequest extends TableRequestHandler { |
| 73 | 73 | ||
| ... | @@ -90,8 +90,7 @@ public class MeterViewMessageHandler extends UiMessageHandler { | ... | @@ -90,8 +90,7 @@ public class MeterViewMessageHandler extends UiMessageHandler { |
| 90 | DeviceService ds = get(DeviceService.class); | 90 | DeviceService ds = get(DeviceService.class); |
| 91 | Device dev = ds.getDevice(DeviceId.deviceId(uri)); | 91 | Device dev = ds.getDevice(DeviceId.deviceId(uri)); |
| 92 | 92 | ||
| 93 | - // TODO: replace with a less brittle solution... | 93 | + if (meterNotSupported(dev)) { |
| 94 | - if (deviceProtocol(dev).equals(OF_10)) { | ||
| 95 | return NOT_SUPPORT_MESSAGE; | 94 | return NOT_SUPPORT_MESSAGE; |
| 96 | } | 95 | } |
| 97 | } | 96 | } |
| ... | @@ -129,6 +128,11 @@ public class MeterViewMessageHandler extends UiMessageHandler { | ... | @@ -129,6 +128,11 @@ public class MeterViewMessageHandler extends UiMessageHandler { |
| 129 | .cell(BANDS, m.bands()); | 128 | .cell(BANDS, m.bands()); |
| 130 | } | 129 | } |
| 131 | 130 | ||
| 131 | + private boolean meterNotSupported(Device dev) { | ||
| 132 | + String protocol = dev.annotations().value(PROTOCOL); | ||
| 133 | + return UNSUPPORTED_PROTOCOLS.contains(protocol); | ||
| 134 | + } | ||
| 135 | + | ||
| 132 | private final class BandFormatter implements CellFormatter { | 136 | private final class BandFormatter implements CellFormatter { |
| 133 | private static final String BREAK = "<br>"; | 137 | private static final String BREAK = "<br>"; |
| 134 | 138 | ... | ... |
-
Please register or login to post a comment