Project

General

Profile

« Previous | Next » 

Revision 39076

reformatted code

View differences:

FunderManagerImpl.java
18 18
 */
19 19
public class FunderManagerImpl implements FunderManager {
20 20

  
21
    @Autowired
22
    private DataSource dataSource;
21
	@Autowired
22
	private DataSource dataSource;
23 23

  
24
    private final static String SEARCH_FUNDERS = "select id, name from funder where lower(name) like lower(?)";
25
    private final static String GET_FUNDER = "select id, name, url, source from funder where id=?";
24
	private final static String SEARCH_FUNDERS = "select id, name from funder where lower(name) like lower(?)";
25
	private final static String GET_FUNDER = "select id, name, url, source from funder where id=?";
26 26

  
27
    @Override
28
    public List<Vocabulary> search(String term) {
29
        return new JdbcTemplate(dataSource).query(SEARCH_FUNDERS,  new String[]{"%" + term + "%"}, new int[]{Types.VARCHAR}, new RowMapper<Vocabulary>() {
30
            @Override
31
            public Vocabulary mapRow(ResultSet rs, int rowNum) throws SQLException {
32
                return new Vocabulary(rs.getString("id"), rs.getString("name"));
33
            }
34
        });
35
    }
27
	@Override
28
	public List<Vocabulary> search(String term) {
29
		return new JdbcTemplate(dataSource).query(SEARCH_FUNDERS, new String[]{"%" + term + "%"}, new int[]{Types.VARCHAR}, new RowMapper<Vocabulary>() {
30
			@Override
31
			public Vocabulary mapRow(ResultSet rs, int rowNum) throws SQLException {
32
				return new Vocabulary(rs.getString("id"), rs.getString("name"));
33
			}
34
		});
35
	}
36 36

  
37
    @Override
38
    public Funder getById(String id) {
39
        try {
40
            return new JdbcTemplate(dataSource).queryForObject(GET_FUNDER, new String[]{id}, new int[]{Types.VARCHAR}, new RowMapper<Funder>() {
41
                @Override
42
                public Funder mapRow(ResultSet rs, int rowNum) throws SQLException {
43
                    return new Funder(rs.getString("id"), rs.getString("name"), rs.getString("url"), rs.getString("source"));
44
                }
45
            });
46
        } catch (EmptyResultDataAccessException e) {
47
            return null;
48
        }
49
    }
37
	@Override
38
	public Funder getById(String id) {
39
		try {
40
			return new JdbcTemplate(dataSource).queryForObject(GET_FUNDER, new String[]{id}, new int[]{Types.VARCHAR}, new RowMapper<Funder>() {
41
				@Override
42
				public Funder mapRow(ResultSet rs, int rowNum) throws SQLException {
43
					return new Funder(rs.getString("id"), rs.getString("name"), rs.getString("url"), rs.getString("source"));
44
				}
45
			});
46
		} catch (EmptyResultDataAccessException e) {
47
			return null;
48
		}
49
	}
50 50
}

Also available in: Unified diff