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.features.data.adaptor.service;
\r
20 import java.util.List;
\r
21 import java.util.Map;
\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
28 public interface ConfigResourceService {
\r
31 * Return NamedParameterJdbcTemplate object.
\r
33 public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;
\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
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
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
48 public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;
\r
51 * Issue an update via a prepared statement, binding the given arguments.
\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
59 public int update(String sql, Map<String, Object> param) throws SvcLogicException;
\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
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
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
74 public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;
\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
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
86 public int update(String sql, Object[] data) throws SvcLogicException;
\r
89 * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,
\r
90 * binding the given arguments.
\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
96 public void save(TransactionLog transactionLog) throws SvcLogicException;
\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
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
107 public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;
\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
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
118 public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;
\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
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
128 public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;
\r
131 * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.
\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
137 public String getConfigPropertyByKey(String key) throws SvcLogicException;
\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
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
150 public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
\r
151 throws SvcLogicException;
\r