Allocate Rule
[holmes/rule-management.git] / rulemgt / src / main / java / org / onap / holmes / rulemgt / wrapper / RuleQueryWrapper.java
1 /**
2  * Copyright 2017 ZTE Corporation.
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
17 package org.onap.holmes.rulemgt.wrapper;
18
19 import org.jvnet.hk2.annotations.Service;
20 import org.onap.holmes.common.api.entity.CorrelationRule;
21 import org.onap.holmes.common.exception.CorrelationException;
22 import org.onap.holmes.common.utils.DbDaoUtil;
23 import org.onap.holmes.rulemgt.db.CorrelationRuleDao;
24
25 import javax.annotation.PostConstruct;
26 import javax.inject.Inject;
27 import java.util.List;
28
29 @Service
30 public class RuleQueryWrapper {
31
32     @Inject
33     private DbDaoUtil daoUtil;
34     private CorrelationRuleDao correlationRuleDao;
35
36     @PostConstruct
37     public void initDaoUtil() {
38         correlationRuleDao = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class);
39     }
40
41     public List<CorrelationRule> queryRuleByEnable(int enable) throws CorrelationException {
42         List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
43                 .queryRuleByRuleEnable(enable);
44         return ruleTemp;
45     }
46
47     public List<CorrelationRule> queryRuleByEngineInstance(String instance) throws CorrelationException {
48         List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
49                 .queryRuleByRuleEngineInstance(instance);
50         return ruleTemp;
51     }
52 }