blob: 6d927caa14289c7e7b4c03c25c3e50602e72a886 [file] [log] [blame]
William Kurkian1bedb412018-07-19 12:55:41 -04001/*
2* Copyright 2018- Cisco
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16package mapper;
17
18import org.slf4j.Logger;
19import org.slf4j.LoggerFactory;
20import com.google.gson.Gson;
21import com.google.gson.GsonBuilder;
William Kurkian18ec3442018-09-10 16:27:37 -040022import com.google.gson.JsonObject;
William Kurkian1bedb412018-07-19 12:55:41 -040023
24public class VesVolthaMapper {
25
26 private final Logger logger = LoggerFactory.getLogger("VesVolthaMapper");
27
28 private Gson gson;
29
30 public VesVolthaMapper() {
31 gson = new GsonBuilder().create();
32 }
33
William Kurkian18ec3442018-09-10 16:27:37 -040034 public VesVolthaAlarm parseAlarm(String json) {
35 return gson.fromJson(json, VesVolthaAlarm.class);
36 }
37
38 public VesVolthaKpi parseKpi(String json) {
39 //return gson.fromJson(json, VesVolthaKpi.class);
40 JsonObject body = gson.fromJson(json, JsonObject.class);
41 VesVolthaKpi kpi = new VesVolthaKpi();
42 kpi.setType(body.get("type").getAsString());
43 kpi.setTs(body.get("ts").getAsString());
44 kpi.setSliceData(body.get("slice_data").toString());
45 return kpi;
William Kurkian1bedb412018-07-19 12:55:41 -040046 }
47}