Jian Li
Committed by Gerrit Code Review

[ONOS-3722] Augment TableModel to support annotations

Change-Id: Ie90fa6b26887ddd5afb03eb116304c16f10396ff
Showing 31 changed files with 79 additions and 36 deletions
...@@ -74,7 +74,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler { ...@@ -74,7 +74,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
74 } 74 }
75 75
76 @Override 76 @Override
77 - protected String noRowsMessage() { 77 + protected String noRowsMessage(ObjectNode payload) {
78 return NO_ROWS_MESSAGE; 78 return NO_ROWS_MESSAGE;
79 } 79 }
80 80
......
...@@ -77,7 +77,7 @@ public class DriverMatrixMessageHandler extends UiMessageHandler { ...@@ -77,7 +77,7 @@ public class DriverMatrixMessageHandler extends UiMessageHandler {
77 } 77 }
78 78
79 @Override 79 @Override
80 - protected String noRowsMessage() { 80 + protected String noRowsMessage(ObjectNode payload) {
81 return NO_ROWS_MESSAGE; 81 return NO_ROWS_MESSAGE;
82 } 82 }
83 83
......
...@@ -92,7 +92,7 @@ public class AlarmTableMessageHandler extends UiMessageHandler { ...@@ -92,7 +92,7 @@ public class AlarmTableMessageHandler extends UiMessageHandler {
92 } 92 }
93 93
94 @Override 94 @Override
95 - protected String noRowsMessage() { 95 + protected String noRowsMessage(ObjectNode payload) {
96 return NO_ROWS_MESSAGE; 96 return NO_ROWS_MESSAGE;
97 } 97 }
98 98
......
...@@ -55,7 +55,7 @@ public abstract class TableRequestHandler extends RequestHandler { ...@@ -55,7 +55,7 @@ public abstract class TableRequestHandler extends RequestHandler {
55 String sortDir = JsonUtils.string(payload, "sortDir", "asc"); 55 String sortDir = JsonUtils.string(payload, "sortDir", "asc");
56 tm.sort(sortCol, TableModel.sortDir(sortDir)); 56 tm.sort(sortCol, TableModel.sortDir(sortDir));
57 57
58 - addTableConfigAnnotations(tm); 58 + addTableConfigAnnotations(tm, payload);
59 59
60 ObjectNode rootNode = MAPPER.createObjectNode(); 60 ObjectNode rootNode = MAPPER.createObjectNode();
61 rootNode.set(nodeName, TableUtils.generateRowArrayNode(tm)); 61 rootNode.set(nodeName, TableUtils.generateRowArrayNode(tm));
...@@ -77,12 +77,13 @@ public abstract class TableRequestHandler extends RequestHandler { ...@@ -77,12 +77,13 @@ public abstract class TableRequestHandler extends RequestHandler {
77 } 77 }
78 78
79 /** 79 /**
80 - * Adds all annotations to table model. 80 + * Adds table configuration specific annotations to table model.
81 * 81 *
82 * @param tm a table model 82 * @param tm a table model
83 + * @param payload the event payload from the client
83 */ 84 */
84 - protected void addTableConfigAnnotations(TableModel tm) { 85 + protected void addTableConfigAnnotations(TableModel tm, ObjectNode payload) {
85 - tm.addAnnotation(NO_ROWS_MSG_KEY, noRowsMessage()); 86 + tm.addAnnotation(NO_ROWS_MSG_KEY, noRowsMessage(payload));
86 } 87 }
87 88
88 /** 89 /**
...@@ -110,9 +111,10 @@ public abstract class TableRequestHandler extends RequestHandler { ...@@ -110,9 +111,10 @@ public abstract class TableRequestHandler extends RequestHandler {
110 * are no rows to display. For example, a host table might return 111 * are no rows to display. For example, a host table might return
111 * "No hosts found". 112 * "No hosts found".
112 * 113 *
114 + * @param payload request payload
113 * @return the message 115 * @return the message
114 */ 116 */
115 - protected abstract String noRowsMessage(); 117 + protected abstract String noRowsMessage(ObjectNode payload);
116 118
117 /** 119 /**
118 * Subclasses should populate the table model by adding 120 * Subclasses should populate the table model by adding
......
...@@ -78,7 +78,7 @@ public class ApplicationViewMessageHandler extends UiMessageHandler { ...@@ -78,7 +78,7 @@ public class ApplicationViewMessageHandler extends UiMessageHandler {
78 } 78 }
79 79
80 @Override 80 @Override
81 - protected String noRowsMessage() { 81 + protected String noRowsMessage(ObjectNode payload) {
82 return NO_ROWS_MESSAGE; 82 return NO_ROWS_MESSAGE;
83 } 83 }
84 84
......
...@@ -72,7 +72,7 @@ public class ClusterViewMessageHandler extends UiMessageHandler { ...@@ -72,7 +72,7 @@ public class ClusterViewMessageHandler extends UiMessageHandler {
72 } 72 }
73 73
74 @Override 74 @Override
75 - protected String noRowsMessage() { 75 + protected String noRowsMessage(ObjectNode payload) {
76 return NO_ROWS_MESSAGE; 76 return NO_ROWS_MESSAGE;
77 } 77 }
78 78
......
...@@ -139,7 +139,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler { ...@@ -139,7 +139,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler {
139 } 139 }
140 140
141 @Override 141 @Override
142 - protected String noRowsMessage() { 142 + protected String noRowsMessage(ObjectNode payload) {
143 return NO_ROWS_MESSAGE; 143 return NO_ROWS_MESSAGE;
144 } 144 }
145 145
......
...@@ -87,7 +87,7 @@ public class FlowViewMessageHandler extends UiMessageHandler { ...@@ -87,7 +87,7 @@ public class FlowViewMessageHandler extends UiMessageHandler {
87 } 87 }
88 88
89 @Override 89 @Override
90 - protected String noRowsMessage() { 90 + protected String noRowsMessage(ObjectNode payload) {
91 return NO_ROWS_MESSAGE; 91 return NO_ROWS_MESSAGE;
92 } 92 }
93 93
......
...@@ -19,7 +19,9 @@ package org.onosproject.ui.impl; ...@@ -19,7 +19,9 @@ package org.onosproject.ui.impl;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.base.Strings; 20 import com.google.common.base.Strings;
21 import com.google.common.collect.ImmutableSet; 21 import com.google.common.collect.ImmutableSet;
22 +import org.onosproject.net.Device;
22 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
24 +import org.onosproject.net.device.DeviceService;
23 import org.onosproject.net.group.Group; 25 import org.onosproject.net.group.Group;
24 import org.onosproject.net.group.GroupBucket; 26 import org.onosproject.net.group.GroupBucket;
25 import org.onosproject.net.group.GroupService; 27 import org.onosproject.net.group.GroupService;
...@@ -45,6 +47,9 @@ public class GroupViewMessageHandler extends UiMessageHandler { ...@@ -45,6 +47,9 @@ public class GroupViewMessageHandler extends UiMessageHandler {
45 private static final String GROUP_DATA_RESP = "groupDataResponse"; 47 private static final String GROUP_DATA_RESP = "groupDataResponse";
46 private static final String GROUPS = "groups"; 48 private static final String GROUPS = "groups";
47 49
50 + private static final String PROTOCOL = "protocol";
51 + private static final String OF_10 = "OF_10";
52 +
48 private static final String ID = "id"; 53 private static final String ID = "id";
49 private static final String APP_ID = "app_id"; 54 private static final String APP_ID = "app_id";
50 private static final String STATE = "state"; 55 private static final String STATE = "state";
...@@ -62,10 +67,16 @@ public class GroupViewMessageHandler extends UiMessageHandler { ...@@ -62,10 +67,16 @@ public class GroupViewMessageHandler extends UiMessageHandler {
62 return ImmutableSet.of(new GroupDataRequest()); 67 return ImmutableSet.of(new GroupDataRequest());
63 } 68 }
64 69
70 + private static String deviceProtocol(Device device) {
71 + String protocol = device.annotations().value(PROTOCOL);
72 + return protocol != null ? protocol : "";
73 + }
74 +
65 // handler for group table requests 75 // handler for group table requests
66 private final class GroupDataRequest extends TableRequestHandler { 76 private final class GroupDataRequest extends TableRequestHandler {
67 77
68 private static final String NO_ROWS_MESSAGE = "No groups found"; 78 private static final String NO_ROWS_MESSAGE = "No groups found";
79 + private static final String NOT_SUPPORT_MESSAGE = "Groups not supported";
69 80
70 private GroupDataRequest() { 81 private GroupDataRequest() {
71 super(GROUP_DATA_REQ, GROUP_DATA_RESP, GROUPS); 82 super(GROUP_DATA_REQ, GROUP_DATA_RESP, GROUPS);
...@@ -77,8 +88,17 @@ public class GroupViewMessageHandler extends UiMessageHandler { ...@@ -77,8 +88,17 @@ public class GroupViewMessageHandler extends UiMessageHandler {
77 } 88 }
78 89
79 @Override 90 @Override
80 - protected String noRowsMessage() { 91 + protected String noRowsMessage(ObjectNode payload) {
81 - // TODO: if devices with OF 1.0, should return not support message 92 + String uri = string(payload, "devId");
93 + if (!Strings.isNullOrEmpty(uri)) {
94 + DeviceService ds = get(DeviceService.class);
95 + Device dev = ds.getDevice(DeviceId.deviceId(uri));
96 +
97 + // TODO: replace with a less brittle solution...
98 + if (deviceProtocol(dev).equals(OF_10)) {
99 + return NOT_SUPPORT_MESSAGE;
100 + }
101 + }
82 return NO_ROWS_MESSAGE; 102 return NO_ROWS_MESSAGE;
83 } 103 }
84 104
......
...@@ -74,7 +74,7 @@ public class HostViewMessageHandler extends UiMessageHandler { ...@@ -74,7 +74,7 @@ public class HostViewMessageHandler extends UiMessageHandler {
74 } 74 }
75 75
76 @Override 76 @Override
77 - protected String noRowsMessage() { 77 + protected String noRowsMessage(ObjectNode payload) {
78 return NO_ROWS_MESSAGE; 78 return NO_ROWS_MESSAGE;
79 } 79 }
80 80
......
...@@ -88,7 +88,7 @@ public class IntentViewMessageHandler extends UiMessageHandler { ...@@ -88,7 +88,7 @@ public class IntentViewMessageHandler extends UiMessageHandler {
88 } 88 }
89 89
90 @Override 90 @Override
91 - protected String noRowsMessage() { 91 + protected String noRowsMessage(ObjectNode payload) {
92 return NO_ROWS_MESSAGE; 92 return NO_ROWS_MESSAGE;
93 } 93 }
94 94
......
...@@ -77,7 +77,7 @@ public class LinkViewMessageHandler extends UiMessageHandler { ...@@ -77,7 +77,7 @@ public class LinkViewMessageHandler extends UiMessageHandler {
77 } 77 }
78 78
79 @Override 79 @Override
80 - protected String noRowsMessage() { 80 + protected String noRowsMessage(ObjectNode payload) {
81 return NO_ROWS_MESSAGE; 81 return NO_ROWS_MESSAGE;
82 } 82 }
83 83
......
...@@ -19,7 +19,9 @@ package org.onosproject.ui.impl; ...@@ -19,7 +19,9 @@ package org.onosproject.ui.impl;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.base.Strings; 20 import com.google.common.base.Strings;
21 import com.google.common.collect.ImmutableSet; 21 import com.google.common.collect.ImmutableSet;
22 +import org.onosproject.net.Device;
22 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
24 +import org.onosproject.net.device.DeviceService;
23 import org.onosproject.net.meter.Band; 25 import org.onosproject.net.meter.Band;
24 import org.onosproject.net.meter.Meter; 26 import org.onosproject.net.meter.Meter;
25 import org.onosproject.net.meter.MeterService; 27 import org.onosproject.net.meter.MeterService;
...@@ -42,6 +44,9 @@ public class MeterViewMessageHandler extends UiMessageHandler { ...@@ -42,6 +44,9 @@ public class MeterViewMessageHandler extends UiMessageHandler {
42 private static final String METER_DATA_RESP = "meterDataResponse"; 44 private static final String METER_DATA_RESP = "meterDataResponse";
43 private static final String METERS = "meters"; 45 private static final String METERS = "meters";
44 46
47 + private static final String PROTOCOL = "protocol";
48 + private static final String OF_10 = "OF_10";
49 +
45 private static final String ID = "id"; 50 private static final String ID = "id";
46 private static final String APP_ID = "app_id"; 51 private static final String APP_ID = "app_id";
47 private static final String STATE = "state"; 52 private static final String STATE = "state";
...@@ -58,10 +63,16 @@ public class MeterViewMessageHandler extends UiMessageHandler { ...@@ -58,10 +63,16 @@ public class MeterViewMessageHandler extends UiMessageHandler {
58 return ImmutableSet.of(new MeterDataRequest()); 63 return ImmutableSet.of(new MeterDataRequest());
59 } 64 }
60 65
66 + private static String deviceProtocol(Device device) {
67 + String protocol = device.annotations().value(PROTOCOL);
68 + return protocol != null ? protocol : "";
69 + }
70 +
61 // handler for meter table requests 71 // handler for meter table requests
62 private final class MeterDataRequest extends TableRequestHandler { 72 private final class MeterDataRequest extends TableRequestHandler {
63 73
64 private static final String NO_ROWS_MESSAGE = "No meters found"; 74 private static final String NO_ROWS_MESSAGE = "No meters found";
75 + private static final String NOT_SUPPORT_MESSAGE = "Meters not supported";
65 76
66 private MeterDataRequest() { 77 private MeterDataRequest() {
67 super(METER_DATA_REQ, METER_DATA_RESP, METERS); 78 super(METER_DATA_REQ, METER_DATA_RESP, METERS);
...@@ -73,8 +84,17 @@ public class MeterViewMessageHandler extends UiMessageHandler { ...@@ -73,8 +84,17 @@ public class MeterViewMessageHandler extends UiMessageHandler {
73 } 84 }
74 85
75 @Override 86 @Override
76 - protected String noRowsMessage() { 87 + protected String noRowsMessage(ObjectNode payload) {
77 - // TODO: if the device with OF 1.0, return not support message 88 + String uri = string(payload, "devId");
89 + if (!Strings.isNullOrEmpty(uri)) {
90 + DeviceService ds = get(DeviceService.class);
91 + Device dev = ds.getDevice(DeviceId.deviceId(uri));
92 +
93 + // TODO: replace with a less brittle solution...
94 + if (deviceProtocol(dev).equals(OF_10)) {
95 + return NOT_SUPPORT_MESSAGE;
96 + }
97 + }
78 return NO_ROWS_MESSAGE; 98 return NO_ROWS_MESSAGE;
79 } 99 }
80 100
......
...@@ -74,7 +74,7 @@ public class PortViewMessageHandler extends UiMessageHandler { ...@@ -74,7 +74,7 @@ public class PortViewMessageHandler extends UiMessageHandler {
74 } 74 }
75 75
76 @Override 76 @Override
77 - protected String noRowsMessage() { 77 + protected String noRowsMessage(ObjectNode payload) {
78 return NO_ROWS_MESSAGE; 78 return NO_ROWS_MESSAGE;
79 } 79 }
80 80
......
...@@ -76,7 +76,7 @@ public class ProcessorViewMessageHandler extends UiMessageHandler { ...@@ -76,7 +76,7 @@ public class ProcessorViewMessageHandler extends UiMessageHandler {
76 } 76 }
77 77
78 @Override 78 @Override
79 - protected String noRowsMessage() { 79 + protected String noRowsMessage(ObjectNode payload) {
80 return NO_ROWS_MESSAGE; 80 return NO_ROWS_MESSAGE;
81 } 81 }
82 82
......
...@@ -65,7 +65,7 @@ public class SettingsViewMessageHandler extends UiMessageHandler { ...@@ -65,7 +65,7 @@ public class SettingsViewMessageHandler extends UiMessageHandler {
65 } 65 }
66 66
67 @Override 67 @Override
68 - protected String noRowsMessage() { 68 + protected String noRowsMessage(ObjectNode payload) {
69 return NO_ROWS_MESSAGE; 69 return NO_ROWS_MESSAGE;
70 } 70 }
71 71
......
...@@ -67,7 +67,7 @@ public class TunnelViewMessageHandler extends UiMessageHandler { ...@@ -67,7 +67,7 @@ public class TunnelViewMessageHandler extends UiMessageHandler {
67 } 67 }
68 68
69 @Override 69 @Override
70 - protected String noRowsMessage() { 70 + protected String noRowsMessage(ObjectNode payload) {
71 return NO_ROWS_MESSAGE; 71 return NO_ROWS_MESSAGE;
72 } 72 }
73 73
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
64 cancelTardy(); 64 cancelTardy();
65 ls.stop(); 65 ls.stop();
66 o.scope.tableData = data[root]; 66 o.scope.tableData = data[root];
67 + o.scope.annots = data.annots;
67 onResp && onResp(); 68 onResp && onResp();
68 69
69 // checks if data changed for row flashing 70 // checks if data changed for row flashing
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
53 <table onos-flash-changes id-prop="id"> 53 <table onos-flash-changes id-prop="id">
54 <tr ng-if="!tableData.length" class="no-data"> 54 <tr ng-if="!tableData.length" class="no-data">
55 <td colspan="5"> 55 <td colspan="5">
56 - No Applications found 56 + {{annots.no_rows_msg}}
57 </td> 57 </td>
58 </tr> 58 </tr>
59 59
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
43 <table onos-flash-changes id-prop="id"> 43 <table onos-flash-changes id-prop="id">
44 <tr ng-if="!tableData.length" class="no-data"> 44 <tr ng-if="!tableData.length" class="no-data">
45 <td colspan="5"> 45 <td colspan="5">
46 - No Cluster Nodes found 46 + {{annots.no_rows_msg}}
47 </td> 47 </td>
48 </tr> 48 </tr>
49 49
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
56 <table onos-flash-changes id-prop="id"> 56 <table onos-flash-changes id-prop="id">
57 <tr ng-if="!tableData.length" class="no-data"> 57 <tr ng-if="!tableData.length" class="no-data">
58 <td colspan="9"> 58 <td colspan="9">
59 - No Devices found 59 + {{annots.no_rows_msg}}
60 </td> 60 </td>
61 </tr> 61 </tr>
62 62
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
60 <table onos-flash-changes id-prop="id"> 60 <table onos-flash-changes id-prop="id">
61 <tr ng-if="!tableData.length" class="no-data"> 61 <tr ng-if="!tableData.length" class="no-data">
62 <td colspan="10"> 62 <td colspan="10">
63 - No Flows found 63 + {{annots.no_rows_msg}}
64 </td> 64 </td>
65 </tr> 65 </tr>
66 66
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
56 <table onos-flash-changes id-prop="id"> 56 <table onos-flash-changes id-prop="id">
57 <tr ng-if="!tableData.length" class="no-data"> 57 <tr ng-if="!tableData.length" class="no-data">
58 <td colspan="6"> 58 <td colspan="6">
59 - No Groups found 59 + {{annots.no_rows_msg}}
60 </td> 60 </td>
61 </tr> 61 </tr>
62 62
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 <table onos-flash-changes id-prop="id"> 28 <table onos-flash-changes id-prop="id">
29 <tr ng-if="!tableData.length" class="no-data"> 29 <tr ng-if="!tableData.length" class="no-data">
30 <td colspan="6"> 30 <td colspan="6">
31 - No Hosts found 31 + {{annots.no_rows_msg}}
32 </td> 32 </td>
33 </tr> 33 </tr>
34 34
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
32 <table onos-flash-changes id-prop="key"> 32 <table onos-flash-changes id-prop="key">
33 <tr ng-if="!tableData.length" class="no-data"> 33 <tr ng-if="!tableData.length" class="no-data">
34 <td colspan="5"> 34 <td colspan="5">
35 - No Intents found 35 + {{annots.no_rows_msg}}
36 </td> 36 </td>
37 </tr> 37 </tr>
38 38
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
44 <table onos-flash-changes id-prop="one"> 44 <table onos-flash-changes id-prop="one">
45 <tr ng-if="!tableData.length" class="no-data"> 45 <tr ng-if="!tableData.length" class="no-data">
46 <td colspan="6"> 46 <td colspan="6">
47 - No Links found 47 + {{annots.no_rows_msg}}
48 </td> 48 </td>
49 </tr> 49 </tr>
50 50
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
55 <table onos-flash-changes id-prop="id"> 55 <table onos-flash-changes id-prop="id">
56 <tr ng-if="!tableData.length" class="no-data"> 56 <tr ng-if="!tableData.length" class="no-data">
57 <td colspan="5"> 57 <td colspan="5">
58 - No Meters found 58 + {{annots.no_rows_msg}}
59 </td> 59 </td>
60 </tr> 60 </tr>
61 61
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
58 <table onos-flash-changes id-prop="id"> 58 <table onos-flash-changes id-prop="id">
59 <tr ng-if="!tableData.length" class="no-data"> 59 <tr ng-if="!tableData.length" class="no-data">
60 <td colspan="8"> 60 <td colspan="8">
61 - No Ports found 61 + {{annots.no_rows_msg}}
62 </td> 62 </td>
63 </tr> 63 </tr>
64 64
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
40 <table onos-flash-changes id-prop="id"> 40 <table onos-flash-changes id-prop="id">
41 <tr ng-if="!tableData.length" class="no-data"> 41 <tr ng-if="!tableData.length" class="no-data">
42 <td colspan="5"> 42 <td colspan="5">
43 - No Processors found 43 + {{annots.no_rows_msg}}
44 </td> 44 </td>
45 </tr> 45 </tr>
46 46
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 <table onos-flash-changes id-prop="id"> 28 <table onos-flash-changes id-prop="id">
29 <tr ng-if="!tableData.length" class="no-data"> 29 <tr ng-if="!tableData.length" class="no-data">
30 <td colspan="6"> 30 <td colspan="6">
31 - No Settings found 31 + {{annots.no_rows_msg}}
32 </td> 32 </td>
33 </tr> 33 </tr>
34 34
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
46 <table onos-flash-changes id-prop="one"> 46 <table onos-flash-changes id-prop="one">
47 <tr ng-if="!tableData.length" class="no-data"> 47 <tr ng-if="!tableData.length" class="no-data">
48 <td colspan="6"> 48 <td colspan="6">
49 - No tunnels found 49 + {{annots.no_rows_msg}}
50 </td> 50 </td>
51 </tr> 51 </tr>
52 52
......