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