Extract the Common Tool
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / utils / CorrelationRuleMapper.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.common.utils;
18
19 import java.sql.ResultSet;
20 import java.sql.SQLException;
21 import java.util.Properties;
22 import org.onap.holmes.common.api.entity.CorrelationRule;
23 import org.skife.jdbi.v2.StatementContext;
24 import org.skife.jdbi.v2.tweak.ResultSetMapper;
25
26 public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
27
28     @Override
29     public CorrelationRule map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
30         CorrelationRule correlationRule = new CorrelationRule();
31         correlationRule.setName(resultSet.getString("name"));
32         correlationRule.setRid(resultSet.getString("rid"));
33         correlationRule.setDescription(resultSet.getString("description"));
34         correlationRule.setEnabled(resultSet.getInt("enable"));
35         correlationRule.setTemplateID(resultSet.getInt("templateID"));
36         correlationRule.setEngineID(resultSet.getString("engineID"));
37         correlationRule.setEngineType(resultSet.getString("engineType"));
38         correlationRule.setCreator(resultSet.getString("creator"));
39         correlationRule.setCreateTime(resultSet.getDate("createTime"));
40         correlationRule.setModifier(resultSet.getString("updator"));
41         correlationRule.setUpdateTime(resultSet.getDate("updateTime"));
42         correlationRule.setParams((Properties) resultSet.getObject("params"));
43         correlationRule.setContent(resultSet.getString("content"));
44         correlationRule.setVendor(resultSet.getString("vendor"));
45         correlationRule.setPackageName(resultSet.getString("package"));
46         correlationRule.setClosedControlLoopName(resultSet.getString("ctrlloop"));
47         return correlationRule;
48     }
49
50 }