List of usage examples for org.springframework.jdbc.core.namedparam MapSqlParameterSource addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value)
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public int getShapeCount(JochreImage jochreImage) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT count(*) FROM ocr_shape" + " INNER JOIN ocr_group ON shape_group_id = group_id" + " INNER JOIN ocr_row ON group_row_id = row_id" + " INNER JOIN ocr_paragraph ON row_paragraph_id = paragraph_id" + " INNER JOIN ocr_image ON paragraph_image_id = image_id" + " WHERE image_id = :image_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("image_id", jochreImage.getId()); LOG.debug(sql);//w w w . j a v a 2s . c o m logParameters(paramSource); int count = jt.queryForInt(sql, paramSource); return count; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<Shape> findShapes(RowOfShapes row) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_SHAPE + " FROM ocr_shape" + " INNER JOIN ocr_group ON shape_group_id = group_id" + " WHERE group_row_id = :group_row_id" + " ORDER BY group_index, shape_index"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("group_row_id", row.getId()); LOG.debug(sql);// w ww . ja va 2 s .c o m logParameters(paramSource); @SuppressWarnings("unchecked") List<Shape> shapes = jt.query(sql, paramSource, new ShapeMapper(this.getGraphicsServiceInternal())); return shapes; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<GroupOfShapes> findGroups(RowOfShapes row) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_GROUP + " FROM ocr_group WHERE group_row_id=:group_row_id" + " ORDER BY group_index"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("group_row_id", row.getId()); LOG.debug(sql);//from w ww.ja va2 s .co m logParameters(paramSource); @SuppressWarnings("unchecked") List<GroupOfShapes> groups = jt.query(sql, paramSource, new GroupOfShapesMapper(this.getGraphicsServiceInternal())); return groups; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<Paragraph> findParagraphs(JochreImage jochreImage) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_PARAGRAPH + " FROM ocr_paragraph WHERE paragraph_image_id=:paragraph_image_id" + " ORDER BY paragraph_index"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("paragraph_image_id", jochreImage.getId()); LOG.debug(sql);/*from w w w. j av a2 s .c om*/ logParameters(paramSource); @SuppressWarnings("unchecked") List<Paragraph> paragraphs = jt.query(sql, paramSource, new ParagraphMapper(this.getGraphicsServiceInternal())); return paragraphs; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public Shape loadShape(int shapeId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_SHAPE + " FROM ocr_shape WHERE shape_id=:shape_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("shape_id", shapeId); LOG.debug(sql);/* w w w . j a v a2 s .c o m*/ logParameters(paramSource); Shape shape = null; try { shape = (Shape) jt.queryForObject(sql, paramSource, new ShapeMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return shape; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public JochreImage loadJochreImage(int imageId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_IMAGE + " FROM ocr_image WHERE image_id=:image_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("image_id", imageId); LOG.debug(sql);//from ww w . ja v a 2 s . c o m logParameters(paramSource); JochreImage image = null; try { image = (JochreImage) jt.queryForObject(sql, paramSource, new JochreImageMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return image; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public RowOfShapes loadRowOfShapes(int rowId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_ROW + " FROM ocr_row WHERE row_id=:row_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("row_id", rowId); LOG.debug(sql);//from w ww . j a v a 2 s .co m logParameters(paramSource); RowOfShapes row = null; try { row = (RowOfShapes) jt.queryForObject(sql, paramSource, new RowOfShapesMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return row; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public GroupOfShapes loadGroupOfShapes(int groupId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_GROUP + " FROM ocr_group WHERE group_id=:group_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("group_id", groupId); LOG.debug(sql);//from w w w .j a va 2s.c o m logParameters(paramSource); GroupOfShapes group = null; try { group = (GroupOfShapes) jt.queryForObject(sql, paramSource, new GroupOfShapesMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return group; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public Paragraph loadParagraph(int paragraphId) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT " + SELECT_PARAGRAPH + " FROM ocr_paragraph WHERE paragraph_id=:paragraph_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("paragraph_id", paragraphId); LOG.debug(sql);/*from www .ja v a 2s . c o m*/ logParameters(paramSource); Paragraph paragraph = null; try { paragraph = (Paragraph) jt.queryForObject(sql, paramSource, new ParagraphMapper(this.getGraphicsServiceInternal())); } catch (EmptyResultDataAccessException ex) { ex.hashCode(); } return paragraph; }
From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java
@Override public List<Integer> findShapeIds(String letter) { NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource()); String sql = "SELECT shape_id FROM ocr_shape" + " INNER JOIN ocr_group ON shape_group_id = group_id" + " INNER JOIN ocr_row ON group_row_id = row_id" + " INNER JOIN ocr_paragraph ON row_paragraph_id = paragraph_id" + " INNER JOIN ocr_image ON paragraph_image_id = image_id" + " WHERE image_imgstatus_id = :image_imgstatus_id" + " AND shape_letter = :shape_letter" + " ORDER BY shape_id"; MapSqlParameterSource paramSource = new MapSqlParameterSource(); paramSource.addValue("image_imgstatus_id", ImageStatus.TRAINING_VALIDATED.getId()); paramSource.addValue("shape_letter", letter); LOG.debug(sql);/* w w w .j a v a2s. c om*/ logParameters(paramSource); @SuppressWarnings("unchecked") List<Integer> shapeIds = jt.queryForList(sql, paramSource, Integer.class); return shapeIds; }