Revision 36089
Added by Antonis Lempesis about 9 years ago
PersonDAO.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.goldoa.service.dao; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.goldoa.domain.*; |
4 |
import eu.dnetlib.goldoa.service.PersonManagerImpl; |
|
4 | 5 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 6 |
import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
6 | 7 |
import org.springframework.jdbc.core.JdbcTemplate; |
... | ... | |
68 | 69 |
|
69 | 70 |
private static final String INSERT_PERSON_ROLE = "insert into person_role (person, role, approved) values (?, ? ,?)"; |
70 | 71 |
|
71 |
private static final String INSERT_AFFILIATION = "insert into affiliation (person, organization, startdate, enddate, department) values (?, ?, ?, ?, ?)";
|
|
72 |
private static final String INSERT_AFFILIATION = "insert into affiliation (id, person, organization, startdate, enddate, department) values (?, ?, ?, ?, ?, ?)";
|
|
72 | 73 |
|
73 | 74 |
private static final String INSERT_ACTIVATION_TOKEN = "insert into account_action (\"user\", type, token, date, expires) values (?, ?, ? , ?, ?)"; |
74 | 75 |
|
... | ... | |
293 | 294 |
public void setValues(PreparedStatement ps, int i) throws SQLException { |
294 | 295 |
Affiliation affiliation = affiliations.get(i); |
295 | 296 |
|
296 |
ps.setString(1, person.getId()); |
|
297 |
ps.setInt(1, PersonManagerImpl.generateId(affiliation)); |
|
298 |
ps.setString(2, person.getId()); |
|
297 | 299 |
|
298 | 300 |
if (affiliation.getOrganization() != null) |
299 |
ps.setString(2, affiliation.getOrganization().getId());
|
|
301 |
ps.setString(3, affiliation.getOrganization().getId());
|
|
300 | 302 |
else |
301 |
ps.setString(2, null);
|
|
303 |
ps.setString(3, null);
|
|
302 | 304 |
|
303 | 305 |
if (affiliation.getStart() != null) |
304 |
ps.setTimestamp(3, new Timestamp(affiliation.getStart().getTime()));
|
|
306 |
ps.setTimestamp(4, new Timestamp(affiliation.getStart().getTime()));
|
|
305 | 307 |
else |
306 |
ps.setTimestamp(3, null);
|
|
308 |
ps.setTimestamp(4, null);
|
|
307 | 309 |
|
308 | 310 |
if (affiliation.getEnd() != null) |
309 |
ps.setTimestamp(4, new Timestamp(affiliation.getEnd().getTime()));
|
|
311 |
ps.setTimestamp(5, new Timestamp(affiliation.getEnd().getTime()));
|
|
310 | 312 |
else |
311 |
ps.setTimestamp(4, null);
|
|
313 |
ps.setTimestamp(5, null);
|
|
312 | 314 |
|
313 |
ps.setString(5, affiliation.getDepartment());
|
|
315 |
ps.setString(6, affiliation.getDepartment());
|
|
314 | 316 |
} |
315 | 317 |
|
316 | 318 |
@Override |
Also available in: Unified diff
Affiliation id is no longer a sequence. Publication affiliations are now saved correctly