2 * Copyright © 2017-2018 AT&T Intellectual Property.
\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
7 * http://www.apache.org/licenses/LICENSE-2.0
\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
15 package org.onap.ccsdk.config.data.adaptor.service;
\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
24 public interface ConfigResourceService {
\r
27 * Return NamedParameterJdbcTemplate object.
\r
29 public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;
\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
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
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
44 public List<Map<String, Object>> query(String sql, Map<String, Object> param) throws SvcLogicException;
\r
47 * Issue an update via a prepared statement, binding the given arguments.
\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
55 public int update(String sql, Map<String, Object> param) throws SvcLogicException;
\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
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
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
70 public List<Map<String, Object>> query(String sql, Object[] data) throws SvcLogicException;
\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
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
82 public int update(String sql, Object[] data) throws SvcLogicException;
\r
85 * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement,
\r
86 * binding the given arguments.
\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
92 public void save(TransactionLog transactionLog) throws SvcLogicException;
\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
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
103 public List<TransactionLog> getTransactionsByRequestId(String requestId) throws SvcLogicException;
\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
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
114 public List<ConfigResource> getConfigResource(ConfigResource configResource) throws SvcLogicException;
\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
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
124 public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException;
\r
127 * Query ConcurrentHashMap having CONFIG_PROPERTY_MAP table data for given key.
\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
133 public String getConfigPropertyByKey(String key) throws SvcLogicException;
\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
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
146 public List<TransactionLog> getTransactionsByRequestId(String requestId, String messageType)
\r
147 throws SvcLogicException;
\r