Revision 35658
Added by Antonis Lempesis over 9 years ago
PublisherDAO.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
private static final String SEARCH_PUBLISHERS = "select id, name from publisher where lower(name) like lower(?)"; |
29 | 29 |
|
30 |
private static final String GET_PUBLISHER = "select id, name, email, contact, discount, source from publisher where id=?"; |
|
30 |
private static final String GET_PUBLISHER = "select id, name, email, contact, apc, discount, source from publisher where id=?";
|
|
31 | 31 |
|
32 |
private static final String UPDATE_PUBLISHER = "update publisher set name=?, email=?, contact=?, discount=?, source=? where id=?"; |
|
32 |
private static final String UPDATE_PUBLISHER = "update publisher set name=?, email=?, contact=?, apc=?, discount=?, source=? where id=?";
|
|
33 | 33 |
|
34 |
private static final String INSERT_PUBLISHER = "insert into publisher (name, email, contact, discount, source, id) values (?, ?, ?, ?, ?, ?)";
|
|
34 |
private static final String INSERT_PUBLISHER = "insert into publisher (name, email, contact, apc, discount, source, id) values (?, ?, ?, ?, ?, ?, ?)";
|
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
public List<Vocabulary> search(String term) { |
... | ... | |
49 | 49 |
public Publisher mapRow(ResultSet rs, int i) throws SQLException { |
50 | 50 |
Person person = rs.getString("contact")!=null?new Person(rs.getString("contact")):null; |
51 | 51 |
|
52 |
return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("discount"), rs.getString("source")); |
|
52 |
return new Publisher(rs.getString("id"), rs.getString("name"), rs.getString("email"), person, rs.getFloat("apc"), rs.getFloat("discount"), rs.getString("source"));
|
|
53 | 53 |
} |
54 | 54 |
}); |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
public Publisher savePublisher(Publisher publisher) { |
58 | 58 |
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); |
59 |
Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getEmail():null, publisher.getDiscount(), publisher.getSource(), publisher.getId()}; |
|
60 |
int[] types = {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.VARCHAR, Types.VARCHAR}; |
|
59 |
Object[] args = {publisher.getName(), publisher.getEmail(), publisher.getContact()!=null?publisher.getContact().getEmail():null, publisher.getAPC(), publisher.getDiscount(), publisher.getSource(), publisher.getId()};
|
|
60 |
int[] types = {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.REAL, Types.REAL, Types.VARCHAR, Types.VARCHAR};
|
|
61 | 61 |
|
62 | 62 |
if (jdbcTemplate.update(UPDATE_PUBLISHER, args, types) == 0) { |
63 | 63 |
jdbcTemplate.update(INSERT_PUBLISHER, args, types); |
Also available in: Unified diff