Added id code and removed from name
Added funtionality to consumer and send kpi events to onap
Change-Id: I0849e3b9188b1fa53210c341f1fc6e6228c5de9b
Signed-off-by: William Kurkian <wkurkian@cisco.com>
diff --git a/src/main/java/mapper/VesVolthaMessage.java b/src/main/java/mapper/VesVolthaAlarm.java
similarity index 97%
rename from src/main/java/mapper/VesVolthaMessage.java
rename to src/main/java/mapper/VesVolthaAlarm.java
index f0327df..743b8f1 100644
--- a/src/main/java/mapper/VesVolthaMessage.java
+++ b/src/main/java/mapper/VesVolthaAlarm.java
@@ -19,7 +19,7 @@
import org.slf4j.LoggerFactory;
import java.util.Map;
-public class VesVolthaMessage {
+public class VesVolthaAlarm {
private String id = "";
private String logical_device_id = "";
private String raised_ts = "";
diff --git a/src/main/java/mapper/VesVolthaKpi.java b/src/main/java/mapper/VesVolthaKpi.java
new file mode 100644
index 0000000..b6bf02e
--- /dev/null
+++ b/src/main/java/mapper/VesVolthaKpi.java
@@ -0,0 +1,53 @@
+/*
+* Copyright 2018- Cisco
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package mapper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Map;
+import com.google.gson.annotations.JsonAdapter;
+
+public class VesVolthaKpi {
+ private String type = "";
+ private String ts = "";
+
+ //@JsonAdapter(StringTypeAdapter.class)
+ private String slice_data;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getSliceData() {
+ return slice_data;
+ }
+
+ public void setSliceData(String slice_data) {
+ this.slice_data = slice_data;
+ }
+}
diff --git a/src/main/java/mapper/VesVolthaMapper.java b/src/main/java/mapper/VesVolthaMapper.java
index a3ee1ab..6d927ca 100644
--- a/src/main/java/mapper/VesVolthaMapper.java
+++ b/src/main/java/mapper/VesVolthaMapper.java
@@ -19,6 +19,7 @@
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
public class VesVolthaMapper {
@@ -30,7 +31,17 @@
gson = new GsonBuilder().create();
}
- public VesVolthaMessage parseJson(String json) {
- return gson.fromJson(json, VesVolthaMessage.class);
+ public VesVolthaAlarm parseAlarm(String json) {
+ return gson.fromJson(json, VesVolthaAlarm.class);
+ }
+
+ public VesVolthaKpi parseKpi(String json) {
+ //return gson.fromJson(json, VesVolthaKpi.class);
+ JsonObject body = gson.fromJson(json, JsonObject.class);
+ VesVolthaKpi kpi = new VesVolthaKpi();
+ kpi.setType(body.get("type").getAsString());
+ kpi.setTs(body.get("ts").getAsString());
+ kpi.setSliceData(body.get("slice_data").toString());
+ return kpi;
}
}