97c48f1ff708eaa96bc2158f7093ecf0bceadb59
[ccsdk/features.git] /
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types;
19
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;
25
26 /**
27  * Event from Network to be recorded in the database
28  *
29  */
30
31 public class EsFaultCurrent extends EsObject {
32
33     public static final String ESDATATYPENAME = "faultcurrent";
34     //private static final String NOALARM = "NonAlarmed";
35
36     private ProblemNotificationXml faultCurrent;
37
38     public ProblemNotificationXml getProblem() {
39         return faultCurrent;
40     }
41
42     public void setProblem(ProblemNotificationXml fault) {
43         this.faultCurrent = fault;
44         setEsId(fault.genSpecificEsId());
45     }
46
47     public boolean isNoAlarmIndication() {
48         return faultCurrent.getSeverity().isNoAlarmIndication();
49     }
50
51     /**
52      * TODO: termquery to matchquery, termquery with scoring, not exact matching
53      * @param nodeName name of the node
54      * @return query builder
55      */
56     public static QueryBuilder getQueryForOneNode( String nodeName) {
57         return QueryBuilders.termQuery("faultCurrent.nodeName", nodeName);
58     }
59
60     public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
61         BoolQueryBuilder bq = QueryBuilders.boolQuery();
62         bq.must(QueryBuilders.termQuery("faultCurrent.nodeName", nodeName));
63         bq.must(QueryBuilders.termQuery("faultCurrent.objectId", objectId));
64         return bq;
65         //return QueryBuilders.termQuery("faultCurrent.objectId", objectId);
66
67     }
68  }