Controller Blueprints Nitrogen to Oxygen Migration
[ccsdk/features.git] / blueprints-processor / adaptors / data-adaptor-provider / src / main / java / org / onap / ccsdk / features / data / adaptor / service / ConfigResourceService.java
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * Modifications Copyright © 2018 IBM.\r
4  * \r
5  * Licensed under the Apache License, Version 2.0 (the "License");\r
6  * you may not use this file except in compliance with the License.\r
7  * You may obtain a copy of the License at\r
8  * \r
9  * http://www.apache.org/licenses/LICENSE-2.0\r
10  * \r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 \r
18 package org.onap.ccsdk.features.data.adaptor.service;\r
19 \r
20 import java.util.List;\r
21 import java.util.Map;\r
22 \r
23 import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource;\r
24 import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog;\r
25 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
26 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
27 \r
28 public interface ConfigResourceService {\r
29 \r
30     /**\r
31      * Return NamedParameterJdbcTemplate object.\r
32      */\r
33     public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
34 \r
35     /**\r
36      * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
37      * query, expecting a result list.\r
38      * <p>\r
39      * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
40      * using the column name as the key).\r
41      *\r
42      * @param sql SQL query to execute\r
43      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
44      *        the corresponding SQL type)\r
45      * @return a List that contains a Map per row\r
46      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
47      */\r
48     public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;\r
49 \r
50     /**\r
51      * Issue an update via a prepared statement, binding the given arguments.\r
52      *\r
53      * @param sql SQL containing named parameters\r
54      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
55      *        the corresponding SQL type)\r
56      * @return the number of rows affected\r
57      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
58      */\r
59     public int update(String sql, Map<String, Object> param) throws SvcLogicException;\r
60 \r
61     /**\r
62      * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
63      * query, expecting a result list.\r
64      * <p>\r
65      * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
66      * using the column name as the key).\r
67      *\r
68      * @param sql SQL query to execute\r
69      * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
70      *        corresponding SQL type)\r
71      * @return a List that contains a Map per row\r
72      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
73      */\r
74     public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
75 \r
76     /**\r
77      * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
78      * prepared statement, binding the given arguments.\r
79      *\r
80      * @param sql SQL containing bind parameters\r
81      * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
82      *        corresponding SQL type)\r
83      * @return the number of rows affected\r
84      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
85      */\r
86     public int update(String sql, Object[] data) throws SvcLogicException;\r
87 \r
88     /**\r
89      * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
90      * binding the given arguments.\r
91      *\r
92      * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
93      *        corresponding SQL type)\r
94      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
95      */\r
96     public void save(TransactionLog transactionLog) throws SvcLogicException;\r
97 \r
98     /**\r
99      * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
100      * TransactionLog RowMapper.\r
101      *\r
102      * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
103      *        corresponding SQL type)\r
104      * @return the result List, containing mapped objects\r
105      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
106      */\r
107     public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
108 \r
109     /**\r
110      * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
111      * query, mapping each row to a Java object via a ConfigResource RowMapper.\r
112      *\r
113      * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
114      *        corresponding SQL type)\r
115      * @return the result List, containing mapped objects\r
116      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
117      */\r
118     public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
119 \r
120     /**\r
121      * Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a\r
122      * prepared statement, binding the given arguments.\r
123      *\r
124      * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
125      *        corresponding SQL type)\r
126      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
127      */\r
128     public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;\r
129 \r
130     /**\r
131      * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
132      *\r
133      * @param key key mapped to a value\r
134      * @return the result string, containing mapped string value\r
135      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
136      */\r
137     public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
138 \r
139     /**\r
140      * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
141      * TransactionLog RowMapper.\r
142      *\r
143      * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
144      *        corresponding SQL type)\r
145      * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
146      *        the corresponding SQL type)\r
147      * @return the result List, containing mapped objects\r
148      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
149      */\r
150     public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
151             throws SvcLogicException;\r
152 \r
153 }\r