Switched from Dropwizard to Springboot
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / utils / CorrelationRuleMapper.java
1 /*
2  * Copyright 2017-2021 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 org.jdbi.v3.core.mapper.RowMapper;
20 import org.jdbi.v3.core.statement.StatementContext;
21 import org.onap.holmes.common.api.entity.CorrelationRule;
22
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.util.Properties;
26
27 public class CorrelationRuleMapper implements RowMapper<CorrelationRule> {
28
29     @Override
30     public CorrelationRule map(ResultSet resultSet, StatementContext statementContext) throws SQLException {
31         CorrelationRule correlationRule = new CorrelationRule();
32         correlationRule.setName(resultSet.getString("name"));
33         correlationRule.setRid(resultSet.getString("rid"));
34         correlationRule.setDescription(resultSet.getString("description"));
35         correlationRule.setEnabled(resultSet.getInt("enable"));
36         correlationRule.setTemplateID(resultSet.getInt("templateID"));
37         correlationRule.setEngineID(resultSet.getString("engineID"));
38         correlationRule.setEngineType(resultSet.getString("engineType"));
39         correlationRule.setCreator(resultSet.getString("creator"));
40         correlationRule.setCreateTime(resultSet.getDate("createTime"));
41         correlationRule.setModifier(resultSet.getString("updator"));
42         correlationRule.setUpdateTime(resultSet.getDate("updateTime"));
43         correlationRule.setParams((Properties) resultSet.getObject("params"));
44         correlationRule.setContent(resultSet.getString("content"));
45         correlationRule.setVendor(resultSet.getString("vendor"));
46         correlationRule.setPackageName(resultSet.getString("package"));
47         correlationRule.setClosedControlLoopName(resultSet.getString("ctrlloop"));
48         correlationRule.setEngineInstance((resultSet.getString("engineinstance")));
49         return correlationRule;
50     }
51
52 }