1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types;
20 import org.elasticsearch.index.query.BoolQueryBuilder;
21 import org.elasticsearch.index.query.QueryBuilder;
22 import org.elasticsearch.index.query.QueryBuilders;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
27 * Event from Network to be recorded in the database
31 public class EsFaultCurrent extends EsObject {
33 public static final String ESDATATYPENAME = "faultcurrent";
34 //private static final String NOALARM = "NonAlarmed";
36 private ProblemNotificationXml faultCurrent;
38 public ProblemNotificationXml getProblem() {
42 public void setProblem(ProblemNotificationXml fault) {
43 this.faultCurrent = fault;
44 setEsId(fault.genSpecificEsId());
47 public boolean isNoAlarmIndication() {
48 return faultCurrent.getSeverity().isNoAlarmIndication();
52 * TODO: termquery to matchquery, termquery with scoring, not exact matching
53 * @param nodeName name of the node
54 * @return query builder
56 public static QueryBuilder getQueryForOneNode( String nodeName) {
57 return QueryBuilders.termQuery("faultCurrent.nodeName", nodeName);
59 public static QueryBuilder getQueryForAll() {
60 return QueryBuilders.matchAllQuery();
63 public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
64 BoolQueryBuilder bq = QueryBuilders.boolQuery();
65 bq.must(QueryBuilders.termQuery("faultCurrent.nodeName", nodeName));
66 bq.must(QueryBuilders.termQuery("faultCurrent.objectId", objectId));
68 //return QueryBuilders.termQuery("faultCurrent.objectId", objectId);
72 public static String getEsdatatypename() {
73 return ESDATATYPENAME;