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/common/src/main/java/org/onosproject/codec/impl/RegionCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/RegionCodec.java
index 5f003e0..f3aa128 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/RegionCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/RegionCodec.java
@@ -23,7 +23,7 @@
import com.google.common.collect.Sets;
import org.onosproject.cluster.NodeId;
import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
+import org.onosproject.net.Annotations;
import org.onosproject.net.region.DefaultRegion;
import org.onosproject.net.region.Region;
import org.onosproject.net.region.RegionId;
@@ -39,7 +39,7 @@
/**
* Codec for the Region class.
*/
-public class RegionCodec extends JsonCodec<Region> {
+public class RegionCodec extends AnnotatedCodec<Region> {
// JSON field names
private static final String REGION_ID = "id";
@@ -77,7 +77,7 @@
masters.add(setsJson);
});
result.set(MASTERS, masters);
- return result;
+ return annotate(result, region, context);
}
@Override
@@ -108,8 +108,9 @@
RegionId regionId = RegionId.regionId(extractMember(REGION_ID, json));
String name = extractMember(NAME, json);
Region.Type type = REGION_TYPE_MAP.get(extractMember(TYPE, json));
+ Annotations annots = extractAnnotations(json, context);
- return new DefaultRegion(regionId, name, type, masters);
+ return new DefaultRegion(regionId, name, type, annots, masters);
}
private String extractMember(String key, ObjectNode json) {
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/RegionCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/RegionCodecTest.java
index 05d95e1..a9e7a2f 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/RegionCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/RegionCodecTest.java
@@ -25,6 +25,8 @@
import org.onosproject.cluster.NodeId;
import org.onosproject.codec.JsonCodec;
import org.onosproject.core.CoreService;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.region.DefaultRegion;
import org.onosproject.net.region.Region;
import org.onosproject.net.region.RegionId;
@@ -75,8 +77,9 @@
RegionId regionId = RegionId.regionId("1");
String name = "foo";
Region.Type type = Region.Type.ROOM;
+ Annotations noAnnots = DefaultAnnotations.EMPTY;
- Region region = new DefaultRegion(regionId, name, type, masters);
+ Region region = new DefaultRegion(regionId, name, type, noAnnots, masters);
ObjectNode regionJson = regionCodec.encode(region, context);
assertThat(regionJson, matchesRegion(region));