CORD GUI - include icon_id in user array.
Change-Id: I6fe3c2f0b619411c74552e5960973e487ae58bfc
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/JsonFactory.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/JsonFactory.java
index 63f8522..3f29599 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/JsonFactory.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/JsonFactory.java
@@ -31,6 +31,7 @@
protected static final String ID = "id";
protected static final String NAME = "name";
protected static final String DESC = "desc";
+ protected static final String ICON_ID = "icon_id";
/**
* Returns a freshly minted object node.
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UserFactory.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UserFactory.java
index f377ad0..472bcb6 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UserFactory.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UserFactory.java
@@ -19,6 +19,9 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Utility functions on users.
*/
@@ -27,6 +30,19 @@
private static final String MAC = "mac";
private static final String PROFILE = "profile";
+
+ // hard-coded icons for the demo
+ private static final Map<String, String> ICON_LOOKUP =
+ new HashMap<String, String>();
+ static {
+ ICON_LOOKUP.put("Mom's PC", "mom");
+ ICON_LOOKUP.put("Dad's PC", "dad");
+ ICON_LOOKUP.put("Jack's iPhone", "boy2");
+ ICON_LOOKUP.put("Jill's iPad", "girl1");
+ }
+
+ private static final String DEFAULT_ICON_ID = "boy1";
+
// no instantiation
private UserFactory() {}
@@ -37,8 +53,12 @@
* @return object node
*/
public static ObjectNode toObjectNode(SubscriberUser user) {
+ String icon = ICON_LOOKUP.get(user.name());
+ icon = icon == null ? DEFAULT_ICON_ID : icon;
+
ObjectNode root = objectNode()
.put(ID, user.id())
+ .put(ICON_ID, icon)
.put(NAME, user.name())
.put(MAC, user.mac());
root.set(PROFILE, XosFunctionFactory.profileForUser(user));