use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class SecurityDao method findUser.
public User findUser(String username) {
User user = this.jochreSession.getObjectCache().getEntity(User.class, username);
if (user == null) {
NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
String sql = "SELECT " + SELECT_USER + " FROM ocr_user WHERE user_username=:user_username";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("user_username", username);
LOG.info(sql);
logParameters(paramSource);
try {
user = jt.queryForObject(sql, paramSource, new UserMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No User found for username " + username);
}
this.jochreSession.getObjectCache().putEntity(User.class, username, user);
}
return user;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class SecurityDao method loadParameters.
public Parameters loadParameters() {
int parametersId = 1;
Parameters parameters = this.jochreSession.getObjectCache().getEntity(Parameters.class, parametersId);
if (parameters == null) {
NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
String sql = "SELECT " + SELECT_PARAM + " FROM ocr_param WHERE param_id=:param_id";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("param_id", parametersId);
LOG.info(sql);
logParameters(paramSource);
try {
parameters = jt.queryForObject(sql, paramSource, new ParametersMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No Parameters found for parameters id " + parametersId);
}
this.jochreSession.getObjectCache().putEntity(Parameters.class, parametersId, parameters);
}
return parameters;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class DocumentDao method loadJochreDocument.
public JochreDocument loadJochreDocument(int docId) {
JochreDocument document = this.jochreSession.getObjectCache().getEntity(JochreDocument.class, docId);
if (document == null) {
NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
String sql = "SELECT " + SELECT_DOCUMENT + " FROM ocr_document WHERE doc_id=:doc_id";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("doc_id", docId);
LOG.info(sql);
logParameters(paramSource);
try {
document = jt.queryForObject(sql, paramSource, new JochreDocumentMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No JochreDocument found for documentId " + docId);
}
this.jochreSession.getObjectCache().putEntity(JochreDocument.class, docId, document);
}
return document;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class DocumentDao method loadJochreDocument.
public JochreDocument loadJochreDocument(String name) {
NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
String sql = "SELECT " + SELECT_DOCUMENT + " FROM ocr_document WHERE doc_name=:doc_name";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("doc_name", name);
LOG.info(sql);
logParameters(paramSource);
JochreDocument jochreDocument = null;
try {
jochreDocument = jt.queryForObject(sql, paramSource, new JochreDocumentMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No JochreDocument found for name " + name);
}
return jochreDocument;
}
use of com.joliciel.jochre.EntityNotFoundException in project jochre by urieli.
the class DocumentDao method loadJochrePage.
public JochrePage loadJochrePage(int pageId) {
JochrePage page = this.jochreSession.getObjectCache().getEntity(JochrePage.class, pageId);
if (page == null) {
NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
String sql = "SELECT " + SELECT_PAGE + " FROM ocr_page WHERE page_id=:page_id";
MapSqlParameterSource paramSource = new MapSqlParameterSource();
paramSource.addValue("page_id", pageId);
LOG.info(sql);
logParameters(paramSource);
try {
page = jt.queryForObject(sql, paramSource, new JochrePageMapper());
} catch (EmptyResultDataAccessException ex) {
throw new EntityNotFoundException("No JochrePage found for pageId " + pageId);
}
this.jochreSession.getObjectCache().putEntity(JochrePage.class, pageId, page);
}
return page;
}
Aggregations