use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class GraphicsDao method loadShape.
public Shape loadShape(int shapeId) {
Shape shape = this.jochreSession.getObjectCache().getEntity(Shape.class, shapeId);
if (shape == null) {
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);
logParameters(paramSource);
try {
shape = jt.queryForObject(sql, paramSource, new ShapeMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No Shape found for shapeId " + shapeId);
}
this.jochreSession.getObjectCache().putEntity(Shape.class, shapeId, shape);
}
return shape;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class GraphicsDao method loadRowOfShapes.
RowOfShapes loadRowOfShapes(int rowId) {
RowOfShapes row = this.jochreSession.getObjectCache().getEntity(RowOfShapes.class, rowId);
if (row == null) {
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);
logParameters(paramSource);
try {
row = jt.queryForObject(sql, paramSource, new RowOfShapesMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No RowOfShapes found for rowId " + rowId);
}
this.jochreSession.getObjectCache().putEntity(RowOfShapes.class, rowId, row);
}
return row;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class GraphicsDao method loadJochreImage.
public JochreImage loadJochreImage(int imageId) {
JochreImage image = this.jochreSession.getObjectCache().getEntity(JochreImage.class, imageId);
if (image == null) {
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);
logParameters(paramSource);
try {
image = jt.queryForObject(sql, paramSource, new JochreImageMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No JochreImage found for imageId " + imageId);
}
this.jochreSession.getObjectCache().putEntity(JochreImage.class, imageId, image);
}
return image;
}
Aggregations