2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
3 * Modifications Copyright © 2018 IBM.
\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
9 * http://www.apache.org/licenses/LICENSE-2.0
\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
18 package org.onap.ccsdk.config.data.adaptor.service;
\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
27 public interface ConfigResourceService {
\r
30 * Return NamedParameterJdbcTemplate object.
\r
32 public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;
\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
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
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
47 public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;
\r
50 * Issue an update via a prepared statement, binding the given arguments.
\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
58 public int update(String sql, Map<String, Object> param) throws SvcLogicException;
\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
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
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
73 public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;
\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
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
85 public int update(String sql, Object[] data) throws SvcLogicException;
\r
88 * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,
\r
89 * binding the given arguments.
\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
95 public void save(TransactionLog transactionLog) throws SvcLogicException;
\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
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
106 public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;
\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
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
117 public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;
\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
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
127 public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;
\r
130 * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.
\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
136 public String getConfigPropertyByKey(String key) throws SvcLogicException;
\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
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
149 public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
\r
150 throws SvcLogicException;
\r