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
34 * { "node": "ddd", "filter": [ { "definition": { "object-id-ref": "", "problem": "" }, "description": "",
35 * "start": "2019-11-26T15:37+00:00", "end": "2019-11-26T23:37+00:00" }], "active": false } => { "id": "sim1"
36 * "node-id": "sim1", "description": "", "start": "2020-01-28T12:00:17.6Z", "end": "2020-01-28T12:00:17.6Z",
37 * "active": false, "object-id-ref": "", "problem": ""
40 public class FrankfurtMaintenanceConverter extends BaseSearchHitConverter {
42 public FrankfurtMaintenanceConverter() {
43 super(ComponentName.MAINTENANCE);
47 public SearchHit convert(SearchHit source) {
49 JSONObject src = source.getSource();
50 JSONObject data = new JSONObject();
51 data.put("id", src.getString("node"));
52 data.put("node-id", src.getString("node"));
53 data.put("active", src.getBoolean("active"));
54 JSONObject filter = null;
55 if (src.has("filter")) {
56 filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null;
58 data.put("start", filter != null ? filter.getString("start") : "");
59 data.put("end", filter != null ? filter.getString("end") : "");
60 data.put("description", filter != null ? filter.getString("description") : "");
61 JSONObject definition =
62 filter != null ? filter.has("definition") ? filter.getJSONObject("definition") : null : null;
63 data.put("problem", definition != null ? definition.getString("problem") : "");
64 data.put("object-id-ref", definition != null ? definition.getString("object-id-ref") : "");
65 return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);