2 * Copyright 2017 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.holmes.rulemgt.send;
19 import lombok.extern.slf4j.Slf4j;
20 import org.jvnet.hk2.annotations.Service;
21 import org.onap.holmes.common.api.entity.CorrelationRule;
22 import org.onap.holmes.rulemgt.wrapper.RuleQueryWrapper;
24 import javax.inject.Inject;
29 public class Ip4AddingRule {
32 private RuleQueryWrapper ruleQueryWrapper;
33 private List<String> engineService;
35 public void getIpList(List<String> ipList){
36 engineService = ipList;
39 public String getEngineIp4AddRule() {
40 List<CorrelationRule> ipRuleList = new ArrayList<>();
41 LinkedHashMap<String,Integer> linkedHashMap = new LinkedHashMap();
44 for(String ip : engineService){
45 ipRuleList = ruleQueryWrapper.queryRuleByEngineInstance(ip);
46 if(ipRuleList != null) {
47 linkedHashMap.put(ip, ipRuleList.size());
51 log.error("getEngineIp4AddRule failed !" + e.getMessage());
55 Collection<Integer> c = linkedHashMap.values();
56 Object[] obj = c.toArray();
59 for(String getKey: linkedHashMap.keySet()){
60 if(linkedHashMap.get(getKey).equals(obj[0])){