Revision 46066
Added by Panagiotis Kanakakis over 7 years ago
modules/uoa-goldoa-service/branches/hibernate/src/test/resources/applicationContext-goldoa-service-test.xml | ||
---|---|---|
24 | 24 |
<bean id="executorService" class="java.util.concurrent.Executors" factory-method="newCachedThreadPool" destroy-method="shutdown" /> |
25 | 25 |
|
26 | 26 |
<context:annotation-config/> |
27 |
<context:property-placeholder location="classpath:applicationContext-goldoa-service.properties" />
|
|
27 |
<!--<context:property-placeholder location="classpath:applicationContext-goldoa-service.properties" />-->
|
|
28 | 28 |
|
29 | 29 |
<context:component-scan base-package="eu.dnetlib.goldoa.service" /> |
30 | 30 |
<context:component-scan base-package="eu.dnetlib.goldoa.service.utils" /> |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/RequestManagerImpl.java | ||
---|---|---|
714 | 714 |
|
715 | 715 |
/*private void loadCommentPersons(RequestInfo requestInfo) throws PersonManagerException { |
716 | 716 |
for (Comment comment : requestInfo.getComments()) { |
717 |
comment.setPerson(personManager.getById(comment.getPerson().getId()));
|
|
717 |
comment.setPerson(personManager.getById(comment.getUser().getId()));
|
|
718 | 718 |
} |
719 | 719 |
}*/ |
720 | 720 |
|
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/dao/UserDAO.java | ||
---|---|---|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
public void saveUser(final User user) { |
117 |
//TO DO ! Roles already in db
|
|
118 |
for (UserRole ur : user.getRoles()) { |
|
117 |
//TODO ! Roles already in db |
|
118 |
/*for (UserRole ur : user.getRoles()) {
|
|
119 | 119 |
Role r = ur.getPk().getRole(); |
120 | 120 |
getSession().persist(r); |
121 |
} |
|
121 |
}*/
|
|
122 | 122 |
persist(user); |
123 | 123 |
} |
124 | 124 |
|
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/dao/PublicationDAO.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
if (publication.getAuthors() != null) { |
52 | 52 |
for (Affiliation affiliation : publication.getAuthors()) { |
53 |
if (jdbcTemplate.update(UPDATE_PUBLICATION_AFFILIATIONS, new String[]{affiliation.getPerson().getId(), affiliation.getOrganization() != null ? affiliation.getOrganization().getId() : null, publication.getId()}, new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}) == 0) {
|
|
53 |
if (jdbcTemplate.update(UPDATE_PUBLICATION_AFFILIATIONS, new String[]{affiliation.getUser().getId(), affiliation.getOrganization() != null ? affiliation.getOrganization().getId() : null, publication.getId()}, new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}) == 0) {
|
|
54 | 54 |
jdbcTemplate.update(INSERT_PUBLICATION_AFFILIATIONS, |
55 |
new Object[]{UserManagerImpl.generateId(affiliation), affiliation.getPerson().getId(), affiliation.getOrganization() != null ? affiliation.getOrganization().getId() : null, affiliation.getStart(), affiliation.getEnd(), affiliation.getDepartment(), publication.getId()},
|
|
55 |
new Object[]{UserManagerImpl.generateId(affiliation), affiliation.getUser().getId(), affiliation.getOrganization() != null ? affiliation.getOrganization().getId() : null, affiliation.getStart(), affiliation.getEnd(), affiliation.getDepartment(), publication.getId()},
|
|
56 | 56 |
new int[]{Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR}); |
57 | 57 |
} |
58 | 58 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/PublicationManagerImpl.java | ||
---|---|---|
103 | 103 |
if (aff.getOrganization() != null && aff.getOrganization().getId() == null) |
104 | 104 |
aff.getOrganization().setId(organizationManager.saveOrganization(aff.getOrganization())); |
105 | 105 |
|
106 |
if (aff.getPerson() != null) {
|
|
107 |
String personId = personManager.generateId(aff.getPerson());
|
|
106 |
if (aff.getUser() != null) {
|
|
107 |
String personId = personManager.generateId(aff.getUser());
|
|
108 | 108 |
|
109 | 109 |
try { |
110 | 110 |
boolean affiliationExists = false; |
... | ... | |
128 | 128 |
|
129 | 129 |
affiliations.add(aff); |
130 | 130 |
|
131 |
aff.getPerson().setAffiliations(affiliations);
|
|
131 |
aff.getUser().setAffiliations(affiliations);
|
|
132 | 132 |
|
133 |
personManager.saveUser(aff.getPerson());
|
|
133 |
personManager.saveUser(aff.getUser());
|
|
134 | 134 |
} |
135 | 135 |
} |
136 | 136 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/UserManagerImpl.java | ||
---|---|---|
252 | 252 |
@Override |
253 | 253 |
public void run() { |
254 | 254 |
/*User user = userDAO.getUserByEmail(email); |
255 |
Role role = userDAO.getRole(roleId);
|
|
255 |
Role role = getRole(roleId); |
|
256 | 256 |
List<User> moderators = getModerators(); |
257 | 257 |
|
258 | 258 |
try { |
... | ... | |
287 | 287 |
public void setTokenTTL(int tokenTTL) { |
288 | 288 |
this.tokenTTL = tokenTTL; |
289 | 289 |
} |
290 |
|
|
291 |
@Override |
|
292 |
public Role getRole(String roleId){ |
|
293 |
return userDAO.getRole(roleId); |
|
294 |
} |
|
290 | 295 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/service/UserManager.java | ||
---|---|---|
50 | 50 |
String generateId(User user); |
51 | 51 |
|
52 | 52 |
public List<User> getAccountingOfficers(); |
53 |
|
|
54 |
public Role getRole(String roleId); |
|
53 | 55 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Comment.java | ||
---|---|---|
74 | 74 |
this.id = id; |
75 | 75 |
} |
76 | 76 |
|
77 |
public User getPerson() {
|
|
77 |
public User getUser() {
|
|
78 | 78 |
return this.user; |
79 | 79 |
} |
80 | 80 |
|
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Journal.java | ||
---|---|---|
53 | 53 |
@Convert( converter=CurrencyConverter.class ) |
54 | 54 |
private Currency apccurrency = Currency.EUR; |
55 | 55 |
|
56 |
|
|
57 |
|
|
58 | 56 |
@OneToOne |
59 | 57 |
@JoinColumn(name = "publisher") |
60 | 58 |
private Publisher publisher; |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Affiliation.java | ||
---|---|---|
19 | 19 |
@OneToOne |
20 | 20 |
@JoinColumn(name="organization") |
21 | 21 |
private Organization organization; |
22 |
//@Column(columnDefinition = "text")
|
|
22 |
@Column(columnDefinition = "text") |
|
23 | 23 |
private String department; |
24 | 24 |
private Timestamp enddate; |
25 | 25 |
private Timestamp startdate; |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Role.java | ||
---|---|---|
26 | 26 |
this.setRole(role); |
27 | 27 |
} |
28 | 28 |
|
29 |
public Role(String id) { |
|
30 |
this.id = id; |
|
31 |
} |
|
29 | 32 |
|
33 |
|
|
30 | 34 |
public List<UserRole> getUserRoles() { |
31 | 35 |
return userRoles; |
32 | 36 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Author.java | ||
---|---|---|
22 | 22 |
private String lastname; |
23 | 23 |
|
24 | 24 |
@Column(columnDefinition = "text") |
25 |
private String initial; |
|
25 |
private String initials;
|
|
26 | 26 |
|
27 | 27 |
@Column(columnDefinition = "text") |
28 | 28 |
private String email; |
... | ... | |
60 | 60 |
this.lastname = lastname; |
61 | 61 |
} |
62 | 62 |
|
63 |
public String getInitial() { |
|
64 |
return initial; |
|
63 |
public String getInitials() {
|
|
64 |
return initials;
|
|
65 | 65 |
} |
66 | 66 |
|
67 |
public void setInitial(String initial) {
|
|
68 |
this.initial = initial;
|
|
67 |
public void setInitials(String initials) {
|
|
68 |
this.initials = initials;
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
public String getEmail() { |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Country.java | ||
---|---|---|
21 | 21 |
public Country() { |
22 | 22 |
} |
23 | 23 |
|
24 |
public Country(String id){ |
|
25 |
this.id = id; |
|
26 |
} |
|
27 |
|
|
24 | 28 |
public String getId() { |
25 | 29 |
return this.id; |
26 | 30 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/java/eu/dnetlib/goldoa/domain/Request.java | ||
---|---|---|
77 | 77 |
private Float projectparticipation; |
78 | 78 |
private Timestamp submissiondate; |
79 | 79 |
private Float transferCost; |
80 |
//@Column(name="publisher_email",columnDefinition = "text") |
|
81 |
//private String publisherEmail; |
|
82 | 80 |
|
81 |
|
|
82 |
@Column(name="publisher_email",columnDefinition = "text") |
|
83 |
private String publisherEmail; |
|
84 |
|
|
83 | 85 |
@Transient |
84 | 86 |
private Eligibility eligibility; |
85 | 87 |
|
... | ... | |
366 | 368 |
public void setEligibility(Eligibility eligibility) { |
367 | 369 |
this.eligibility = eligibility; |
368 | 370 |
} |
371 |
|
|
372 |
public String getPublisherEmail() { |
|
373 |
return publisherEmail; |
|
374 |
} |
|
375 |
|
|
376 |
public void setPublisherEmail(String publisherEmail) { |
|
377 |
this.publisherEmail = publisherEmail; |
|
378 |
} |
|
379 |
|
|
369 | 380 |
} |
modules/uoa-goldoa-service/branches/hibernate/src/main/resources/eu/dnetlib/goldoa/service/applicationContext-goldoa-service.properties | ||
---|---|---|
1 | 1 |
goldoa.db.driverClassName = org.postgresql.Driver |
2 |
goldoa.db.url = jdbc:postgresql://194.177.192.221:5432/goldoa |
|
2 |
|
|
3 |
goldoa.db.url = jdbc:postgresql://194.177.192.119:5432/goldoa-test-1 |
|
3 | 4 |
goldoa.db.username = dnet |
4 | 5 |
goldoa.db.department = dnetPwd |
5 | 6 |
|
modules/uoa-goldoa-service/branches/hibernate/src/main/resources/eu/dnetlib/goldoa/service/dataSource.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
4 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
5 |
xsi:schemaLocation="http://www.springframework.org/schema/beans |
|
6 |
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> |
|
7 |
|
|
8 |
<!--<bean id="goldoa.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
|
9 |
<property name="driverClassName" value="org.hsqldb.jdbcDriver" /> |
|
10 |
<property name="url" value="jdbc:hsqldb:mem:testDB"/> |
|
11 |
<property name="username" value="SA" /> |
|
12 |
<property name="department" value="" /> |
|
13 |
</bean> |
|
14 |
--> |
|
15 |
<!--<bean id="goldoa.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
|
16 |
<property name="driverClassName" value="${goldoa.db.driverClassName}" /> |
|
17 |
<property name="url" value="${goldoa.db.url}" /> |
|
18 |
<property name="username" value="${goldoa.db.username}" /> |
|
19 |
<property name="password" value="${goldoa.db.password}" /> |
|
20 |
</bean>--> |
|
21 |
<bean id="goldoa.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
|
22 |
<property name="driverClassName" value="${goldoa.db.driverClassName}" /> |
|
23 |
<property name="url" value="${goldoa.db.url}" /> |
|
24 |
<property name="username" value="${goldoa.db.username}" /> |
|
25 |
<property name="department" value="${goldoa.db.department}" /> |
|
26 |
<property name="maxIdle" value="10" /> |
|
27 |
<property name="maxActive" value="100" /> |
|
28 |
<property name="maxWait" value="10000" /> |
|
29 |
<property name="validationQuery" value="SELECT 1;" /> |
|
30 |
<property name="testOnBorrow" value="true" /> |
|
31 |
<property name="testOnReturn" value="true" /> |
|
32 |
<property name="testWhileIdle" value="true" /> |
|
33 |
<property name="timeBetweenEvictionRunsMillis" value="1200000" /> |
|
34 |
<property name="minEvictableIdleTimeMillis" value="1800000" /> |
|
35 |
<property name="numTestsPerEvictionRun" value="5" /> |
|
36 |
<property name="poolPreparedStatements" value="true" /> |
|
37 |
<property name="defaultAutoCommit" value="true" /> |
|
38 |
</bean> |
|
39 |
|
|
40 |
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> |
|
41 |
<property name="dataSource" ref="goldoa.dataSource" /> |
|
42 |
<property name="configLocation" value="classpath:hibernate-cfg.xml" /> |
|
43 |
</bean> |
|
44 |
</beans> |
modules/uoa-goldoa-service/branches/hibernate/src/main/resources/eu/dnetlib/goldoa/service/hibernate-cfg.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<!DOCTYPE hibernate-configuration PUBLIC |
|
4 |
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" |
|
5 |
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> |
|
6 |
|
|
7 |
|
|
8 |
<hibernate-configuration> |
|
9 |
<session-factory> |
|
10 |
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property> |
|
11 |
<property name="hibernate.hbm2ddl.auto">create</property> |
|
12 |
<property name="show_sql">true</property> |
|
13 |
<property name="connection.pool_size">1</property> |
|
14 |
<property name="format_sql">true</property> |
|
15 |
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> |
|
16 |
|
|
17 |
<mapping class = "eu.dnetlib.goldoa.domain.User"/> |
|
18 |
<mapping class = "eu.dnetlib.goldoa.domain.Role"/> |
|
19 |
<mapping class = "eu.dnetlib.goldoa.domain.UserRole"/> |
|
20 |
<mapping class = "eu.dnetlib.goldoa.domain.UserRolePK"/> |
|
21 |
<mapping class = "eu.dnetlib.goldoa.domain.Organization"/> |
|
22 |
<mapping class = "eu.dnetlib.goldoa.domain.Affiliation"/> |
|
23 |
|
|
24 |
<mapping class = "eu.dnetlib.goldoa.domain.Country"/> |
|
25 |
<mapping class = "eu.dnetlib.goldoa.domain.File"/> |
|
26 |
<mapping class = "eu.dnetlib.goldoa.domain.Funder"/> |
|
27 |
<mapping class = "eu.dnetlib.goldoa.domain.Help"/> |
|
28 |
<mapping class = "eu.dnetlib.goldoa.domain.Invoice"/> |
|
29 |
<mapping class = "eu.dnetlib.goldoa.domain.Publisher"/> |
|
30 |
<mapping class = "eu.dnetlib.goldoa.domain.Journal"/> |
|
31 |
<mapping class = "eu.dnetlib.goldoa.domain.Language"/> |
|
32 |
<mapping class = "eu.dnetlib.goldoa.domain.JournalDiscount"/> |
|
33 |
<mapping class = "eu.dnetlib.goldoa.domain.JournalDiscountPK"/> |
|
34 |
<mapping class = "eu.dnetlib.goldoa.domain.Budget"/> |
|
35 |
<mapping class = "eu.dnetlib.goldoa.domain.Budgetfile"/> |
|
36 |
<mapping class = "eu.dnetlib.goldoa.domain.Comment"/> |
|
37 |
<mapping class = "eu.dnetlib.goldoa.domain.CommentTemplate"/> |
|
38 |
<mapping class = "eu.dnetlib.goldoa.domain.Project"/> |
|
39 |
<mapping class = "eu.dnetlib.goldoa.domain.PublisherDiscount"/> |
|
40 |
<mapping class = "eu.dnetlib.goldoa.domain.PublisherDiscountPK"/> |
|
41 |
<mapping class = "eu.dnetlib.goldoa.domain.AccountAction"/> |
|
42 |
<mapping class = "eu.dnetlib.goldoa.domain.Request"/> |
|
43 |
<mapping class = "eu.dnetlib.goldoa.domain.Publication"/> |
|
44 |
<mapping class = "eu.dnetlib.goldoa.domain.RequestCoFunder"/> |
|
45 |
<mapping class = "eu.dnetlib.goldoa.domain.RequestCoFunderPK"/> |
|
46 |
<mapping class = "eu.dnetlib.goldoa.domain.RequestComment"/> |
|
47 |
<mapping class = "eu.dnetlib.goldoa.domain.Identifier"/> |
|
48 |
<mapping class = "eu.dnetlib.goldoa.domain.Author"/> |
|
49 |
<mapping class = "eu.dnetlib.goldoa.domain.BankAccount"/> |
|
50 |
<mapping class = "eu.dnetlib.goldoa.domain.BankTransferReceipt"/> |
|
51 |
<mapping class = "eu.dnetlib.goldoa.domain.BudgetContract"/> |
|
52 |
</session-factory> |
|
53 |
</hibernate-configuration> |
Also available in: Unified diff