b99b74f87193b3dfe2653789b467183de1e50166
[ccsdk/features.git] /
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.config.data.adaptor.service;\r
19 \r
20 import java.util.List;\r
21 import java.util.Map;\r
22 import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
23 import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
24 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
25 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
26 \r
27 public interface ConfigResourceService {\r
28 \r
29     /**\r
30      * Return NamedParameterJdbcTemplate object.\r
31      */\r
32     public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
33 \r
34     /**\r
35      * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
36      * query, expecting a result list.\r
37      * <p>\r
38      * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
39      * using the column name as the key).\r
40      *\r
41      * @param sql SQL query to execute\r
42      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
43      *        the corresponding SQL type)\r
44      * @return a List that contains a Map per row\r
45      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
46      */\r
47     public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;\r
48 \r
49     /**\r
50      * Issue an update via a prepared statement, binding the given arguments.\r
51      *\r
52      * @param sql SQL containing named parameters\r
53      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
54      *        the corresponding SQL type)\r
55      * @return the number of rows affected\r
56      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
57      */\r
58     public int update(String sql, Map<String, Object> param) throws SvcLogicException;\r
59 \r
60     /**\r
61      * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
62      * query, expecting a result list.\r
63      * <p>\r
64      * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
65      * using the column name as the key).\r
66      *\r
67      * @param sql SQL query to execute\r
68      * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
69      *        corresponding SQL type)\r
70      * @return a List that contains a Map per row\r
71      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
72      */\r
73     public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;\r
74 \r
75     /**\r
76      * Issue a single SQL update operation (such as an insert, update or delete statement) via a\r
77      * prepared statement, binding the given arguments.\r
78      *\r
79      * @param sql SQL containing bind parameters\r
80      * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the\r
81      *        corresponding SQL type)\r
82      * @return the number of rows affected\r
83      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
84      */\r
85     public int update(String sql, Object[] data) throws SvcLogicException;\r
86 \r
87     /**\r
88      * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,\r
89      * binding the given arguments.\r
90      *\r
91      * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the\r
92      *        corresponding SQL type)\r
93      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
94      */\r
95     public void save(TransactionLog transactionLog) throws SvcLogicException;\r
96 \r
97     /**\r
98      * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
99      * TransactionLog RowMapper.\r
100      *\r
101      * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
102      *        corresponding SQL type)\r
103      * @return the result List, containing mapped objects\r
104      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
105      */\r
106     public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;\r
107 \r
108     /**\r
109      * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the\r
110      * query, mapping each row to a Java object via a ConfigResource RowMapper.\r
111      *\r
112      * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the\r
113      *        corresponding SQL type)\r
114      * @return the result List, containing mapped objects\r
115      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
116      */\r
117     public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;\r
118 \r
119     /**\r
120      * Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a\r
121      * prepared statement, binding the given arguments.\r
122      *\r
123      * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the\r
124      *        corresponding SQL type)\r
125      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert\r
126      */\r
127     public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;\r
128 \r
129     /**\r
130      * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.\r
131      *\r
132      * @param key key mapped to a value\r
133      * @return the result string, containing mapped string value\r
134      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if fails\r
135      */\r
136     public String getConfigPropertyByKey(String key) throws SvcLogicException;\r
137 \r
138     /**\r
139      * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a\r
140      * TransactionLog RowMapper.\r
141      *\r
142      * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the\r
143      *        corresponding SQL type)\r
144      * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess\r
145      *        the corresponding SQL type)\r
146      * @return the result List, containing mapped objects\r
147      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
148      */\r
149     public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)\r
150             throws SvcLogicException;\r
151 \r
152 }\r