2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto;
24 import org.json.JSONObject;
25 import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
30 * convert maintenance object from el alto version to frankfurt
39 * "object-id-ref": "",
43 * "start": "2019-11-26T15:37+00:00",
44 * "end": "2019-11-26T23:37+00:00"
53 * "start": "2020-01-28T12:00:17.6Z",
54 * "end": "2020-01-28T12:00:17.6Z",
56 * "object-id-ref": "",
60 public class FrankfurtMaintenanceConverter extends BaseSearchHitConverter {
62 public FrankfurtMaintenanceConverter() {
63 super(ComponentName.MAINTENANCE);
67 public SearchHit convert(SearchHit source) {
69 JSONObject src = source.getSource();
70 JSONObject data = new JSONObject();
71 data.put("id", src.getString("node"));
72 data.put("node-id", src.getString("node"));
73 data.put("active", src.getBoolean("active"));
74 JSONObject filter = null;
75 if (src.has("filter")) {
76 filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null;
78 data.put("start", filter != null ? filter.getString("start") : "");
79 data.put("end", filter != null ? filter.getString("end") : "");
80 data.put("description", filter != null ? filter.getString("description") : "");
81 JSONObject definition = filter!=null?filter.has("definition")?filter.getJSONObject("definition"):null:null;
82 data.put("problem", definition!=null?definition.getString("problem"):"");
83 data.put("object-id-ref", definition!=null?definition.getString("object-id-ref"):"");
84 return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);