Revision 46738
Added by Panagiotis Kanakakis about 7 years ago
PublicationDAO.java | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
public Publication savePublication(Publication publication) { |
39 |
logger.debug("save publication"); |
|
40 |
persist(publication); |
|
39 |
|
|
40 |
Publication p = getPublication(publication.getId()); |
|
41 |
Publication pub_merged = null; |
|
42 |
|
|
43 |
logger.debug("publication id -> " + p.getId()); |
|
44 |
logger.debug("publication id -> " + publication.getId()); |
|
45 |
if(p!=null) |
|
46 |
pub_merged = (Publication) getSession().merge(publication); |
|
47 |
else |
|
48 |
persist(publication); |
|
49 |
|
|
41 | 50 |
return publication; |
42 | 51 |
} |
43 | 52 |
|
... | ... | |
58 | 67 |
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) { |
59 | 68 |
jdbcTemplate.update(INSERT_PUBLICATION_AFFILIATIONS, |
60 | 69 |
new Object[]{UserManagerImpl.generateId(affiliation), affiliation.getUser().getId(), affiliation.getOrganization() != null ? affiliation.getOrganization().getId() : null, affiliation.getStart(), affiliation.getEnd(), affiliation.getDepartment(), publication.getId()}, |
61 |
new int[]{Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR}); |
|
70 |
new int[]{ Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR});
|
|
62 | 71 |
} |
63 | 72 |
} |
64 | 73 |
}*/ |
... | ... | |
67 | 76 |
public void loadAffiliations(Publication publication) { |
68 | 77 |
/*List<Affiliation> affiliations = new JdbcTemplate(dataSource).query(LOAD_AFFILIATIONS, new String[]{publication.getId()}, new int[]{Types.VARCHAR}, new RowMapper<Affiliation>() { |
69 | 78 |
@Override |
70 |
public Affiliation mapRow(ResultSet rs, int rowNum) throws SQLException { |
|
79 |
public Affiliation mapRow( ResultSet rs, int rowNum) throws SQLException {
|
|
71 | 80 |
Affiliation aff = new Affiliation(); |
72 | 81 |
|
73 | 82 |
aff.setId(rs.getInt("id")); |
... | ... | |
76 | 85 |
aff.setEnd(rs.getDate("enddate")); |
77 | 86 |
|
78 | 87 |
aff.setPerson(this.parsePerson(rs.getString("person"))); |
79 |
aff.setOrganization(this.parseOrganisation(rs.getString("organisation"))); |
|
88 |
aff.setOrganization(th is.parseOrganisation(rs.getString("organisation")));
|
|
80 | 89 |
|
81 | 90 |
return aff; |
82 | 91 |
} |
83 | 92 |
|
84 | 93 |
private Organization parseOrganisation(String organisation) { |
85 |
if (organisation != null) { |
|
94 |
if (organisation != nu ll) {
|
|
86 | 95 |
Organization org = new Organization(); |
87 | 96 |
String[] parts = organisation.split("\\|\\|"); |
88 | 97 |
|
Also available in: Unified diff