Simon Hunt

CORD GUI - include icon_id in user array.

Change-Id: I6fe3c2f0b619411c74552e5960973e487ae58bfc
...@@ -31,6 +31,7 @@ public abstract class JsonFactory { ...@@ -31,6 +31,7 @@ public abstract class JsonFactory {
31 protected static final String ID = "id"; 31 protected static final String ID = "id";
32 protected static final String NAME = "name"; 32 protected static final String NAME = "name";
33 protected static final String DESC = "desc"; 33 protected static final String DESC = "desc";
34 + protected static final String ICON_ID = "icon_id";
34 35
35 /** 36 /**
36 * Returns a freshly minted object node. 37 * Returns a freshly minted object node.
......
...@@ -19,6 +19,9 @@ package org.onosproject.cord.gui.model; ...@@ -19,6 +19,9 @@ package org.onosproject.cord.gui.model;
19 19
20 import com.fasterxml.jackson.databind.node.ObjectNode; 20 import com.fasterxml.jackson.databind.node.ObjectNode;
21 21
22 +import java.util.HashMap;
23 +import java.util.Map;
24 +
22 /** 25 /**
23 * Utility functions on users. 26 * Utility functions on users.
24 */ 27 */
...@@ -27,6 +30,19 @@ public class UserFactory extends JsonFactory { ...@@ -27,6 +30,19 @@ public class UserFactory extends JsonFactory {
27 private static final String MAC = "mac"; 30 private static final String MAC = "mac";
28 private static final String PROFILE = "profile"; 31 private static final String PROFILE = "profile";
29 32
33 +
34 + // hard-coded icons for the demo
35 + private static final Map<String, String> ICON_LOOKUP =
36 + new HashMap<String, String>();
37 + static {
38 + ICON_LOOKUP.put("Mom's PC", "mom");
39 + ICON_LOOKUP.put("Dad's PC", "dad");
40 + ICON_LOOKUP.put("Jack's iPhone", "boy2");
41 + ICON_LOOKUP.put("Jill's iPad", "girl1");
42 + }
43 +
44 + private static final String DEFAULT_ICON_ID = "boy1";
45 +
30 // no instantiation 46 // no instantiation
31 private UserFactory() {} 47 private UserFactory() {}
32 48
...@@ -37,8 +53,12 @@ public class UserFactory extends JsonFactory { ...@@ -37,8 +53,12 @@ public class UserFactory extends JsonFactory {
37 * @return object node 53 * @return object node
38 */ 54 */
39 public static ObjectNode toObjectNode(SubscriberUser user) { 55 public static ObjectNode toObjectNode(SubscriberUser user) {
56 + String icon = ICON_LOOKUP.get(user.name());
57 + icon = icon == null ? DEFAULT_ICON_ID : icon;
58 +
40 ObjectNode root = objectNode() 59 ObjectNode root = objectNode()
41 .put(ID, user.id()) 60 .put(ID, user.id())
61 + .put(ICON_ID, icon)
42 .put(NAME, user.name()) 62 .put(NAME, user.name())
43 .put(MAC, user.mac()); 63 .put(MAC, user.mac());
44 root.set(PROFILE, XosFunctionFactory.profileForUser(user)); 64 root.set(PROFILE, XosFunctionFactory.profileForUser(user));
......