Revision 50509
Added by Sandro La Bruzzo about 6 years ago
DatasourceManagerClients.java | ||
---|---|---|
33 | 33 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
34 | 34 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
35 | 35 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
36 |
import org.springframework.transaction.annotation.Transactional; |
|
36 | 37 |
|
37 | 38 |
public class DatasourceManagerClients { |
38 | 39 |
|
... | ... | |
122 | 123 |
} |
123 | 124 |
} |
124 | 125 |
|
126 |
|
|
127 |
@Transactional(readOnly = true) |
|
125 | 128 |
public List<Map<String, Object>> searchSQL(final String sql, final Map<String, Object> sqlParams) throws DsmException { |
126 | 129 |
try { |
127 | 130 |
log.debug("Executing SQL: " + sql); |
... | ... | |
133 | 136 |
} |
134 | 137 |
} |
135 | 138 |
|
139 |
|
|
140 |
@Transactional(readOnly = true) |
|
136 | 141 |
public List<Map<String, Object>> searchSQL(final Resource sqlResource, final Map<String, Object> sqlParams) throws DsmException { |
137 | 142 |
try { |
138 | 143 |
return searchSQL(IOUtils.toString(sqlResource.getInputStream()), sqlParams); |
... | ... | |
142 | 147 |
} |
143 | 148 |
} |
144 | 149 |
|
150 |
|
|
151 |
@Transactional |
|
145 | 152 |
public void updateSQL(final String dsId, final String sql, final AfterSqlUpdate op, final Map<String, Object> sqlparams) |
146 | 153 |
throws DsmException { |
147 | 154 |
log.debug("Executing query SQL: " + sql); |
... | ... | |
160 | 167 |
} |
161 | 168 |
|
162 | 169 |
} |
163 |
|
|
170 |
@Transactional |
|
164 | 171 |
public void updateSQL(final String dsId, final Resource sqlResource, final AfterSqlUpdate op, final Map<String, Object> sqlparams) |
165 | 172 |
throws DsmException { |
166 | 173 |
try { |
... | ... | |
171 | 178 |
} |
172 | 179 |
} |
173 | 180 |
|
181 |
@Transactional(readOnly = true) |
|
174 | 182 |
public Datasource<Organization<?>, Identity> getDatasourceById(final String id) throws DsmException { |
175 | 183 |
final List<Map<String, Object>> list = searchSQL(dsQuery, ImmutableMap.of("dsId", id)); |
176 | 184 |
|
... | ... | |
189 | 197 |
return ds; |
190 | 198 |
} |
191 | 199 |
|
200 |
|
|
201 |
@Transactional(readOnly = true) |
|
192 | 202 |
public List<Api<ApiParam>> getApis(final String dsId) throws DsmException { |
193 | 203 |
|
194 | 204 |
return searchSQL(listApisByDsId, ImmutableMap.of("dsId", dsId)) |
... | ... | |
197 | 207 |
.collect(Collectors.toList()); |
198 | 208 |
} |
199 | 209 |
|
210 |
@Transactional(readOnly = true) |
|
200 | 211 |
public boolean isDefinedParam(final String apiId, final String param) throws DsmException { |
201 | 212 |
return !searchSQL(isDefinedParamQuery, ImmutableMap.of("apiId", apiId, "param", param)).isEmpty(); |
202 | 213 |
} |
... | ... | |
219 | 230 |
} |
220 | 231 |
} |
221 | 232 |
|
233 |
@Transactional(readOnly = true) |
|
222 | 234 |
public void regenerateProfiles() throws DsmException { |
223 | 235 |
searchSQL("SELECT id FROM dsm_datasources", new HashMap<>()).stream() |
224 | 236 |
.map(m -> m.get("id").toString()) |
Also available in: Unified diff
upgraded version of jdbc driver for postgres, this includes a lot of changes, Because we have to add @transactional
annotation in some properties to avoid connection closed exception