Working on Bay-Area-Region Demo.
- added latitude / longitude parameters to regions, so the icons can be "placed" on a GEO-map

Change-Id: I5cf939f22597d4658ab603459b2b3059ba0db0c9
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
index 7c2a5b8..295995f 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicElementConfig.java
@@ -22,20 +22,46 @@
  */
 public abstract class BasicElementConfig<S> extends AllowedEntityConfig<S> {
 
-    protected static final String NAME = "name";
-    protected static final String UI_TYPE = "uiType";
+    /**
+     * Key for friendly name.
+     */
+    public static final String NAME = "name";
 
-    protected static final String LATITUDE = "latitude";
-    protected static final String LONGITUDE = "longitude";
+    /**
+     * Key for UI type (glyph identifier).
+     */
+    public static final String UI_TYPE = "uiType";
 
+    /**
+     * Key for latitude.
+     */
+    public static final String LATITUDE = "latitude";
+
+    /**
+     * Key for longitude.
+     */
+    public static final String LONGITUDE = "longitude";
+
+    /**
+     * Key for rack address.
+     */
     protected static final String RACK_ADDRESS = "rackAddress";
+
+    /**
+     * Key for owner.
+     */
     protected static final String OWNER = "owner";
 
+    /**
+     * Threshold for detecting double value is zero.
+     */
     protected static final double ZERO_THRESHOLD = Double.MIN_VALUE * 2.0;
+
     private static final double DEFAULT_COORD = 0.0;
 
     /**
-     * Returns friendly label for the element.
+     * Returns friendly label for the element. If not set, returns the
+     * element identifier.
      *
      * @return friendly label or element identifier itself if not set
      */
@@ -55,7 +81,7 @@
 
     /**
      * Returns the UI type (glyph image to be used) for the element in
-     * the Topology View.
+     * the Topology View. If not set, null is returned.
      *
      * @return the UI type
      */
@@ -65,7 +91,8 @@
 
     /**
      * Sets the UI type (glyph image to be used) for the element in
-     * the Topology View.
+     * the Topology View. Setting this to null will indicate that the
+     * default glyph image should be used for the element type.
      *
      * @param uiType the UI type; null for default
      * @return self
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicRegionConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicRegionConfig.java
index 2d15fa5..e27157e 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicRegionConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicRegionConfig.java
@@ -18,7 +18,6 @@
 
 import com.google.common.base.MoreObjects;
 import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.Config;
 import org.onosproject.net.region.Region;
 import org.onosproject.net.region.RegionId;
 
@@ -28,46 +27,30 @@
 /**
  * Basic configuration for network regions.
  */
-public final class BasicRegionConfig extends Config<RegionId> {
+public final class BasicRegionConfig extends BasicElementConfig<RegionId> {
 
-    private static final String NAME = "name";
     private static final String TYPE = "type";
     private static final String DEVICES = "devices";
 
     @Override
     public boolean isValid() {
-        return hasOnlyFields(NAME, TYPE, DEVICES);
+        return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, UI_TYPE,
+                RACK_ADDRESS, OWNER, TYPE, DEVICES);
     }
 
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
-                .add("name", name())
-                .add("type", type())
-                .add("devices", devices())
+                .add(NAME, name())
+                .add(TYPE, type())
+                .add(UI_TYPE, uiType())
+                .add(LATITUDE, latitude())
+                .add(LONGITUDE, longitude())
+                .add(DEVICES, devices())
                 .toString();
     }
 
     /**
-     * Returns the region name.
-     *
-     * @return the region name
-     */
-    public String name() {
-        return get(NAME, null);
-    }
-
-    /**
-     * Sets the name of this region.
-     *
-     * @param name name of region, or null to unset
-     * @return the config of the region
-     */
-    public BasicRegionConfig name(String name) {
-        return (BasicRegionConfig) setOrClear(NAME, name);
-    }
-
-    /**
      * Returns the region type.
      *
      * @return the region type
diff --git a/core/api/src/main/java/org/onosproject/net/region/DefaultRegion.java b/core/api/src/main/java/org/onosproject/net/region/DefaultRegion.java
index 1926a3d..d229e92 100644
--- a/core/api/src/main/java/org/onosproject/net/region/DefaultRegion.java
+++ b/core/api/src/main/java/org/onosproject/net/region/DefaultRegion.java
@@ -19,6 +19,8 @@
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
 import org.onosproject.cluster.NodeId;
+import org.onosproject.net.AbstractAnnotated;
+import org.onosproject.net.Annotations;
 
 import java.util.List;
 import java.util.Objects;
@@ -27,7 +29,7 @@
 /**
  * Default implementation of a region.
  */
-public final class DefaultRegion implements Region {
+public final class DefaultRegion extends AbstractAnnotated implements Region {
 
     private final RegionId id;
     private final String name;
@@ -40,9 +42,12 @@
      * @param id      region identifier
      * @param name    friendly name
      * @param type    region type
+     * @param annots  annotations
      * @param masters list of sets of cluster node identifiers; in order of mastership
      */
-    public DefaultRegion(RegionId id, String name, Type type, List<Set<NodeId>> masters) {
+    public DefaultRegion(RegionId id, String name, Type type,
+                         Annotations annots, List<Set<NodeId>> masters) {
+        super(annots);
         this.id = id;
         this.name = name;
         this.type = type;
diff --git a/core/api/src/main/java/org/onosproject/net/region/Region.java b/core/api/src/main/java/org/onosproject/net/region/Region.java
index afe1805..ed8fff18 100644
--- a/core/api/src/main/java/org/onosproject/net/region/Region.java
+++ b/core/api/src/main/java/org/onosproject/net/region/Region.java
@@ -17,6 +17,7 @@
 package org.onosproject.net.region;
 
 import org.onosproject.cluster.NodeId;
+import org.onosproject.net.Annotated;
 
 import java.util.List;
 import java.util.Set;
@@ -26,7 +27,7 @@
  * logical region. Optionally, devices in the region can share the same
  * cluster nodes mastership affinities.
  */
-public interface Region {
+public interface Region extends Annotated {
 
     /**
      * Coarse representation of the type of the region.
@@ -58,6 +59,11 @@
         BUILDING,
 
         /**
+         * Region represents a data center.
+         */
+        DATA_CENTER,
+
+        /**
          * Region represents a building floor.
          */
         FLOOR,
diff --git a/core/api/src/main/java/org/onosproject/net/region/RegionStore.java b/core/api/src/main/java/org/onosproject/net/region/RegionStore.java
index 49cc378..b8527c7 100644
--- a/core/api/src/main/java/org/onosproject/net/region/RegionStore.java
+++ b/core/api/src/main/java/org/onosproject/net/region/RegionStore.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.region;
 
 import org.onosproject.cluster.NodeId;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.DeviceId;
 import org.onosproject.store.Store;
 
@@ -67,12 +68,13 @@
      * @param regionId      region identifier
      * @param name          friendly name
      * @param type          region type
+     * @param annots        annotations
      * @param masterNodeIds list of master nodes; null implies empty list
      * @return new region descriptor
      * @throws IllegalArgumentException if item already exists
      */
     Region createRegion(RegionId regionId, String name, Region.Type type,
-                        List<Set<NodeId>> masterNodeIds);
+                        Annotations annots, List<Set<NodeId>> masterNodeIds);
 
     /**
      * Updates the specified new region using the supplied data.
@@ -80,12 +82,13 @@
      * @param regionId      region identifier
      * @param name          friendly name
      * @param type          region type
+     * @param annots        annotations
      * @param masterNodeIds list of master nodes; null implies empty list
      * @return new region descriptor
      * @throws IllegalArgumentException if item already exists
      */
     Region updateRegion(RegionId regionId, String name, Region.Type type,
-                        List<Set<NodeId>> masterNodeIds);
+                        Annotations annots, List<Set<NodeId>> masterNodeIds);
 
     /**
      * Removes the specified region using the new set of data.