CORD Subscriber GUI -- More bundle wrangling.
Change-Id: I2fafdb281712d7747399d61611c3d4bb663a39b5
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
index 847527f..f09ecfe 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
@@ -17,9 +17,75 @@
package org.onosproject.cord.gui;
+import com.google.common.collect.ImmutableList;
+import org.onosproject.cord.gui.model.Bundle;
+import org.onosproject.cord.gui.model.BundleDescriptor;
+import org.onosproject.cord.gui.model.BundleFactory;
+import org.onosproject.cord.gui.model.SubscriberUser;
+
+import java.util.ArrayList;
+import java.util.List;
+
/**
* In memory cache of the model of the subscriber's account.
*/
public class CordModelCache {
+ // faked for the demo
+ private static final int SUBSCRIBER_ID = 92;
+ private static final String MAC_1 = "010203040506";
+ private static final String MAC_2 = "010203040507";
+ private static final String MAC_3 = "010203040508";
+ private static final String MAC_4 = "010203040509";
+
+ private Bundle currentBundle;
+ private final List<SubscriberUser> users;
+
+ /**
+ * Constructs a model cache, initializing it with basic bundle.
+ */
+ public CordModelCache() {
+ currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE);
+ users = new ArrayList<SubscriberUser>();
+ initUsers();
+ }
+
+ /**
+ * Used to initialize users for the demo. These are currently fake.
+ */
+ public void initUsers() {
+ users.add(new SubscriberUser(1, "Mom's MacBook", MAC_1));
+ users.add(new SubscriberUser(2, "Dad's iPad", MAC_2));
+ users.add(new SubscriberUser(3, "Dick's laptop", MAC_3));
+ users.add(new SubscriberUser(4, "Jane's laptop", MAC_4));
+ }
+
+ /**
+ * Returns the currently selected bundle.
+ *
+ * @return current bundle
+ */
+ public Bundle getCurrentBundle() {
+ return currentBundle;
+ }
+
+ /**
+ * Sets a new bundle.
+ *
+ * @param bundleId bundle identifier
+ * @throws IllegalArgumentException if bundle ID is unknown
+ */
+ public void setCurrentBundle(String bundleId) {
+ BundleDescriptor bdesc = BundleFactory.bundleFromId(bundleId);
+ currentBundle = new Bundle(bdesc);
+ }
+
+ /**
+ * Returns the list of current users for this subscriber account.
+ *
+ * @return the list of users
+ */
+ public List<SubscriberUser> getUsers() {
+ return ImmutableList.copyOf(users);
+ }
}