Revision 47708
Added by Alessia Bardi almost 7 years ago
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/claims/ClaimDatabaseUtils.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 | 4 |
|
5 |
import eu.dnetlib.enabling.database.DataSourceFactory; |
|
6 |
import eu.dnetlib.enabling.database.utils.JdbcTemplateFactory; |
|
5 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
6 |
import org.springframework.jdbc.core.JdbcTemplate;
|
|
8 |
import org.springframework.beans.factory.annotation.Value;
|
|
7 | 9 |
import org.springframework.stereotype.Component; |
8 | 10 |
|
9 | 11 |
/** |
... | ... | |
15 | 17 |
public class ClaimDatabaseUtils { |
16 | 18 |
|
17 | 19 |
@Autowired |
18 |
JdbcTemplate claimsJdbcTemplate; |
|
20 |
private JdbcTemplateFactory claimsJdbcTemplateFactory; |
|
21 |
@Autowired |
|
22 |
private DataSourceFactory claimsDataSourceFactory; |
|
19 | 23 |
|
24 |
@Value("${dnet.openaire.claims.db.name}") |
|
25 |
private String dbName; |
|
26 |
|
|
27 |
|
|
20 | 28 |
public List<Claim> query(String sqlQuery){ |
21 |
return this.claimsJdbcTemplate.query(sqlQuery, |
|
29 |
this.claimsJdbcTemplateFactory.setDataSourceFactory(claimsDataSourceFactory); |
|
30 |
return this.claimsJdbcTemplateFactory.createJdbcTemplate(dbName).query(sqlQuery, |
|
22 | 31 |
(rs, rowNum) -> new Claim().setSemantics(rs.getString("semantics")) |
23 | 32 |
.setSource(rs.getString("source_id")).setSourceType(rs.getString("source_type")) |
24 | 33 |
.setTarget(rs.getString("target_id")).setTargetType(rs.getString("target_type"))); |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/workflows/nodes/claims/applicationContext-dnet-openaire-claims.properties | ||
---|---|---|
1 |
dnet.openaire.claims.db.url=jdbc:postgresql://localhost:5432/dnet_openaireplus |
|
1 |
dnet.openaire.claims.db.baseurl=jdbc:postgresql://localhost:5432 |
|
2 |
dnet.openaire.claims.db.name=dnet_openaireplus |
|
2 | 3 |
dnet.openaire.claims.db.username=dnet |
3 | 4 |
dnet.openaire.claims.db.password=dnetPwd |
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/workflows/nodes/claims/applicationContext-claims.xml | ||
---|---|---|
6 | 6 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd |
7 | 7 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> |
8 | 8 |
|
9 |
<bean id="claimsJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" |
|
10 |
p:dataSource-ref="claimsDatasource"/> |
|
9 |
<!--<bean id="claimsJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"--> |
|
10 |
<!--p:dataSource-ref="claimsDatasource"/>--> |
|
11 |
<bean id="claimsJdbcTemplateFactory" |
|
12 |
class="eu.dnetlib.enabling.database.utils.JdbcTemplateFactory" |
|
13 |
p:dataSourceFactory-ref="claimsDataSourceFactory" /> |
|
11 | 14 |
|
12 |
<bean id="claimsDatasource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"> |
|
13 |
<property name="driverClassName" value="org.postgresql.Driver"/> |
|
14 |
<property name="url" value="${dnet.openaire.claims.db.url}"/> |
|
15 |
<property name="username" value="${dnet.openaire.claims.db.username}"/> |
|
16 |
<property name="password" value="${dnet.openaire.claims.db.password}"/> |
|
17 |
</bean> |
|
15 |
<!--<bean id="claimsDatasource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">--> |
|
16 |
<!--<property name="driverClassName" value="org.postgresql.Driver"/>--> |
|
17 |
<!--<property name="url" value="${dnet.openaire.claims.db.url}"/>--> |
|
18 |
<!--<property name="username" value="${dnet.openaire.claims.db.username}"/>--> |
|
19 |
<!--<property name="password" value="${dnet.openaire.claims.db.password}"/>--> |
|
20 |
<!--</bean>--> |
|
21 |
<bean id="claimsDataSourceFactory" |
|
22 |
class="eu.dnetlib.enabling.database.DataSourceFactoryImpl" |
|
23 |
p:driverClassName="org.postgresql.Driver" |
|
24 |
p:baseUrl="${dnet.openaire.claims.db.baseurl}" |
|
25 |
p:username="${dnet.openaire.claims.db.username}" |
|
26 |
p:password="${dnet.openaire.claims.db.password}" /> |
|
18 | 27 |
|
28 |
|
|
19 | 29 |
<bean id="claimDatabaseUtils" class="eu.dnetlib.msro.openaireplus.workflows.nodes.claims.ClaimDatabaseUtils" /> |
20 | 30 |
</beans> |
modules/dnet-openaireplus-workflows/trunk/pom.xml | ||
---|---|---|
43 | 43 |
</dependency> |
44 | 44 |
<dependency> |
45 | 45 |
<groupId>eu.dnetlib</groupId> |
46 |
<artifactId>cnr-enabling-database-service</artifactId> |
|
47 |
<version>[3.0.0,4.0.0)</version> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>eu.dnetlib</groupId> |
|
46 | 51 |
<artifactId>dnet-msro-service</artifactId> |
47 | 52 |
<version>[3.0.0,4.0.0)</version> |
48 | 53 |
</dependency> |
Also available in: Unified diff
Using database service classes to avoid exception 'Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented.'. We are locked to an old jdbc driver (for hibernate?)