William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 1 | /*
|
| 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 | */
|
| 16 | package mapper;
|
| 17 |
|
| 18 | import org.slf4j.Logger;
|
| 19 | import org.slf4j.LoggerFactory;
|
| 20 | import com.google.gson.Gson;
|
| 21 | import com.google.gson.GsonBuilder;
|
William Kurkian | 18ec344 | 2018-09-10 16:27:37 -0400 | [diff] [blame] | 22 | import com.google.gson.JsonObject;
|
William Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 23 |
|
| 24 | public 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 Kurkian | 18ec344 | 2018-09-10 16:27:37 -0400 | [diff] [blame] | 34 | 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 Kurkian | 1bedb41 | 2018-07-19 12:55:41 -0400 | [diff] [blame] | 46 | }
|
| 47 | }
|