Revision 48139
Added by Alessia Bardi almost 7 years ago
ClaimDatabaseUtils.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 | 4 |
|
5 |
import eu.dnetlib.data.mapreduce.util.OafRowKeyDecoder; |
|
6 |
import eu.dnetlib.data.proto.FieldTypeProtos.DataInfo; |
|
7 |
import eu.dnetlib.data.proto.FieldTypeProtos.Qualifier; |
|
8 |
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions; |
|
9 | 5 |
import eu.dnetlib.enabling.database.DataSourceFactory; |
10 | 6 |
import eu.dnetlib.enabling.database.utils.JdbcTemplateFactory; |
11 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
21 | 17 |
public class ClaimDatabaseUtils { |
22 | 18 |
|
23 | 19 |
@Autowired |
24 |
private JdbcTemplateFactory claimsJdbcTemplateFactory;
|
|
20 |
private JdbcTemplateFactory claimsJdbcTemplateFactory;
|
|
25 | 21 |
@Autowired |
26 | 22 |
private DataSourceFactory claimsDataSourceFactory; |
27 | 23 |
|
28 | 24 |
@Value("${dnet.openaire.claims.db.name}") |
29 | 25 |
private String dbName; |
30 | 26 |
|
31 |
|
|
32 |
public List<Claim> query(final String sqlQuery){ |
|
27 |
public List<Claim> query(final String sqlQuery) { |
|
33 | 28 |
this.claimsJdbcTemplateFactory.setDataSourceFactory(claimsDataSourceFactory); |
34 | 29 |
return this.claimsJdbcTemplateFactory.createJdbcTemplate(dbName).query(sqlQuery, |
35 | 30 |
(rs, rowNum) -> new Claim().setSemantics(rs.getString("semantics")) |
... | ... | |
37 | 32 |
.setTarget(rs.getString("target_id")).setTargetType(rs.getString("target_type"))); |
38 | 33 |
} |
39 | 34 |
|
40 |
public int count(final String sqlCountQuery){ |
|
35 |
public int count(final String sqlCountQuery) {
|
|
41 | 36 |
this.claimsJdbcTemplateFactory.setDataSourceFactory(claimsDataSourceFactory); |
42 | 37 |
return this.claimsJdbcTemplateFactory.createJdbcTemplate(dbName).queryForObject(sqlCountQuery, Integer.class); |
43 | 38 |
} |
Also available in: Unified diff
integrated (hopefully) all required changes from dnet40